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

Set interpreter config to debug as well in evm.SetDebug and update tracing tests #2061

Merged
merged 10 commits into from Apr 19, 2023

Conversation

eelanagaraj
Copy link
Contributor

@eelanagaraj eelanagaraj commented Apr 4, 2023

Description

Debugging the failure of the test case TestBlockTracingConcurrentMapAccess and then later in the tracers_test suite in #1978 led to the two following observations:

  • in the evm.SetDebug function, we currently only set evm.Config.Debug but not evm.interpreter.cfg.Debug, but both of these are used in EVM execution code. Fixing this is necessary for the go native tracing implementation to work
  • the tracers_test suite has been commented out for the past few years but now mostly work with the original geth tests

The debug setting issue seems to have arisen with an upstream merge where we changed EVM/interpreter initialization from passing the config by reference to passing by value. This caused the divergence in debug config values. For now, I opted by setting both debug config values in the setter function instead of reverting to passing by reference, since upstream still passes the config by value and I imagine this could lead to the exact same issue in the future (and minimizes the diff).

This PR:

  • fixes the config debug setting here (so that this subtle change doesn't get buried in the larger PR & that CI passes)
  • takes some of the tracer_test fixes from the go-native tracing PR and implements them here so we have a clearer signal of what expected values are before the native tracing implementation

Tested

  • tracing unit tests
  • ensured that all the tracing tests pass with/without the Debug config change locally
  • testing on blockscout rc1staging (TODO -- manually check that differences in outputs make sense, and make sure this doesn't break anything unexpected with older transaction tracing)
  • ran rosetta CLI checks for limited time with new blockchain node to check that balance reconciliation looks good

Related Issues

Prep to get #1978 into mergeable state

Backwards compatibility

This changes the traces outputted, as this now does not trace calls when distributing fees or completing tobin transfer logic. This breaks from current tracing behavior, but seems consistent with previous (pre #1695) functionality and intended functionality (from the comments).

@github-actions
Copy link

github-actions bot commented Apr 4, 2023

Coverage from tests in ./e2e_test/... for ./consensus/istanbul/... at commit 7ff71e2

coverage: 49.1% of statements across all listed packages
coverage:  61.5% of statements in consensus/istanbul
coverage:  37.5% of statements in consensus/istanbul/announce
coverage:  54.4% 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.3% of statements in consensus/istanbul/core
coverage:  45.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

@github-actions
Copy link

github-actions bot commented Apr 4, 2023

5803 passed, 46 skipped

@codecov
Copy link

codecov bot commented Apr 4, 2023

Codecov Report

Patch coverage has no change and project coverage change: +0.03 🎉

Comparison is base (bffb07d) 54.24% compared to head (6ec865a) 54.27%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2061      +/-   ##
==========================================
+ Coverage   54.24%   54.27%   +0.03%     
==========================================
  Files         692      692              
  Lines      115618   115628      +10     
==========================================
+ Hits        62714    62759      +45     
+ Misses      49056    49036      -20     
+ Partials     3848     3833      -15     
Impacted Files Coverage Δ
accounts/abi/bind/backends/simulated.go 60.72% <0.00%> (-0.23%) ⬇️
consensus/istanbul/protocol.go 0.00% <ø> (ø)
core/vm/evm.go 14.14% <0.00%> (-0.15%) ⬇️
eth/filters/api.go 44.44% <0.00%> (-0.03%) ⬇️
eth/filters/filter.go 62.14% <ø> (ø)
trie/proof.go 75.94% <ø> (ø)
trie/stacktrie.go 87.42% <ø> (ø)

... and 26 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@eelanagaraj eelanagaraj force-pushed the eelanagaraj/test-debug-config-change branch from 94280c1 to 2212085 Compare April 6, 2023 11:28
@eelanagaraj eelanagaraj changed the title [DO NOT MERGE] Test: Use EVM GetDebug in interpreter instead of value stored in cfg Set interpreter config to debug as well in evm.SetDebug and update tracing tests Apr 6, 2023
@eelanagaraj eelanagaraj changed the title Set interpreter config to debug as well in evm.SetDebug and update tracing tests [DO NOT MERGE] Set interpreter config to debug as well in evm.SetDebug and update tracing tests Apr 6, 2023
@eelanagaraj eelanagaraj changed the title [DO NOT MERGE] Set interpreter config to debug as well in evm.SetDebug and update tracing tests Set interpreter config to debug as well in evm.SetDebug and update tracing tests Apr 11, 2023
@eelanagaraj eelanagaraj force-pushed the eelanagaraj/test-debug-config-change branch from 864671b to 41bc603 Compare April 14, 2023 10:07
@eelanagaraj eelanagaraj marked this pull request as ready for review April 14, 2023 10:12
@eelanagaraj eelanagaraj requested review from a team, palango and hbandura and removed request for a team April 14, 2023 10:12
Copy link
Contributor

@palango palango left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for digging so deep into this code!

Some comments:

  • What about fixing this by passing the config as a reference?
  • Does TestTraceTransactionWithRegistryDeployed fail without the prior commits fixing the flags?
  • I'd merge some commits, so that the history gets a bit nicer.

@eelanagaraj
Copy link
Contributor Author

eelanagaraj commented Apr 14, 2023

@palango 🙏

What about fixing this by passing the config as a reference?

geth passes the config by value in NewEVM and wanted to minimize the diff there. In more recent commits, they have entirely gotten rid of passing the config to the interpreter (and instead just use the one). I figured it'd be best for now to contain the changes within the SetDebug function for now and ultimately move towards the geth solution of refactoring the entire interpreter/evm. (Also I was nervous that within a future upstream merge, this change could again come back in, whereas the SetDebug code is entirely Celo-specific). Lmk if that makes sense or if you still think it's preferable to go back to passing by value!

Does TestTraceTransactionWithRegistryDeployed fail without the prior commits fixing the flags?

yes!

I'd merge some commits, so that the history gets a bit nicer.

def, planning to squash merge this. I initially kept stuff in separate undo/redo steps to save CI results while testing (obvi overwrote those when rebasing master hehe). Happy to split things up to separate commits if squash-merging isn't an option! 😄

@palango
Copy link
Contributor

palango commented Apr 14, 2023

Lmk if that makes sense or if you still think it's preferable to go back to passing by value!

Makes a lot of sense, lets keep it like that for now.

Last question: How did you generate the updates in the tracer tests?

@eelanagaraj
Copy link
Contributor Author

Makes a lot of sense, lets keep it like that for now.

Sounds good!

Last question: How did you generate the updates in the tracer tests?

I took most of the changes from the go-native tracer PR -- basically, that PR got these tests runnable (they have been commented out for 4 years 😅 ). The idea was to get those tests runnable with input pre-/post- the fix (no changes -- they pass either way; this was also one of the reasons for the undo/redo in the commit history since I wanted to confirm this in CI in addition to locally). The hope is that with these tests added on master, we will have a bit stronger of a signal about the go-native tracer implementation (i.e. that PR should require no changes to the input files to get those cases running).

For the JSON files:

  • I tried to make the least amount of changes to get them running (i.e. usually change gas values in outputs)
  • In a few cases the inputs simply didn't work (I tried everything I could think of to decode these including using the transaction formats from the commit when they were added, but couldn't find a way 😭), I used the files from geth with slight changes to outputs to get them running (thank you for that tip btw @palango !).

Happy to add clarification anywhere or lmk if you can think of additional steps to take regarding the native tracer changes! 🙏

@eelanagaraj
Copy link
Contributor Author

@palango oop I also added one last TODO to the PR -- I won't merge this until after the blockscout results comparison for some txs & making sure that it doesn't break things. Then, blockscout outputs should be identical for the go-native tracer once this change is merged!

Copy link
Contributor

@palango palango left a comment

Choose a reason for hiding this comment

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

Great, that all sounds good to me.
I really like the approach of fixing tests before the native tracer PR so that we can be confident that nothing changes.

@eelanagaraj eelanagaraj merged commit 7ff71e2 into master Apr 19, 2023
21 of 23 checks passed
@eelanagaraj eelanagaraj deleted the eelanagaraj/test-debug-config-change branch April 19, 2023 12:01
@eelanagaraj eelanagaraj mentioned this pull request Apr 21, 2023
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.

None yet

2 participants