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

Update to specs-actors v0.9.8 #3725

Merged
merged 8 commits into from
Sep 10, 2020
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
4 changes: 3 additions & 1 deletion api/api_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"time"

"github.com/filecoin-project/go-state-types/dline"

"github.com/filecoin-project/specs-actors/actors/runtime/proof"

"github.com/ipfs/go-cid"
Expand Down Expand Up @@ -318,7 +320,7 @@ type FullNode interface {
StateMinerActiveSectors(context.Context, address.Address, types.TipSetKey) ([]*ChainSectorInfo, error)
// StateMinerProvingDeadline calculates the deadline at some epoch for a proving period
// and returns the deadline-related calculations.
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*miner.DeadlineInfo, error)
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
// StateMinerPower returns the power of the indicated miner
StateMinerPower(context.Context, address.Address, types.TipSetKey) (*MinerPower, error)
// StateMinerInfo returns info about the indicated miner
Expand Down
6 changes: 4 additions & 2 deletions api/apistruct/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"io"
"time"

"github.com/filecoin-project/go-state-types/dline"

"github.com/ipfs/go-cid"
metrics "github.com/libp2p/go-libp2p-core/metrics"
"github.com/libp2p/go-libp2p-core/network"
Expand Down Expand Up @@ -162,7 +164,7 @@ type FullNodeStruct struct {
StateNetworkName func(context.Context) (dtypes.NetworkName, error) `perm:"read"`
StateMinerSectors func(context.Context, address.Address, *bitfield.BitField, bool, types.TipSetKey) ([]*api.ChainSectorInfo, error) `perm:"read"`
StateMinerActiveSectors func(context.Context, address.Address, types.TipSetKey) ([]*api.ChainSectorInfo, error) `perm:"read"`
StateMinerProvingDeadline func(context.Context, address.Address, types.TipSetKey) (*miner.DeadlineInfo, error) `perm:"read"`
StateMinerProvingDeadline func(context.Context, address.Address, types.TipSetKey) (*dline.Info, error) `perm:"read"`
StateMinerPower func(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) `perm:"read"`
StateMinerInfo func(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error) `perm:"read"`
StateMinerDeadlines func(context.Context, address.Address, types.TipSetKey) ([]*miner.Deadline, error) `perm:"read"`
Expand Down Expand Up @@ -738,7 +740,7 @@ func (c *FullNodeStruct) StateMinerActiveSectors(ctx context.Context, addr addre
return c.Internal.StateMinerActiveSectors(ctx, addr, tsk)
}

func (c *FullNodeStruct) StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*miner.DeadlineInfo, error) {
func (c *FullNodeStruct) StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*dline.Info, error) {
return c.Internal.StateMinerProvingDeadline(ctx, addr, tsk)
}

Expand Down
8 changes: 8 additions & 0 deletions build/params_shared_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ func MessagesTopic(netName dtypes.NetworkName) string { return "/fil/msgs/" + st
func DhtProtocolName(netName dtypes.NetworkName) protocol.ID {
return protocol.ID("/fil/kad/" + string(netName))
}

func UseNewestNetwork() bool {
// TODO: Put these in a container we can iterate over
if UpgradeBreezeHeight <= 0 && UpgradeSmokeHeight <= 0 {
return true
}
return false
}
3 changes: 3 additions & 0 deletions build/params_shared_vals.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package build
import (
"math/big"

"github.com/filecoin-project/go-state-types/network"

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
Expand All @@ -20,6 +22,7 @@ const UnixfsLinksPerLevel = 1024
// Consensus / Network

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

// Epochs
const ForkLengthThreshold = Finality
Expand Down
5 changes: 4 additions & 1 deletion build/params_testground.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"math/big"

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
)
Expand Down Expand Up @@ -73,9 +74,11 @@ var (
UpgradeBreezeHeight abi.ChainEpoch = -1
BreezeGasTampingDuration abi.ChainEpoch = 0

UpgradeSmokeHeight = -1
UpgradeSmokeHeight abi.ChainEpoch = -1

DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
}

NewestNetworkVersion = network.Version2
)
6 changes: 3 additions & 3 deletions chain/gen/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"fmt"

"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/go-state-types/network"

"github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore"
Expand Down Expand Up @@ -406,8 +406,8 @@ func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, stateroot ci
verifNeeds := make(map[address.Address]abi.PaddedPieceSize)
var sum abi.PaddedPieceSize

