Skip to content

Commit 7762469

Browse files
authored
Add Etherlink authorization gas overhead (#102)
Etherlink (chain ID 42793) nodes don't account for gas consumed by authorization list items when estimating gas. Add ETHERLINK_CHAIN_ID and ETHERLINK_GAS_PER_AUTHORIZATION constants and, for requests targeting that chain, increase the tx_request gas limit by (authorization_count * ETHERLINK_GAS_PER_AUTHORIZATION) before building the typed transaction. A debug log records the chain_id, authorization_count, and extra_gas applied.
1 parent 3011976 commit 7762469

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

executors/src/eoa/worker/transaction.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ use std::time::Duration;
33
/// Fixed overhead added to gas estimates to account for estimation inaccuracies
44
const GAS_ESTIMATION_FIXED_OVERHEAD: u64 = 50_000;
55

6+
/// Etherlink chain ID - requires extra gas per authorization list item
7+
const ETHERLINK_CHAIN_ID: u64 = 42793;
8+
/// Extra gas to add per authorization list item on Etherlink
9+
const ETHERLINK_GAS_PER_AUTHORIZATION: u64 = 500_000;
10+
611
use alloy::{
712
consensus::{
813
SignableTransaction, Signed, TxEip4844Variant, TxEip4844WithSidecar, TypedTransaction,
@@ -364,6 +369,22 @@ impl<C: Chain> EoaExecutorWorker<C> {
364369
}
365370
}
366371

372+
// Etherlink (42793) requires extra gas per authorization list item
373+
// because their node's gas estimation doesn't account for it.
374+
if request.chain_id == ETHERLINK_CHAIN_ID {
375+
if let Some(auth_list) = &tx_request.authorization_list {
376+
let extra = auth_list.len() as u64 * ETHERLINK_GAS_PER_AUTHORIZATION;
377+
let current_gas = tx_request.gas.unwrap_or(0);
378+
tracing::debug!(
379+
chain_id = ETHERLINK_CHAIN_ID,
380+
authorization_count = auth_list.len(),
381+
extra_gas = extra,
382+
"Adding Etherlink authorization list gas overhead"
383+
);
384+
tx_request = tx_request.with_gas_limit(current_gas + extra);
385+
}
386+
}
387+
367388
// Build typed transaction
368389
tx_request
369390
.build_typed_tx()

0 commit comments

Comments
 (0)