genesis: Fix importing 8k+ deals
This commit is contained in:
parent
f11b1bbbeb
commit
6dd2f5369e
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
@ -101,26 +102,43 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
|
|
||||||
var dealIDs []abi.DealID
|
var dealIDs []abi.DealID
|
||||||
{
|
{
|
||||||
|
publish := func(params *market.PublishStorageDealsParams) error {
|
||||||
|
fmt.Printf("publishing %d storage deals on miner %s with worker %s\n", len(params.Deals), params.Deals[0].Proposal.Provider, m.Worker)
|
||||||
|
|
||||||
|
ret, err := doExecValue(ctx, vm, builtin.StorageMarketActorAddr, m.Worker, big.Zero(), builtin.MethodsMarket.PublishStorageDeals, mustEnc(params))
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("failed to create genesis miner: %w", err)
|
||||||
|
}
|
||||||
|
var ids market.PublishStorageDealsReturn
|
||||||
|
if err := ids.UnmarshalCBOR(bytes.NewReader(ret)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
dealIDs = append(dealIDs, ids.IDs...)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
params := &market.PublishStorageDealsParams{}
|
params := &market.PublishStorageDealsParams{}
|
||||||
for _, preseal := range m.Sectors {
|
for _, preseal := range m.Sectors {
|
||||||
|
|
||||||
params.Deals = append(params.Deals, market.ClientDealProposal{
|
params.Deals = append(params.Deals, market.ClientDealProposal{
|
||||||
Proposal: preseal.Deal,
|
Proposal: preseal.Deal,
|
||||||
ClientSignature: crypto.Signature{Type: crypto.SigTypeBLS}, // TODO: do we want to sign these? Or do we want to fake signatures for genesis setup?
|
ClientSignature: crypto.Signature{Type: crypto.SigTypeBLS}, // TODO: do we want to sign these? Or do we want to fake signatures for genesis setup?
|
||||||
})
|
})
|
||||||
fmt.Printf("calling publish storage deals on miner %s with worker %s\n", preseal.Deal.Provider, m.Worker)
|
|
||||||
|
if len(params.Deals) == cbg.MaxLength {
|
||||||
|
if err := publish(params); err != nil {
|
||||||
|
return cid.Undef, err
|
||||||
|
}
|
||||||
|
|
||||||
|
params = &market.PublishStorageDealsParams{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret, err := doExecValue(ctx, vm, builtin.StorageMarketActorAddr, m.Worker, big.Zero(), builtin.MethodsMarket.PublishStorageDeals, mustEnc(params))
|
if len(params.Deals) > 0 {
|
||||||
if err != nil {
|
if err := publish(params); err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
|
return cid.Undef, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var ids market.PublishStorageDealsReturn
|
|
||||||
if err := ids.UnmarshalCBOR(bytes.NewReader(ret)); err != nil {
|
|
||||||
return cid.Undef, err
|
|
||||||
}
|
|
||||||
|
|
||||||
dealIDs = ids.IDs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup windowed post
|
// setup windowed post
|
||||||
|
@ -36,7 +36,7 @@ func doExecValue(ctx context.Context, vm *vm.VM, to, from address.Address, value
|
|||||||
From: from,
|
From: from,
|
||||||
Method: method,
|
Method: method,
|
||||||
Params: params,
|
Params: params,
|
||||||
GasLimit: 1000000,
|
GasLimit: 100000000000,
|
||||||
GasPrice: types.NewInt(0),
|
GasPrice: types.NewInt(0),
|
||||||
Value: value,
|
Value: value,
|
||||||
Nonce: act.Nonce,
|
Nonce: act.Nonce,
|
||||||
|
Loading…
Reference in New Issue
Block a user