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

EVM tracing support #802

Merged
merged 18 commits into from
Jan 16, 2023
Merged

EVM tracing support #802

merged 18 commits into from
Jan 16, 2023

Conversation

akru
Copy link
Contributor

@akru akru commented Dec 9, 2022

Pull Request Summary

This PR based on Moonbeam great job with EVM tracing support. As base used EVM tracing module from PureStake repositories, adopted and improved to suits Astar requirements and code base.

Tracing modules PR: AstarNetwork/astar-frame#120

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 force-pushed the feature/evm-tracing branch from 00843ea to 0fa613c Compare December 23, 2022 07:42
@akru akru marked this pull request as ready for review December 23, 2022 08:45
/// Maximum number of logs in a query.
#[clap(long, default_value = "10000")]
pub max_past_logs: u32,

Copy link
Member

Choose a reason for hiding this comment

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

Good docs page will be needed for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, parameters should be explained in details.

}
}

pub struct TracingConfig {
Copy link
Member

Choose a reason for hiding this comment

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

How about EvmTracingConfig? It's more precise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

pub mod tracing;

#[derive(Clone)]
pub struct TracingConfig {
Copy link
Member

Choose a reason for hiding this comment

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

EvmTracingConfig perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely, let me fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed

Comment on lines +326 to +339
if let Some(trace_filter_requester) = tracing_config.tracing_requesters.trace {
io.merge(
Trace::new(
client,
trace_filter_requester,
tracing_config.trace_filter_max_count,
)
.into_rpc(),
)?;
}

if let Some(debug_requester) = tracing_config.tracing_requesters.debug {
io.merge(Debug::new(debug_requester).into_rpc())?;
}
Copy link
Member

Choose a reason for hiding this comment

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

Haven't checked the code in details, but can't we just reuse the existing function and add the highlighted part only to this method?

Something like:

fn create_full_tracing(...) -> Result<...> {
  let io = create_full(...)?;

  // the code you added

}

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 to have.

I planed to remove one of this function when all runtimes will implement Debug runtime API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -1467,4 +1467,70 @@ impl_runtime_apis! {
Executive::try_execute_block(block, state_root_check, select).expect("execute-block failed")
}
}

#[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.

Could you please explain why is this feature flag used?

Not sure I understand given it's runtime code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically we can build runtime without this feature, because it’s still experimental. But in near future it could be moved to default or removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this feature

Copy link
Member

@shunsukew shunsukew left a comment

Choose a reason for hiding this comment

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

Ethereum doesn't allow Debug RPCs by default. Node operators need to configure to intentionally allow Debug APIs being exposed.
https://geth.ethereum.org/docs/interacting-with-geth/rpc

The default whitelist allows access to the eth, net and web3 namespaces. To enable access to other APIs like debugging (debug), they must be configured using the --http.api flag. Enabling these APIs over HTTP is not recommended because access to these methods increases the attack surface.

I think we should do the same at least by having a new flag, otherwise all public node operators need some measurements to block these RPCs in front of node processes.

I just noticed it's already implemented so.

@shunsukew shunsukew self-requested a review January 3, 2023 15:29
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.

Checked the delta & LGTM but perhaps @shunsukew or @0x7CFE who invested more time into EVM tracing can provide better feedback.

@akru
Copy link
Contributor Author

akru commented Jan 13, 2023

@shunsukew @0x7CFE please take a look

akru and others added 2 commits January 13, 2023 14:30
@shunsukew shunsukew self-requested a review January 13, 2023 05:58
Copy link
Contributor

@0x7CFE 0x7CFE left a comment

Choose a reason for hiding this comment

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

Was that intentional that spec version was updated only for local runtime?

@@ -1448,6 +1448,70 @@ impl_runtime_apis! {
}
}

impl moonbeam_rpc_primitives_debug::DebugRuntimeApi<Block> for Runtime {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this impl is mostly copypaste? Maybe we should extract it into a single module, used by all runtimes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That’s right, usually multi-runtimes projects create something like common module with shared implementations. Problem here it’s under macros and move it outside makes code more and more sophisticated.

@akru
Copy link
Contributor Author

akru commented Jan 13, 2023

@0x7CFE please point me to spec version you mean.

@akru akru changed the base branch from master to 5.x.x January 16, 2023 04:56
@akru akru merged commit fe58b85 into 5.x.x Jan 16, 2023
@akru akru deleted the feature/evm-tracing branch January 16, 2023 08:38
@0x7CFE
Copy link
Contributor

0x7CFE commented Jan 17, 2023

@0x7CFE please point me to spec version you mean.

@akru please ignore that, I misread the code.

akru added a commit that referenced this pull request Mar 13, 2023
* EVM tracing support (#802)

* Added EVM tracing into local runtime

* Added tracing CLI

* Compilation fixes

* Added EVM tracing host functions

* Added EVM tracing into parachain runtimes

* TracingConfig -> EvmTracingConfig

* Compilation fixes

* Fix clippy errors

* Fix formatting

* Updated dependencies in Cargo.lock

* Updated Cargo.lock

* Update bin/collator/src/local/service.rs

Co-authored-by: Shunsuke Watanabe <[email protected]>

* Update bin/collator/src/parachain/service.rs

Co-authored-by: Shunsuke Watanabe <[email protected]>

* Bump astar/shiden runtime specs

Co-authored-by: Shunsuke Watanabe <[email protected]>

* Fix srtool build

* [CI] temporary disable aarch64 target

* [CI] fix binaries upload for release pipeline

* Fix CI errors

* Update rust toolchain version to 2023-01-11

* Update Cargo.lock

* Added txpool rpc support (#855)

* Added txpool rpc support

* Fix licensing

* Bump dependencies & runtime versions

* Remove outdated migrations from runtimes

* Sort review comments

---------

Co-authored-by: Shunsuke Watanabe <[email protected]>
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.

4 participants