Skip to content

Commit

Permalink
Implement FIP-0031
Browse files Browse the repository at this point in the history
  • Loading branch information
arajasek committed Mar 12, 2022
1 parent 67889b4 commit b4dc0f7
Show file tree
Hide file tree
Showing 52 changed files with 2,389 additions and 70 deletions.
Binary file modified build/openrpc/full.json.gz
Binary file not shown.
Binary file modified build/openrpc/miner.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 @@ -48,6 +48,7 @@ var UpgradeHyperdriveHeight = abi.ChainEpoch(-16)
var UpgradeChocolateHeight = abi.ChainEpoch(-17)

var UpgradeOhSnapHeight = abi.ChainEpoch(-18)
var UpgradeFVM1Height = abi.ChainEpoch(-19)

var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
Expand Down Expand Up @@ -91,6 +92,7 @@ func init() {
UpgradeHyperdriveHeight = getUpgradeHeight("LOTUS_HYPERDRIVE_HEIGHT", UpgradeHyperdriveHeight)
UpgradeChocolateHeight = getUpgradeHeight("LOTUS_CHOCOLATE_HEIGHT", UpgradeChocolateHeight)
UpgradeOhSnapHeight = getUpgradeHeight("LOTUS_OHSNAP_HEIGHT", UpgradeOhSnapHeight)
UpgradeFVM1Height = getUpgradeHeight("LOTUS_FVM1_HEIGHT", UpgradeFVM1Height)

BuildType |= Build2k

Expand Down
2 changes: 2 additions & 0 deletions build/params_butterfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const UpgradeChocolateHeight = -17

const UpgradeOhSnapHeight = 240

var UpgradeFVM1Height = abi.ChainEpoch(99999999999999)

func init() {
policy.SetConsensusMinerMinPower(abi.NewStoragePower(2 << 30))
policy.SetSupportedProofTypes(
Expand Down
2 changes: 2 additions & 0 deletions build/params_calibnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ const UpgradeChocolateHeight = 312746
// 2022-02-10T19:23:00Z
const UpgradeOhSnapHeight = 682006

var UpgradeFVM1Height = abi.ChainEpoch(99999999999999)

func init() {
policy.SetConsensusMinerMinPower(abi.NewStoragePower(32 << 30))
policy.SetSupportedProofTypes(
Expand Down
4 changes: 4 additions & 0 deletions build/params_interop.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var UpgradeTurboHeight = abi.ChainEpoch(-15)
var UpgradeHyperdriveHeight = abi.ChainEpoch(-16)
var UpgradeChocolateHeight = abi.ChainEpoch(-17)
var UpgradeOhSnapHeight = abi.ChainEpoch(-18)
var UpgradeFVM1Height = abi.ChainEpoch(-19)

var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
Expand Down Expand Up @@ -93,6 +94,9 @@ 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)
UpgradeOhSnapHeight = getUpgradeHeight("LOTUS_OHSNAP_HEIGHT", UpgradeOhSnapHeight)
UpgradeFVM1Height = getUpgradeHeight("LOTUS_FVM1_HEIGHT", UpgradeFVM1Height)

BuildType |= BuildInteropnet
SetAddressNetwork(address.Testnet)
Expand Down
2 changes: 2 additions & 0 deletions build/params_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ const UpgradeChocolateHeight = 1231620
// 2022-03-01T15:00:00Z
var UpgradeOhSnapHeight = abi.ChainEpoch(1594680)

var UpgradeFVM1Height = abi.ChainEpoch(99999999999999)

func init() {
if os.Getenv("LOTUS_USE_TEST_ADDRESSES") != "1" {
SetAddressNetwork(address.Mainnet)
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.Version15
const NewestNetworkVersion = network.Version16

/* 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 @@ -100,6 +100,7 @@ var (
UpgradeHyperdriveHeight abi.ChainEpoch = -15
UpgradeChocolateHeight abi.ChainEpoch = -16
UpgradeOhSnapHeight abi.ChainEpoch = -17
UpgradeFVM1Height abi.ChainEpoch = -18

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

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

builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
)

func init() {
Expand Down Expand Up @@ -56,6 +58,10 @@ func init() {
builtin.RegisterActorState(builtin7.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})

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

var Methods = builtin4.MethodsAccount
Expand Down Expand Up @@ -84,6 +90,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case builtin7.AccountActorCodeID:
return load7(store, act.Head)

case builtin8.AccountActorCodeID:
return load8(store, act.Head)

}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
Expand Down Expand Up @@ -112,6 +121,9 @@ func MakeState(store adt.Store, av actors.Version, addr address.Address) (State,
case actors.Version7:
return make7(store, addr)

case actors.Version8:
return make8(store, addr)

}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
Expand Down Expand Up @@ -140,6 +152,9 @@ func GetActorCodeID(av actors.Version) (cid.Cid, error) {
case actors.Version7:
return builtin7.AccountActorCodeID, nil

case actors.Version8:
return builtin8.AccountActorCodeID, nil

}

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

account8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/account"
)

var _ State = (*state8)(nil)

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

func make8(store adt.Store, addr address.Address) (State, error) {
out := state8{store: store}
out.State = account8.State{Address: addr}
return &out, nil
}

type state8 struct {
account8.State
store adt.Store
}

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

func (s *state8) GetState() interface{} {
return &s.State
}
62 changes: 47 additions & 15 deletions chain/actors/builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,47 +26,50 @@ import (
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
smoothing7 "github.com/filecoin-project/specs-actors/v7/actors/util/smoothing"

builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
smoothing8 "github.com/filecoin-project/specs-actors/v8/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"

miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner"
proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof"
miner8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/miner"
proof8 "github.com/filecoin-project/specs-actors/v8/actors/runtime/proof"
)

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

var (
ExpectedLeadersPerEpoch = builtin7.ExpectedLeadersPerEpoch
ExpectedLeadersPerEpoch = builtin8.ExpectedLeadersPerEpoch
)

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

const (
MethodSend = builtin7.MethodSend
MethodConstructor = builtin7.MethodConstructor
MethodSend = builtin8.MethodSend
MethodConstructor = builtin8.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 = proof7.SectorInfo
type ExtendedSectorInfo = proof7.ExtendedSectorInfo
type PoStProof = proof7.PoStProof
type SectorInfo = proof8.SectorInfo
type ExtendedSectorInfo = proof8.ExtendedSectorInfo
type PoStProof = proof8.PoStProof
type FilterEstimate = smoothing0.FilterEstimate

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

func FromV0FilterEstimate(v0 smoothing0.FilterEstimate) FilterEstimate {
Expand Down Expand Up @@ -111,6 +114,12 @@ func FromV7FilterEstimate(v7 smoothing7.FilterEstimate) FilterEstimate {

}

func FromV8FilterEstimate(v8 smoothing8.FilterEstimate) FilterEstimate {

return (FilterEstimate)(v8)

}

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

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

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

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

if builtin8.IsBuiltinActor(c) {
return true
}

return false
}

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

if c == builtin8.AccountActorCodeID {
return true
}

return false
}

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

if c == builtin8.StorageMinerActorCodeID {
return true
}

return false
}

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

if c == builtin8.MultisigActorCodeID {
return true
}

return false
}

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

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

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

builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
)

func MakeState(store adt.Store, av actors.Version) (State, error) {
Expand All @@ -45,6 +47,9 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
case actors.Version7:
return make7(store)

case actors.Version8:
return make8(store)

}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
Expand Down Expand Up @@ -73,14 +78,17 @@ func GetActorCodeID(av actors.Version) (cid.Cid, error) {
case actors.Version7:
return builtin7.CronActorCodeID, nil

case actors.Version8:
return builtin8.CronActorCodeID, nil

}

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

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

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

cron8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/cron"
)

var _ State = (*state8)(nil)

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

func make8(store adt.Store) (State, error) {
out := state8{store: store}
out.State = *cron8.ConstructState(cron8.BuiltInEntries())
return &out, nil
}

type state8 struct {
cron8.State
store adt.Store
}

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

0 comments on commit b4dc0f7

Please sign in to comment.