Skip to content

Commit

Permalink
add v7 actor files (#4637)
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode authored and ta0li committed Jan 4, 2022
1 parent 41532c3 commit 7a91e50
Show file tree
Hide file tree
Showing 44 changed files with 2,543 additions and 198 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@ actor-sources:

actor-render:
cd venus-devtool && go run ./compatible/actors/*.go render ../venus-shared/actors/

actor-replica:
cd venus-devtool && go run ./compatible/actors/*.go replica --dst ../venus-shared/actors/
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ github.com/filecoin-project/go-state-types v0.0.0-20200928172055-2df22083d8ab/go
github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
github.com/filecoin-project/go-state-types v0.1.1-0.20210810190654-139e0e79e69e/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
github.com/filecoin-project/go-state-types v0.1.1-0.20210915140513-d354ccf10379/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
github.com/filecoin-project/go-state-types v0.1.1 h1:LR260vya4p++atgf256W6yV3Lxl5mKrBFcEZePWQrdg=
github.com/filecoin-project/go-state-types v0.1.1/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe h1:dF8u+LEWeIcTcfUcCf3WFVlc81Fr2JKg8zPzIbBDKDw=
Expand All @@ -363,8 +362,9 @@ github.com/filecoin-project/specs-actors/v5 v5.0.4/go.mod h1:5BAKRAMsOOlD8+qCw4U
github.com/filecoin-project/specs-actors/v6 v6.0.0/go.mod h1:V1AYfi5GkHXipx1mnVivoICZh3wtwPxDVuds+fbfQtk=
github.com/filecoin-project/specs-actors/v6 v6.0.1 h1:laxvHNsvrq83Y9n+W7znVCePi3oLyRf0Rkl4jFO8Wew=
github.com/filecoin-project/specs-actors/v6 v6.0.1/go.mod h1:V1AYfi5GkHXipx1mnVivoICZh3wtwPxDVuds+fbfQtk=
github.com/filecoin-project/specs-actors/v7 v7.0.0-20211117170924-fd07a4c7dff9 h1:H10WnEAJQH3JwHyaHwMEgaaj00z+/QMCb9Sjd/SUW1w=
github.com/filecoin-project/specs-actors/v7 v7.0.0-20211117170924-fd07a4c7dff9/go.mod h1:p6LIOFezA1rgRLMewbvdi3Pp6SAu+q9FtJ9CAleSjrE=
github.com/filecoin-project/specs-actors/v7 v7.0.0-20211118013026-3dce48197cec h1:KV9vE+Sl2Y3qKsrpba4HcE7wHwK7v6O5U/S0xHbje6A=
github.com/filecoin-project/specs-actors/v7 v7.0.0-20211118013026-3dce48197cec/go.mod h1:p6LIOFezA1rgRLMewbvdi3Pp6SAu+q9FtJ9CAleSjrE=
github.com/filecoin-project/specs-storage v0.1.1-0.20201105051918-5188d9774506 h1:Ur/l2+6qN+lQiqjozWWc5p9UDaAMDZKTlDS98oRnlIw=
github.com/filecoin-project/specs-storage v0.1.1-0.20201105051918-5188d9774506/go.mod h1:nJRRM7Aa9XVvygr3W9k6xGF46RWzr2zxF/iGoAIfA/g=
github.com/filecoin-project/test-vectors/schema v0.0.5 h1:w3zHQhzM4pYxJDl21avXjOKBLF8egrvwUwjpT8TquDg=
Expand Down
1 change: 1 addition & 0 deletions venus-devtool/compatible/actors/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ var replicaCmd = &cli.Command{
}

replacers := [][2]string{
{"github.com/filecoin-project/lotus/chain/actors", "github.com/filecoin-project/venus/venus-shared/actors"},
{"github.com/filecoin-project/lotus/chain/actors/adt", "github.com/filecoin-project/venus/venus-shared/actors/adt"},
{"github.com/filecoin-project/lotus/chain/actors/aerrors", "github.com/filecoin-project/venus/venus-shared/actors/aerrors"},
}
Expand Down
6 changes: 3 additions & 3 deletions venus-devtool/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ go 1.16

require (
github.com/filecoin-project/go-jsonrpc v0.1.5
github.com/filecoin-project/lotus v1.12.0
github.com/filecoin-project/lotus v1.13.2-0.20211213233817-8a4246227153
github.com/filecoin-project/venus v0.0.0-00010101000000-000000000000
github.com/filecoin-project/venus/venus-shared v0.0.1
github.com/filecoin-project/venus/venus-shared v0.0.0-00010101000000-000000000000
github.com/ipfs/go-ipfs-http-client v0.1.0 // indirect
github.com/urfave/cli/v2 v2.3.0
github.com/whyrusleeping/cbor-gen v0.0.0-20211110122933-f57984553008
Expand All @@ -18,4 +18,4 @@ replace (
github.com/filecoin-project/venus/venus-shared => ../venus-shared/
github.com/ipfs/go-ipfs-cmds => github.com/ipfs-force-community/go-ipfs-cmds v0.6.1-0.20210521090123-4587df7fa0ab
github.com/multiformats/go-multiaddr => github.com/multiformats/go-multiaddr v0.3.0
)
)
431 changes: 316 additions & 115 deletions venus-devtool/go.sum

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions venus-shared/actors/builtin/account/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"

builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"

builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
)

func init() {
Expand Down Expand Up @@ -52,6 +54,10 @@ func init() {
builtin.RegisterActorState(builtin6.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})

builtin.RegisterActorState(builtin7.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
}

var Methods = builtin4.MethodsAccount
Expand All @@ -77,6 +83,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case builtin6.AccountActorCodeID:
return load6(store, act.Head)

case builtin7.AccountActorCodeID:
return load7(store, act.Head)

}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
Expand All @@ -102,6 +111,9 @@ func MakeState(store adt.Store, av actors.Version, addr address.Address) (State,
case actors.Version6:
return make6(store, addr)

case actors.Version7:
return make7(store, addr)

}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
Expand All @@ -127,6 +139,9 @@ func GetActorCodeID(av actors.Version) (cid.Cid, error) {
case actors.Version6:
return builtin6.AccountActorCodeID, nil

case actors.Version7:
return builtin7.AccountActorCodeID, nil

}

return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
Expand Down
42 changes: 42 additions & 0 deletions venus-shared/actors/builtin/account/state.v7.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// FETCHED FROM LOTUS: builtin/account/state.go.template

package account

import (
"github.com/filecoin-project/go-address"
"github.com/ipfs/go-cid"

"github.com/filecoin-project/venus/venus-shared/actors/adt"

account7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/account"
)

var _ State = (*state7)(nil)

func load7(store adt.Store, root cid.Cid) (State, error) {
out := state7{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}

func make7(store adt.Store, addr address.Address) (State, error) {
out := state7{store: store}
out.State = account7.State{Address: addr}
return &out, nil
}

type state7 struct {
account7.State
store adt.Store
}

func (s *state7) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}

func (s *state7) GetState() interface{} {
return &s.State
}
60 changes: 46 additions & 14 deletions venus-shared/actors/builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,46 +25,49 @@ import (
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
smoothing6 "github.com/filecoin-project/specs-actors/v6/actors/util/smoothing"

builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
smoothing7 "github.com/filecoin-project/specs-actors/v7/actors/util/smoothing"

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"

"github.com/filecoin-project/venus/venus-shared/actors/adt"
types "github.com/filecoin-project/venus/venus-shared/chain"

miner6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/miner"
proof6 "github.com/filecoin-project/specs-actors/v6/actors/runtime/proof"
miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner"
proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof"
)

var SystemActorAddr = builtin6.SystemActorAddr
var BurntFundsActorAddr = builtin6.BurntFundsActorAddr
var CronActorAddr = builtin6.CronActorAddr
var SystemActorAddr = builtin7.SystemActorAddr
var BurntFundsActorAddr = builtin7.BurntFundsActorAddr
var CronActorAddr = builtin7.CronActorAddr
var SaftAddress = makeAddress("t0122")
var ReserveAddress = makeAddress("t090")
var RootVerifierAddress = makeAddress("t080")

var (
ExpectedLeadersPerEpoch = builtin6.ExpectedLeadersPerEpoch
ExpectedLeadersPerEpoch = builtin7.ExpectedLeadersPerEpoch
)

const (
EpochDurationSeconds = builtin6.EpochDurationSeconds
EpochsInDay = builtin6.EpochsInDay
SecondsInDay = builtin6.SecondsInDay
EpochDurationSeconds = builtin7.EpochDurationSeconds
EpochsInDay = builtin7.EpochsInDay
SecondsInDay = builtin7.SecondsInDay
)

const (
MethodSend = builtin6.MethodSend
MethodConstructor = builtin6.MethodConstructor
MethodSend = builtin7.MethodSend
MethodConstructor = builtin7.MethodConstructor
)

// These are all just type aliases across actor versions. In the future, that might change
// and we might need to do something fancier.
type SectorInfo = proof6.SectorInfo
type PoStProof = proof6.PoStProof
type SectorInfo = proof7.SectorInfo
type PoStProof = proof7.PoStProof
type FilterEstimate = smoothing0.FilterEstimate

func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight, verifiedWeight abi.DealWeight) abi.StoragePower {
return miner6.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
return miner7.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
}

func FromV0FilterEstimate(v0 smoothing0.FilterEstimate) FilterEstimate {
Expand Down Expand Up @@ -103,6 +106,12 @@ func FromV6FilterEstimate(v6 smoothing6.FilterEstimate) FilterEstimate {

}

func FromV7FilterEstimate(v7 smoothing7.FilterEstimate) FilterEstimate {

return (FilterEstimate)(v7)

}

type ActorStateLoader func(store adt.Store, root cid.Cid) (cbor.Marshaler, error)

var ActorStateLoaders = make(map[cid.Cid]ActorStateLoader)
Expand Down Expand Up @@ -140,6 +149,9 @@ func ActorNameByCode(c cid.Cid) string {
case builtin6.IsBuiltinActor(c):
return builtin6.ActorNameByCode(c)

case builtin7.IsBuiltinActor(c):
return builtin7.ActorNameByCode(c)

default:
return "<unknown>"
}
Expand Down Expand Up @@ -171,6 +183,10 @@ func IsBuiltinActor(c cid.Cid) bool {
return true
}

if builtin7.IsBuiltinActor(c) {
return true
}

return false
}

Expand Down Expand Up @@ -200,6 +216,10 @@ func IsAccountActor(c cid.Cid) bool {
return true
}

if c == builtin7.AccountActorCodeID {
return true
}

return false
}

Expand Down Expand Up @@ -229,6 +249,10 @@ func IsStorageMinerActor(c cid.Cid) bool {
return true
}

if c == builtin7.StorageMinerActorCodeID {
return true
}

return false
}

Expand Down Expand Up @@ -258,6 +282,10 @@ func IsMultisigActor(c cid.Cid) bool {
return true
}

if c == builtin7.MultisigActorCodeID {
return true
}

return false
}

Expand Down Expand Up @@ -287,6 +315,10 @@ func IsPaymentChannelActor(c cid.Cid) bool {
return true
}

if c == builtin7.PaymentChannelActorCodeID {
return true
}

return false
}

Expand Down
12 changes: 10 additions & 2 deletions venus-shared/actors/builtin/cron/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"

builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"

builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
)

func MakeState(store adt.Store, av actors.Version) (State, error) {
Expand All @@ -42,6 +44,9 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
case actors.Version6:
return make6(store)

case actors.Version7:
return make7(store)

}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
Expand All @@ -67,14 +72,17 @@ func GetActorCodeID(av actors.Version) (cid.Cid, error) {
case actors.Version6:
return builtin6.CronActorCodeID, nil

case actors.Version7:
return builtin7.CronActorCodeID, nil

}

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

var (
Address = builtin6.CronActorAddr
Methods = builtin6.MethodsCron
Address = builtin7.CronActorAddr
Methods = builtin7.MethodsCron
)

type State interface {
Expand Down
37 changes: 37 additions & 0 deletions venus-shared/actors/builtin/cron/state.v7.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// FETCHED FROM LOTUS: builtin/cron/state.go.template

package cron

import (
"github.com/ipfs/go-cid"

"github.com/filecoin-project/venus/venus-shared/actors/adt"

cron7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/cron"
)

var _ State = (*state7)(nil)

func load7(store adt.Store, root cid.Cid) (State, error) {
out := state7{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}

func make7(store adt.Store) (State, error) {
out := state7{store: store}
out.State = *cron7.ConstructState(cron7.BuiltInEntries())
return &out, nil
}

type state7 struct {
cron7.State
store adt.Store
}

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

0 comments on commit 7a91e50

Please sign in to comment.