Skip to content

evmonlyapp: answer eth_call and eth_estimateGas while a block executes - #4394

Open
suryuhh wants to merge 1 commit into
sei-protocol:mainfrom
suryuhh:rpc/eth-call-while-executing
Open

suryuhh wants to merge 1 commit into
sei-protocol:mainfrom
suryuhh:rpc/eth-call-while-executing

Conversation

@suryuhh

@suryuhh suryuhh commented Sep 30, 2026

Copy link
Copy Markdown

On current main, eth_call and eth_estimateGas take the executor lock and can wait behind FinalizeBlock; they can then fail while the finalized block awaits Commit. This ports suryuhh/sei-chain#3 to main after #4366 introduced asynchronous state commits.

Each request now uses a point-in-time state snapshot whose height matches the last committed block's execution context. Requests can run while the next block executes. If state and block metadata are briefly out of step, the request waits; a failed state commit is still reported.

The application and executor packages pass under -race. Tests cover calls during a stalled block, the Commit boundary, and a failed asynchronous write. The fork's response-rate benchmark used an older main; this port has not yet been load-benchmarked.

@cursor

cursor Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes read-path concurrency and snapshot/commit height pairing for RPC; incorrect pairing could serve wrong state, though tests exercise races and commit failures.

Overview
eth_call and eth_estimateGas no longer take the executor lock or block on AwaitCommits, so RPC can serve the last committed state while FinalizeBlock runs the next block.

The app pairs committed block metadata with a caller-owned state snapshot via openCommittedState: it loads the executor from settler, opens a store view, checks CommitFailure() without waiting on an in-flight commit, and retries when snapshot height and cursor disagree (waiting on commits or on cursor Watch updates after Commit). Executor APIs add CallOnSnapshot / EstimateGasOnSnapshot; the old entry points only open a view and delegate. The pending-commit refusal for read-only calls is removed; failed async writes still surface to callers when the store remains at the prior height.

Tests cover calls during a stalled finalize, the commit boundary, concurrent finalize + RPC, and commit-failure reporting.

Reviewed by Cursor Bugbot for commit 1b2eaea. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1b2eaea. Configure here.

changeSetEncoder: changeSetEncoder,
validators: slices.Clone(validators),
executor: utils.NewMutex(new(utils.Option[*evmonly.Executor])),
cursor: utils.NewMutex(&evmOnlyCursorState{}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InitChain races committed-state readers

Low Severity

InitChain publishes the executor on settler before writing the committed cursor, and that write does not call Updated(). openCommittedState now reads settler without the executor lock, so a concurrent call can observe a zero gasLimit at height 0, or wait for committed.height that InitChain never signals.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1b2eaea. Configure here.

This branch has not been deployed

No deployments
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