Skip to content

Commit

Permalink
Introduce v5 actors
Browse files Browse the repository at this point in the history
  • Loading branch information
arajasek committed May 6, 2021
1 parent 549b63a commit a36f1e9
Show file tree
Hide file tree
Showing 43 changed files with 1,688 additions and 74 deletions.
9 changes: 7 additions & 2 deletions api/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ var TwoFull = DefaultFullOpts(2)

var FullNodeWithLatestActorsAt = func(upgradeHeight abi.ChainEpoch) FullNodeOpts {
if upgradeHeight == -1 {
upgradeHeight = 3
// Attention: Update this when introducing new actor versions or your tests will be sad
upgradeHeight = 4
}

return FullNodeOpts{
Expand All @@ -138,8 +139,12 @@ var FullNodeWithLatestActorsAt = func(upgradeHeight abi.ChainEpoch) FullNodeOpts
Migration: stmgr.UpgradeActorsV3,
}, {
Network: network.Version12,
Height: upgradeHeight,
Height: 3,
Migration: stmgr.UpgradeActorsV4,
}, {
Network: network.Version13,
Height: upgradeHeight,
Migration: stmgr.UpgradeActorsV5,
}})
},
}
Expand Down
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 @@ -39,6 +39,8 @@ var UpgradeNorwegianHeight = abi.ChainEpoch(40)

var UpgradeActorsV4Height = abi.ChainEpoch(45)

var UpgradeHyperdriveHeight = abi.ChainEpoch(50)

var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
}
Expand Down Expand Up @@ -78,6 +80,7 @@ func init() {
UpgradeActorsV3Height = getUpgradeHeight("LOTUS_ACTORSV3_HEIGHT", UpgradeActorsV3Height)
UpgradeNorwegianHeight = getUpgradeHeight("LOTUS_NORWEGIAN_HEIGHT", UpgradeNorwegianHeight)
UpgradeActorsV4Height = getUpgradeHeight("LOTUS_ACTORSV4_HEIGHT", UpgradeActorsV4Height)
UpgradeHyperdriveHeight = getUpgradeHeight("LOTUS_HYPERDRIVE_HEIGHT", UpgradeHyperdriveHeight)

BuildType |= Build2k
}
Expand Down
1 change: 1 addition & 0 deletions build/params_butterfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const UpgradeOrangeHeight = 210
const UpgradeActorsV3Height = 240
const UpgradeNorwegianHeight = UpgradeActorsV3Height + (builtin2.EpochsInHour * 12)
const UpgradeActorsV4Height = 8922
const UpgradeHyperdriveHeight = 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 @@ -45,6 +45,8 @@ const UpgradeNorwegianHeight = 114000

const UpgradeActorsV4Height = 193789

const UpgradeHyperdriveHeight = 9999999

