Skip to content

Commit 0487746

Browse files
authored
Optimize sending l2 delayed transactions (#128)
* Fix path * Optimize sending l2 transactions
1 parent 65c0b1f commit 0487746

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

regression-test.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cd "$(dirname "$0")"
77
cd regression-tests
88
scripts=$(find . -maxdepth 1 -name '*.bash' ! -name 'common.bash' | sort)
99

10-
for script in $(find regression-tests -maxdepth 1 -name '*.bash' ! -name 'common.bash' | sort); do
10+
for script in $(find . -maxdepth 1 -name '*.bash' ! -name 'common.bash' | sort); do
1111
echo "Running $(basename "$script")"
1212
attempt=1
1313
max_attempts=3

regression-tests/batcher-e2e.bash

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ echo "starting nodes"
2020
echo "starting tx spammer"
2121
docker compose run --detach scripts send-l2 --ethamount 10 --to user_l2user --times 2000 --delay 200 --wait
2222

23-
for i in {1..100}; do
24-
echo "sending delayed tx"
25-
docker compose run --detach scripts send-l2-delayed --ethamount 10 --to user_delayed_user --from espresso-sequencer --wait
26-
sleep 2
27-
done
23+
echo "sending delayed tx"
24+
docker compose run --detach scripts send-l2-delayed --ethamount 10 --to user_delayed_user --from espresso-sequencer --times 100 --delay 2000 --wait
2825

2926
check_validator_root_matches_sequencer() {
3027
local block=$1

scripts/ethcommands.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,20 @@ async function sendL2DelayedTransaction(argv: any, parentChainUrl: string, chain
143143
const l1provider = new ethers.providers.WebSocketProvider(parentChainUrl);
144144
const l1Account = namedAccount("funnel", argv.threadId).connect(l1provider)
145145
const nonce = await l1Account.getTransactionCount("pending")
146-
const response = await l1Account.sendTransaction({
147-
to: inboxAddr,
148-
value: 0,
149-
data: argv.data,
150-
nonce: nonce,
151-
})
152-
if (argv.wait) {
153-
const receipt = await response.wait()
154-
console.log(receipt)
146+
for (let index = 0; index < argv.times; index++) {
147+
const response = await l1Account.sendTransaction({
148+
to: inboxAddr,
149+
value: 0,
150+
data: argv.data,
151+
nonce: nonce + index,
152+
})
153+
if (argv.wait) {
154+
const receipt = await response.wait()
155+
console.log(receipt)
156+
}
157+
if (argv.delay > 0) {
158+
await new Promise(f => setTimeout(f, argv.delay));
159+
}
155160
}
156161
l1provider.destroy()
157162
}

0 commit comments

Comments
 (0)