Skip to content

Commit

Permalink
make batch size variable
Browse files Browse the repository at this point in the history
  • Loading branch information
LexLuthr committed Mar 21, 2024
1 parent 1bc9116 commit 89ea1ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions cli/filplus.go
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,11 @@ If the client id different then claim can be extended up to Maximum 5 years from
Usage: "number of block confirmations to wait for",
Value: int(build.MessageConfidence),
},
&cli.IntFlag{
Name: "batch-size",
Usage: "number of extend requests per batch. If set incorrectly, this will lead to out of gas error",
Value: 1000,
},
},
ArgsUsage: "<claim1> <claim2> ... or <miner1=claim1> <miner2=claims2> ...",
Action: func(cctx *cli.Context) error {
Expand Down Expand Up @@ -1073,7 +1078,7 @@ If the client id different then claim can be extended up to Maximum 5 years from
}
}

msgs, err := CreateExtendClaimMsg(ctx, api, claimMap, miners, clientAddr, abi.ChainEpoch(tmax), all, cctx.Bool("assume-yes"))
msgs, err := CreateExtendClaimMsg(ctx, api, claimMap, miners, clientAddr, abi.ChainEpoch(tmax), all, cctx.Bool("assume-yes"), cctx.Int("batch-size"))
if err != nil {
return err
}
Expand Down Expand Up @@ -1126,7 +1131,7 @@ type ProvInfo struct {
// 6. Extend all claims for multiple miner IDs with different client address (2 messages)
// 7. Extend specified claims for a miner ID with different client address (2 messages)
// 8. Extend specific claims for specific miner ID with different client address (2 messages)
func CreateExtendClaimMsg(ctx context.Context, api api.FullNode, pcm map[verifregtypes13.ClaimId]ProvInfo, miners []string, wallet address.Address, tmax abi.ChainEpoch, all, assumeYes bool) ([]*types.Message, error) {
func CreateExtendClaimMsg(ctx context.Context, api api.FullNode, pcm map[verifregtypes13.ClaimId]ProvInfo, miners []string, wallet address.Address, tmax abi.ChainEpoch, all, assumeYes bool, batchSize int) ([]*types.Message, error) {

ac, err := api.StateLookupID(ctx, wallet, types.EmptyTSK)
if err != nil {
Expand Down Expand Up @@ -1276,7 +1281,6 @@ func CreateExtendClaimMsg(ctx context.Context, api api.FullNode, pcm map[verifre

var msgs []*types.Message

const batchSize = 1000
for i := 0; i < len(terms); i += batchSize {
batchEnd := i + batchSize
if batchEnd > len(terms) {
Expand Down
8 changes: 4 additions & 4 deletions itests/direct_data_onboard_verified_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ func TestVerifiedDDOExtendClaim(t *testing.T) {
pcm[verifregtypes13.ClaimId(allocationId)] = prov

// Extend claim with same client
msgs, err := cli.CreateExtendClaimMsg(ctx, client.FullNode, pcm, []string{}, verifiedClientAddr1, (builtin.EpochsInYear*3)+3000, false, true)
msgs, err := cli.CreateExtendClaimMsg(ctx, client.FullNode, pcm, []string{}, verifiedClientAddr1, (builtin.EpochsInYear*3)+3000, false, true, 100)
require.NoError(t, err)
require.NotNil(t, msgs)
require.Len(t, msgs, 1)
Expand All @@ -834,11 +834,11 @@ func TestVerifiedDDOExtendClaim(t *testing.T) {
require.EqualValues(t, newclaim.TermMax-oldclaim.TermMax, 3000)

// Extend claim with non-verified client | should fail
_, err = cli.CreateExtendClaimMsg(ctx, client.FullNode, pcm, []string{}, unverifiedClient.Address, verifregtypes13.MaximumVerifiedAllocationTerm, false, true)
_, err = cli.CreateExtendClaimMsg(ctx, client.FullNode, pcm, []string{}, unverifiedClient.Address, verifregtypes13.MaximumVerifiedAllocationTerm, false, true, 100)
require.ErrorContains(t, err, "does not have any datacap")

// Extend all claim with verified client
msgs, err = cli.CreateExtendClaimMsg(ctx, client.FullNode, nil, []string{miner.ActorAddr.String()}, verifiedClientAddr2, verifregtypes13.MaximumVerifiedAllocationTerm, true, true)
msgs, err = cli.CreateExtendClaimMsg(ctx, client.FullNode, nil, []string{miner.ActorAddr.String()}, verifiedClientAddr2, verifregtypes13.MaximumVerifiedAllocationTerm, true, true, 100)
require.NoError(t, err)
require.Len(t, msgs, 1)
smsg, err = client.MpoolPushMessage(ctx, msgs[0], nil)
Expand All @@ -848,7 +848,7 @@ func TestVerifiedDDOExtendClaim(t *testing.T) {
require.True(t, wait.Receipt.ExitCode.IsSuccess())

// Extend all claims with lower TermMax
msgs, err = cli.CreateExtendClaimMsg(ctx, client.FullNode, pcm, []string{}, verifiedClientAddr2, builtin.EpochsInYear*4, false, true)
msgs, err = cli.CreateExtendClaimMsg(ctx, client.FullNode, pcm, []string{}, verifiedClientAddr2, builtin.EpochsInYear*4, false, true, 100)
require.NoError(t, err)
require.Nil(t, msgs)

Expand Down

0 comments on commit 89ea1ba

Please sign in to comment.