Skip to content

Commit

Permalink
Merge pull request #7357 from filecoin-project/asr/v6actors
Browse files Browse the repository at this point in the history
Add v6 actors
  • Loading branch information
magik6k authored Sep 22, 2021
2 parents b9bfcc4 + 7b4c657 commit e68c8cb
Show file tree
Hide file tree
Showing 51 changed files with 2,347 additions and 67 deletions.
Binary file modified build/openrpc/full.json.gz
Binary file not shown.
3 changes: 3 additions & 0 deletions build/params_2k.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ var UpgradeTurboHeight = abi.ChainEpoch(-15)

var UpgradeHyperdriveHeight = abi.ChainEpoch(-16)

var UpgradeChocolateHeight = abi.ChainEpoch(-17)

var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
}
Expand Down Expand Up @@ -82,6 +84,7 @@ func init() {
UpgradeNorwegianHeight = getUpgradeHeight("LOTUS_NORWEGIAN_HEIGHT", UpgradeNorwegianHeight)
UpgradeTurboHeight = getUpgradeHeight("LOTUS_ACTORSV4_HEIGHT", UpgradeTurboHeight)
UpgradeHyperdriveHeight = getUpgradeHeight("LOTUS_HYPERDRIVE_HEIGHT", UpgradeHyperdriveHeight)
UpgradeChocolateHeight = getUpgradeHeight("LOTUS_CHOCOLATE_HEIGHT", UpgradeChocolateHeight)

BuildType |= Build2k
}
Expand Down
3 changes: 2 additions & 1 deletion build/params_butterfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ const UpgradeOrangeHeight = 210
const UpgradeTrustHeight = 240
const UpgradeNorwegianHeight = UpgradeTrustHeight + (builtin2.EpochsInHour * 12)
const UpgradeTurboHeight = 8922
const UpgradeHyperdriveHeight = 9999999
const UpgradeHyperdriveHeight = 9999998
const UpgradeChocolateHeight = 9999999

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 @@ -49,6 +49,8 @@ const UpgradeTurboHeight = 390

const UpgradeHyperdriveHeight = 420

const UpgradeChocolateHeight = 999999999

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 @@ -44,6 +44,7 @@ var UpgradeNorwegianHeight = abi.ChainEpoch(-14)
var UpgradeTurboHeight = abi.ChainEpoch(-15)

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

var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
Expand Down
7 changes: 5 additions & 2 deletions build/params_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,16 @@ const UpgradeTurboHeight = 712320
// 2021-06-30T22:00:00Z
var UpgradeHyperdriveHeight = abi.ChainEpoch(892800)

// ???
var UpgradeChocolateHeight = abi.ChainEpoch(999999999)

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

