Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(engine): Original_storage bug fix; more tracing tests #390

Merged
merged 1 commit into from
Dec 9, 2021

Conversation

birchmd
Copy link
Member

@birchmd birchmd commented Dec 9, 2021

The primary goal of this PR was to add more tests for our geth tracing feature. This is accomplished, and also uncovered a bug in the engine.

The implementation of original_storage was incorrect in always returning None. The original value is accessible because SputnikVM does not change storage values until after the transaction is complete (it stores intermediate writes in memory). This incorrect implementation was causing one of the example transactions I chose to check the trace of to not be replayed correctly (it was assigning the wrong gas cost to one of the SSTORE steps because the original value was listed as missing).

This PR fixed this original_storage bug along with adding the new tracing tests.

The tests also uncovered a bug in how I was interpreting the memory_cost from SputnikVM, and fixes that as well.

Note: by simply changing the original_storage implementation without taking into account any backwards compatibility, it means the debug tracing of old transactions may differ slightly from what happened when they were originally executed on NEAR. Personally I think this is acceptable because debug tracing is generally most useful for recent transactions only. Therefore, this bug will have been fixed in the engine by the time anyone wants to debug a transaction and they will see consistent results.

Note: fixing the original_storage bug causes the 1inch and uniswap gas costs to increase a little. This may have cause more transactions to hit the NEAR gas limit if they were already close to it. However, I believe it still necessary to make this change because we want our EVM implementation to be as accurate as possible. Hopefully this change will not break anything because the increase is small. And if it does, the problem should be resolved relatively quickly because another wasm cost decrease is coming to mainnet soon.

@birchmd birchmd added C-bug Category: Something isn't working. A-testing Area: If something has added tests, or changed them. A-standalone Area: the standalone engine EVM A-engine Area: purely engine EVM related labels Dec 9, 2021
Copy link
Contributor

@joshuajbouw joshuajbouw left a comment

Choose a reason for hiding this comment

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

Looks great. Good find.

I believe that we should be fine for the difference for now between old txs and new txs. Though, it really does suck :(.

The small increase in our gas limit is not good, but it is completely unavoidable as this is a requirement.

@birchmd birchmd merged commit 123d583 into develop Dec 9, 2021
@birchmd birchmd deleted the geth-trace-tests branch December 9, 2021 19:45
@joshuajbouw joshuajbouw mentioned this pull request Dec 10, 2021
artob pushed a commit that referenced this pull request Dec 10, 2021
* Feat(engine): London hard fork support (#244)
* Fix(exit precompile): Address to refund in case of error is an argument (#311)
* Feat(engine): Make engine parametric in storage access (#314)
* Test verifying the EVM log returns the correct address (#341)
* Remove sdk::current_account_id usage from engine-precompiles (#346)
* Remove Default trait bound from engine IO (#342)
* Remove some sdk usage from core logic (#347)
* Factor out blockchain environment variable access as a trait (#349)
* Factor out NEAR promise host functions into a trait (#353)
* Borsh deserialized value field for call args (#351)
* Refactor(eth-connector): Use Result return values instead of panicking (#355)
* Gate all NEAR host functions behind the contract feature (#356)
* Bump @openzeppelin/contracts from 4.3.2 to 4.3.3 in /etc/eth-contracts
* Chore: Newtypes for gas (#344)
* Feat(standalone): Standalone (#345)
* Minor fixes to sdk refactor (#359)
* Refactor(engine): Move submit logic into engine module (#366)
* Feat(standalone): Storage backend (#375)
* NEAR random numbers from solidity contract (#368)
* Feat(standalone): EVM tracing via SputnikVM (#383)
* Feat(standalone): Bootstrap storage from relayer and state snapshots (#379)
* Feat(standalone): Structures and logic for keeping storage in sync with the blockchain (#382)
* Feat(standalone): Capture geth-like tracing from SputnikVM events (#384)
* Connector cleanup (#374)
* Remove betanet
* Fix(engine): original_storage bug fix; more tracing tests (#390)
* Increase NEAR Gas for ft_on_transfer (#389)

Co-authored-by: Andrew Bednoff <andrew.bednoff@aurora.dev>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Evgeny Ukhanov <evgeny.ukhanov@aurora.dev>
Co-authored-by: Marcelo Fornet <marcelo.fornet@aurora.dev>
Co-authored-by: Michael Birch <michael.birch@aurora.dev>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-engine Area: purely engine EVM related A-standalone Area: the standalone engine EVM A-testing Area: If something has added tests, or changed them. C-bug Category: Something isn't working.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants