diff --git a/chain/actors/actor_init.go b/chain/actors/actor_init.go index 346279dc2..f7c2fb6d4 100644 --- a/chain/actors/actor_init.go +++ b/chain/actors/actor_init.go @@ -169,7 +169,7 @@ func IsSingletonActor(code cid.Cid) bool { return code == StoragePowerCodeCid || code == StorageMarketCodeCid || code == InitCodeCid || code == CronCodeCid } -func (ias *InitActorState) AddActor(cst hamt.CborIpldStore, addr address.Address) (address.Address, error) { +func (ias *InitActorState) AddActor(cst cbor.IpldStore, addr address.Address) (address.Address, error) { nid := ias.NextID amap, err := hamt.LoadNode(context.TODO(), cst, ias.AddressMap) @@ -195,7 +195,7 @@ func (ias *InitActorState) AddActor(cst hamt.CborIpldStore, addr address.Address return NewIDAddress(nid) } -func (ias *InitActorState) Lookup(cst hamt.CborIpldStore, addr address.Address) (address.Address, error) { +func (ias *InitActorState) Lookup(cst cbor.IpldStore, addr address.Address) (address.Address, error) { amap, err := hamt.LoadNode(context.TODO(), cst, ias.AddressMap) if err != nil { return address.Undef, xerrors.Errorf("ias lookup failed loading hamt node: %w", err) diff --git a/chain/actors/actor_miner2.go b/chain/actors/actor_miner2.go index c3639eebc..eb9e633dc 100644 --- a/chain/actors/actor_miner2.go +++ b/chain/actors/actor_miner2.go @@ -63,8 +63,8 @@ func (sma StorageMinerActor2) StorageMinerConstructor(act *types.Actor, vmctx ty } var self StorageMinerActorState - sectors := amt2.NewAMT(types.WrapStorage(vmctx.Storage())) - scid, serr := sectors.Flush() + sectors := amt2.NewAMT(vmctx.Ipld()) + scid, serr := sectors.Flush(context.TODO()) if serr != nil { return nil, aerrors.HandleExternalError(serr, "initializing AMT") } @@ -219,7 +219,7 @@ func (sma StorageMinerActor2) ProveCommitSector(act *types.Actor, vmctx types.VM // Note: There must exist a unique index in the miner's sector set for each // sector ID. The `faults`, `recovered`, and `done` parameters of the // SubmitPoSt method express indices into this sector set. - nssroot, err := AddToSectorSet2(ctx, types.WrapStorage(vmctx.Storage()), self.Sectors, params.SectorID, us.Info.CommR, commD) + nssroot, err := AddToSectorSet2(ctx, vmctx.Ipld(), self.Sectors, params.SectorID, us.Info.CommR, commD) if err != nil { return nil, err } @@ -233,7 +233,7 @@ func (sma StorageMinerActor2) ProveCommitSector(act *types.Actor, vmctx types.VM // // Note: Proving period is a function of sector size; small sectors take less // time to prove than large sectors do. Sector size is selected when pledging. - pss, lerr := amt2.LoadAMT(types.WrapStorage(vmctx.Storage()), self.ProvingSet) + pss, lerr := amt2.LoadAMT(vmctx.Context(), vmctx.Ipld(), self.ProvingSet) if lerr != nil { return nil, aerrors.HandleExternalError(lerr, "could not load proving set node") } @@ -315,12 +315,12 @@ func (sma StorageMinerActor2) SubmitFallbackPoSt(act *types.Actor, vmctx types.V copy(seed[:], rand) } - pss, lerr := amt2.LoadAMT(types.WrapStorage(vmctx.Storage()), self.ProvingSet) + pss, lerr := amt2.LoadAMT(vmctx.Context(), vmctx.Ipld(), self.ProvingSet) if lerr != nil { return nil, aerrors.HandleExternalError(lerr, "could not load proving set node") } - ss, lerr := amt2.LoadAMT(types.WrapStorage(vmctx.Storage()), self.Sectors) + ss, lerr := amt2.LoadAMT(vmctx.Context(), vmctx.Ipld(), self.Sectors) if lerr != nil { return nil, aerrors.HandleExternalError(lerr, "could not load proving set node") } @@ -332,7 +332,7 @@ func (sma StorageMinerActor2) SubmitFallbackPoSt(act *types.Actor, vmctx types.V activeFaults := uint64(0) var sectorInfos []ffi.PublicSectorInfo - if err := pss.ForEach(func(id uint64, v *cbg.Deferred) error { + if err := pss.ForEach(vmctx.Context(), func(id uint64, v *cbg.Deferred) error { if faults[id] { activeFaults++ return nil @@ -421,7 +421,7 @@ func (sma StorageMinerActor2) GetPower2(act *types.Actor, vmctx types.VMContext, return self.Power.Bytes(), nil } -func SectorIsUnique2(ctx context.Context, s types.Storage, sroot cid.Cid, sid uint64) (bool, ActorError) { +func SectorIsUnique2(ctx context.Context, s cbor.IpldStore, sroot cid.Cid, sid uint64) (bool, ActorError) { found, _, _, err := GetFromSectorSet2(ctx, s, sroot, sid) if err != nil { return false, err @@ -430,22 +430,22 @@ func SectorIsUnique2(ctx context.Context, s types.Storage, sroot cid.Cid, sid ui return !found, nil } -func AddToSectorSet2(ctx context.Context, blks amt2.Blocks, ss cid.Cid, sectorID uint64, commR, commD []byte) (cid.Cid, ActorError) { +func AddToSectorSet2(ctx context.Context, blks cbor.IpldStore, ss cid.Cid, sectorID uint64, commR, commD []byte) (cid.Cid, ActorError) { if sectorID >= build.MinerMaxSectors { return cid.Undef, aerrors.Newf(25, "sector ID out of range: %d", sectorID) } - ssr, err := amt2.LoadAMT(blks, ss) + ssr, err := amt2.LoadAMT(ctx, blks, ss) if err != nil { return cid.Undef, aerrors.HandleExternalError(err, "could not load sector set node") } // TODO: Spec says to use SealCommitment, and construct commD from deals each time, // but that would make SubmitPoSt way, way more expensive - if err := ssr.Set(sectorID, [][]byte{commR, commD}); err != nil { + if err := ssr.Set(ctx, sectorID, [][]byte{commR, commD}); err != nil { return cid.Undef, aerrors.HandleExternalError(err, "failed to set commitment in sector set") } - ncid, err := ssr.Flush() + ncid, err := ssr.Flush(ctx) if err != nil { return cid.Undef, aerrors.HandleExternalError(err, "failed to flush sector set") } @@ -453,18 +453,18 @@ func AddToSectorSet2(ctx context.Context, blks amt2.Blocks, ss cid.Cid, sectorID return ncid, nil } -func GetFromSectorSet2(ctx context.Context, s types.Storage, ss cid.Cid, sectorID uint64) (bool, []byte, []byte, ActorError) { +func GetFromSectorSet2(ctx context.Context, cst cbor.IpldStore, ss cid.Cid, sectorID uint64) (bool, []byte, []byte, ActorError) { if sectorID >= build.MinerMaxSectors { return false, nil, nil, aerrors.Newf(25, "sector ID out of range: %d", sectorID) } - ssr, err := amt2.LoadAMT(types.WrapStorage(s), ss) + ssr, err := amt2.LoadAMT(ctx, cst, ss) if err != nil { return false, nil, nil, aerrors.HandleExternalError(err, "could not load sector set node") } var comms [][]byte - err = ssr.Get(sectorID, &comms) + err = ssr.Get(ctx, sectorID, &comms) if err != nil { if _, ok := err.(*amt2.ErrNotFound); ok { return false, nil, nil, nil @@ -479,20 +479,20 @@ func GetFromSectorSet2(ctx context.Context, s types.Storage, ss cid.Cid, sectorI return true, comms[0], comms[1], nil } -func RemoveFromSectorSet2(ctx context.Context, s types.Storage, ss cid.Cid, ids []uint64) (cid.Cid, aerrors.ActorError) { +func RemoveFromSectorSet2(ctx context.Context, cst cbor.IpldStore, ss cid.Cid, ids []uint64) (cid.Cid, aerrors.ActorError) { - ssr, err := amt2.LoadAMT(types.WrapStorage(s), ss) + ssr, err := amt2.LoadAMT(ctx, cst, ss) if err != nil { return cid.Undef, aerrors.HandleExternalError(err, "could not load sector set node") } for _, id := range ids { - if err := ssr.Delete(id); err != nil { + if err := ssr.Delete(ctx, id); err != nil { log.Warnf("failed to delete sector %d from set: %s", id, err) } } - ncid, err := ssr.Flush() + ncid, err := ssr.Flush(ctx) if err != nil { return cid.Undef, aerrors.HandleExternalError(err, "failed to flush sector set") } @@ -673,7 +673,7 @@ func (sma StorageMinerActor2) DeclareFaults(act *types.Actor, vmctx types.VMCont return nil, aerrors.Absorb(err, 1, "failed to merge bitfields") } - ss, nerr := amt2.LoadAMT(types.WrapStorage(vmctx.Storage()), self.Sectors) + ss, nerr := amt2.LoadAMT(vmctx.Context(), vmctx.Ipld(), self.Sectors) if nerr != nil { return nil, aerrors.HandleExternalError(nerr, "failed to load sector set") } @@ -760,6 +760,8 @@ func (sma StorageMinerActor2) SlashConsensusFault(act *types.Actor, vmctx types. } func (sma StorageMinerActor2) SubmitElectionPoSt(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, aerrors.ActorError) { + ctx := vmctx.Context() + if vmctx.Message().From != NetworkAddress { return nil, aerrors.Newf(1, "submit election post can only be called by the storage power actor") } @@ -773,12 +775,12 @@ func (sma StorageMinerActor2) SubmitElectionPoSt(act *types.Actor, vmctx types.V return nil, aerrors.New(1, "slashed miners can't perform election PoSt") } - pss, nerr := amt2.LoadAMT(types.WrapStorage(vmctx.Storage()), self.ProvingSet) + pss, nerr := amt2.LoadAMT(ctx, vmctx.Ipld(), self.ProvingSet) if nerr != nil { return nil, aerrors.HandleExternalError(nerr, "failed to load proving set") } - ss, nerr := amt2.LoadAMT(types.WrapStorage(vmctx.Storage()), self.Sectors) + ss, nerr := amt2.LoadAMT(ctx, vmctx.Ipld(), self.Sectors) if nerr != nil { return nil, aerrors.HandleExternalError(nerr, "failed to load proving set") } @@ -795,7 +797,7 @@ func (sma StorageMinerActor2) SubmitElectionPoSt(act *types.Actor, vmctx types.V } var comms [][]byte - err := pss.Get(f, &comms) + err := pss.Get(ctx, f, &comms) if err != nil { var notfound *amt2.ErrNotFound if !xerrors.As(err, ¬found) { @@ -823,6 +825,7 @@ func (sma StorageMinerActor2) SubmitElectionPoSt(act *types.Actor, vmctx types.V } func onSuccessfulPoSt2(self *StorageMinerActorState, vmctx types.VMContext, activeFaults uint64) aerrors.ActorError { + ctx := vmctx.Context() // FORK if vmctx.BlockHeight() < build.ForkBootyBayHeight { return onSuccessfulPoSt(self, vmctx, activeFaults) @@ -833,12 +836,12 @@ func onSuccessfulPoSt2(self *StorageMinerActorState, vmctx types.VMContext, acti return err } - pss, nerr := amt2.LoadAMT(types.WrapStorage(vmctx.Storage()), self.ProvingSet) + pss, nerr := amt2.LoadAMT(ctx, vmctx.Ipld(), self.ProvingSet) if nerr != nil { return aerrors.HandleExternalError(nerr, "failed to load proving set") } - ss, nerr := amt2.LoadAMT(types.WrapStorage(vmctx.Storage()), self.Sectors) + ss, nerr := amt2.LoadAMT(ctx, vmctx.Ipld(), self.Sectors) if nerr != nil { return aerrors.HandleExternalError(nerr, "failed to load sector set") } @@ -893,7 +896,7 @@ func onSuccessfulPoSt2(self *StorageMinerActorState, vmctx types.VMContext, acti var ncid cid.Cid var err aerrors.ActorError - ncid, err = RemoveFromSectorSet2(vmctx.Context(), vmctx.Storage(), self.Sectors, faults) + ncid, err = RemoveFromSectorSet2(ctx, vmctx.Ipld(), self.Sectors, faults) if err != nil { return err } diff --git a/chain/actors/actor_miner_test.go b/chain/actors/actor_miner_test.go index e08342248..c80519276 100644 --- a/chain/actors/actor_miner_test.go +++ b/chain/actors/actor_miner_test.go @@ -16,8 +16,8 @@ import ( "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/lib/rlepluslazy" - hamt "github.com/ipfs/go-hamt-ipld" blockstore "github.com/ipfs/go-ipfs-blockstore" + cbor "github.com/ipfs/go-ipld-cbor" "github.com/stretchr/testify/assert" cbg "github.com/whyrusleeping/cbor-gen" ) @@ -233,7 +233,7 @@ func getMinerState(ctx context.Context, st types.StateTree, bs blockstore.Blocks return nil, err } - cst := hamt.CSTFromBstore(bs) + cst := cbor.NewCborStore(bs) var mstate actors.StorageMinerActorState if err := cst.Get(ctx, mact.Head, &mstate); err != nil { diff --git a/chain/actors/actor_multisig.go b/chain/actors/actor_multisig.go index 8579c6643..59fa745b3 100644 --- a/chain/actors/actor_multisig.go +++ b/chain/actors/actor_multisig.go @@ -26,8 +26,8 @@ var MultiSigMethods = musigMethods{1, 2, 3, 4, 5, 6, 7, 8, 9} type MultiSigConstructorParams = samsig.ConstructorParams type MultiSigProposeParams = samsig.ProposeParams type MultiSigTxID = samsig.TxnIDParams -type MultiSigAddSignerParam = samsig.AddSigner -type MultiSigRemoveSignerParam = samsig.RemoveSigner +type MultiSigAddSignerParam = samsig.AddSignerParams +type MultiSigRemoveSignerParam = samsig.RemoveSignerParams type MultiSigSwapSignerParams = samsig.SwapSignerParams type MultiSigChangeReqParams = samsig.ChangeNumApprovalsThresholdParams diff --git a/chain/actors/actor_storagemarket.go b/chain/actors/actor_storagemarket.go index eec94fca0..05cf93987 100644 --- a/chain/actors/actor_storagemarket.go +++ b/chain/actors/actor_storagemarket.go @@ -11,6 +11,7 @@ import ( "github.com/filecoin-project/go-amt-ipld" "github.com/ipfs/go-cid" "github.com/ipfs/go-hamt-ipld" + cbor "github.com/ipfs/go-ipld-cbor" "github.com/filecoin-project/go-address" cborutil "github.com/filecoin-project/go-cbor-util" @@ -260,7 +261,7 @@ func setMarketBalances(vmctx types.VMContext, nd *hamt.Node, set map[address.Add return c, nil } -func GetMarketBalances(ctx context.Context, store hamt.CborIpldStore, rcid cid.Cid, addrs ...address.Address) ([]StorageParticipantBalance, *hamt.Node, ActorError) { +func GetMarketBalances(ctx context.Context, store cbor.IpldStore, rcid cid.Cid, addrs ...address.Address) ([]StorageParticipantBalance, *hamt.Node, ActorError) { ctx, span := trace.StartSpan(ctx, "GetMarketBalances") defer span.End() diff --git a/chain/actors/actor_storagepower.go b/chain/actors/actor_storagepower.go index 31e9e5822..7b525ff32 100644 --- a/chain/actors/actor_storagepower.go +++ b/chain/actors/actor_storagepower.go @@ -8,6 +8,7 @@ import ( "github.com/filecoin-project/go-amt-ipld" cid "github.com/ipfs/go-cid" hamt "github.com/ipfs/go-hamt-ipld" + cbor "github.com/ipfs/go-ipld-cbor" "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" "go.opencensus.io/trace" @@ -742,7 +743,7 @@ func MinerSetHas(vmctx types.VMContext, rcid cid.Cid, maddr address.Address) (bo } } -func MinerSetList(ctx context.Context, cst hamt.CborIpldStore, rcid cid.Cid) ([]address.Address, error) { +func MinerSetList(ctx context.Context, cst cbor.IpldStore, rcid cid.Cid) ([]address.Address, error) { nd, err := hamt.LoadNode(ctx, cst, rcid) if err != nil { return nil, xerrors.Errorf("failed to load miner set: %w", err) diff --git a/chain/actors/actor_storagepower_test.go b/chain/actors/actor_storagepower_test.go index c84492eae..172c6e8ff 100644 --- a/chain/actors/actor_storagepower_test.go +++ b/chain/actors/actor_storagepower_test.go @@ -15,7 +15,6 @@ import ( "github.com/filecoin-project/lotus/chain/wallet" cid "github.com/ipfs/go-cid" - hamt "github.com/ipfs/go-hamt-ipld" bstore "github.com/ipfs/go-ipfs-blockstore" cbor "github.com/ipfs/go-ipld-cbor" mh "github.com/multiformats/go-multihash" @@ -130,7 +129,7 @@ func cheatStorageMarketTotal(t *testing.T, vm *vm.VM, bs bstore.Blockstore) { t.Fatal(err) } - cst := hamt.CSTFromBstore(bs) + cst := cbor.NewCborStore(bs) var smastate StoragePowerState if err := cst.Get(context.TODO(), sma.Head, &smastate); err != nil { diff --git a/chain/actors/aerrors/wrap.go b/chain/actors/aerrors/wrap.go index b3dea8f09..928d3fb70 100644 --- a/chain/actors/aerrors/wrap.go +++ b/chain/actors/aerrors/wrap.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - hamt "github.com/ipfs/go-hamt-ipld" + cbor "github.com/ipfs/go-ipld-cbor" "golang.org/x/xerrors" ) @@ -160,7 +160,7 @@ func HandleExternalError(err error, msg string) ActorError { } } - if xerrors.Is(err, &hamt.SerializationError{}) { + if xerrors.Is(err, &cbor.SerializationError{}) { return &actorError{ fatal: false, retCode: 253, diff --git a/chain/actors/harness2_test.go b/chain/actors/harness2_test.go index b51eb234f..a75f69172 100644 --- a/chain/actors/harness2_test.go +++ b/chain/actors/harness2_test.go @@ -10,9 +10,9 @@ import ( "github.com/ipfs/go-cid" dstore "github.com/ipfs/go-datastore" - hamt "github.com/ipfs/go-hamt-ipld" blockstore "github.com/ipfs/go-ipfs-blockstore" bstore "github.com/ipfs/go-ipfs-blockstore" + cbor "github.com/ipfs/go-ipld-cbor" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" @@ -236,7 +236,7 @@ func (h *Harness) Apply(t testing.TB, msg types.Message) (*vm.ApplyRet, *state.S if err != nil { t.Fatalf("Flushing VM: %+v", err) } - cst := hamt.CSTFromBstore(h.bs) + cst := cbor.NewCborStore(h.bs) state, err := state.LoadStateTree(cst, stateroot) if err != nil { t.Fatalf("Loading state tree: %+v", err) diff --git a/chain/gen/mining.go b/chain/gen/mining.go index dec684ec2..e3c163828 100644 --- a/chain/gen/mining.go +++ b/chain/gen/mining.go @@ -6,7 +6,7 @@ import ( bls "github.com/filecoin-project/filecoin-ffi" amt "github.com/filecoin-project/go-amt-ipld" cid "github.com/ipfs/go-cid" - hamt "github.com/ipfs/go-hamt-ipld" + cbor "github.com/ipfs/go-ipld-cbor" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" @@ -99,7 +99,7 @@ func MinerCreateBlock(ctx context.Context, sm *stmgr.StateManager, w *wallet.Wal } next.ParentWeight = pweight - cst := hamt.CSTFromBstore(sm.ChainStore().Blockstore()) + cst := cbor.NewCborStore(sm.ChainStore().Blockstore()) tree, err := state.LoadStateTree(cst, st) if err != nil { return nil, xerrors.Errorf("failed to load state tree: %w", err) diff --git a/chain/gen/utils.go b/chain/gen/utils.go index 9787102c7..c7bcb2d1d 100644 --- a/chain/gen/utils.go +++ b/chain/gen/utils.go @@ -11,6 +11,7 @@ import ( hamt "github.com/ipfs/go-hamt-ipld" blockstore "github.com/ipfs/go-ipfs-blockstore" bstore "github.com/ipfs/go-ipfs-blockstore" + cbor "github.com/ipfs/go-ipld-cbor" peer "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" @@ -33,7 +34,7 @@ func SetupInitActor(bs bstore.Blockstore, addrs []address.Address) (*types.Actor var ias actors.InitActorState ias.NextID = 100 - cst := hamt.CSTFromBstore(bs) + cst := cbor.NewCborStore(bs) amap := hamt.NewNode(cst) for i, a := range addrs { @@ -67,7 +68,7 @@ func SetupInitActor(bs bstore.Blockstore, addrs []address.Address) (*types.Actor } func MakeInitialStateTree(bs bstore.Blockstore, actmap map[address.Address]types.BigInt) (*state.StateTree, error) { - cst := hamt.CSTFromBstore(bs) + cst := cbor.NewCborStore(bs) state, err := state.NewStateTree(cst) if err != nil { return nil, xerrors.Errorf("making new state tree: %w", err) @@ -148,7 +149,7 @@ func MakeInitialStateTree(bs bstore.Blockstore, actmap map[address.Address]types } func SetupCronActor(bs bstore.Blockstore) (*types.Actor, error) { - cst := hamt.CSTFromBstore(bs) + cst := cbor.NewCborStore(bs) cas := &actors.CronActorState{} stcid, err := cst.Put(context.TODO(), cas) @@ -165,7 +166,7 @@ func SetupCronActor(bs bstore.Blockstore) (*types.Actor, error) { } func SetupStoragePowerActor(bs bstore.Blockstore) (*types.Actor, error) { - cst := hamt.CSTFromBstore(bs) + cst := cbor.NewCborStore(bs) nd := hamt.NewNode(cst) emptyhamt, err := cst.Put(context.TODO(), nd) if err != nil { @@ -198,7 +199,7 @@ func SetupStoragePowerActor(bs bstore.Blockstore) (*types.Actor, error) { } func SetupStorageMarketActor(bs bstore.Blockstore, sroot cid.Cid, deals []actors.StorageDealProposal) (cid.Cid, error) { - cst := hamt.CSTFromBstore(bs) + cst := cbor.NewCborStore(bs) nd := hamt.NewNode(cst) emptyHAMT, err := cst.Put(context.TODO(), nd) if err != nil { @@ -322,7 +323,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid return cid.Undef, nil, err } - cst := hamt.CSTFromBstore(cs.Blockstore()) + cst := cbor.NewCborStore(cs.Blockstore()) if err := reassignMinerActorAddress(vm, cst, maddrret, maddr); err != nil { return cid.Undef, nil, err } @@ -381,7 +382,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid return c, deals, err } -func reassignMinerActorAddress(vm *vm.VM, cst hamt.CborIpldStore, from, to address.Address) error { +func reassignMinerActorAddress(vm *vm.VM, cst cbor.IpldStore, from, to address.Address) error { if from == to { return nil } @@ -406,7 +407,7 @@ func reassignMinerActorAddress(vm *vm.VM, cst hamt.CborIpldStore, from, to addre return initActorReassign(vm, cst, from, to) } -func adjustStorageMarketTracking(vm *vm.VM, cst hamt.CborIpldStore, from, to address.Address) error { +func adjustStorageMarketTracking(vm *vm.VM, cst cbor.IpldStore, from, to address.Address) error { ctx := context.TODO() act, err := vm.StateTree().GetActor(actors.StoragePowerAddress) if err != nil { @@ -451,7 +452,7 @@ func adjustStorageMarketTracking(vm *vm.VM, cst hamt.CborIpldStore, from, to add return nil } -func initActorReassign(vm *vm.VM, cst hamt.CborIpldStore, from, to address.Address) error { +func initActorReassign(vm *vm.VM, cst cbor.IpldStore, from, to address.Address) error { ctx := context.TODO() initact, err := vm.StateTree().GetActor(actors.InitAddress) if err != nil { @@ -643,7 +644,7 @@ func MakeGenesisBlock(bs bstore.Blockstore, sys *types.VMSyscalls, balances map[ } func AdjustInitActorStartID(ctx context.Context, bs blockstore.Blockstore, stateroot cid.Cid, val uint64) (cid.Cid, error) { - cst := hamt.CSTFromBstore(bs) + cst := cbor.NewCborStore(bs) tree, err := state.LoadStateTree(cst, stateroot) if err != nil { diff --git a/chain/state/statetree.go b/chain/state/statetree.go index 620702e4c..6e33aeb3e 100644 --- a/chain/state/statetree.go +++ b/chain/state/statetree.go @@ -6,6 +6,7 @@ import ( "github.com/ipfs/go-cid" hamt "github.com/ipfs/go-hamt-ipld" + cbor "github.com/ipfs/go-ipld-cbor" logging "github.com/ipfs/go-log/v2" "go.opencensus.io/trace" "golang.org/x/xerrors" @@ -19,13 +20,13 @@ var log = logging.Logger("statetree") type StateTree struct { root *hamt.Node - Store hamt.CborIpldStore + Store cbor.IpldStore actorcache map[address.Address]*types.Actor snapshot cid.Cid } -func NewStateTree(cst hamt.CborIpldStore) (*StateTree, error) { +func NewStateTree(cst cbor.IpldStore) (*StateTree, error) { return &StateTree{ root: hamt.NewNode(cst), Store: cst, @@ -33,7 +34,7 @@ func NewStateTree(cst hamt.CborIpldStore) (*StateTree, error) { }, nil } -func LoadStateTree(cst hamt.CborIpldStore, c cid.Cid) (*StateTree, error) { +func LoadStateTree(cst cbor.IpldStore, c cid.Cid) (*StateTree, error) { nd, err := hamt.LoadNode(context.Background(), cst, c) if err != nil { log.Errorf("loading hamt node %s failed: %s", c, err) diff --git a/chain/state/statetree_test.go b/chain/state/statetree_test.go index 17d71daca..66864f034 100644 --- a/chain/state/statetree_test.go +++ b/chain/state/statetree_test.go @@ -7,11 +7,11 @@ import ( address "github.com/filecoin-project/go-address" actors "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" - hamt "github.com/ipfs/go-hamt-ipld" + cbor "github.com/ipfs/go-ipld-cbor" ) func BenchmarkStateTreeSet(b *testing.B) { - cst := hamt.NewCborStore() + cst := cbor.NewMemCborStore() st, err := NewStateTree(cst) if err != nil { b.Fatal(err) @@ -38,7 +38,7 @@ func BenchmarkStateTreeSet(b *testing.B) { } func BenchmarkStateTreeSetFlush(b *testing.B) { - cst := hamt.NewCborStore() + cst := cbor.NewMemCborStore() st, err := NewStateTree(cst) if err != nil { b.Fatal(err) @@ -68,7 +68,7 @@ func BenchmarkStateTreeSetFlush(b *testing.B) { } func BenchmarkStateTree10kGetActor(b *testing.B) { - cst := hamt.NewCborStore() + cst := cbor.NewMemCborStore() st, err := NewStateTree(cst) if err != nil { b.Fatal(err) @@ -110,7 +110,7 @@ func BenchmarkStateTree10kGetActor(b *testing.B) { } func TestSetCache(t *testing.T) { - cst := hamt.NewCborStore() + cst := cbor.NewMemCborStore() st, err := NewStateTree(cst) if err != nil { t.Fatal(err) diff --git a/chain/stmgr/forks.go b/chain/stmgr/forks.go index 0cb9cea16..9bce70767 100644 --- a/chain/stmgr/forks.go +++ b/chain/stmgr/forks.go @@ -9,8 +9,8 @@ import ( "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/types" "github.com/ipfs/go-cid" - hamt "github.com/ipfs/go-hamt-ipld" blockstore "github.com/ipfs/go-ipfs-blockstore" + cbor "github.com/ipfs/go-ipld-cbor" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" ) @@ -66,7 +66,7 @@ func (sm *StateManager) handleStateForks(ctx context.Context, pstate cid.Cid, he } func fixTooFewSnowballs(ctx context.Context, sm *StateManager, pstate cid.Cid) (cid.Cid, error) { - cst := hamt.CSTFromBstore(sm.cs.Blockstore()) + cst := cbor.NewCborStore(sm.cs.Blockstore()) st, err := state.LoadStateTree(cst, pstate) if err != nil { return cid.Undef, err @@ -122,7 +122,7 @@ func fixTooFewSnowballs(ctx context.Context, sm *StateManager, pstate cid.Cid) ( 1.2) Change their code cid to point to the new miner actor code */ func fixBlizzardAMTBug(ctx context.Context, sm *StateManager, pstate cid.Cid) (cid.Cid, error) { - cst := hamt.CSTFromBstore(sm.cs.Blockstore()) + cst := cbor.NewCborStore(sm.cs.Blockstore()) st, err := state.LoadStateTree(cst, pstate) if err != nil { return cid.Undef, err @@ -169,21 +169,19 @@ func fixBlizzardAMTBug(ctx context.Context, sm *StateManager, pstate cid.Cid) (c return st.Flush(ctx) } -func fixMiner(ctx context.Context, cst hamt.CborIpldStore, bs blockstore.Blockstore, mscid cid.Cid) (cid.Cid, error) { +func fixMiner(ctx context.Context, cst cbor.IpldStore, bs blockstore.Blockstore, mscid cid.Cid) (cid.Cid, error) { var mstate actors.StorageMinerActorState if err := cst.Get(ctx, mscid, &mstate); err != nil { return cid.Undef, xerrors.Errorf("failed to load miner actor state: %w", err) } - amts := amt.WrapBlockstore(bs) - - nsectors, err := amtFsck(amts, mstate.Sectors) + nsectors, err := amtFsck(cst, mstate.Sectors) if err != nil { return cid.Undef, xerrors.Errorf("error fsck'ing sector set: %w", err) } mstate.Sectors = nsectors - nproving, err := amtFsck(amts, mstate.ProvingSet) + nproving, err := amtFsck(cst, mstate.ProvingSet) if err != nil { return cid.Undef, xerrors.Errorf("error fsck'ing proving set: %w", err) } @@ -197,16 +195,17 @@ func fixMiner(ctx context.Context, cst hamt.CborIpldStore, bs blockstore.Blockst return nmcid, nil } -func amtFsck(s amt.Blocks, ss cid.Cid) (cid.Cid, error) { - a, err := amt.LoadAMT(s, ss) +func amtFsck(cst cbor.IpldStore, ss cid.Cid) (cid.Cid, error) { + ctx := context.TODO() + a, err := amt.LoadAMT(ctx, cst, ss) if err != nil { return cid.Undef, xerrors.Errorf("could not load AMT: %w", a) } - b := amt.NewAMT(s) + b := amt.NewAMT(cst) - err = a.ForEach(func(id uint64, data *cbg.Deferred) error { - err := b.Set(id, data) + err = a.ForEach(ctx, func(id uint64, data *cbg.Deferred) error { + err := b.Set(ctx, id, data) if err != nil { return xerrors.Errorf("could not copy at idx (%d): %w", id, err) } @@ -217,7 +216,7 @@ func amtFsck(s amt.Blocks, ss cid.Cid) (cid.Cid, error) { return cid.Undef, xerrors.Errorf("could not copy: %w", err) } - nss, err := b.Flush() + nss, err := b.Flush(ctx) if err != nil { return cid.Undef, xerrors.Errorf("could not flush: %w", err) } diff --git a/chain/stmgr/forks_test.go b/chain/stmgr/forks_test.go index 77a94e25e..a3b4638a5 100644 --- a/chain/stmgr/forks_test.go +++ b/chain/stmgr/forks_test.go @@ -18,8 +18,8 @@ import ( "github.com/filecoin-project/lotus/chain/vm" "github.com/ipfs/go-cid" - hamt "github.com/ipfs/go-hamt-ipld" blockstore "github.com/ipfs/go-ipfs-blockstore" + cbor "github.com/ipfs/go-ipld-cbor" logging "github.com/ipfs/go-log" mh "github.com/multiformats/go-multihash" cbg "github.com/whyrusleeping/cbor-gen" @@ -121,7 +121,7 @@ func TestForkHeightTriggers(t *testing.T) { } stmgr.ForksAtHeight[testForkHeight] = func(ctx context.Context, sm *StateManager, pstate cid.Cid) (cid.Cid, error) { - cst := hamt.CSTFromBstore(sm.ChainStore().Blockstore()) + cst := cbor.NewCborStore(sm.ChainStore().Blockstore()) st, err := state.LoadStateTree(cst, pstate) if err != nil { return cid.Undef, err diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index 6d018a4d8..f447a22eb 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -19,6 +19,7 @@ import ( "github.com/ipfs/go-cid" hamt "github.com/ipfs/go-hamt-ipld" blockstore "github.com/ipfs/go-ipfs-blockstore" + cbor "github.com/ipfs/go-ipld-cbor" logging "github.com/ipfs/go-log/v2" "go.opencensus.io/trace" ) @@ -301,7 +302,7 @@ func (sm *StateManager) GetActor(addr address.Address, ts *types.TipSet) (*types stcid := ts.ParentState() - cst := hamt.CSTFromBstore(sm.cs.Blockstore()) + cst := cbor.NewCborStore(sm.cs.Blockstore()) state, err := state.LoadStateTree(cst, stcid) if err != nil { return nil, xerrors.Errorf("load state tree: %w", err) @@ -332,7 +333,7 @@ func (sm *StateManager) LoadActorState(ctx context.Context, a address.Address, o return nil, err } - cst := hamt.CSTFromBstore(sm.cs.Blockstore()) + cst := cbor.NewCborStore(sm.cs.Blockstore()) if err := cst.Get(ctx, act.Head, out); err != nil { return nil, err } @@ -357,7 +358,7 @@ func (sm *StateManager) ResolveToKeyAddress(ctx context.Context, addr address.Ad return address.Undef, xerrors.Errorf("resolve address failed to get tipset state: %w", err) } - cst := hamt.CSTFromBstore(sm.cs.Blockstore()) + cst := cbor.NewCborStore(sm.cs.Blockstore()) tree, err := state.LoadStateTree(cst, st) if err != nil { return address.Undef, xerrors.Errorf("failed to load state tree") @@ -575,7 +576,7 @@ func (sm *StateManager) ListAllActors(ctx context.Context, ts *types.TipSet) ([] return nil, err } - cst := hamt.CSTFromBstore(sm.cs.Blockstore()) + cst := cbor.NewCborStore(sm.cs.Blockstore()) r, err := hamt.LoadNode(ctx, cst, st) if err != nil { return nil, err @@ -602,7 +603,7 @@ func (sm *StateManager) MarketBalance(ctx context.Context, addr address.Address, if _, err := sm.LoadActorState(ctx, actors.StorageMarketAddress, &state, ts); err != nil { return actors.StorageParticipantBalance{}, err } - cst := hamt.CSTFromBstore(sm.cs.Blockstore()) + cst := cbor.NewCborStore(sm.cs.Blockstore()) b, _, err := actors.GetMarketBalances(ctx, cst, state.Balances, addr) if err != nil { return actors.StorageParticipantBalance{}, err diff --git a/chain/stmgr/utils.go b/chain/stmgr/utils.go index 5480dc949..982f1a171 100644 --- a/chain/stmgr/utils.go +++ b/chain/stmgr/utils.go @@ -18,7 +18,6 @@ import ( amt "github.com/filecoin-project/go-amt-ipld" cid "github.com/ipfs/go-cid" - hamt "github.com/ipfs/go-hamt-ipld" blockstore "github.com/ipfs/go-ipfs-blockstore" cbor "github.com/ipfs/go-ipld-cbor" "github.com/libp2p/go-libp2p-core/peer" @@ -236,7 +235,7 @@ func GetMinerSectorSize(ctx context.Context, sm *StateManager, ts *types.TipSet, return 0, xerrors.Errorf("(get ssize) failed to load miner actor state: %w", err) } - cst := hamt.CSTFromBstore(sm.cs.Blockstore()) + cst := cbor.NewCborStore(sm.cs.Blockstore()) var minfo actors.MinerInfo if err := cst.Get(ctx, mas.Info, &minfo); err != nil { return 0, xerrors.Errorf("failed to read miner info: %w", err) @@ -296,7 +295,7 @@ func ListMinerActors(ctx context.Context, sm *StateManager, ts *types.TipSet) ([ return nil, err } - cst := hamt.CSTFromBstore(sm.ChainStore().Blockstore()) + cst := cbor.NewCborStore(sm.ChainStore().Blockstore()) miners, err := actors.MinerSetList(ctx, cst, state.Miners) if err != nil { return nil, err diff --git a/chain/store/store.go b/chain/store/store.go index 41ceac02f..9874c10bf 100644 --- a/chain/store/store.go +++ b/chain/store/store.go @@ -25,9 +25,9 @@ import ( car "github.com/ipfs/go-car" "github.com/ipfs/go-cid" dstore "github.com/ipfs/go-datastore" - hamt "github.com/ipfs/go-hamt-ipld" blockstore "github.com/ipfs/go-ipfs-blockstore" bstore "github.com/ipfs/go-ipfs-blockstore" + cbor "github.com/ipfs/go-ipld-cbor" format "github.com/ipfs/go-ipld-format" logging "github.com/ipfs/go-log/v2" dag "github.com/ipfs/go-merkledag" @@ -644,7 +644,7 @@ func (cs *ChainStore) MessagesForTipset(ts *types.TipSet) ([]ChainMsg, error) { applied := make(map[address.Address]uint64) balances := make(map[address.Address]types.BigInt) - cst := hamt.CSTFromBstore(cs.bs) + cst := cbor.NewCborStore(cs.bs) st, err := state.LoadStateTree(cst, ts.Blocks()[0].ParentStateRoot) if err != nil { return nil, xerrors.Errorf("failed to load state tree") @@ -713,7 +713,7 @@ func (cs *ChainStore) readMsgMetaCids(mmc cid.Cid) ([]cid.Cid, []cid.Cid, error) return mmcids.bls, mmcids.secpk, nil } - cst := hamt.CSTFromBstore(cs.bs) + cst := cbor.NewCborStore(cs.bs) var msgmeta types.MsgMeta if err := cst.Get(context.TODO(), mmc, &msgmeta); err != nil { return nil, nil, xerrors.Errorf("failed to load msgmeta: %w", err) diff --git a/chain/sync.go b/chain/sync.go index 7c8e13b36..e3009dc71 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -16,8 +16,8 @@ import ( "github.com/hashicorp/go-multierror" "github.com/ipfs/go-cid" dstore "github.com/ipfs/go-datastore" - hamt "github.com/ipfs/go-hamt-ipld" bstore "github.com/ipfs/go-ipfs-blockstore" + cbor "github.com/ipfs/go-ipld-cbor" logging "github.com/ipfs/go-log/v2" "github.com/libp2p/go-libp2p-core/connmgr" "github.com/libp2p/go-libp2p-core/peer" @@ -731,7 +731,7 @@ func (syncer *Syncer) checkBlockMessages(ctx context.Context, b *types.FullBlock return err } - cst := hamt.CSTFromBstore(syncer.store.Blockstore()) + cst := cbor.NewCborStore(syncer.store.Blockstore()) st, err := state.LoadStateTree(cst, stateroot) if err != nil { return xerrors.Errorf("failed to load base state tree: %w", err) diff --git a/chain/types/vmcontext.go b/chain/types/vmcontext.go index 6adbc9f6b..7e99adcf3 100644 --- a/chain/types/vmcontext.go +++ b/chain/types/vmcontext.go @@ -9,7 +9,7 @@ import ( "github.com/filecoin-project/go-amt-ipld" "github.com/filecoin-project/lotus/chain/actors/aerrors" cid "github.com/ipfs/go-cid" - hamt "github.com/ipfs/go-hamt-ipld" + cbor "github.com/ipfs/go-ipld-cbor" cbg "github.com/whyrusleeping/cbor-gen" ) @@ -32,7 +32,7 @@ type StateTree interface { type VMContext interface { Message() *Message Origin() address.Address - Ipld() hamt.CborIpldStore + Ipld() cbor.IpldStore Send(to address.Address, method uint64, value BigInt, params []byte) ([]byte, aerrors.ActorError) BlockHeight() uint64 GasUsed() BigInt diff --git a/chain/validation/state.go b/chain/validation/state.go index d91e776a9..8ea8521aa 100644 --- a/chain/validation/state.go +++ b/chain/validation/state.go @@ -7,8 +7,8 @@ import ( "github.com/ipfs/go-cid" "github.com/ipfs/go-datastore" - "github.com/ipfs/go-hamt-ipld" blockstore "github.com/ipfs/go-ipfs-blockstore" + cbor "github.com/ipfs/go-ipld-cbor" "github.com/minio/blake2b-simd" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" @@ -32,7 +32,7 @@ type StateWrapper struct { // The blockstore underlying the state tree and storage. bs blockstore.Blockstore // HAMT-CBOR store on top of the blockstore. - cst hamt.CborIpldStore + cst cbor.IpldStore // A store for encryption keys. keys *keyStore @@ -48,7 +48,7 @@ var _ vstate.Wrapper = &StateWrapper{} func NewState() *StateWrapper { bs := blockstore.NewBlockstore(datastore.NewMapDatastore()) - cst := hamt.CSTFromBstore(bs) + cst := cbor.NewCborStore(bs) // Put EmptyObjectCid value in the store. When an actor is initially created its Head is set to this value. _, err := cst.Put(context.TODO(), map[string]string{}) if err != nil { @@ -302,7 +302,7 @@ func (a *actorWrapper) Balance() vtypes.BigInt { // type directStorage struct { - cst hamt.CborIpldStore + cst cbor.IpldStore } func (d *directStorage) Get(c cid.Cid, out interface{}) error { diff --git a/chain/vm/mkactor.go b/chain/vm/mkactor.go index a84387321..ae1c9277c 100644 --- a/chain/vm/mkactor.go +++ b/chain/vm/mkactor.go @@ -4,9 +4,7 @@ import ( "context" "github.com/ipfs/go-cid" - dstore "github.com/ipfs/go-datastore" - hamt "github.com/ipfs/go-hamt-ipld" - bstore "github.com/ipfs/go-ipfs-blockstore" + cbor "github.com/ipfs/go-ipld-cbor" "github.com/filecoin-project/go-address" "github.com/filecoin-project/lotus/chain/actors" @@ -16,8 +14,7 @@ import ( ) func init() { - bs := bstore.NewBlockstore(dstore.NewMapDatastore()) - cst := hamt.CSTFromBstore(bs) + cst := cbor.NewMemCborStore() emptyobject, err := cst.Put(context.TODO(), map[string]string{}) if err != nil { panic(err) diff --git a/chain/vm/spec_shim.go b/chain/vm/spec_shim.go index 9bb3e717b..8067d75f6 100644 --- a/chain/vm/spec_shim.go +++ b/chain/vm/spec_shim.go @@ -11,6 +11,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/aerrors" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/specs-actors/actors/abi" + "github.com/filecoin-project/specs-actors/actors/runtime" vmr "github.com/filecoin-project/specs-actors/actors/runtime" "github.com/filecoin-project/specs-actors/actors/runtime/exitcode" "github.com/ipfs/go-cid" @@ -22,6 +23,8 @@ type runtimeShim struct { vmr.Runtime } +var _ runtime.Runtime = (*runtimeShim)(nil) + func (rs *runtimeShim) shimCall(f func() interface{}) (rval []byte, aerr aerrors.ActorError) { defer func() { if r := recover(); r != nil { @@ -119,8 +122,13 @@ func (dwt *dumbWrapperType) Into(um vmr.CBORUnmarshaler) error { return um.UnmarshalCBOR(bytes.NewReader(dwt.val)) } -func (rs *runtimeShim) Send(to address.Address, method abi.MethodNum, params abi.MethodParams, value abi.TokenAmount) (vmr.SendReturn, exitcode.ExitCode) { - ret, err := rs.vmctx.Send(to, uint64(method), types.BigInt(value), []byte(params)) +func (rs *runtimeShim) Send(to address.Address, method abi.MethodNum, m runtime.CBORMarshaler, value abi.TokenAmount) (vmr.SendReturn, exitcode.ExitCode) { + buf := new(bytes.Buffer) + if err := m.MarshalCBOR(buf); err != nil { + rs.Abort(exitcode.SysErrInvalidParameters, "failed to marshal input parameters: %s", err) + } + + ret, err := rs.vmctx.Send(to, uint64(method), types.BigInt(value), buf.Bytes()) if err != nil { if err.IsFatal() { panic(err) diff --git a/chain/vm/vm.go b/chain/vm/vm.go index 6f6ffd93b..d7557a591 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -10,6 +10,7 @@ import ( cid "github.com/ipfs/go-cid" hamt "github.com/ipfs/go-hamt-ipld" blockstore "github.com/ipfs/go-ipfs-blockstore" + cbor "github.com/ipfs/go-ipld-cbor" logging "github.com/ipfs/go-log/v2" cbg "github.com/whyrusleeping/cbor-gen" "go.opencensus.io/trace" @@ -49,7 +50,7 @@ type VMContext struct { state *state.StateTree msg *types.Message height uint64 - cst hamt.CborIpldStore + cst cbor.IpldStore gasAvailable types.BigInt gasUsed types.BigInt @@ -122,7 +123,7 @@ func (vmc *VMContext) Storage() types.Storage { return vmc } -func (vmc *VMContext) Ipld() hamt.CborIpldStore { +func (vmc *VMContext) Ipld() cbor.IpldStore { return vmc.cst } @@ -203,7 +204,7 @@ func (vmctx *VMContext) VerifySignature(sig *types.Signature, act address.Addres return nil } -func ResolveToKeyAddr(state types.StateTree, cst hamt.CborIpldStore, addr address.Address) (address.Address, aerrors.ActorError) { +func ResolveToKeyAddr(state types.StateTree, cst cbor.IpldStore, addr address.Address) (address.Address, aerrors.ActorError) { if addr.Protocol() == address.BLS || addr.Protocol() == address.SECP256K1 { return addr, nil } @@ -241,23 +242,18 @@ func (vmctx *VMContext) Context() context.Context { return vmctx.ctx } -type hBlocks interface { - GetBlock(context.Context, cid.Cid) (block.Block, error) - AddBlock(block.Block) error -} - -var _ hBlocks = (*gasChargingBlocks)(nil) +var _ cbor.IpldBlockstore = (*gasChargingBlocks)(nil) type gasChargingBlocks struct { chargeGas func(uint64) aerrors.ActorError - under hBlocks + under cbor.IpldBlockstore } -func (bs *gasChargingBlocks) GetBlock(ctx context.Context, c cid.Cid) (block.Block, error) { +func (bs *gasChargingBlocks) Get(c cid.Cid) (block.Block, error) { if err := bs.chargeGas(gasGetObj); err != nil { return nil, err } - blk, err := bs.under.GetBlock(ctx, c) + blk, err := bs.under.Get(c) if err != nil { return nil, aerrors.Escalate(err, "failed to get block from blockstore") } @@ -268,11 +264,11 @@ func (bs *gasChargingBlocks) GetBlock(ctx context.Context, c cid.Cid) (block.Blo return blk, nil } -func (bs *gasChargingBlocks) AddBlock(blk block.Block) error { +func (bs *gasChargingBlocks) Put(blk block.Block) error { if err := bs.chargeGas(gasPutObj + uint64(len(blk.RawData()))*gasPutPerByte); err != nil { return err } - if err := bs.under.AddBlock(blk); err != nil { + if err := bs.under.Put(blk); err != nil { return aerrors.Escalate(err, "failed to write data to disk") } return nil @@ -292,7 +288,7 @@ func (vm *VM) makeVMContext(ctx context.Context, sroot cid.Cid, msg *types.Messa gasUsed: usedGas, gasAvailable: msg.GasLimit, } - vmc.cst = &hamt.BasicCborIpldStore{ + vmc.cst = &cbor.BasicIpldStore{ Blocks: &gasChargingBlocks{vmc.ChargeGas, vm.cst.Blocks}, Atlas: vm.cst.Atlas, } @@ -302,7 +298,7 @@ func (vm *VM) makeVMContext(ctx context.Context, sroot cid.Cid, msg *types.Messa type VM struct { cstate *state.StateTree base cid.Cid - cst *hamt.BasicCborIpldStore + cst *cbor.BasicIpldStore buf *bufbstore.BufferedBS blockHeight uint64 blockMiner address.Address @@ -314,7 +310,7 @@ type VM struct { func NewVM(base cid.Cid, height uint64, r Rand, maddr address.Address, cbs blockstore.Blockstore, syscalls *types.VMSyscalls) (*VM, error) { buf := bufbstore.NewBufferedBstore(cbs) - cst := hamt.CSTFromBstore(buf) + cst := cbor.NewCborStore(buf) state, err := state.LoadStateTree(cst, base) if err != nil { return nil, err diff --git a/cli/multisig.go b/cli/multisig.go index 1592265a3..38d6b72ef 100644 --- a/cli/multisig.go +++ b/cli/multisig.go @@ -19,6 +19,7 @@ import ( "github.com/filecoin-project/specs-actors/actors/abi" cid "github.com/ipfs/go-cid" "github.com/ipfs/go-hamt-ipld" + cbor "github.com/ipfs/go-ipld-cbor" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" "gopkg.in/urfave/cli.v2" @@ -224,7 +225,7 @@ var msigInspectCmd = &cli.Command{ func GetMultisigPending(ctx context.Context, lapi api.FullNode, hroot cid.Cid) (map[int64]*actors.MultiSigTransaction, error) { bs := apibstore.NewAPIBlockstore(lapi) - cst := hamt.CSTFromBstore(bs) + cst := cbor.NewCborStore(bs) nd, err := hamt.LoadNode(ctx, cst, hroot) if err != nil { diff --git a/cli/state.go b/cli/state.go index f92044aaa..1cf34dccb 100644 --- a/cli/state.go +++ b/cli/state.go @@ -14,6 +14,7 @@ import ( actors "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/miner" + samsig "github.com/filecoin-project/specs-actors/actors/builtin/multisig" "github.com/libp2p/go-libp2p-core/peer" "golang.org/x/xerrors" @@ -862,7 +863,7 @@ func parseParamsForMethod(act cid.Cid, method uint64, args []string) ([]byte, er case actors.StoragePowerCodeCid: f = actors.StoragePowerActor{}.Exports()[method] case actors.MultisigCodeCid: - f = actors.MultiSigActor{}.Exports()[method] + f = samsig.MultiSigActor{}.Exports()[method] case actors.PaymentChannelCodeCid: f = actors.PaymentChannelActor{}.Exports()[method] default: diff --git a/go.mod b/go.mod index a4ae032cc..933684f4f 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/filecoin-project/filecoin-ffi v0.0.0-20191219131535-bb699517a590 github.com/filecoin-project/go-address v0.0.0-20200107215422-da8eea2842b5 github.com/filecoin-project/go-amt-ipld v0.0.0-20191205011053-79efc22d6cdc - github.com/filecoin-project/go-amt-ipld/v2 v2.0.0 + github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200131012142-05d80eeccc5e github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2 github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03 github.com/filecoin-project/go-data-transfer v0.0.0-20191219005021-4accf56bd2ce @@ -22,7 +22,7 @@ require ( github.com/filecoin-project/go-paramfetch v0.0.1 github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200203173614-42d67726bb62 github.com/filecoin-project/go-statestore v0.1.0 - github.com/filecoin-project/specs-actors v0.0.0-20200122220748-cd3f221cb40b + github.com/filecoin-project/specs-actors v0.0.0-20200204204849-b1474eeb2fb5 github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 github.com/go-ole/go-ole v1.2.4 // indirect github.com/gorilla/mux v1.7.3 @@ -40,7 +40,7 @@ require ( github.com/ipfs/go-filestore v0.0.2 github.com/ipfs/go-fs-lock v0.0.1 github.com/ipfs/go-graphsync v0.0.4 - github.com/ipfs/go-hamt-ipld v0.0.14 + github.com/ipfs/go-hamt-ipld v0.0.15-0.20200204200533-99b8553ef242 github.com/ipfs/go-ipfs-blockstore v0.1.1 github.com/ipfs/go-ipfs-chunker v0.0.1 github.com/ipfs/go-ipfs-ds-help v0.0.1 @@ -48,7 +48,7 @@ require ( github.com/ipfs/go-ipfs-exchange-offline v0.0.1 github.com/ipfs/go-ipfs-files v0.0.4 github.com/ipfs/go-ipfs-routing v0.1.0 - github.com/ipfs/go-ipld-cbor v0.0.3 + github.com/ipfs/go-ipld-cbor v0.0.5-0.20200204214505-252690b78669 github.com/ipfs/go-ipld-format v0.0.2 github.com/ipfs/go-log v1.0.1 github.com/ipfs/go-log/v2 v2.0.2 @@ -114,5 +114,3 @@ replace github.com/golangci/golangci-lint => github.com/golangci/golangci-lint v replace github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi replace github.com/coreos/go-systemd => github.com/coreos/go-systemd/v22 v22.0.0 - -replace github.com/filecoin-project/specs-actors => ../specs-actors diff --git a/go.sum b/go.sum index 75067c57b..3f6025aca 100644 --- a/go.sum +++ b/go.sum @@ -105,8 +105,8 @@ github.com/filecoin-project/go-address v0.0.0-20200107215422-da8eea2842b5 h1:/Mm github.com/filecoin-project/go-address v0.0.0-20200107215422-da8eea2842b5/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0= github.com/filecoin-project/go-amt-ipld v0.0.0-20191205011053-79efc22d6cdc h1:cODZD2YzpTUtrOSxbEnWFcQHidNRZiRdvLxySjGvG/M= github.com/filecoin-project/go-amt-ipld v0.0.0-20191205011053-79efc22d6cdc/go.mod h1:KsFPWjF+UUYl6n9A+qbg4bjFgAOneicFZtDH/LQEX2U= -github.com/filecoin-project/go-amt-ipld/v2 v2.0.0 h1:rQ7GTJbWE5XqUCPiBgs4gbTKD2wC7MynZhSaf7ZzlUM= -github.com/filecoin-project/go-amt-ipld/v2 v2.0.0/go.mod h1:PAZ5tvSfMfWE327osqFXKm7cBpCpBk2Nh0qKsJUmjjk= +github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200131012142-05d80eeccc5e h1:IOoff6yAZSJ5zHCPY2jzGNwQYQU6ygsRVe/cSnJrY+o= +github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200131012142-05d80eeccc5e/go.mod h1:boRtQhzmxNocrMxOXo1NYn4oUc1NGvR8tEa79wApNXg= github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2 h1:av5fw6wmm58FYMgJeoB/lK9XXrgdugYiTqkdxjTy9k8= github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2/go.mod h1:pqTiPHobNkOVM5thSRsHYjyQfq7O5QSCMhvuu9JoDlg= github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03 h1:2pMXdBnCiXjfCYx/hLqFxccPoqsSveQFxVLvNxy9bus= @@ -123,8 +123,8 @@ github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200203173614-42d67726bb6 github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200203173614-42d67726bb62/go.mod h1:jNGVCDihkMFnraYVLH1xl4ceZQVxx/u4dOORrTKeRi0= github.com/filecoin-project/go-statestore v0.1.0 h1:t56reH59843TwXHkMcwyuayStBIiWBRilQjQ+5IiwdQ= github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI= -github.com/filecoin-project/specs-actors v0.0.0-20200122220748-cd3f221cb40b h1:Lmoh8SVqTiXzQKCwL521J7PA7HD5ihIwKAXYsWH1RiY= -github.com/filecoin-project/specs-actors v0.0.0-20200122220748-cd3f221cb40b/go.mod h1:8S2iUF6zqQ9dIUBj8mWlDlDA3bU75Tmd+aTgzTayYKA= +github.com/filecoin-project/specs-actors v0.0.0-20200204204849-b1474eeb2fb5 h1:rDyP5UTPFxdfS7D5I0XLdaQZZoNGYTic1X9ptKmRSlM= +github.com/filecoin-project/specs-actors v0.0.0-20200204204849-b1474eeb2fb5/go.mod h1:9vrrnLVhF2Zz6R3VBI7lKxQYRvPpsc1FTUyNqCvuYME= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 h1:EzDjxMg43q1tA2c0MV3tNbaontnHLplHyFF6M5KiVP0= @@ -248,8 +248,10 @@ github.com/ipfs/go-fs-lock v0.0.1 h1:XHX8uW4jQBYWHj59XXcjg7BHlHxV9ZOYs6Y43yb7/l0 github.com/ipfs/go-fs-lock v0.0.1/go.mod h1:DNBekbboPKcxs1aukPSaOtFA3QfSdi5C855v0i9XJ8Y= github.com/ipfs/go-graphsync v0.0.4 h1:iF98+J8pcqvEb48IM0TemqeGARsCDtwQ73P9ejMZIuU= github.com/ipfs/go-graphsync v0.0.4/go.mod h1:6UACBjfOXEa8rQL3Q/JpZpWS0nZDCLx134WUkjrmFpQ= -github.com/ipfs/go-hamt-ipld v0.0.14 h1:yNMDYacEGKg9UYZ1AmHjbetiKLMQQZRVHF8EW+2+O5w= -github.com/ipfs/go-hamt-ipld v0.0.14/go.mod h1:9qtwSG3ADoN1lo0Y+1+nsIY7aovJ1BP8g2P++igXuPo= +github.com/ipfs/go-hamt-ipld v0.0.15-0.20200131012125-dd88a59d3f2e h1:bUtmeXx6JpjxRPlMdlKfPXC5kKhLHuueXKgs1Txb9ZU= +github.com/ipfs/go-hamt-ipld v0.0.15-0.20200131012125-dd88a59d3f2e/go.mod h1:9aQJu/i/TaRDW6jqB5U217dLIDopn50wxLdHXM2CTfE= +github.com/ipfs/go-hamt-ipld v0.0.15-0.20200204200533-99b8553ef242 h1:OYVGeYkGSRZdBJ35JHPXQ9deQxlLtJ3Ln0FuaJOu6x8= +github.com/ipfs/go-hamt-ipld v0.0.15-0.20200204200533-99b8553ef242/go.mod h1:kq3Pi+UP3oHhAdKexE+kHHYRKMoFNuGero0R7q3hWGg= github.com/ipfs/go-ipfs-blockstore v0.0.1/go.mod h1:d3WClOmRQKFnJ0Jz/jj/zmksX0ma1gROTlovZKBmN08= github.com/ipfs/go-ipfs-blockstore v0.1.0/go.mod h1:5aD0AvHPi7mZc6Ci1WCAhiBQu2IsfTduLl+422H6Rqw= github.com/ipfs/go-ipfs-blockstore v0.1.1 h1:+PAFREAlSxLs9IEtrRcnJ/DqWkGlDa+l547WFZnohNw= @@ -283,6 +285,10 @@ github.com/ipfs/go-ipfs-util v0.0.1/go.mod h1:spsl5z8KUnrve+73pOhSVZND1SIxPW5RyB github.com/ipfs/go-ipld-cbor v0.0.2/go.mod h1:wTBtrQZA3SoFKMVkp6cn6HMRteIB1VsmHA0AQFOn7Nc= github.com/ipfs/go-ipld-cbor v0.0.3 h1:ENsxvybwkmke7Z/QJOmeJfoguj6GH3Y0YOaGrfy9Q0I= github.com/ipfs/go-ipld-cbor v0.0.3/go.mod h1:wTBtrQZA3SoFKMVkp6cn6HMRteIB1VsmHA0AQFOn7Nc= +github.com/ipfs/go-ipld-cbor v0.0.4 h1:Aw3KPOKXjvrm6VjwJvFf1F1ekR/BH3jdof3Bk7OTiSA= +github.com/ipfs/go-ipld-cbor v0.0.4/go.mod h1:BkCduEx3XBCO6t2Sfo5BaHzuok7hbhdMm9Oh8B2Ftq4= +github.com/ipfs/go-ipld-cbor v0.0.5-0.20200204214505-252690b78669 h1:jIVle1vGSzxyUhseYNEqd7qcDVRrIbJ7UxGwao70cF0= +github.com/ipfs/go-ipld-cbor v0.0.5-0.20200204214505-252690b78669/go.mod h1:BkCduEx3XBCO6t2Sfo5BaHzuok7hbhdMm9Oh8B2Ftq4= github.com/ipfs/go-ipld-format v0.0.1/go.mod h1:kyJtbkDALmFHv3QR6et67i35QzO3S0dCDnkOJhcZkms= github.com/ipfs/go-ipld-format v0.0.2 h1:OVAGlyYT6JPZ0pEfGntFPS40lfrDmaDbQwNHEY2G9Zs= github.com/ipfs/go-ipld-format v0.0.2/go.mod h1:4B6+FM2u9OJ9zCV+kSbgFAZlOrv1Hqbf0INGQgiKf9k= @@ -734,13 +740,10 @@ github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc h1:BCPnHtcboa github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc/go.mod h1:r45hJU7yEoA81k6MWNhpMj/kms0n14dkzkxYHoB96UM= github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba h1:X4n8JG2e2biEZZXdBKt9HX7DN3bYGFUqljqqy0DqgnY= github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba/go.mod h1:CHQnYnQUEPydYCwuy8lmTHfGmdw9TKrhWV0xLx8l0oM= -github.com/whyrusleeping/cbor-gen v0.0.0-20190910031516-c1cbffdb01bb/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY= github.com/whyrusleeping/cbor-gen v0.0.0-20190917003517-d78d67427694/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY= github.com/whyrusleeping/cbor-gen v0.0.0-20191116002219-891f55cd449d/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY= github.com/whyrusleeping/cbor-gen v0.0.0-20191212224538-d370462a7e8a/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY= github.com/whyrusleeping/cbor-gen v0.0.0-20191216205031-b047b6acb3c0/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY= -github.com/whyrusleeping/cbor-gen v0.0.0-20200122015334-52eaf73beaf5 h1:wqba3bIey6d92UBNPKHybEu5blL1ZKr9yzu1ycmJW04= -github.com/whyrusleeping/cbor-gen v0.0.0-20200122015334-52eaf73beaf5/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI= github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158 h1:WXhVOwj2USAXB5oMDwRl3piOux2XMV9TANaYxXHdkoE= github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= diff --git a/node/impl/full/chain.go b/node/impl/full/chain.go index bf3fb4a6c..88a5effd1 100644 --- a/node/impl/full/chain.go +++ b/node/impl/full/chain.go @@ -203,7 +203,7 @@ func resolveOnce(bs blockstore.Blockstore) func(ctx context.Context, ds ipld.Nod } if strings.HasPrefix(names[0], "@H:") { - cst := hamt.CSTFromBstore(bs) + cst := cbor.NewCborStore(bs) h, err := hamt.LoadNode(ctx, cst, nd.Cid()) if err != nil { diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 8315f6318..82289a782 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -10,6 +10,7 @@ import ( cid "github.com/ipfs/go-cid" "github.com/ipfs/go-hamt-ipld" + cbor "github.com/ipfs/go-ipld-cbor" "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" "go.uber.org/fx" @@ -146,7 +147,7 @@ func (a *StateAPI) stateForTs(ctx context.Context, ts *types.TipSet) (*state.Sta } buf := bufbstore.NewBufferedBstore(a.Chain.Blockstore()) - cst := hamt.CSTFromBstore(buf) + cst := cbor.NewCborStore(buf) return state.LoadStateTree(cst, st) } @@ -174,7 +175,7 @@ func (a *StateAPI) StateReadState(ctx context.Context, act *types.Actor, ts *typ return nil, err } - blk, err := state.Store.(*hamt.BasicCborIpldStore).Blocks.GetBlock(ctx, act.Head) + blk, err := state.Store.(*cbor.BasicIpldStore).Blocks.Get(act.Head) if err != nil { return nil, err } @@ -246,7 +247,7 @@ func (a *StateAPI) StateMarketParticipants(ctx context.Context, ts *types.TipSet if _, err := a.StateManager.LoadActorState(ctx, actors.StorageMarketAddress, &state, ts); err != nil { return nil, err } - cst := hamt.CSTFromBstore(a.StateManager.ChainStore().Blockstore()) + cst := cbor.NewCborStore(a.StateManager.ChainStore().Blockstore()) nd, err := hamt.LoadNode(ctx, cst, state.Balances) if err != nil { return nil, err @@ -303,7 +304,7 @@ func (a *StateAPI) StateMarketStorageDeal(ctx context.Context, dealId uint64, ts } func (a *StateAPI) StateChangedActors(ctx context.Context, old cid.Cid, new cid.Cid) (map[string]types.Actor, error) { - cst := hamt.CSTFromBstore(a.Chain.Blockstore()) + cst := cbor.NewCborStore(a.Chain.Blockstore()) nh, err := hamt.LoadNode(ctx, cst, new) if err != nil {