diff --git a/cli/filplus.go b/cli/filplus.go index 7d794ff9e2b..22930a97cc9 100644 --- a/cli/filplus.go +++ b/cli/filplus.go @@ -1276,22 +1276,27 @@ func CreateExtendClaimMsg(ctx context.Context, api api.FullNode, pcm map[verifre var msgs []*types.Message - if len(terms) > 0 { + const batchSize = 1000 + for i := 0; i < len(terms); i += batchSize { + batchEnd := i + batchSize + if batchEnd > len(terms) { + batchEnd = len(terms) + } + + batch := terms[i:batchEnd] + params, err := actors.SerializeParams(&verifregtypes13.ExtendClaimTermsParams{ - Terms: terms, + Terms: batch, }) - if err != nil { return nil, xerrors.Errorf("failed to searialise the parameters: %s", err) } - oclaimMsg := &types.Message{ To: verifreg.Address, From: wallet, Method: verifreg.Methods.ExtendClaimTerms, Params: params, } - msgs = append(msgs, oclaimMsg) } @@ -1311,32 +1316,6 @@ func CreateExtendClaimMsg(ctx context.Context, api api.FullNode, pcm map[verifre return nil, xerrors.Errorf("requested datacap %s is greater then the available datacap %s", rDataCap, aDataCap) } - ncparams, err := actors.SerializeParams(&verifregtypes13.AllocationRequests{ - Extensions: newClaims, - }) - - if err != nil { - return nil, xerrors.Errorf("failed to searialise the parameters: %s", err) - } - - transferParams, err := actors.SerializeParams(&datacap2.TransferParams{ - To: builtin.VerifiedRegistryActorAddr, - Amount: big.Mul(rDataCap, builtin.TokenPrecision), - OperatorData: ncparams, - }) - - if err != nil { - return nil, xerrors.Errorf("failed to serialize transfer parameters: %s", err) - } - - nclaimMsg := &types.Message{ - To: builtin.DatacapActorAddr, - From: wallet, - Method: datacap.Methods.TransferExported, - Params: transferParams, - Value: big.Zero(), - } - if !assumeYes { out := fmt.Sprintf("Some of the specified allocation have a different client address and will require %d Datacap to extend. Proceed? Yes [Y/y] / No [N/n], Ctrl+C (^C) to exit", rDataCap.Int) validate := func(input string) error { @@ -1372,7 +1351,41 @@ func CreateExtendClaimMsg(ctx context.Context, api api.FullNode, pcm map[verifre } } - msgs = append(msgs, nclaimMsg) + // Batch in 1000 to avoid running out of gas + for i := 0; i < len(newClaims); i += batchSize { + batchEnd := i + batchSize + if batchEnd > len(newClaims) { + batchEnd = len(newClaims) + } + + batch := newClaims[i:batchEnd] + + ncparams, err := actors.SerializeParams(&verifregtypes13.AllocationRequests{ + Extensions: batch, + }) + if err != nil { + return nil, xerrors.Errorf("failed to searialise the parameters: %s", err) + } + + transferParams, err := actors.SerializeParams(&datacap2.TransferParams{ + To: builtin.VerifiedRegistryActorAddr, + Amount: big.Mul(rDataCap, builtin.TokenPrecision), + OperatorData: ncparams, + }) + + if err != nil { + return nil, xerrors.Errorf("failed to serialize transfer parameters: %s", err) + } + + nclaimMsg := &types.Message{ + To: builtin.DatacapActorAddr, + From: wallet, + Method: datacap.Methods.TransferExported, + Params: transferParams, + Value: big.Zero(), + } + msgs = append(msgs, nclaimMsg) + } } return msgs, nil