-
Notifications
You must be signed in to change notification settings - Fork 200
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 tracing for transactions using on-chain randomness in latest block #2186
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Coverage from tests in coverage: 50.7% of statements across all listed packagescoverage: 63.2% of statements in consensus/istanbul coverage: 42.7% of statements in consensus/istanbul/announce coverage: 55.8% of statements in consensus/istanbul/backend coverage: 0.0% of statements in consensus/istanbul/backend/backendtest coverage: 24.3% of statements in consensus/istanbul/backend/internal/replica coverage: 64.9% of statements in consensus/istanbul/core coverage: 50.0% of statements in consensus/istanbul/db coverage: 0.0% of statements in consensus/istanbul/proxy coverage: 64.4% of statements in consensus/istanbul/uptime coverage: 51.8% of statements in consensus/istanbul/validator coverage: 79.2% of statements in consensus/istanbul/validator/random |
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #2186 +/- ##
==========================================
+ Coverage 55.10% 55.19% +0.09%
==========================================
Files 680 681 +1
Lines 114370 114407 +37
==========================================
+ Hits 63019 63144 +125
+ Misses 47468 47385 -83
+ Partials 3883 3878 -5
☔ View full report in Codecov by Sentry. |
eelanagaraj
changed the title
WIP
Fix tracing for transactions using on-chain randomness in latest block
Sep 18, 2023
eelanagaraj
changed the title
Fix tracing for transactions using on-chain randomness in latest block
WIP: Fix tracing for transactions using on-chain randomness in latest block
Sep 18, 2023
eelanagaraj
force-pushed
the
eelanagaraj/fix-random-tracing
branch
from
September 18, 2023 15:43
1e5f042
to
e7f8ea2
Compare
carterqw2
reviewed
Sep 19, 2023
palango
reviewed
Sep 19, 2023
eelanagaraj
changed the title
WIP: Fix tracing for transactions using on-chain randomness in latest block
Fix tracing for transactions using on-chain randomness in latest block
Sep 19, 2023
carterqw2
approved these changes
Sep 19, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes transaction tracing bug where the tracer did not include the block randomness for block whose transaction was being traced. For
(tx_i, block_n)
, it would fetch the state forblock_n-1
and then reexecute all txs up untiltx_i
, but would omit the random commitment at the very start ofblock_n
.This affects the following endpoints:
TraceTransaction
TraceBlock*
StandardTraceBlock*
IntermediateRoots
TraceChain
Note:
TraceCall
performs correctly since this applies the tx at the end of the requested block, so the block randomness of the next block is irrelevant.Implementation note
eth/tracers/api.go
) but this results in even more messiness because theeth/state_accessor/stateAtTransaction
function needs to have the solution duplicatedOne alternative here is just directly updating the
stateAtTransaction
function and then updating the API to usestateAtTransaction
with the block & 0th index transaction to set up the state properly pre-tracing. I thought this was potentially a bit unclear + more likely to be accidentally overwritten in future merges but happy to reconsider!Factors out
ApplyBlockRandomnessTx
fromcore/state_processor/Process
so that it can be used bystate_accessor
as well.Tested
Unfortunately, testing this via an e2e/unit test is extremely involved, since tracing a simple interaction with
Random.sol
will not suffice. It appears necessary to trace a transaction where a contract interacts withRandom.sol
(tracing a non-view call), and deploying a contract manually in the test feels unnecessary.TraceChain
& not using thelive
database for multiple blocks 🤔Backwards compatibility
This changes the behavior of the tracing API endpoints but is not expected to be a consensus-relevant breaking change.