Skip to content

Revive, Estimate Gas with Binary Search#11000

Merged
0xOmarA merged 40 commits intomasterfrom
0xOmarA/revive-gas-estimation-binary-search
Mar 20, 2026
Merged

Revive, Estimate Gas with Binary Search#11000
0xOmarA merged 40 commits intomasterfrom
0xOmarA/revive-gas-estimation-binary-search

Conversation

@0xOmarA
Copy link
Copy Markdown
Contributor

@0xOmarA 0xOmarA commented Feb 5, 2026

Description

This PR implements binary search for the gas estimation logic in the eth-rpc which means that gas estimations are no longer just simple dry runs but that binary search is now used to find the smallest gas limit at which the transaction would run.

This PR closes paritytech/contract-issues#217 and also kind of fixes paritytech/contract-issues#259 or at least makes it harder to trigger the case in which we observe it, but the underlying issue still exists.

The binary search algorithm implemented in this PR is as close as possible to that used in Geth

Note

This PR does not fix paritytech/contract-issues#259 where the dry run could fail but the submission succeeds. It makes it so that it's harder for that case to be triggered by the underlying issue causing paritytech/contract-issues#259 is still there and it's caused by the overflows and saturations that happen in the gas -> fee -> weight computations

@0xOmarA 0xOmarA added the T7-smart_contracts This PR/Issue is related to smart contracts. label Feb 5, 2026
@0xOmarA
Copy link
Copy Markdown
Contributor Author

0xOmarA commented Feb 5, 2026

/cmd prdoc --audience runtime_dev --bump patch

@0xOmarA 0xOmarA requested review from a team as code owners February 6, 2026 16:00
Comment thread substrate/frame/revive/rpc/src/client/runtime_api.rs
Comment thread substrate/frame/revive/src/lib.rs Outdated
Comment thread substrate/frame/revive/src/lib.rs Outdated
Comment thread substrate/frame/revive/src/lib.rs
Copy link
Copy Markdown
Contributor

@marian-radu marian-radu left a comment

Choose a reason for hiding this comment

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

LGTM!

@0xOmarA 0xOmarA requested a review from a team as a code owner February 23, 2026 17:05
Comment on lines +1815 to +1816
// TODO: Implement a short circuit for simple transfers. We just need to determine the gas
// needed for it.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we take care of it here, or remove the TODO if we estimate the impact is acceptable

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think that the impact is acceptable here so I will remove this TODO all together

Copy link
Copy Markdown
Contributor

@pgherveou pgherveou left a comment

Choose a reason for hiding this comment

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

can we test it out against Paseo, I believe all operations should still work when targeting an old runtime without the updated runtime API

@0xOmarA 0xOmarA added this pull request to the merge queue Mar 20, 2026
Merged via the queue into master with commit 1c2eeb7 Mar 20, 2026
245 of 249 checks passed
@0xOmarA 0xOmarA deleted the 0xOmarA/revive-gas-estimation-binary-search branch March 20, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature T7-smart_contracts This PR/Issue is related to smart contracts.

Projects

None yet

4 participants