The gas estimates in the broadcast files for Arbitrum Sepolia are significantly lower than the actual gas used. This doesn't break broadcasting with forge script
, but it breaks off-chain tooling that uses forge script
to estimate the gas without broadcasting the transactions.
To reproduce this bug, you'll need a funded private key on Arbitrum Sepolia. Here's a faucet.
Steps to reproduce:
git clone git@github.com:sam-goldman/ArbSepoliaGasEstimation.git
cd ArbSepoliaGasEstimation
forge install
- Run the following Forge script, replacing
<your_private_key>
with a funded private key on Arbitrum Sepolia:
PRIVATE_KEY=<your_private_key> forge script script/Counter.s.sol --rpc-url https://sepolia-rollup.arbitrum.io/rpc --broadcast
- Open the broadcast file, which should be at
broadcast/Counter.s.sol/421614/run-latest.json
- Go to the
transactions
array, then go to the second element in the array, which corresponds to thecounter.increment()
call. You'll see that the"transaction.gas"
field is0x6af7
, which is 27383 gas. - In the same file, go to the second element in the
receipts
array (i.e. the receipt that corresponds to theincrement
call). ThegasUsed
is0xa98c
, which is43404
gas. This is ~1.5x the estimated gas of 27383.