Skip to content

Commit

Permalink
Revert "Allow starting networks from arbitrary actor versions"
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k authored May 26, 2021
1 parent 409f96d commit 43c62f4
Show file tree
Hide file tree
Showing 126 changed files with 643 additions and 3,164 deletions.
Binary file modified build/openrpc/full.json.gz
Binary file not shown.
20 changes: 10 additions & 10 deletions build/params_2k.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ var UpgradeIgnitionHeight = abi.ChainEpoch(-2)
var UpgradeRefuelHeight = abi.ChainEpoch(-3)
var UpgradeTapeHeight = abi.ChainEpoch(-4)

var UpgradeActorsV2Height = abi.ChainEpoch(-5)
var UpgradeLiftoffHeight = abi.ChainEpoch(-6)
var UpgradeActorsV2Height = abi.ChainEpoch(10)
var UpgradeLiftoffHeight = abi.ChainEpoch(-5)

var UpgradeKumquatHeight = abi.ChainEpoch(-7)
var UpgradeCalicoHeight = abi.ChainEpoch(-8)
var UpgradePersianHeight = abi.ChainEpoch(-9)
var UpgradeOrangeHeight = abi.ChainEpoch(-10)
var UpgradeClausHeight = abi.ChainEpoch(-11)
var UpgradeKumquatHeight = abi.ChainEpoch(15)
var UpgradeCalicoHeight = abi.ChainEpoch(20)
var UpgradePersianHeight = abi.ChainEpoch(25)
var UpgradeOrangeHeight = abi.ChainEpoch(27)
var UpgradeClausHeight = abi.ChainEpoch(30)

var UpgradeActorsV3Height = abi.ChainEpoch(-12)
var UpgradeActorsV3Height = abi.ChainEpoch(35)

var UpgradeNorwegianHeight = abi.ChainEpoch(-13)
var UpgradeNorwegianHeight = abi.ChainEpoch(40)

var UpgradeActorsV4Height = abi.ChainEpoch(-14)
var UpgradeActorsV4Height = abi.ChainEpoch(45)

var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
Expand Down
2 changes: 1 addition & 1 deletion build/params_shared_vals.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const UnixfsLinksPerLevel = 1024
// Consensus / Network

const AllowableClockDriftSecs = uint64(1)
const NewestNetworkVersion = network.Version12
const NewestNetworkVersion = network.Version11
const ActorUpgradeNetworkVersion = network.Version4

// Epochs
Expand Down
Empty file removed chain/actors/adt/temp
Empty file.
Empty file removed chain/actors/aerrors/temp
Empty file.
72 changes: 33 additions & 39 deletions chain/actors/agen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,33 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strconv"
"text/template"

lotusactors "github.com/filecoin-project/lotus/chain/actors"

"golang.org/x/xerrors"
)

var latestVersion = 4

var versions = []int{0, 2, 3, latestVersion}

var versionImports = map[int]string{
0: "/",
2: "/v2/",
3: "/v3/",
latestVersion: "/v4/",
}

var actors = map[string][]int{
"account": lotusactors.Versions,
"cron": lotusactors.Versions,
"init": lotusactors.Versions,
"market": lotusactors.Versions,
"miner": lotusactors.Versions,
"multisig": lotusactors.Versions,
"paych": lotusactors.Versions,
"power": lotusactors.Versions,
"system": lotusactors.Versions,
"reward": lotusactors.Versions,
"verifreg": lotusactors.Versions,
"account": versions,
"cron": versions,
"init": versions,
"market": versions,
"miner": versions,
"multisig": versions,
"paych": versions,
"power": versions,
"reward": versions,
"verifreg": versions,
}

