Skip to content

[INT-454] Add chunking of safe multisig batching + LZ_BATCH_SIZE - #1613

Merged
ItsAdel merged 2 commits into
mainfrom
adel/batch-tx-max
Jul 14, 2025
Merged

[INT-454] Add chunking of safe multisig batching + LZ_BATCH_SIZE#1613
ItsAdel merged 2 commits into
mainfrom
adel/batch-tx-max

Conversation

@ItsAdel

@ItsAdel ItsAdel commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

When using the LZ_ENABLE_EXPERIMENTAL_BATCHED_SEND feature flag, it will batch all txs together, even if there are 100s of transactions. This can result in exceeding gas limits and reverting, so in practice, users have only been using this feature flag when they are expecting about 7 transactions at once.

Example Queue: https://app.safe.global/transactions/queue?safe=bnb:0x1fBd62569885EDc6b757f6C27699F30aB6b0A05a

Command ran:
LZ_BATCH_SIZE=2 LZ_ENABLE_EXPERIMENTAL_BATCHED_SEND=1 npx hardhat lz:oapp:wire --oapp-config layerzero.config.ts --safe --log-level debug

Output:

verbose: [signAndSendFlow] Sending the transactions
debug:   [sign & send] Signing 6 transactions
warn:    [sign & send] You are using experimental batched transaction sending
debug:   [sign & send] Signing 3 transactions for ETHEREUM_V2_MAINNET
debug:   [sign & send] Creating signer for ETHEREUM_V2_MAINNET
debug:   [sign & send] Signing 3 transactions for BSC_V2_MAINNET
debug:   [sign & send] Creating signer for BSC_V2_MAINNET
debug:   [sign & send] Sending 3 transactions for ETHEREUM_V2_MAINNET in 2 batches of up to 2
debug:   [sign & send] Signing batch 1/2 (2 transactions) for ETHEREUM_V2_MAINNET
debug:   [sign & send] Sending 3 transactions for BSC_V2_MAINNET in 2 batches of up to 2
debug:   [sign & send] Signing batch 1/2 (2 transactions) for BSC_V2_MAINNET
debug:   [sign & send] Signed batch 1/2 for BSC_V2_MAINNET, got hash 0x516ec32040ecceec02b0ae11230e122b1c61ebf0b8be1ab6172cb2fa873c6900
Signing... ███████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1/6
Signing... ███████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 2/6
debug:   [sign & send] Signed batch 2/2 for BSC_V2_MAINNET, got hash 0x3dae64802e62763cbac8d69657a6e551d2f89d163a9fb74a0b45edcb3701d394
Signing... ██████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 3/6
debug:   [sign & send] Successfully signed 6 transactions for BSC_V2_MAINNET
debug:   [sign & send] Signed batch 1/2 for ETHEREUM_V2_MAINNET, got hash 0x33031c481defdf25516ded19489b3dda1faf67747ef403b5a516ef6a3647eb48
Signing... ██████████████████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 4/6
Signing... █████████████████████████████████████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░ 5/6
debug:   [sign & send] Signed batch 2/2 for ETHEREUM_V2_MAINNET, got hash 0xe52e3dd3fc6253020b9341379d0ccf7e2a69c867bc830305c28c85499032be56
Signing... █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ 6/6
verbose: [signAndSendFlow] Sent the transactions

@ItsAdel
ItsAdel requested review from a team and Copilot July 11, 2025 00:00
@ItsAdel ItsAdel self-assigned this Jul 11, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements chunking functionality for LayerZero's experimental batched multisig transaction sending to prevent gas limit failures when processing large transaction batches. The chunking is controlled by a new LZ_BATCH_SIZE environment variable with a default value of 20.

Key changes include:

  • Added configurable batch size chunking with LZ_BATCH_SIZE environment variable (defaults to 20)
  • Enhanced error handling to halt further batch processing when a batch fails
  • Improved logging to show batch progress and completion status

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/devtools/src/transactions/signer.ts Implements chunking logic in sendBatchedIfAvailable function with configurable batch sizes and early termination on failures
packages/devtools/test/transactions/signer.test.ts Adds comprehensive test coverage for chunking scenarios including edge cases, error handling, and multi-EID batching
.changeset/dull-dolphins-share.md Documents the feature addition for release notes

Comment thread packages/devtools/src/transactions/signer.ts Outdated
Comment thread packages/devtools/test/transactions/signer.test.ts
@ItsAdel ItsAdel removed their assignment Jul 11, 2025

@ravinagill15 ravinagill15 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Comment thread packages/devtools/src/transactions/signer.ts
Comment thread packages/devtools/src/transactions/signer.ts

@shankars99 shankars99 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ItsAdel
ItsAdel merged commit feb000c into main Jul 14, 2025
11 checks passed
@ItsAdel
ItsAdel deleted the adel/batch-tx-max branch July 14, 2025 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants