Set hamt bitwidth
This commit is contained in:
parent
48c5494cf9
commit
c544c2b5c5
@ -5,6 +5,9 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
|
||||||
|
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
||||||
|
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,7 +19,7 @@ func init() {
|
|||||||
func testGeneration(t testing.TB, n int, msgs int) {
|
func testGeneration(t testing.TB, n int, msgs int) {
|
||||||
g, err := NewGenerator()
|
g, err := NewGenerator()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatalf("%+v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
g.msgsPerBlock = msgs
|
g.msgsPerBlock = msgs
|
||||||
|
@ -176,7 +176,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
return nil, xerrors.Errorf("unmarshaling account meta: %w", err)
|
return nil, xerrors.Errorf("unmarshaling account meta: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
st, err := cst.Put(ctx, account.State{Address: ainfo.Owner})
|
st, err := cst.Put(ctx, &account.State{Address: ainfo.Owner})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ func SetupInitActor(bs bstore.Blockstore, netname string, initialActors []genesi
|
|||||||
ias.NetworkName = netname
|
ias.NetworkName = netname
|
||||||
|
|
||||||
cst := cbor.NewCborStore(bs)
|
cst := cbor.NewCborStore(bs)
|
||||||
amap := hamt.NewNode(cst)
|
amap := hamt.NewNode(cst, hamt.UseTreeBitWidth(5)) // TODO: use spec adt map
|
||||||
|
|
||||||
for i, a := range initialActors {
|
for i, a := range initialActors {
|
||||||
if a.Type != genesis.TAccount {
|
if a.Type != genesis.TAccount {
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
func SetupStoragePowerActor(bs bstore.Blockstore) (*types.Actor, error) {
|
func SetupStoragePowerActor(bs bstore.Blockstore) (*types.Actor, error) {
|
||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
cst := cbor.NewCborStore(bs)
|
cst := cbor.NewCborStore(bs)
|
||||||
nd := hamt.NewNode(cst)
|
nd := hamt.NewNode(cst, hamt.UseTreeBitWidth(5))
|
||||||
emptyhamt, err := cst.Put(ctx, nd)
|
emptyhamt, err := cst.Put(ctx, nd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -36,7 +36,7 @@ func NewStateTree(cst cbor.IpldStore) (*StateTree, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func LoadStateTree(cst cbor.IpldStore, c cid.Cid) (*StateTree, error) {
|
func LoadStateTree(cst cbor.IpldStore, c cid.Cid) (*StateTree, error) {
|
||||||
nd, err := hamt.LoadNode(context.Background(), cst, c)
|
nd, err := hamt.LoadNode(context.Background(), cst, c, hamt.UseTreeBitWidth(5))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("loading hamt node %s failed: %s", c, err)
|
log.Errorf("loading hamt node %s failed: %s", c, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -192,7 +192,7 @@ func (a *adtStore) Context() context.Context {
|
|||||||
var _ adt.Store = (*adtStore)(nil)
|
var _ adt.Store = (*adtStore)(nil)
|
||||||
|
|
||||||
func (st *StateTree) Revert() error {
|
func (st *StateTree) Revert() error {
|
||||||
nd, err := hamt.LoadNode(context.Background(), st.Store, st.snapshot)
|
nd, err := hamt.LoadNode(context.Background(), st.Store, st.snapshot, hamt.UseTreeBitWidth(5))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -608,7 +608,7 @@ func (sm *StateManager) ListAllActors(ctx context.Context, ts *types.TipSet) ([]
|
|||||||
}
|
}
|
||||||
|
|
||||||
cst := cbor.NewCborStore(sm.cs.Blockstore())
|
cst := cbor.NewCborStore(sm.cs.Blockstore())
|
||||||
r, err := hamt.LoadNode(ctx, cst, st)
|
r, err := hamt.LoadNode(ctx, cst, st, hamt.UseTreeBitWidth(5))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
@ -41,7 +42,7 @@ func NewInvoker() *invoker {
|
|||||||
inv.Register(actors.CronCodeCid, actors.CronActor{}, actors.CronActorState{})
|
inv.Register(actors.CronCodeCid, actors.CronActor{}, actors.CronActorState{})
|
||||||
inv.Register(actors.StoragePowerCodeCid, actors.StoragePowerActor{}, actors.StoragePowerState{})
|
inv.Register(actors.StoragePowerCodeCid, actors.StoragePowerActor{}, actors.StoragePowerState{})
|
||||||
inv.Register(actors.StorageMarketCodeCid, market.Actor{}, market.State{})
|
inv.Register(actors.StorageMarketCodeCid, market.Actor{}, market.State{})
|
||||||
inv.Register(actors.StorageMinerCodeCid, actors.StorageMinerActor{}, actors.StorageMinerActorState{})
|
inv.Register(actors.StorageMinerCodeCid, miner.Actor{}, miner.State{})
|
||||||
inv.Register(actors.MultisigCodeCid, multisig.Actor{}, multisig.State{})
|
inv.Register(actors.MultisigCodeCid, multisig.Actor{}, multisig.State{})
|
||||||
inv.Register(actors.PaymentChannelCodeCid, actors.PaymentChannelActor{}, actors.PaymentChannelActorState{})
|
inv.Register(actors.PaymentChannelCodeCid, actors.PaymentChannelActor{}, actors.PaymentChannelActorState{})
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ func GetMultisigPending(ctx context.Context, lapi api.FullNode, hroot cid.Cid) (
|
|||||||
bs := apibstore.NewAPIBlockstore(lapi)
|
bs := apibstore.NewAPIBlockstore(lapi)
|
||||||
cst := cbor.NewCborStore(bs)
|
cst := cbor.NewCborStore(bs)
|
||||||
|
|
||||||
nd, err := hamt.LoadNode(ctx, cst, hroot)
|
nd, err := hamt.LoadNode(ctx, cst, hroot, hamt.UseTreeBitWidth(5))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-crypto"
|
"github.com/filecoin-project/go-crypto"
|
||||||
crypto2 "github.com/libp2p/go-libp2p-core/crypto"
|
crypto2 "github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
"github.com/minio/blake2b-simd"
|
"github.com/minio/blake2b-simd"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/lib/sigs"
|
"github.com/filecoin-project/lotus/lib/sigs"
|
||||||
@ -55,5 +55,5 @@ func (secpSigner) Verify(sig []byte, a address.Address, msg []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
sigs.RegisterSignature(crypto2.Secp256k1, secpSigner{})
|
sigs.RegisterSignature(crypto2.SigTypeSecp256k1, secpSigner{})
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
"go.opencensus.io/trace"
|
"go.opencensus.io/trace"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Sign takes in signature type, private key and message. Returns a signature for that message.
|
// Sign takes in signature type, private key and message. Returns a signature for that message.
|
||||||
|
@ -206,7 +206,7 @@ func resolveOnce(bs blockstore.Blockstore) func(ctx context.Context, ds ipld.Nod
|
|||||||
if strings.HasPrefix(names[0], "@H:") {
|
if strings.HasPrefix(names[0], "@H:") {
|
||||||
cst := cbor.NewCborStore(bs)
|
cst := cbor.NewCborStore(bs)
|
||||||
|
|
||||||
h, err := hamt.LoadNode(ctx, cst, nd.Cid())
|
h, err := hamt.LoadNode(ctx, cst, nd.Cid(), hamt.UseTreeBitWidth(5))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, xerrors.Errorf("resolving hamt link: %w", err)
|
return nil, nil, xerrors.Errorf("resolving hamt link: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -254,11 +254,11 @@ func (a *StateAPI) StateMarketParticipants(ctx context.Context, ts *types.TipSet
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
cst := cbor.NewCborStore(a.StateManager.ChainStore().Blockstore())
|
cst := cbor.NewCborStore(a.StateManager.ChainStore().Blockstore())
|
||||||
escrow, err := hamt.LoadNode(ctx, cst, state.EscrowTable)
|
escrow, err := hamt.LoadNode(ctx, cst, state.EscrowTable, hamt.UseTreeBitWidth(5)) // todo: adt map
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
locked, err := hamt.LoadNode(ctx, cst, state.EscrowTable)
|
locked, err := hamt.LoadNode(ctx, cst, state.EscrowTable, hamt.UseTreeBitWidth(5))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -338,12 +338,12 @@ func (a *StateAPI) StateMarketStorageDeal(ctx context.Context, dealId abi.DealID
|
|||||||
func (a *StateAPI) StateChangedActors(ctx context.Context, old cid.Cid, new cid.Cid) (map[string]types.Actor, error) {
|
func (a *StateAPI) StateChangedActors(ctx context.Context, old cid.Cid, new cid.Cid) (map[string]types.Actor, error) {
|
||||||
cst := cbor.NewCborStore(a.Chain.Blockstore())
|
cst := cbor.NewCborStore(a.Chain.Blockstore())
|
||||||
|
|
||||||
nh, err := hamt.LoadNode(ctx, cst, new)
|
nh, err := hamt.LoadNode(ctx, cst, new, hamt.UseTreeBitWidth(5))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
oh, err := hamt.LoadNode(ctx, cst, old)
|
oh, err := hamt.LoadNode(ctx, cst, old, hamt.UseTreeBitWidth(5))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
ffi "github.com/filecoin-project/filecoin-ffi"
|
ffi "github.com/filecoin-project/filecoin-ffi"
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
@ -107,7 +108,10 @@ func (s *FPoStScheduler) checkFaults(ctx context.Context, ssi sectorbuilder.Sort
|
|||||||
|
|
||||||
var faultIDs []abi.SectorNumber
|
var faultIDs []abi.SectorNumber
|
||||||
if len(faults) > 0 {
|
if len(faults) > 0 {
|
||||||
params := &miner.DeclareTemporaryFaultsParams{Duration: 900} // TODO: duration is annoying
|
params := &miner.DeclareTemporaryFaultsParams{
|
||||||
|
Duration: 900, // TODO: duration is annoying
|
||||||
|
SectorNumbers:abi.NewBitField(),
|
||||||
|
}
|
||||||
|
|
||||||
for _, fault := range faults {
|
for _, fault := range faults {
|
||||||
if _, ok := declaredFaults[(fault.SectorNum)]; ok {
|
if _, ok := declaredFaults[(fault.SectorNum)]; ok {
|
||||||
@ -121,8 +125,8 @@ func (s *FPoStScheduler) checkFaults(ctx context.Context, ssi sectorbuilder.Sort
|
|||||||
faultIDs = make([]abi.SectorNumber, 0, len(declaredFaults))
|
faultIDs = make([]abi.SectorNumber, 0, len(declaredFaults))
|
||||||
for fault := range declaredFaults {
|
for fault := range declaredFaults {
|
||||||
faultIDs = append(faultIDs, fault)
|
faultIDs = append(faultIDs, fault)
|
||||||
|
params.SectorNumbers.Set(uint64(fault))
|
||||||
}
|
}
|
||||||
params.SectorNumbers = faultIDs
|
|
||||||
|
|
||||||
if len(faultIDs) > 0 {
|
if len(faultIDs) > 0 {
|
||||||
if err := s.declareFaults(ctx, uint64(len(faultIDs)), params); err != nil {
|
if err := s.declareFaults(ctx, uint64(len(faultIDs)), params); err != nil {
|
||||||
@ -134,7 +138,7 @@ func (s *FPoStScheduler) checkFaults(ctx context.Context, ssi sectorbuilder.Sort
|
|||||||
return faultIDs, nil
|
return faultIDs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FPoStScheduler) runPost(ctx context.Context, eps abi.ChainEpoch, ts *types.TipSet) (*actors.SubmitFallbackPoStParams, error) {
|
func (s *FPoStScheduler) runPost(ctx context.Context, eps abi.ChainEpoch, ts *types.TipSet) (*abi.OnChainPoStVerifyInfo, error) {
|
||||||
ctx, span := trace.StartSpan(ctx, "storage.runPost")
|
ctx, span := trace.StartSpan(ctx, "storage.runPost")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
@ -177,18 +181,28 @@ func (s *FPoStScheduler) runPost(ctx context.Context, eps abi.ChainEpoch, ts *ty
|
|||||||
elapsed := time.Since(tsStart)
|
elapsed := time.Since(tsStart)
|
||||||
log.Infow("submitting PoSt", "pLen", len(proof), "elapsed", elapsed)
|
log.Infow("submitting PoSt", "pLen", len(proof), "elapsed", elapsed)
|
||||||
|
|
||||||
candidates := make([]types.EPostTicket, len(scandidates))
|
mid, err := address.IDFromAddress(s.actor)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
candidates := make([]abi.PoStCandidate, len(scandidates))
|
||||||
for i, sc := range scandidates {
|
for i, sc := range scandidates {
|
||||||
part := make([]byte, 32)
|
part := make([]byte, 32)
|
||||||
copy(part, sc.PartialTicket[:])
|
copy(part, sc.PartialTicket[:])
|
||||||
candidates[i] = types.EPostTicket{
|
candidates[i] = abi.PoStCandidate{
|
||||||
Partial: part,
|
RegisteredProof: abi.RegisteredProof_StackedDRG32GiBPoSt, // TODO: build setting
|
||||||
SectorID: sc.SectorNum,
|
PartialTicket: part,
|
||||||
ChallengeIndex: sc.SectorChallengeIndex,
|
SectorID: abi.SectorID{
|
||||||
|
Miner: abi.ActorID(mid),
|
||||||
|
Number: sc.SectorNum,
|
||||||
|
},
|
||||||
|
ChallengeIndex: int64(sc.SectorChallengeIndex), // TODO: fix spec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &actors.SubmitFallbackPoStParams{
|
return &abi.OnChainPoStVerifyInfo{
|
||||||
|
ProofType: abi.RegisteredProof_StackedDRG32GiBPoSt, // TODO: build setting
|
||||||
Proof: proof,
|
Proof: proof,
|
||||||
Candidates: candidates,
|
Candidates: candidates,
|
||||||
}, nil
|
}, nil
|
||||||
@ -217,7 +231,7 @@ func (s *FPoStScheduler) sortedSectorInfo(ctx context.Context, ts *types.TipSet)
|
|||||||
return sectorbuilder.NewSortedPublicSectorInfo(sbsi), nil
|
return sectorbuilder.NewSortedPublicSectorInfo(sbsi), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FPoStScheduler) submitPost(ctx context.Context, proof *actors.SubmitFallbackPoStParams) error {
|
func (s *FPoStScheduler) submitPost(ctx context.Context, proof *abi.OnChainPoStVerifyInfo) error {
|
||||||
ctx, span := trace.StartSpan(ctx, "storage.commitPost")
|
ctx, span := trace.StartSpan(ctx, "storage.commitPost")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
@ -229,7 +243,7 @@ func (s *FPoStScheduler) submitPost(ctx context.Context, proof *actors.SubmitFal
|
|||||||
msg := &types.Message{
|
msg := &types.Message{
|
||||||
To: s.actor,
|
To: s.actor,
|
||||||
From: s.worker,
|
From: s.worker,
|
||||||
Method: builtin.MethodsMiner.SubmitFallbackPoSt,
|
Method: builtin.MethodsMiner.SubmitWindowedPoSt,
|
||||||
Params: enc,
|
Params: enc,
|
||||||
Value: types.NewInt(1000), // currently hard-coded late fee in actor, returned if not late
|
Value: types.NewInt(1000), // currently hard-coded late fee in actor, returned if not late
|
||||||
GasLimit: types.NewInt(10000000), // i dont know help
|
GasLimit: types.NewInt(10000000), // i dont know help
|
||||||
|
Loading…
Reference in New Issue
Block a user