Use more inline-gen

This commit is contained in:
Łukasz Magiera 2021-10-18 17:46:50 +02:00
parent e493d9e2e3
commit 463f55ba13
3 changed files with 28 additions and 9 deletions

View File

@ -8,9 +8,21 @@ import (
type Version int type Version int
/* inline-gen template
var LatestVersion = 6 var LatestVersion = 6
var Versions = []int{0, 2, 3, 4, 5, LatestVersion} var Versions = []int{ {{range .actorVersions}} {{.}}, {{end}} }
const ({{range .actorVersions}}
Version{{.}} Version = {{.}}{{end}}
)
/* inline-gen start */
var LatestVersion = 6
var Versions = []int{0, 2, 3, 4, 5, 6}
const ( const (
Version0 Version = 0 Version0 Version = 0
@ -21,6 +33,8 @@ const (
Version6 Version = 6 Version6 Version = 6
) )
/* inline-gen end */
// Converts a network version into an actors adt version. // Converts a network version into an actors adt version.
func VersionForNetwork(version network.Version) (Version, error) { func VersionForNetwork(version network.Version) (Version, error) {
switch version { switch version {

View File

@ -152,7 +152,16 @@ func VersionForNetwork(ver network.Version) (types.StateTreeVersion, error) {
return types.StateTreeVersion2, nil return types.StateTreeVersion2, nil
case network.Version12: case network.Version12:
return types.StateTreeVersion3, nil return types.StateTreeVersion3, nil
/* inline-gen template
{{$lastNv := .latestNetworkVersion}}
case{{range .networkVersions}} {{if (ge . 13.)}} network.Version{{.}}{{if (lt . $lastNv)}},{{end}}{{end}}{{end}}:
/* inline-gen start */
case network.Version13, network.Version14: case network.Version13, network.Version14:
/* inline-gen end */
return types.StateTreeVersion4, nil return types.StateTreeVersion4, nil
default: default:
panic(fmt.Sprintf("unsupported network version %d", ver)) panic(fmt.Sprintf("unsupported network version %d", ver))

View File

@ -3,15 +3,11 @@
- [ ] Import new actors - [ ] Import new actors
- [ ] Define upgrade heights in `build/params_` - [ ] Define upgrade heights in `build/params_`
- [ ] Generate adapters - [ ] Generate adapters
- [ ] Add the new version in `chain/actors/agen/main.go` - [ ] Update `gen/inlinegen-data.json`
- [ ] Update adapter code in `chain/actors/version.go` if needed
- [ ] Update adapter code in `chain/actors/builtin` if needed - [ ] Update adapter code in `chain/actors/builtin` if needed
- [ ] Update `chain/actors/policy/policy.go` - [ ] Run `make actors-gen`
- [ ] Update `chain/actors/version.go` - [ ] Update `chain/consensus/filcns/upgrades.go`
- [ ] Register in `chain/vm/invoker.go`
- [ ] Update `chain/types/state.go`
- [ ] Update `chain/state/statetree.go` (New / Load)
- [ ] Update `chain/stmgr/forks.go`
- [ ] Schedule - [ ] Schedule
- [ ] Migration - [ ] Migration
- [ ] Update upgrade schedule in `chain/sync_test.go` - [ ] Update upgrade schedule in `chain/sync_test.go`
- [ ] Register in init in `chain/stmgr/utils.go`