if os.Getenv("LOTUS_DISABLE_HYPERDRIVE") == "1" {
UpgradeHyperdriveHeight = math.MaxInt64
if os.Getenv("LOTUS_DISABLE_CHOCOLATE") == "1" {
UpgradeChocolateHeight = math.MaxInt64
}

Devnet = false
Expand Down
2 changes: 2 additions & 0 deletions build/params_nerpanet.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const UpgradeNorwegianHeight = 201000
const UpgradeTurboHeight = 203000
const UpgradeHyperdriveHeight = 379178

const UpgradeChocolateHeight = 999999999

func init() {
// Minimum block production power is set to 4 TiB
// Rationale is to discourage small-scale miners from trying to take over the network
Expand Down
4 changes: 3 additions & 1 deletion build/params_shared_vals.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ const UnixfsLinksPerLevel = 1024
// Consensus / Network

const AllowableClockDriftSecs = uint64(1)
const NewestNetworkVersion = network.Version13

// TODO: This is still terrible...What's the impact of updating this before mainnet actually upgrades
const NewestNetworkVersion = network.Version14

// Epochs
const ForkLengthThreshold = Finality
Expand Down
1 change: 1 addition & 0 deletions build/params_testground.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ var (
UpgradeNorwegianHeight abi.ChainEpoch = -13
UpgradeTurboHeight abi.ChainEpoch = -14
UpgradeHyperdriveHeight abi.ChainEpoch = -15
UpgradeChocolateHeight abi.ChainEpoch = -16

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 @@ -21,6 +21,8 @@ import (
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"

builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"

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

func init() {
Expand All @@ -44,6 +46,10 @@ func init() {
builtin.RegisterActorState(builtin5.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})

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

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

case builtin6.AccountActorCodeID:
return load6(store, act.Head)

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

case actors.Version6:
return make6(store, addr)

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

case actors.Version6:
return builtin6.AccountActorCodeID, nil

}

return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
Expand Down
40 changes: 40 additions & 0 deletions chain/actors/builtin/account/v6.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"

account6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/account"
)

var _ State = (*state6)(nil)

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

func make6(store adt.Store, addr address.Address) (State, error) {
out := state6{store: store}
out.State = account6.State{Address: addr}
return &out, nil
}

type state6 struct {
account6.State
store adt.Store
}

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

func (s *state6) 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 @@ -20,46 +20,49 @@ import (
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
smoothing5 "github.com/filecoin-project/specs-actors/v5/actors/util/smoothing"

builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
smoothing6 "github.com/filecoin-project/specs-actors/v6/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"

miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"
miner6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/miner"
proof6 "github.com/filecoin-project/specs-actors/v6/actors/runtime/proof"
)

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

var (
ExpectedLeadersPerEpoch = builtin5.ExpectedLeadersPerEpoch
ExpectedLeadersPerEpoch = builtin6.ExpectedLeadersPerEpoch
)

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

const (
MethodSend = builtin5.MethodSend
MethodConstructor = builtin5.MethodConstructor
MethodSend = builtin6.MethodSend
MethodConstructor = builtin6.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 = proof5.SectorInfo
type PoStProof = proof5.PoStProof
type SectorInfo = proof6.SectorInfo
type PoStProof = proof6.PoStProof
type FilterEstimate = smoothing0.FilterEstimate

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

func FromV0FilterEstimate(v0 smoothing0.FilterEstimate) FilterEstimate {
Expand Down Expand Up @@ -92,6 +95,12 @@ func FromV5FilterEstimate(v5 smoothing5.FilterEstimate) FilterEstimate {

}

func FromV6FilterEstimate(v6 smoothing6.FilterEstimate) FilterEstimate {

return (FilterEstimate)(v6)

}

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

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

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

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

if builtin6.IsBuiltinActor(c) {
return true
}

return false
}

Expand All @@ -178,6 +194,10 @@ func IsAccountActor(c cid.Cid) bool {
return true
}

if c == builtin6.AccountActorCodeID {
return true
}

return false
}

Expand All @@ -203,6 +223,10 @@ func IsStorageMinerActor(c cid.Cid) bool {
return true
}

if c == builtin6.StorageMinerActorCodeID {
return true
}

return false
}

Expand All @@ -228,6 +252,10 @@ func IsMultisigActor(c cid.Cid) bool {
return true
}

if c == builtin6.MultisigActorCodeID {
return true
}

return false
}

Expand All @@ -253,6 +281,10 @@ func IsPaymentChannelActor(c cid.Cid) bool {
return true
}

if c == builtin6.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 @@ -15,6 +15,8 @@ import (
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"

builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"

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

func MakeState(store adt.Store, av actors.Version) (State, error) {
Expand All @@ -35,6 +37,9 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
case actors.Version5:
return make5(store)

case actors.Version6:
return make6(store)

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

case actors.Version6:
return builtin6.CronActorCodeID, nil

}

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

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

type State interface {
Expand Down
35 changes: 35 additions & 0 deletions chain/actors/builtin/cron/v6.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"

cron6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/cron"
)

var _ State = (*state6)(nil)

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

func make6(store adt.Store) (State, error) {
out := state6{store: store}
out.State = *cron6.ConstructState(cron6.BuiltInEntries())
return &out, nil
}

type state6 struct {
cron6.State
store adt.Store
}

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

0 comments on commit e68c8cb

Please sign in to comment.