Skip to content

Commit 56e9595

Browse files
authored
deps: update to lotus v1.18.0 with support for nv17
* deps: update to lotus v1.18.0 release * deps: update ffi to match lotus v1.18.0 * schema: implement precommitinfov9 task and schema - close #1076 * schema: implement minor beneficiary task and schema - closes #1077 * schema: implement datacap balance task and schema - fixes #1078 * docker: update build image to 1.18.7 * replace deprecated libp2p deps
1 parent 6e1cfb8 commit 56e9595

File tree

125 files changed

+5635
-1413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+5635
-1413
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ orbs:
66
executors:
77
dockerizer:
88
docker:
9-
- image: cimg/go:1.17.6
9+
- image: cimg/go:1.18.7
1010
environment:
1111
IMAGE_NAME: filecoin/lily
1212
golang:
1313
docker:
14-
- image: cimg/go:1.17.6
14+
- image: cimg/go:1.18.7
1515

1616
commands:
1717
install-deps:
@@ -148,7 +148,7 @@ jobs:
148148
test:
149149
resource_class: xlarge
150150
docker:
151-
- image: cimg/go:1.17.6
151+
- image: cimg/go:1.18.7
152152
- image: timescale/timescaledb:2.5.0-pg13
153153
environment:
154154
POSTGRES_PASSWORD: password
@@ -183,7 +183,7 @@ jobs:
183183
integration-test:
184184
resource_class: large
185185
docker:
186-
- image: cimg/go:1.17.6
186+
- image: cimg/go:1.18.7
187187
- image: timescale/timescaledb:2.5.0-pg13
188188
environment:
189189
POSTGRES_PASSWORD: password

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SHELL=/usr/bin/env bash
22

3-
GO_BUILD_IMAGE?=golang:1.17.6
3+
GO_BUILD_IMAGE?=golang:1.18.7
44
PG_IMAGE?=postgres:10
55
REDIS_IMAGE?=redis:6
66
LILY_IMAGE_NAME?=filecoin/lily
@@ -82,7 +82,7 @@ testfull: build
8282
docker-compose up -d
8383
sleep 2
8484
LILY_DB="postgres://postgres:password@localhost:5432/postgres?sslmode=disable" ./lily migrate --latest
85-
-TZ= PGSSLMODE=disable LILY_TEST_DB="postgres://postgres:password@localhost:5432/postgres?sslmode=disable" go test ./... -v
85+
-TZ= PGSSLMODE=disable LILY_TEST_DB="postgres://postgres:password@localhost:5432/postgres?sslmode=disable" go test ./...
8686
docker-compose down
8787

8888
# testshort runs tests that don't require external dependencies such as postgres or redis

chain/actors/actors.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package actors
22

