Skip to content

feat: add --gas override flag to deploy and write - #404

Open
ygd58 wants to merge 1 commit into
genlayerlabs:v0.40-devfrom
ygd58:feat/gas-override-flag
Open

feat: add --gas override flag to deploy and write#404
ygd58 wants to merge 1 commit into
genlayerlabs:v0.40-devfrom
ygd58:feat/gas-override-flag

Conversation

@ygd58

@ygd58 ygd58 commented Aug 7, 2026

Copy link
Copy Markdown

Summary

Fixes the CLI-side half of #402: no way to override gas estimation for deploy/write.

On Bradbury, genlayer write used the exact eth_estimateGas result as the outer EVM gas limit for addTransaction. The outer transaction reverted twice before GenVM was ever reached; identical calldata succeeded when replayed with a larger explicit gas limit (1,319,997 estimated & reverted twice; 2,000,000 explicit & finalized).

Change

Adds --gas <gasLimit> to both deploy and write, threaded through to genlayer-js's writeContract/deployContract gas option (see genlayer-js#205, which adds that option and this PR depends on).

Added a parseGasLimit helper next to the existing parseValidUntil in fees.ts, reusing the same parseBigNumberishOption validation (non-negative integer, decimal or 0x-hex) plus a positive-value check specific to gas.

Dependency note: this PR's own tests mock the genlayer-js client, so they pass regardless of merge order. But the --gas flag has no actual runtime effect until genlayer-js#205 ships, since older genlayer-js versions don't read a gas field at all (it's silently ignored — the writeParams/deployParams objects here are any-typed, so nothing breaks, it just won't do anything yet).

Testing

  • 9 new cases across tests/actions/{write,deploy}.test.ts: valid override passed through as a bigint, omitted when not provided, invalid value rejected before the SDK call (via the existing failSpinner error path, not a thrown rejection — matches how every other validation error in this codebase surfaces), zero rejected.
  • 2 new cases in tests/commands/{write,deploy}.test.ts: confirms the --gas CLI flag is actually parsed by commander and reaches the action.
  • Full suite: 585 passed, 52 files, no regressions.
  • npx tsc --noEmit: 0 new errors in any file I touched (write.ts, deploy.ts, fees.ts, commands/index.ts). The existing pre-existing errors elsewhere (staking/vesting/keychain) are from this repo's source being ahead of its currently-published genlayer-js npm dependency — unrelated to this change.

On Bradbury, `genlayer write` used the exact eth_estimateGas result as
the outer EVM gas limit, and the transaction reverted twice before
GenVM was ever reached; identical calldata succeeded when replayed
with a larger explicit gas limit. The CLI exposed no way to override
gas estimation for either deploy or write.

Adds `--gas <gasLimit>` to both commands, threaded through to
genlayer-js's writeContract/deployContract `gas` option (see
genlayer-js PR genlayerlabs#205, which this depends on — this PR's tests use a
mocked genlayer-js client so they don't need that change merged
first, but the flag has no runtime effect against genlayer-js
versions that don't understand the `gas` field yet).

Added a `parseGasLimit` helper next to the existing `parseValidUntil`
in fees.ts, reusing the same `parseBigNumberishOption` validation
(non-negative integer, decimal or 0x-hex) plus a positive-value check
specific to gas (zero isn't a meaningful gas limit).

Tests: 9 new cases across tests/actions/{write,deploy}.test.ts (valid
override passed through as bigint, omitted when not provided, invalid
value rejected before the SDK call, zero rejected) and
tests/commands/{write,deploy}.test.ts (CLI flag parsing reaches the
action). Full suite: 585 passed (52 files), no regressions. TypeScript:
0 new errors in any file I touched (`npx tsc --noEmit` shows
pre-existing, unrelated errors in staking/vesting/keychain code from
genlayer-cli's source being ahead of its published genlayer-js
dependency — none in write.ts, deploy.ts, fees.ts, or
commands/index.ts).
@github-actions
github-actions Bot changed the base branch from main to v0.40-dev August 7, 2026 11:32
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

This PR targeted main, which is only the default/static branch.

I retargeted it to v0.40-dev, the active development branch. Pushes to v0.40-dev automatically fast-forward main.

@coderabbitai

coderabbitai Bot commented Aug 7, 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: 38bd7a7f-cac6-4f66-9b18-ba63f8a1a009

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