func init() {
policy.SetConsensusMinerMinPower(abi.NewStoragePower(32 << 30))
policy.SetSupportedProofTypes(
Expand Down
3 changes: 3 additions & 0 deletions build/params_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ const UpgradeNorwegianHeight = 665280
// 2021-04-29T06:00:00Z
var UpgradeActorsV4Height = abi.ChainEpoch(712320)

// ???
var UpgradeHyperdriveHeight = abi.ChainEpoch(9999999)

func init() {
policy.SetConsensusMinerMinPower(abi.NewStoragePower(10 << 40))

Expand Down
1 change: 1 addition & 0 deletions build/params_nerpanet.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const UpgradeOrangeHeight = 300
const UpgradeActorsV3Height = 600
const UpgradeNorwegianHeight = 999999
const UpgradeActorsV4Height = 99999999
const UpgradeHyperdriveHeight = 999999999

func init() {
// Minimum block production power is set to 4 TiB
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.Version11
const NewestNetworkVersion = network.Version13
const ActorUpgradeNetworkVersion = network.Version4

// Epochs
Expand Down
29 changes: 15 additions & 14 deletions build/params_testground.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,21 @@ var (
UpgradeBreezeHeight abi.ChainEpoch = -1
BreezeGasTampingDuration abi.ChainEpoch = 0

UpgradeSmokeHeight abi.ChainEpoch = -1
UpgradeIgnitionHeight abi.ChainEpoch = -2
UpgradeRefuelHeight abi.ChainEpoch = -3
UpgradeTapeHeight abi.ChainEpoch = -4
UpgradeActorsV2Height abi.ChainEpoch = 10
UpgradeLiftoffHeight abi.ChainEpoch = -5
UpgradeKumquatHeight abi.ChainEpoch = -6
UpgradeCalicoHeight abi.ChainEpoch = -7
UpgradePersianHeight abi.ChainEpoch = -8
UpgradeOrangeHeight abi.ChainEpoch = -9
UpgradeClausHeight abi.ChainEpoch = -10
UpgradeActorsV3Height abi.ChainEpoch = -11
UpgradeNorwegianHeight abi.ChainEpoch = -12
UpgradeActorsV4Height abi.ChainEpoch = -13
UpgradeSmokeHeight abi.ChainEpoch = -1
UpgradeIgnitionHeight abi.ChainEpoch = -2
UpgradeRefuelHeight abi.ChainEpoch = -3
UpgradeTapeHeight abi.ChainEpoch = -4
UpgradeActorsV2Height abi.ChainEpoch = 10
UpgradeLiftoffHeight abi.ChainEpoch = -5
UpgradeKumquatHeight abi.ChainEpoch = -6
UpgradeCalicoHeight abi.ChainEpoch = -7
UpgradePersianHeight abi.ChainEpoch = -8
UpgradeOrangeHeight abi.ChainEpoch = -9
UpgradeClausHeight abi.ChainEpoch = -10
UpgradeActorsV3Height abi.ChainEpoch = -11
UpgradeNorwegianHeight abi.ChainEpoch = -12
UpgradeActorsV4Height abi.ChainEpoch = -13
UpgradeHyperdriveHeight abi.ChainEpoch = -13

DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
Expand Down
7 changes: 4 additions & 3 deletions chain/actors/agen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ import (
"golang.org/x/xerrors"
)

var latestVersion = 4
var latestVersion = 5

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

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

var actors = map[string][]int{
Expand Down
9 changes: 9 additions & 0 deletions chain/actors/builtin/account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"

builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"

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

func init() {
Expand All @@ -37,6 +39,10 @@ func init() {
builtin.RegisterActorState(builtin4.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})

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

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

case builtin5.AccountActorCodeID:
return load5(store, act.Head)

}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
Expand Down
30 changes: 30 additions & 0 deletions chain/actors/builtin/account/v5.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package account

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

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

account5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/account"
)

var _ State = (*state5)(nil)

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

type state5 struct {
account5.State
store adt.Store
}

func (s *state5) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}
60 changes: 46 additions & 14 deletions chain/actors/builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,49 @@ import (
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
smoothing4 "github.com/filecoin-project/specs-actors/v4/actors/util/smoothing"

builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
smoothing5 "github.com/filecoin-project/specs-actors/v5/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"

miner4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/miner"
proof4 "github.com/filecoin-project/specs-actors/v4/actors/runtime/proof"
miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"
)

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

var (
ExpectedLeadersPerEpoch = builtin4.ExpectedLeadersPerEpoch
ExpectedLeadersPerEpoch = builtin5.ExpectedLeadersPerEpoch
)

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

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

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

func FromV0FilterEstimate(v0 smoothing0.FilterEstimate) FilterEstimate {
Expand All @@ -83,6 +86,12 @@ func FromV4FilterEstimate(v4 smoothing4.FilterEstimate) FilterEstimate {

}

func FromV5FilterEstimate(v5 smoothing5.FilterEstimate) FilterEstimate {

return (FilterEstimate)(v5)

}

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

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

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

default:
return "<unknown>"
}
Expand All @@ -137,6 +149,10 @@ func IsBuiltinActor(c cid.Cid) bool {
return true
}

if builtin5.IsBuiltinActor(c) {
return true
}

return false
}

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

if c == builtin5.AccountActorCodeID {
return true
}

return false
}

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

if c == builtin5.StorageMinerActorCodeID {
return true
}

return false
}

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

if c == builtin5.MultisigActorCodeID {
return true
}

return false
}

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

if c == builtin5.PaymentChannelActorCodeID {
return true
}

return false
}

Expand Down
6 changes: 3 additions & 3 deletions chain/actors/builtin/cron/cron.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package cron

import (
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
)

var (
Address = builtin4.CronActorAddr
Methods = builtin4.MethodsCron
Address = builtin5.CronActorAddr
Methods = builtin5.MethodsCron
)
13 changes: 11 additions & 2 deletions chain/actors/builtin/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"

builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"

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

func init() {
Expand All @@ -39,11 +41,15 @@ func init() {
builtin.RegisterActorState(builtin4.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})

builtin.RegisterActorState(builtin5.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
}

var (
Address = builtin4.InitActorAddr
Methods = builtin4.MethodsInit
Address = builtin5.InitActorAddr
Methods = builtin5.MethodsInit
)

func Load(store adt.Store, act *types.Actor) (State, error) {
Expand All @@ -61,6 +67,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case builtin4.InitActorCodeID:
return load4(store, act.Head)

case builtin5.InitActorCodeID:
return load5(store, act.Head)

}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
Expand Down
Loading

0 comments on commit a36f1e9

Please sign in to comment.