-
Notifications
You must be signed in to change notification settings - Fork 766
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
feat: add geth debug_traceBlock methods #2366
Conversation
ethers-core/src/types/trace/geth.rs
Outdated
|
||
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] | ||
#[serde(untagged)] | ||
pub enum GethTraceResult { | ||
ResultKnown{result: GethTraceFrame}, | ||
ResultUnknown{result: Value}, | ||
DefaultKnown(GethTraceFrame), | ||
DefaultUnknown(Value), | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] | ||
#[serde(from = "GethTraceResult")] | ||
#[serde(untagged)] | ||
pub enum GethTrace { | ||
Known(GethTraceFrame), | ||
Unknown(Value), | ||
} | ||
|
||
impl From<GethTraceResult> for GethTrace { | ||
fn from(value: GethTraceResult) -> Self { | ||
match value { | ||
GethTraceResult::DefaultKnown(t) => GethTrace::Known(t), | ||
GethTraceResult::DefaultUnknown(v) => GethTrace::Unknown(v), | ||
GethTraceResult::ResultKnown{result} => GethTrace::Known(result), | ||
GethTraceResult::ResultUnknown{result} => GethTrace::Unknown(result), | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could probably be cleaned up. It was done to convert a batch of traces to a Vec<GethTrace>
since debug_traceBlock
wraps each trace in a "result" key.
Example raw response:
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"result": {
"from": "0x1b7aa44088a0ea95bdc65fef6e5071e946bf7d8f",
"gas": "0x0",
"gasUsed": "0x5208",
"to": "0x7cb47db064be90f6ace1673ebfe5b3a102f369b8",
"input": "0x",
"value": "0xb1a2bc2ec50000",
"type": "CALL"
}
},
{
"result": {
"from": "0xe77e6c57b20b3de8c998b4552126feaeaf32b762",
"gas": "0x2ee0",
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK. @gakonst are you more familiar with the debug endpoint? I don't know enough to say if types are correct
Needs
- tests fixed
- clippy addressed
cargo +nightly fmt
Thank you! Clippy, formatting, and tests have been fixed. Test was failing when calling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tried out - lgtm
Motivation
Support for more Geth
debug
methods.Solution
Adds
debug_traceBlockByNumber
anddebug_traceBlockByHash
RPC methods.PR Checklist