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

Plugable EVM tracing #883

Merged
merged 1 commit into from
Mar 20, 2023
Merged

Plugable EVM tracing #883

merged 1 commit into from
Mar 20, 2023

Conversation

akru
Copy link
Contributor

@akru akru commented Mar 16, 2023

Pull Request Summary

This PR introduce EVM tracing as optional feature. Using runtime overriding it makes possible to enable tracing on runtimes that don't have tracing runtime API.

New rust features:

  • evm-tracing on runtimes: enable tracing runtime API when build with specified feature - used for tracing runtimes
  • evm-tracing on collator: enable tracing RPC and host functions required for tracing runtimes.

Usage:

  • download tracing node and runtime
  • use --wasm-runtime-overrides flag to substitute tracing runtime instead of production
  • EVM tracing API available on node

Check list

  • added or updated unit tests
  • updated Astar official documentation
  • added OnRuntimeUpgrade hook for precompile revert code registration
  • updated spec version
  • updated semver

@akru akru requested review from Dinonard, 0x7CFE and bLd75 March 16, 2023 15:44
Copy link
Member

@Dinonard Dinonard 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 we can avoid having production runtime include unnecessary code but I don't believe this PR is the best way to achieve this.

@@ -31,6 +31,7 @@ pub struct Cli {
pub run: cumulus_client_cli::RunCmd,

/// Enable EVM tracing module on a non-authority node.
#[cfg(feature = "evm-tracing")]
Copy link
Member

Choose a reason for hiding this comment

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

Instead of adding options one by one, and having #[cfg(feature = "evm-tracing")]] over each, you should create a struct and flatten it. Perfect example is few lines above for the cumulus_client_cli.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Preprocessor conditions makes it possible to exclude tracing dependencies from production client.

Copy link
Member

Choose a reason for hiding this comment

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

That is correct. However, I didn't comment that at all.

My comment relates to having many feature checks and I suggest to add only one instead and use the flatten macro.

@@ -168,6 +176,7 @@ impl RelayChainCli {
}

/// EVM tracing CLI flags.
#[cfg(feature = "evm-tracing")]
Copy link
Member

Choose a reason for hiding this comment

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

Why not move all evm-tracing related type into a separate module?
The code would be much cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn’t change anything here, just add few preprocessor conditions; all comments are fair for 5.0 without this PR.

Copy link
Member

Choose a reason for hiding this comment

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

I commented what you changed - adding the feature check 🤷‍♂️.

Comment on lines +906 to +912

#[cfg(not(feature = "evm-tracing"))]
if config.chain_spec.is_astar() {
start_astar_node(config, polkadot_config, collator_options, para_id, cli.enable_evm_rpc)
.await
.map(|r| r.0)
.map_err(Into::into)
Copy link
Member

Choose a reason for hiding this comment

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

This isn't clean nor is it scalable - why not instead introduce a new struct/type, like AdditionalConfiguration which would aggregate all additional config types?

That way you keep a single entry point for the start_xyz_node function. If we need to add additional ones in the future, how will that look like otherwise?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point for refactoring the service.

})
)
}).await
}
Copy link
Member

Choose a reason for hiding this comment

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

We've discussed in the team that service code is already too complex as it is. Adding additional 1000+ lines of C/P code with slight modification looks like another giant leap in the wrong direction.

We should carefully rethink this approach - the solution which you're basing this PR on didn't include this code in production for a reason.

Merging this, as it is, makes further development and maintenance of this code even more difficult than before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Up to me it not grown complexity, good point is have full refactoring instead of trying to deal with complexity in this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, then we have differing opinions. Mine is based on doing the uplifts roughly for the last year.
And with this code, it looks like that will be even more complex now that it was before.

Copy link
Member

@Dinonard Dinonard left a comment

Choose a reason for hiding this comment

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

Let's get it merged to remove the unconditional EVM tracing code from runtimes 👍

@akru akru merged commit f52a671 into master Mar 20, 2023
@akru akru deleted the feature/plugable-evm-tracing branch March 20, 2023 11:58
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.

2 participants