Set hamt bitwidth

This commit is contained in:
Łukasz Magiera 2020-02-14 15:14:39 +01:00
parent 48c5494cf9
commit c544c2b5c5
13 changed files with 47 additions and 28 deletions

View File

@ -5,6 +5,9 @@ import (
"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"
)
@ -16,7 +19,7 @@ func init() {
func testGeneration(t testing.TB, n int, msgs int) {
g, err := NewGenerator()
if err != nil {
t.Fatal(err)
t.Fatalf("%+v", err)
}
g.msgsPerBlock = msgs

View File

@ -176,7 +176,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
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 {
return nil, err
}

View File

@ -24,7 +24,7 @@ func SetupInitActor(bs bstore.Blockstore, netname string, initialActors []genesi
ias.NetworkName = netname
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 {
if a.Type != genesis.TAccount {

View File

@ -16,7 +16,7 @@ import (
func SetupStoragePowerActor(bs bstore.Blockstore) (*types.Actor, error) {
ctx := context.TODO()
cst := cbor.NewCborStore(bs)
nd := hamt.NewNode(cst)
nd := hamt.NewNode(cst, hamt.UseTreeBitWidth(5))
emptyhamt, err := cst.Put(ctx, nd)
if err != nil {
return nil, err

View File

@ -36,7 +36,7 @@ func NewStateTree(cst cbor.IpldStore) (*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 {
log.Errorf("loading hamt node %s failed: %s", c, err)
return nil, err
@ -192,7 +192,7 @@ func (a *adtStore) Context() context.Context {
var _ adt.Store = (*adtStore)(nil)
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 {
return err
}

View File

@ -608,7 +608,7 @@ func (sm *StateManager) ListAllActors(ctx context.Context, ts *types.TipSet) ([]
}
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 {
return nil, err
}

View File

@ -8,6 +8,7 @@ import (
"strings"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
@ -41,7 +42,7 @@ func NewInvoker() *invoker {
inv.Register(actors.CronCodeCid, actors.CronActor{}, actors.CronActorState{})
inv.Register(actors.StoragePowerCodeCid, actors.StoragePowerActor{}, actors.StoragePowerState{})
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.PaymentChannelCodeCid, actors.PaymentChannelActor{}, actors.PaymentChannelActorState{})

View File

@ -231,7 +231,7 @@ func GetMultisigPending(ctx context.Context, lapi api.FullNode, hroot cid.Cid) (
bs := apibstore.NewAPIBlockstore(lapi)
cst := cbor.NewCborStore(bs)
nd, err := hamt.LoadNode(ctx, cst, hroot)
nd, err := hamt.LoadNode(ctx, cst, hroot, hamt.UseTreeBitWidth(5))
if err != nil {
return nil, err
}

View File

@ -5,7 +5,7 @@ import (
"github.com/filecoin-project/go-address"
"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/filecoin-project/lotus/lib/sigs"
@ -55,5 +55,5 @@ func (secpSigner) Verify(sig []byte, a address.Address, msg []byte) error {
}
func init() {
sigs.RegisterSignature(crypto2.Secp256k1, secpSigner{})
sigs.RegisterSignature(crypto2.SigTypeSecp256k1, secpSigner{})
}

View File

@ -5,10 +5,11 @@ import (
"fmt"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/specs-actors/actors/crypto"
"go.opencensus.io/trace"
"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.

View File

@ -206,7 +206,7 @@ func resolveOnce(bs blockstore.Blockstore) func(ctx context.Context, ds ipld.Nod
if strings.HasPrefix(names[0], "@H:") {
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 {
return nil, nil, xerrors.Errorf("resolving hamt link: %w", err)
}

View File

@ -254,11 +254,11 @@ func (a *StateAPI) StateMarketParticipants(ctx context.Context, ts *types.TipSet
return nil, err
}
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 {
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 {
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) {
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 {
return nil, err
}
oh, err := hamt.LoadNode(ctx, cst, old)
oh, err := hamt.LoadNode(ctx, cst, old, hamt.UseTreeBitWidth(5))
if err != nil {
return nil, err
}

View File

@ -5,6 +5,7 @@ import (
"time"
ffi "github.com/filecoin-project/filecoin-ffi"
"github.com/filecoin-project/go-address"
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
"github.com/filecoin-project/specs-actors/actors/abi"
"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
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 {
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))
for fault := range declaredFaults {
faultIDs = append(faultIDs, fault)
params.SectorNumbers.Set(uint64(fault))
}
params.SectorNumbers = faultIDs
if len(faultIDs) > 0 {
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
}
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")
defer span.End()
@ -177,18 +181,28 @@ func (s *FPoStScheduler) runPost(ctx context.Context, eps abi.ChainEpoch, ts *ty
elapsed := time.Since(tsStart)
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 {
part := make([]byte, 32)
copy(part, sc.PartialTicket[:])
candidates[i] = types.EPostTicket{
Partial: part,
SectorID: sc.SectorNum,
ChallengeIndex: sc.SectorChallengeIndex,
candidates[i] = abi.PoStCandidate{
RegisteredProof: abi.RegisteredProof_StackedDRG32GiBPoSt, // TODO: build setting
PartialTicket: part,
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,
Candidates: candidates,
}, nil
@ -217,7 +231,7 @@ func (s *FPoStScheduler) sortedSectorInfo(ctx context.Context, ts *types.TipSet)
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")
defer span.End()
@ -229,7 +243,7 @@ func (s *FPoStScheduler) submitPost(ctx context.Context, proof *actors.SubmitFal
msg := &types.Message{
To: s.actor,
From: s.worker,
Method: builtin.MethodsMiner.SubmitFallbackPoSt,
Method: builtin.MethodsMiner.SubmitWindowedPoSt,
Params: enc,
Value: types.NewInt(1000), // currently hard-coded late fee in actor, returned if not late
GasLimit: types.NewInt(10000000), // i dont know help