nwv := func(context.Context, abi.ChainEpoch) runtime.NetworkVersion {
return runtime.NetworkVersion1
nwv := func(context.Context, abi.ChainEpoch) network.Version {
return build.NewestNetworkVersion
}

vmopt := vm.VMOpts{
Expand Down
8 changes: 6 additions & 2 deletions chain/gen/genesis/miners.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import (
"fmt"
"math/rand"

"github.com/filecoin-project/lotus/build"

"github.com/filecoin-project/go-state-types/network"

"github.com/filecoin-project/lotus/chain/state"

"github.com/ipfs/go-cid"
Expand Down Expand Up @@ -61,8 +65,8 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
return big.Zero(), nil
}

nwv := func(context.Context, abi.ChainEpoch) runtime.NetworkVersion {
return runtime.NetworkVersion1
nwv := func(context.Context, abi.ChainEpoch) network.Version {
return build.NewestNetworkVersion
}

vmopt := &vm.VMOpts{
Expand Down
9 changes: 4 additions & 5 deletions chain/stmgr/forks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/specs-actors/actors/util/adt"
"golang.org/x/xerrors"

"github.com/filecoin-project/lotus/chain/actors"
Expand Down Expand Up @@ -73,15 +72,15 @@ func (ta *testActor) Exports() []interface{} {
}
}

func (ta *testActor) Constructor(rt runtime.Runtime, params *adt.EmptyValue) *adt.EmptyValue {
func (ta *testActor) Constructor(rt runtime.Runtime, params *abi.EmptyValue) *abi.EmptyValue {
rt.ValidateImmediateCallerAcceptAny()
rt.State().Create(&testActorState{11})
fmt.Println("NEW ACTOR ADDRESS IS: ", rt.Message().Receiver())

return adt.Empty
return abi.Empty
}

func (ta *testActor) TestMethod(rt runtime.Runtime, params *adt.EmptyValue) *adt.EmptyValue {
func (ta *testActor) TestMethod(rt runtime.Runtime, params *abi.EmptyValue) *abi.EmptyValue {
rt.ValidateImmediateCallerAcceptAny()
var st testActorState
rt.State().Readonly(&st)
Expand All @@ -96,7 +95,7 @@ func (ta *testActor) TestMethod(rt runtime.Runtime, params *adt.EmptyValue) *adt
}
}

return adt.Empty
return abi.Empty
}

func TestForkHeightTriggers(t *testing.T) {
Expand Down
16 changes: 10 additions & 6 deletions chain/stmgr/stmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"sync"

"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/go-state-types/network"

"github.com/filecoin-project/specs-actors/actors/builtin/power"

Expand Down Expand Up @@ -1124,14 +1124,18 @@ func (sm *StateManager) GetCirculatingSupply(ctx context.Context, height abi.Cha
return csi.FilCirculating, nil
}

func (sm *StateManager) GetNtwkVersion(ctx context.Context, height abi.ChainEpoch) runtime.NetworkVersion {
if build.UpgradeBreezeHeight == 0 {
return runtime.NetworkVersion1
func (sm *StateManager) GetNtwkVersion(ctx context.Context, height abi.ChainEpoch) network.Version {
if build.UseNewestNetwork() {
return build.NewestNetworkVersion
}

if height <= build.UpgradeBreezeHeight {
return runtime.NetworkVersion0
return network.Version0
}

return runtime.NetworkVersion1
if height <= build.UpgradeSmokeHeight {
return network.Version1
}

return build.NewestNetworkVersion
}
4 changes: 2 additions & 2 deletions chain/stmgr/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,8 @@ func init() {
// Explicitly add send, it's special.
methods[builtin.MethodSend] = MethodMeta{
Name: "Send",
Params: reflect.TypeOf(new(adt.EmptyValue)),
Ret: reflect.TypeOf(new(adt.EmptyValue)),
Params: reflect.TypeOf(new(abi.EmptyValue)),
Ret: reflect.TypeOf(new(abi.EmptyValue)),
}

// Learn method names from the builtin.Methods* structs.
Expand Down
6 changes: 2 additions & 4 deletions chain/vm/invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"golang.org/x/xerrors"

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/cron"
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
Expand All @@ -27,9 +28,6 @@ import (
"github.com/filecoin-project/specs-actors/actors/builtin/system"
"github.com/filecoin-project/specs-actors/actors/runtime"
vmr "github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/specs-actors/actors/util/adt"

"github.com/filecoin-project/lotus/chain/actors/aerrors"
)

type Invoker struct {
Expand All @@ -47,7 +45,7 @@ func NewInvoker() *Invoker {
}

// add builtInCode using: register(cid, singleton)
inv.Register(builtin.SystemActorCodeID, system.Actor{}, adt.EmptyValue{})
inv.Register(builtin.SystemActorCodeID, system.Actor{}, abi.EmptyValue{})
inv.Register(builtin.InitActorCodeID, init_.Actor{}, init_.State{})
inv.Register(builtin.RewardActorCodeID, reward.Actor{}, reward.State{})
inv.Register(builtin.CronActorCodeID, cron.Actor{}, cron.State{})
Expand Down
9 changes: 5 additions & 4 deletions chain/vm/invoker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"io"
"testing"

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

cbor "github.com/ipfs/go-ipld-cbor"
"github.com/stretchr/testify/assert"
cbg "github.com/whyrusleeping/cbor-gen"
Expand All @@ -13,7 +15,6 @@ import (
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/specs-actors/actors/util/adt"
)

type basicContract struct{}
Expand Down Expand Up @@ -60,17 +61,17 @@ func (b basicContract) Exports() []interface{} {
}
}

func (basicContract) InvokeSomething0(rt runtime.Runtime, params *basicParams) *adt.EmptyValue {
func (basicContract) InvokeSomething0(rt runtime.Runtime, params *basicParams) *abi.EmptyValue {
rt.Abortf(exitcode.ExitCode(params.B), "params.B")
return nil
}

func (basicContract) BadParam(rt runtime.Runtime, params *basicParams) *adt.EmptyValue {
func (basicContract) BadParam(rt runtime.Runtime, params *basicParams) *abi.EmptyValue {
rt.Abortf(255, "bad params")
return nil
}

func (basicContract) InvokeSomething10(rt runtime.Runtime, params *basicParams) *adt.EmptyValue {
func (basicContract) InvokeSomething10(rt runtime.Runtime, params *basicParams) *abi.EmptyValue {
rt.Abortf(exitcode.ExitCode(params.B+10), "params.B")
return nil
}
Expand Down
7 changes: 4 additions & 3 deletions chain/vm/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
gruntime "runtime"
"time"

"github.com/filecoin-project/go-state-types/network"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
Expand All @@ -16,7 +18,6 @@ import (
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/runtime"
vmr "github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/specs-actors/actors/util/adt"
"github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor"
cbg "github.com/whyrusleeping/cbor-gen"
Expand Down Expand Up @@ -56,7 +57,7 @@ type Runtime struct {
lastGasCharge *types.GasTrace
}

func (rt *Runtime) NetworkVersion() vmr.NetworkVersion {
func (rt *Runtime) NetworkVersion() network.Version {
return rt.vm.GetNtwkVersion(rt.ctx, rt.CurrEpoch())
}

Expand Down Expand Up @@ -136,7 +137,7 @@ func (rt *Runtime) shimCall(f func() interface{}) (rval []byte, aerr aerrors.Act
switch ret := ret.(type) {
case []byte:
return ret, nil
case *adt.EmptyValue:
case *abi.EmptyValue:
return nil, nil
case cbg.CBORMarshaler:
buf := new(bytes.Buffer)
Expand Down
6 changes: 3 additions & 3 deletions chain/vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"reflect"
"time"

"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/go-state-types/network"

bstore "github.com/filecoin-project/lotus/lib/blockstore"

Expand Down Expand Up @@ -142,7 +142,7 @@ func (vm *UnsafeVM) MakeRuntime(ctx context.Context, msg *types.Message, origin
}

type CircSupplyCalculator func(context.Context, abi.ChainEpoch, *state.StateTree) (abi.TokenAmount, error)
type NtwkVersionGetter func(context.Context, abi.ChainEpoch) runtime.NetworkVersion
type NtwkVersionGetter func(context.Context, abi.ChainEpoch) network.Version

type VM struct {
cstate *state.StateTree
Expand Down Expand Up @@ -722,7 +722,7 @@ func (vm *VM) SetInvoker(i *Invoker) {
vm.inv = i
}

func (vm *VM) GetNtwkVersion(ctx context.Context, ce abi.ChainEpoch) runtime.NetworkVersion {
func (vm *VM) GetNtwkVersion(ctx context.Context, ce abi.ChainEpoch) network.Version {
return vm.ntwkVersion(ctx, ce)
}

Expand Down
Loading