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

feat: add geth debug_traceBlock methods #2366

Merged
merged 3 commits into from
Apr 27, 2023

Conversation

bsh98
Copy link
Contributor

@bsh98 bsh98 commented Apr 19, 2023

Motivation

Support for more Geth debug methods.

Solution

Adds debug_traceBlockByNumber and debug_traceBlockByHash RPC methods.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Comment on lines 90 to 118

#[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),
}
}
}

Copy link
Contributor Author

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",
...

Copy link
Collaborator

@prestwich prestwich left a 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

@bsh98
Copy link
Contributor Author

bsh98 commented Apr 27, 2023

Thank you! Clippy, formatting, and tests have been fixed. Test was failing when calling get_block with an eth provider and the celo feature enabled.

@bsh98 bsh98 requested a review from prestwich April 27, 2023 19:17
Copy link
Owner

@gakonst gakonst left a comment

Choose a reason for hiding this comment

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

tried out - lgtm

@gakonst gakonst merged commit 97d363b into gakonst:master Apr 27, 2023
14 of 15 checks passed
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

3 participants