func main() {
Expand Down Expand Up @@ -64,14 +71,14 @@ func generateAdapters() error {
}

tpl := template.Must(template.New("").Funcs(template.FuncMap{
"import": func(v int) string { return getVersionImports()[v] },
"import": func(v int) string { return versionImports[v] },
}).Parse(string(af)))

var b bytes.Buffer

err = tpl.Execute(&b, map[string]interface{}{
"versions": versions,
"latestVersion": lotusactors.LatestVersion,
"latestVersion": latestVersion,
})
if err != nil {
return err
Expand All @@ -96,14 +103,14 @@ func generateState(actDir string) error {
return xerrors.Errorf("loading state adapter template: %w", err)
}

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

var b bytes.Buffer

err := tpl.Execute(&b, map[string]interface{}{
"v": version,
"import": getVersionImports()[version],
"import": versionImports[version],
})
if err != nil {
return err
Expand All @@ -127,14 +134,14 @@ func generateMessages(actDir string) error {
return xerrors.Errorf("loading message adapter template: %w", err)
}

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

var b bytes.Buffer

err := tpl.Execute(&b, map[string]interface{}{
"v": version,
"import": getVersionImports()[version],
"import": versionImports[version],
})
if err != nil {
return err
Expand All @@ -160,13 +167,13 @@ func generatePolicy(policyPath string) error {
}

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

err = tpl.Execute(&b, map[string]interface{}{
"versions": lotusactors.Versions,
"latestVersion": lotusactors.LatestVersion,
"versions": versions,
"latestVersion": latestVersion,
})
if err != nil {
return err
Expand All @@ -191,13 +198,13 @@ func generateBuiltin(builtinPath string) error {
}

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

err = tpl.Execute(&b, map[string]interface{}{
"versions": lotusactors.Versions,
"latestVersion": lotusactors.LatestVersion,
"versions": versions,
"latestVersion": latestVersion,
})
if err != nil {
return err
Expand All @@ -209,16 +216,3 @@ func generateBuiltin(builtinPath string) error {

return nil
}

func getVersionImports() map[int]string {
versionImports := make(map[int]string, lotusactors.LatestVersion)
for _, v := range lotusactors.Versions {
if v == 0 {
versionImports[v] = "/"
} else {
versionImports[v] = "/v" + strconv.Itoa(v) + "/"
}
}

return versionImports
}
Empty file removed chain/actors/agen/temp
Empty file.
41 changes: 0 additions & 41 deletions chain/actors/builtin/account/account.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package account

import (
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
Expand Down Expand Up @@ -61,48 +60,8 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}

func MakeState(store adt.Store, av actors.Version, addr address.Address) (State, error) {
switch av {

case actors.Version0:
return make0(store, addr)

case actors.Version2:
return make2(store, addr)

case actors.Version3:
return make3(store, addr)

case actors.Version4:
return make4(store, addr)

}
return nil, xerrors.Errorf("unknown actor version %d", av)
}

func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {

case actors.Version0:
return builtin0.AccountActorCodeID, nil

case actors.Version2:
return builtin2.AccountActorCodeID, nil

case actors.Version3:
return builtin3.AccountActorCodeID, nil

case actors.Version4:
return builtin4.AccountActorCodeID, nil

}

return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}

type State interface {
cbor.Marshaler

PubkeyAddress() (address.Address, error)
GetState() interface{}
}
23 changes: 0 additions & 23 deletions chain/actors/builtin/account/actor.go.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package account

import (
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
Expand Down Expand Up @@ -35,30 +34,8 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}

func MakeState(store adt.Store, av actors.Version, addr address.Address) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return make{{.}}(store, addr)
{{end}}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}

func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return builtin{{.}}.AccountActorCodeID, nil
{{end}}
}

return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}

type State interface {
cbor.Marshaler

PubkeyAddress() (address.Address, error)
GetState() interface{}
}
10 changes: 0 additions & 10 deletions chain/actors/builtin/account/state.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}

func make{{.v}}(store adt.Store, addr address.Address) (State, error) {
out := state{{.v}}{store: store}
out.State = account{{.v}}.State{Address:addr}
return &out, nil
}

type state{{.v}} struct {
account{{.v}}.State
store adt.Store
Expand All @@ -34,7 +28,3 @@ type state{{.v}} struct {
func (s *state{{.v}}) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}

func (s *state{{.v}}) GetState() interface{} {
return &s.State
}
Empty file removed chain/actors/builtin/account/temp
Empty file.
10 changes: 0 additions & 10 deletions chain/actors/builtin/account/v0.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}

func make0(store adt.Store, addr address.Address) (State, error) {
out := state0{store: store}
out.State = account0.State{Address: addr}
return &out, nil
}

type state0 struct {
account0.State
store adt.Store
Expand All @@ -34,7 +28,3 @@ type state0 struct {
func (s *state0) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}

func (s *state0) GetState() interface{} {
return &s.State
}
10 changes: 0 additions & 10 deletions chain/actors/builtin/account/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}

func make2(store adt.Store, addr address.Address) (State, error) {
out := state2{store: store}
out.State = account2.State{Address: addr}
return &out, nil
}

type state2 struct {
account2.State
store adt.Store
Expand All @@ -34,7 +28,3 @@ type state2 struct {
func (s *state2) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}

func (s *state2) GetState() interface{} {
return &s.State
}
10 changes: 0 additions & 10 deletions chain/actors/builtin/account/v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}

func make3(store adt.Store, addr address.Address) (State, error) {
out := state3{store: store}
out.State = account3.State{Address: addr}
return &out, nil
}

type state3 struct {
account3.State
store adt.Store
Expand All @@ -34,7 +28,3 @@ type state3 struct {
func (s *state3) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}

func (s *state3) GetState() interface{} {
return &s.State
}
10 changes: 0 additions & 10 deletions chain/actors/builtin/account/v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}

func make4(store adt.Store, addr address.Address) (State, error) {
out := state4{store: store}
out.State = account4.State{Address: addr}
return &out, nil
}

type state4 struct {
account4.State
store adt.Store
Expand All @@ -34,7 +28,3 @@ type state4 struct {
func (s *state4) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}

func (s *state4) GetState() interface{} {
return &s.State
}
Loading

0 comments on commit 43c62f4

Please sign in to comment.