update to latest hamt changes
This commit is contained in:
parent
5cc089be12
commit
dfe87c9f6f
@ -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 hamt.CborIpldStore, 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.Addres
|
||||
return NewIDAddress(nid)
|
||||
}
|
||||
|
||||
func (ias *InitActorState) Lookup(cst *hamt.CborIpldStore, addr address.Address) (address.Address, error) {
|
||||
func (ias *InitActorState) Lookup(cst hamt.CborIpldStore, 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)
|
||||
|
@ -260,7 +260,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 hamt.CborIpldStore, rcid cid.Cid, addrs ...address.Address) ([]StorageParticipantBalance, *hamt.Node, ActorError) {
|
||||
ctx, span := trace.StartSpan(ctx, "GetMarketBalances")
|
||||
defer span.End()
|
||||
|
||||
|
@ -742,7 +742,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 hamt.CborIpldStore, 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)
|
||||
|
@ -381,7 +381,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 hamt.CborIpldStore, from, to address.Address) error {
|
||||
if from == to {
|
||||
return nil
|
||||
}
|
||||
@ -406,7 +406,7 @@ func reassignMinerActorAddress(vm *vm.VM, cst *hamt.CborIpldStore, from, to addr
|
||||
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 hamt.CborIpldStore, from, to address.Address) error {
|
||||
ctx := context.TODO()
|
||||
act, err := vm.StateTree().GetActor(actors.StoragePowerAddress)
|
||||
if err != nil {
|
||||
@ -451,7 +451,7 @@ func adjustStorageMarketTracking(vm *vm.VM, cst *hamt.CborIpldStore, from, to ad
|
||||
return nil
|
||||
}
|
||||
|
||||
func initActorReassign(vm *vm.VM, cst *hamt.CborIpldStore, from, to address.Address) error {
|
||||
func initActorReassign(vm *vm.VM, cst hamt.CborIpldStore, from, to address.Address) error {
|
||||
ctx := context.TODO()
|
||||
initact, err := vm.StateTree().GetActor(actors.InitAddress)
|
||||
if err != nil {
|
||||
|
@ -19,13 +19,13 @@ var log = logging.Logger("statetree")
|
||||
|
||||
type StateTree struct {
|
||||
root *hamt.Node
|
||||
Store *hamt.CborIpldStore
|
||||
Store hamt.CborIpldStore
|
||||
|
||||
actorcache map[address.Address]*types.Actor
|
||||
snapshot cid.Cid
|
||||
}
|
||||
|
||||
func NewStateTree(cst *hamt.CborIpldStore) (*StateTree, error) {
|
||||
func NewStateTree(cst hamt.CborIpldStore) (*StateTree, error) {
|
||||
return &StateTree{
|
||||
root: hamt.NewNode(cst),
|
||||
Store: cst,
|
||||
@ -33,7 +33,7 @@ func NewStateTree(cst *hamt.CborIpldStore) (*StateTree, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func LoadStateTree(cst *hamt.CborIpldStore, c cid.Cid) (*StateTree, error) {
|
||||
func LoadStateTree(cst hamt.CborIpldStore, 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)
|
||||
|
@ -169,7 +169,7 @@ 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 hamt.CborIpldStore, 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)
|
||||
|
@ -2,6 +2,7 @@ package types
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/filecoin-project/go-sectorbuilder"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
@ -31,7 +32,7 @@ type StateTree interface {
|
||||
type VMContext interface {
|
||||
Message() *Message
|
||||
Origin() address.Address
|
||||
Ipld() *hamt.CborIpldStore
|
||||
Ipld() hamt.CborIpldStore
|
||||
Send(to address.Address, method uint64, value BigInt, params []byte) ([]byte, aerrors.ActorError)
|
||||
BlockHeight() uint64
|
||||
GasUsed() BigInt
|
||||
|
@ -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 hamt.CborIpldStore
|
||||
// A store for encryption keys.
|
||||
keys *keyStore
|
||||
|
||||
@ -302,7 +302,7 @@ func (a *actorWrapper) Balance() vtypes.BigInt {
|
||||
//
|
||||
|
||||
type directStorage struct {
|
||||
cst *hamt.CborIpldStore
|
||||
cst hamt.CborIpldStore
|
||||
}
|
||||
|
||||
func (d *directStorage) Get(c cid.Cid, out interface{}) error {
|
||||
|
@ -49,7 +49,7 @@ type VMContext struct {
|
||||
state *state.StateTree
|
||||
msg *types.Message
|
||||
height uint64
|
||||
cst *hamt.CborIpldStore
|
||||
cst hamt.CborIpldStore
|
||||
|
||||
gasAvailable types.BigInt
|
||||
gasUsed types.BigInt
|
||||
@ -122,7 +122,7 @@ func (vmc *VMContext) Storage() types.Storage {
|
||||
return vmc
|
||||
}
|
||||
|
||||
func (vmc *VMContext) Ipld() *hamt.CborIpldStore {
|
||||
func (vmc *VMContext) Ipld() hamt.CborIpldStore {
|
||||
return vmc.cst
|
||||
}
|
||||
|
||||
@ -203,7 +203,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 hamt.CborIpldStore, addr address.Address) (address.Address, aerrors.ActorError) {
|
||||
if addr.Protocol() == address.BLS || addr.Protocol() == address.SECP256K1 {
|
||||
return addr, nil
|
||||
}
|
||||
@ -292,7 +292,7 @@ func (vm *VM) makeVMContext(ctx context.Context, sroot cid.Cid, msg *types.Messa
|
||||
gasUsed: usedGas,
|
||||
gasAvailable: msg.GasLimit,
|
||||
}
|
||||
vmc.cst = &hamt.CborIpldStore{
|
||||
vmc.cst = &hamt.BasicCborIpldStore{
|
||||
Blocks: &gasChargingBlocks{vmc.ChargeGas, vm.cst.Blocks},
|
||||
Atlas: vm.cst.Atlas,
|
||||
}
|
||||
@ -302,7 +302,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.CborIpldStore
|
||||
cst *hamt.BasicCborIpldStore
|
||||
buf *bufbstore.BufferedBS
|
||||
blockHeight uint64
|
||||
blockMiner address.Address
|
||||
|
2
go.mod
2
go.mod
@ -39,7 +39,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-0.20191218031521-b2c774a54db1
|
||||
github.com/ipfs/go-hamt-ipld v0.0.14
|
||||
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
|
||||
|
2
go.sum
2
go.sum
@ -243,6 +243,8 @@ github.com/ipfs/go-graphsync v0.0.4 h1:iF98+J8pcqvEb48IM0TemqeGARsCDtwQ73P9ejMZI
|
||||
github.com/ipfs/go-graphsync v0.0.4/go.mod h1:6UACBjfOXEa8rQL3Q/JpZpWS0nZDCLx134WUkjrmFpQ=
|
||||
github.com/ipfs/go-hamt-ipld v0.0.14-0.20191218031521-b2c774a54db1 h1:0xpCaaXvN8bPyws3ObiCn7G0KIfgbS9E132eL57dHx8=
|
||||
github.com/ipfs/go-hamt-ipld v0.0.14-0.20191218031521-b2c774a54db1/go.mod h1:8yRx0xLUps1Xq8ZDnIwIVdQRp7JjA55gGvCiRHT91Vk=
|
||||
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-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=
|
||||
|
@ -170,7 +170,7 @@ func (a *StateAPI) StateReadState(ctx context.Context, act *types.Actor, ts *typ
|
||||
return nil, err
|
||||
}
|
||||
|
||||
blk, err := state.Store.Blocks.GetBlock(ctx, act.Head)
|
||||
blk, err := state.Store.(*hamt.BasicCborIpldStore).Blocks.GetBlock(ctx, act.Head)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user