Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate v7 actors #7617

Merged
merged 6 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified build/openrpc/full.json.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions build/params_2k.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ var UpgradeHyperdriveHeight = abi.ChainEpoch(-16)

var UpgradeChocolateHeight = abi.ChainEpoch(-17)

var UpgradeSnapDealsHeight = abi.ChainEpoch(-18)

var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
}
Expand Down
1 change: 1 addition & 0 deletions build/params_butterfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const UpgradeNorwegianHeight = -14
const UpgradeTurboHeight = -15
const UpgradeHyperdriveHeight = -16
const UpgradeChocolateHeight = 6360
const UpgradeSnapDealsHeight = 99999999

func init() {
policy.SetConsensusMinerMinPower(abi.NewStoragePower(2 << 30))
Expand Down
2 changes: 2 additions & 0 deletions build/params_calibnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const UpgradeHyperdriveHeight = 420

const UpgradeChocolateHeight = 312746

const UpgradeSnapDealsHeight = 99999999

func init() {
policy.SetConsensusMinerMinPower(abi.NewStoragePower(32 << 30))
policy.SetSupportedProofTypes(
Expand Down
1 change: 1 addition & 0 deletions build/params_interop.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var UpgradeTurboHeight = abi.ChainEpoch(-15)

var UpgradeHyperdriveHeight = abi.ChainEpoch(-16)
var UpgradeChocolateHeight = abi.ChainEpoch(-17)
var UpgradeSnapDealsHeight = abi.ChainEpoch(-18)

var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
Expand Down
10 changes: 6 additions & 4 deletions build/params_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,20 @@ const UpgradeNorwegianHeight = 665280
const UpgradeTurboHeight = 712320

// 2021-06-30T22:00:00Z
var UpgradeHyperdriveHeight = abi.ChainEpoch(892800)
const UpgradeHyperdriveHeight = 892800

// 2021-10-26T13:30:00Z
var UpgradeChocolateHeight = abi.ChainEpoch(1231620)
const UpgradeChocolateHeight = 1231620

var UpgradeSnapDealsHeight = abi.ChainEpoch(999999999999)

func init() {
if os.Getenv("LOTUS_USE_TEST_ADDRESSES") != "1" {
SetAddressNetwork(address.Mainnet)
}

if os.Getenv("LOTUS_DISABLE_CHOCOLATE") == "1" {
UpgradeChocolateHeight = math.MaxInt64
if os.Getenv("LOTUS_DISABLE_SNAPDEALS") == "1" {
UpgradeSnapDealsHeight = math.MaxInt64
}

Devnet = false
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 @@ -34,7 +34,7 @@ const NewestNetworkVersion = network.Version{{.latestNetworkVersion}}

/* inline-gen start */

const NewestNetworkVersion = network.Version14
const NewestNetworkVersion = network.Version15

/* inline-gen end */

Expand Down
1 change: 1 addition & 0 deletions build/params_testground.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ var (
UpgradeTurboHeight abi.ChainEpoch = -14
UpgradeHyperdriveHeight abi.ChainEpoch = -15
UpgradeChocolateHeight abi.ChainEpoch = -16
UpgradeSnapDealsHeight abi.ChainEpoch = -17

DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
Expand Down
15 changes: 15 additions & 0 deletions chain/actors/builtin/account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,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 @@ -50,6 +52,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 @@ -75,6 +81,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 @@ -100,6 +109,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 @@ -125,6 +137,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
40 changes: 40 additions & 0 deletions chain/actors/builtin/account/v7.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package account

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

"github.com/filecoin-project/lotus/chain/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 chain/actors/builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,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/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"

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 @@ -101,6 +104,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 @@ -138,6 +147,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 @@ -169,6 +181,10 @@ func IsBuiltinActor(c cid.Cid) bool {
return true
}

if builtin7.IsBuiltinActor(c) {
return true
}

return false
}

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

if c == builtin7.AccountActorCodeID {
return true
}

return false
}

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

if c == builtin7.StorageMinerActorCodeID {
return true
}

return false
}

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

if c == builtin7.MultisigActorCodeID {
return true
}

return false
}

Expand Down Expand Up @@ -285,6 +313,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 chain/actors/builtin/cron/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,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 @@ -40,6 +42,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 @@ -65,14 +70,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
35 changes: 35 additions & 0 deletions chain/actors/builtin/cron/v7.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package cron

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

"github.com/filecoin-project/lotus/chain/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