Skip to content

feat: expose gas overrides for intelligent contract transactions - #215

Open
MuncleUscles wants to merge 1 commit into
v2-devfrom
feat/unified-transaction-gas
Open

feat: expose gas overrides for intelligent contract transactions#215
MuncleUscles wants to merge 1 commit into
v2-devfrom
feat/unified-transaction-gas

Conversation

@MuncleUscles

Copy link
Copy Markdown
Member

What

  • Add top-level gas?: bigint to writeContract and deployContract.
  • Use an explicit limit unchanged for both local-key and injected-wallet transactions.
  • Keep the existing 2× estimation headroom when gas is omitted.
  • Stop before signing or broadcast when estimation fails instead of silently falling back to 200,000.
  • Document that this controls the outer EVM ConsensusMain.addTransaction call and is separate from GenLayer fees.

Why

Large intelligent-contract deployment calldata can require more intrinsic EVM gas than the old 200,000 fallback. When estimation reverts, callers currently cannot supply the correct outer transaction limit, so the fallback can be rejected with intrinsic gas too low before GenLayer receives a deployment.

This unifies the intelligent-contract actions with viem's existing top-level sendTransaction({ gas }) convention. It does not change GenLayer consensus/execution budgets or protocol fee accounting.

This is an organization-owned replacement for #205 and credits @ygd58 for the original gas-override proposal and test approach.

Testing done

  • npm test -- --run — 130 tests passed; no type errors.
  • npm run build — ESM, CJS, and declaration builds passed.
  • npx eslint . --ext .ts — passed.
  • Added coverage for write/deploy overrides, invalid limits, estimation bypass, and no-broadcast estimation failures.

Decisions made

  • Reuse the public name gas rather than introducing a GenLayer-specific name.
  • Keep the current 2× estimated-gas safety margin for callers that omit the override.
  • Treat estimation failure as actionable and non-broadcasting; callers may inspect the revert or retry with an explicit limit.
  • No protocol, consensus, or fee-budget behavior changes.

Risk and rollback

The behavioral change is limited to intelligent-contract writes/deployments whose gas estimation fails: they now fail early instead of broadcasting with 200,000. Reverting this commit restores the previous fallback.

Checks

  • I have tested this code
  • I have reviewed my own PR
  • I have created an issue for this PR
  • I have set a descriptive PR title compliant with conventional commits

Reviewing tips

Start with _sendTransaction in src/contracts/actions.ts, then review the public types and the focused tests.

User facing release notes

writeContract and deployContract now accept an optional top-level gas limit for the outer EVM transaction. This is separate from GenLayer fees. If estimation fails and no limit is supplied, the SDK stops before broadcast with a clear error.

Unify writeContract and deployContract with sendTransaction's gas option, preserve estimation headroom by default, and stop before broadcast when estimation fails.
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 236bb261-2939-41ae-8497-7d36491db539

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant