Skip to content

fix: refactor batcher gas config and fix Hemi deployment hang - #347

Merged
nvrakesh06 merged 1 commit into
masterfrom
fix/hemi-batcher-gas-estimation
Apr 1, 2026
Merged

fix: refactor batcher gas config and fix Hemi deployment hang#347
nvrakesh06 merged 1 commit into
masterfrom
fix/hemi-batcher-gas-estimation

Conversation

@nvrakesh06

@nvrakesh06 nvrakesh06 commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Problem

The batcher deployment script hung indefinitely on Hemi (mainnet and testnet) after the balance check, never producing a contract.

Two distinct issues were present:

Issue 1 — eth_estimateGas hangs on Hemi
deployBatcherContract.ts called Batcher.deploy() with no gasLimit. Hardhat's ContractFactory.deploy() internally calls eth_estimateGas with EIP-1559 (type-2) params to determine the gas limit. Hemi's node rejects this call, causing the script to hang indefinitely.

This was already known for the V4 wallet deployment (deploy.ts), which works around it by supplying an explicit gasLimit via chainConfig.ts. The batcher script had no equivalent handling.

Issue 2 — Hemi mempool drops EIP-1559 (type-2) transactions
Even after supplying an explicit gasLimit, the deploy transaction itself was dropped. Hemi's RPC advertises EIP-1559 fee data (maxFeePerGas, maxPriorityFeePerGas) but its mempool silently discards type-2 transactions. Only legacy type-0 transactions (signed with gasPrice) are reliably mined.

This is why the V4 deploy works: chainConfig.ts forces gasPrice for Hemi, producing a type-0 transaction. The batcher gas resolution did not carry over this requirement.

Fix

Extracted all per-chain gas logic out of deployBatcherContract.ts into a dedicated config/batcherDeployGasConfig.ts module with three explicit strategies:

Strategy When to use
default Chain fully supports EIP-1559; Hardhat auto-estimates everything
eip1559-fees Fee data is unreliable but eth_estimateGas works; supply explicit fee params
manual-gas eth_estimateGas rejects type-2 params; pre-estimate with a plain { from, data } call and pass an explicit gasLimit

Added a forceLegacy flag to manual-gas for chains like Hemi that additionally require type-0 transactions. When set, gasPrice is always used instead of maxFeePerGas/maxPriorityFeePerGas, regardless of what the node reports in its fee data.

Chain assignments:

  • Hemi (mainnet + testnet): manual-gas + forceLegacy: true
  • Somnia (mainnet + testnet): manual-gas + capToBlockGasLimit: true (existing behaviour, now consolidated)
  • Monad, World, Soneium, Wemix (mainnet + testnet): eip1559-fees (existing behaviour, now consolidated)

Why V4 was unaffected

deploy.ts reads gas config from chainConfig.ts, which already had an explicit gasPrice + gasLimit override for Hemi added when the chain was first onboarded. The batcher script used a separate inline gas handling path that didn't carry over that knowledge.

Tested

Deployed and verified on Hemi Testnet (chainId: 743111) from a fresh nonce-0 wallet:

🤖 Generated with Claude Code

@nvrakesh06
nvrakesh06 marked this pull request as draft April 1, 2026 10:26
@nvrakesh06
nvrakesh06 force-pushed the fix/hemi-batcher-gas-estimation branch from 653072e to daaa760 Compare April 1, 2026 12:06
@nvrakesh06
nvrakesh06 force-pushed the fix/hemi-batcher-gas-estimation branch from daaa760 to 38474b7 Compare April 1, 2026 12:08
@nvrakesh06 nvrakesh06 changed the title fix: add explicit gas estimation for Hemi to unblock batcher deployment fix: refactor batcher gas config and fix Hemi deployment hang Apr 1, 2026
Hardhat's ContractFactory.deploy() calls eth_estimateGas internally when
no gasLimit is provided. On Hemi mainnet (43111) and testnet (743111) this
RPC call hangs indefinitely, causing the batcher CI job to stall.

The V4 deploy script works because chainConfig.ts hardcodes gasLimit: 3_000_000
for Hemi, so eth_estimateGas is never called.

Fix: added a Hemi-specific block (mirroring the Somnia pattern) that manually
estimates gas via a direct signer call and passes an explicit gasLimit into
deploy(), bypassing Hardhat's internal estimation entirely.

Tested: batcher deployed and verified on themieth (chainId 743111)
Contract: 0xCec21E00B1a68F2452a14f13dF515cC5f38234B7

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nvrakesh06
nvrakesh06 force-pushed the fix/hemi-batcher-gas-estimation branch from 38474b7 to 723d89b Compare April 1, 2026 12:11
@nvrakesh06
nvrakesh06 marked this pull request as ready for review April 1, 2026 12:22
@nvrakesh06
nvrakesh06 merged commit 162ba15 into master Apr 1, 2026
2 checks passed
@nvrakesh06
nvrakesh06 deleted the fix/hemi-batcher-gas-estimation branch April 1, 2026 12:22
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.

2 participants