Skip to content

Commit

Permalink
chore: fill block with multiple txs
Browse files Browse the repository at this point in the history
  • Loading branch information
rach-id committed Jan 27, 2025
1 parent 89e3161 commit 716beb2
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions tools/chainbuilder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ func Run(ctx context.Context, cfg BuilderConfig, dir string) error {
return firstErr
}

const blobSize = 2_000_000

func generateSquareRoutine(
ctx context.Context,
signer *user.Signer,
Expand All @@ -467,23 +469,27 @@ func generateSquareRoutine(

account := signer.Accounts()[0]

blob, err := share.NewV0Blob(cfg.Namespace, crypto.CRandBytes(cfg.BlockSize))
if err != nil {
return err
}
blobTxs := make([][]byte, 0)
for size := 0; size < cfg.BlockSize; size += blobSize {
blob, err := share.NewV0Blob(cfg.Namespace, crypto.CRandBytes(blobSize))
if err != nil {
return err
}

blobGas := blobtypes.DefaultEstimateGas([]uint32{uint32(cfg.BlockSize)})
fee := float64(blobGas) * appconsts.DefaultMinGasPrice * 2
tx, _, err := signer.CreatePayForBlobs(account.Name(), []*share.Blob{blob}, user.SetGasLimit(blobGas), user.SetFee(uint64(fee)))
if err != nil {
return err
}
if err := signer.IncrementSequence(account.Name()); err != nil {
return err
blobGas := blobtypes.DefaultEstimateGas([]uint32{uint32(blobSize)})
fee := float64(blobGas) * appconsts.DefaultMinGasPrice * 2
tx, _, err := signer.CreatePayForBlobs(account.Name(), []*share.Blob{blob}, user.SetGasLimit(blobGas), user.SetFee(uint64(fee)))
if err != nil {
return err
}
if err := signer.IncrementSequence(account.Name()); err != nil {
return err
}
blobTxs = append(blobTxs, tx)
}

dataSquare, txs, err := square.Build(
[][]byte{tx},
blobTxs,
maxSquareSize,
appconsts.SubtreeRootThreshold(1),
)
Expand Down

0 comments on commit 716beb2

Please sign in to comment.