Skip to content

feat(op-reth): add Soul Gas Token (SGT) support with acceptance tests#148

Open
blockchaindevsh wants to merge 2 commits intoop-esfrom
sgt_rust_v2
Open

feat(op-reth): add Soul Gas Token (SGT) support with acceptance tests#148
blockchaindevsh wants to merge 2 commits intoop-esfrom
sgt_rust_v2

Conversation

@blockchaindevsh
Copy link

@blockchaindevsh blockchaindevsh commented Mar 20, 2026

The go changes mainly migrates the sgt e2e tests to the op-acceptance tests(cd op-acceptance-tests && just sgt).

Essential op-reth changes are under the ./rust directory.

Details of this PR can be seen in the msg of the squashed commit.

External rust dependencies PRs will be created separately.

Add SGT support to the Rust OP Stack implementation and execution-client
agnostic acceptance tests, enabling alternative gas payment using Soul
Gas Tokens from a predeploy contract.

Rust changes (under rust/):
- Patch revm/alloy-evm with forked SGT-enabled versions (revm 34.0.0 based)
- Add SgtConfig type and SGT constants (contract addr, balance slot)
- Parse SGT config from genesis config.optimism (soulGasTokenTime,
  isSoulBackedByNative) — same format as op-geth
- Thread SGT config through OpBlockExecutionCtx → EVM via configure_sgt()
- Add OpHardforks trait methods: is_sgt_active_at_timestamp(),
  is_sgt_native_backed()
- RPC: dual HTTP server support (--http.sgt.addr/port) returning
  native+SGT combined balance on eth_getBalance
- TxPool: check native+SGT combined balance for tx validation
  (only when SGT is active, zero overhead on non-SGT chains)
- CLI: --http.sgt.addr and --http.sgt.port arguments

Acceptance tests (20/20 passing):
- Deposit: basic, accumulation, multi-account independence, native backing
- Gas payment: native-only, full SGT, full SGT+native, partial SGT
- Gas payment + tx value: full SGT, partial SGT
- Insufficient funds: SGT-only, native-only, combined, with tx value
- Balance invariant: preSGT + preNative == postSGT + postNative + gasCost + txValue
- Genesis: contract deployment, balanceOf returns zero
- Smoke: native transfer, balance query

Gas payment priority (enforced by forked revm handler):
- Deduction: SGT first → native second
- Refund: native first → SGT second

No MSRV bump (stays 1.88), no reth version bump (stays v1.11.0).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move SGT configuration from OpBlockExecutionCtx + Evm::configure_sgt()
to CfgEnv fields, matching how OpSpecId passes hardfork info. This
eliminates the alloy-evm fork entirely.

Changes:
- Remove configure_sgt() from Evm trait impl and OpEvm inherent method
- Remove sgt_config from OpBlockExecutionCtx
- Set CfgEnv.sgt_enabled/sgt_is_native_backed in evm_env(), next_evm_env(),
  evm_env_for_payload()
- Switch revm fork from blockchaindevsh/revm to QuarkChain/revm@3a6aa085
  which adds is_sgt_enabled()/is_sgt_native_backed() to Cfg trait
- Drop alloy-evm fork (blockchaindevsh/evm) from [patch.crates-io]

External dependency: QuarkChain/revm@3a6aa085 (only fork needed)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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