33
import (
4+
actorstypes "github.com/filecoin-project/go-state-types/actors"
45
"github.com/filecoin-project/lotus/chain/actors"
56
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
67
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
@@ -27,6 +28,7 @@ const (
2728
Version6 Version = 6
2829
Version7 Version = 7
2930
Version8 Version = 8
31+
Version9 Version = 9
3032
)
3133
const (
3234
AccountKey = "account"
@@ -40,12 +42,13 @@ const (
4042
RewardKey = "reward"
4143
SystemKey = "system"
4244
VerifregKey = "verifiedregistry"
45+
DatacapKey = "datacap"
4346
)
4447

4548
// GetActorCodeID looks up a builtin actor's code CID by actor version and canonical actor name.
4649
func GetActorCodeID(av Version, name string) (cid.Cid, bool) {
4750
// Actors V8 and above
48-
if c, ok := actors.GetActorCodeID(actors.Version(av), name); ok {
51+
if c, ok := actors.GetActorCodeID(actorstypes.Version(av), name); ok {
4952
return c, true
5053
}
5154

chain/actors/agen/generator/gen.go

Lines changed: 69 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,52 @@ package generator
33
import (
44
"bytes"
55
"fmt"
6+
"go/format"
67
"io/ioutil"
78
"os"
89
"path/filepath"
10+
"strconv"
911
"text/template"
10-
)
11-
12-
var latestVersion = 8
13-
14-
var versions = []int{0, 2, 3, 4, 5, 6, 7, latestVersion}
1512

16-
var versionImports = map[int]string{
17-
0: "/",
18-
2: "/v2/",
19-
3: "/v3/",
20-
4: "/v4/",
21-
5: "/v5/",
22-
6: "/v6/",
23-
7: "/v7/",
24-
latestVersion: "/v8/",
25-
}
13+
lotusactors "github.com/filecoin-project/lotus/chain/actors"
14+
"golang.org/x/xerrors"
15+
)
2616

2717
var actors = map[string][]int{
28-
"init": versions,
29-
"market": versions,
30-
"miner": versions,
31-
"multisig": versions,
32-
"power": versions,
33-
"reward": versions,
34-
"verifreg": versions,
18+
//"account": lotusactors.Versions,
19+
//"cron": lotusactors.Versions,
20+
"init": lotusactors.Versions,
21+
"market": lotusactors.Versions,
22+
"miner": lotusactors.Versions,
23+
"multisig": lotusactors.Versions,
24+
//"paych": lotusactors.Versions,
25+
"power": lotusactors.Versions,
26+
//"system": lotusactors.Versions,
27+
"reward": lotusactors.Versions,
28+
"verifreg": lotusactors.Versions,
29+
"datacap": lotusactors.Versions[8:],
3530
}
3631

3732
func Gen() error {
3833
if err := generateAdapters(); err != nil {
3934
return err
4035
}
4136

42-
if err := generatePolicy(); err != nil {
37+
if err := generatePolicy("chain/actors/policy/policy.go"); err != nil {
4338
return err
4439
}
4540

46-
if err := generateBuiltin(); err != nil {
41+
if err := generateBuiltin("chain/actors/builtin/builtin.go"); err != nil {
4742
return err
4843
}
4944
return nil
5045
}
5146

5247
func generateAdapters() error {
53-
actorsDir := "chain/actors/builtin"
5448
for act, versions := range actors {
55-
actDir := filepath.Join(actorsDir, act)
49+
actDir := filepath.Join("chain/actors/builtin", act)
5650

57-
if err := generateState(actDir); err != nil {
51+
if err := generateState(actDir, versions); err != nil {
5852
return err
5953
}
6054

@@ -65,24 +59,29 @@ func generateAdapters() error {
6559
{
6660
af, err := ioutil.ReadFile(filepath.Join(actDir, "actor.go.template"))
6761
if err != nil {
68-
return fmt.Errorf("loading actor template: %w", err)
62+
return xerrors.Errorf("loading actor template: %w", err)
6963
}
7064

7165
tpl := template.Must(template.New("").Funcs(template.FuncMap{
72-
"import": func(v int) string { return versionImports[v] },
66+
"import": func(v int) string { return getVersionImports()[v] },
7367
}).Parse(string(af)))
7468

7569
var b bytes.Buffer
7670

7771
err = tpl.Execute(&b, map[string]interface{}{
7872
"versions": versions,
79-
"latestVersion": latestVersion,
73+
"latestVersion": lotusactors.LatestVersion,
8074
})
8175
if err != nil {
8276
return err
8377
}
8478

85-
if err := ioutil.WriteFile(filepath.Join(actDir, fmt.Sprintf("%s.go", act)), b.Bytes(), 0o666); err != nil {
79+
fmted, err := format.Source(b.Bytes())
80+
if err != nil {
81+
return err
82+
}
83+
84+
if err := ioutil.WriteFile(filepath.Join(actDir, fmt.Sprintf("%s.go", act)), fmted, 0666); err != nil {
8685
return err
8786
}
8887
}
@@ -91,31 +90,31 @@ func generateAdapters() error {
9190
return nil
9291
}
9392

94-
func generateState(actDir string) error {
93+
func generateState(actDir string, versions []int) error {
9594
af, err := ioutil.ReadFile(filepath.Join(actDir, "state.go.template"))
9695
if err != nil {
9796
if os.IsNotExist(err) {
9897
return nil // skip
9998
}
10099

101-
return fmt.Errorf("loading state adapter template: %w", err)
100+
return xerrors.Errorf("loading state adapter template: %w", err)
102101
}
103102

104103
for _, version := range versions {
105-
fmt.Println("parsing", actDir)
106104
tpl := template.Must(template.New("").Funcs(template.FuncMap{}).Parse(string(af)))
107105

108106
var b bytes.Buffer
109107

110108
err := tpl.Execute(&b, map[string]interface{}{
111-
"v": version,
112-
"import": versionImports[version],
109+
"v": version,
110+
"import": getVersionImports()[version],
111+
"latestVersion": lotusactors.LatestVersion,
113112
})
114113
if err != nil {
115114
return err
116115
}
117116

118-
if err := ioutil.WriteFile(filepath.Join(actDir, fmt.Sprintf("v%d.go", version)), b.Bytes(), 0o666); err != nil {
117+
if err := ioutil.WriteFile(filepath.Join(actDir, fmt.Sprintf("v%d.go", version)), b.Bytes(), 0666); err != nil {
119118
return err
120119
}
121120
}
@@ -130,88 +129,102 @@ func generateMessages(actDir string) error {
130129
return nil // skip
131130
}
132131

133-
return fmt.Errorf("loading message adapter template: %w", err)
132+
return xerrors.Errorf("loading message adapter template: %w", err)
134133
}
135134

136-
for _, version := range versions {
135+
for _, version := range lotusactors.Versions {
137136
tpl := template.Must(template.New("").Funcs(template.FuncMap{}).Parse(string(af)))
138137

139138
var b bytes.Buffer
140139

141140
err := tpl.Execute(&b, map[string]interface{}{
142-
"v": version,
143-
"import": versionImports[version],
141+
"v": version,
142+
"import": getVersionImports()[version],
143+
"latestVersion": lotusactors.LatestVersion,
144144
})
145145
if err != nil {
146146
return err
147147
}
148148

149-
if err := ioutil.WriteFile(filepath.Join(actDir, fmt.Sprintf("message%d.go", version)), b.Bytes(), 0o666); err != nil {
149+
if err := ioutil.WriteFile(filepath.Join(actDir, fmt.Sprintf("message%d.go", version)), b.Bytes(), 0666); err != nil {
150150
return err
151151
}
152152
}
153153

154154
return nil
155155
}
156156

157-
func generatePolicy() error {
158-
policyPath := "chain/actors/policy/policy.go"
157+
func generatePolicy(policyPath string) error {
158+
159159
pf, err := ioutil.ReadFile(policyPath + ".template")
160160
if err != nil {
161161
if os.IsNotExist(err) {
162162
return nil // skip
163163
}
164164

165-
return fmt.Errorf("loading policy template file: %w", err)
165+
return xerrors.Errorf("loading policy template file: %w", err)
166166
}
167167

168168
tpl := template.Must(template.New("").Funcs(template.FuncMap{
169-
"import": func(v int) string { return versionImports[v] },
169+
"import": func(v int) string { return getVersionImports()[v] },
170170
}).Parse(string(pf)))
171171
var b bytes.Buffer
172172

173173
err = tpl.Execute(&b, map[string]interface{}{
174-
"versions": versions,
175-
"latestVersion": latestVersion,
174+
"versions": lotusactors.Versions,
175+
"latestVersion": lotusactors.LatestVersion,
176176
})
177177
if err != nil {
178178
return err
179179
}
180180

181-
if err := ioutil.WriteFile(policyPath, b.Bytes(), 0o666); err != nil {
181+
if err := ioutil.WriteFile(policyPath, b.Bytes(), 0666); err != nil {
182182
return err
183183
}
184184

185185
return nil
186186
}
187187

188-
func generateBuiltin() error {
189-
builtinPath := "chain/actors/builtin/builtin.go"
188+
func generateBuiltin(builtinPath string) error {
189+
190190
bf, err := ioutil.ReadFile(builtinPath + ".template")
191191
if err != nil {
192192
if os.IsNotExist(err) {
193193
return nil // skip
194194
}
195195

196-
return fmt.Errorf("loading builtin template file: %w", err)
196+
return xerrors.Errorf("loading builtin template file: %w", err)
197197
}
198198

199199
tpl := template.Must(template.New("").Funcs(template.FuncMap{
200-
"import": func(v int) string { return versionImports[v] },
200+
"import": func(v int) string { return getVersionImports()[v] },
201201
}).Parse(string(bf)))
202202
var b bytes.Buffer
203203

204204
err = tpl.Execute(&b, map[string]interface{}{
205-
"versions": versions,
206-
"latestVersion": latestVersion,
205+
"versions": lotusactors.Versions,
206+
"latestVersion": lotusactors.LatestVersion,
207207
})
208208
if err != nil {
209209
return err
210210
}
211211

212-
if err := ioutil.WriteFile(builtinPath, b.Bytes(), 0o666); err != nil {
212+
if err := ioutil.WriteFile(builtinPath, b.Bytes(), 0666); err != nil {
213213
return err
214214
}
215215

216216
return nil
217217
}
218+
219+
func getVersionImports() map[int]string {
220+
versionImports := make(map[int]string, lotusactors.LatestVersion)
221+
for _, v := range lotusactors.Versions {
222+
if v == 0 {
223+
versionImports[v] = "/"
224+
} else {
225+
versionImports[v] = "/v" + strconv.Itoa(v) + "/"
226+
}
227+
}
228+
229+
return versionImports
230+
}

0 commit comments

Comments
 (0)