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

Misbehaviour in debug_traceCall #8103

Open
1 task done
Arvmor opened this issue May 4, 2024 · 3 comments
Open
1 task done

Misbehaviour in debug_traceCall #8103

Arvmor opened this issue May 4, 2024 · 3 comments
Assignees
Labels
A-execution Related to the Execution and EVM A-rpc Related to the RPC implementation C-bug An unexpected or incorrect behavior

Comments

@Arvmor
Copy link

Arvmor commented May 4, 2024

Describe the bug

In reth, we fail to retain contract address when using debug_traceCall,
however the exact same function, without anychanges, returns the right values in geth

Steps to reproduce

Reth, faulty response:

curl http://localhost:8545/ -X POST -H 'Content-Type: application/json' -d '{"id":1,"jsonrpc":"2.0","method":"debug_traceCall","params":[{"data":"0x03e11a81a460ea6fd96a73d5672f1f4aa684697d4b44cc46c8229b","from":"0xaeeb8456f598f7242ed32bc9658ba20f6b4557fd","gas":"0x927c0","gasPrice":"0x149d12861","to":"0x0015fe03456b000000009a38ba029a1d515f00e8","value":"0x49e1b0a"},"0x12e0a13",{"stateOverrides":{},"tracer":"{ retVal: [], callStack: [], byte2Hex: function(byte) { if (byte < 0x10) return \"0\" + byte.toString(16); return byte.toString(16); }, array2Hex: function(arr) { var retVal = \"\"; for (var i = 0; i < arr.length; i++) retVal += this.byte2Hex(arr[i]); return retVal; }, getAddr: function(log) { return this.array2Hex(log.contract.getAddress()); }, step: function(log, db) { var opcode = log.op.toNumber(); if (opcode == 0x54) { this.retVal.push(this.getAddr(log) + \":\" + log.stack.peek(0).toString(16)); } if (opcode == 0x55) this.retVal.push(this.getAddr(log) + \":\" + log.stack.peek(0).toString(16) + \";\" + log.stack.peek(1).toString(16)); }, fault: function(log, db) { this.retVal.push(\"FAULT: \"); }, result: function(ctx, db) { return this.retVal; } }"}]}'
[":29014e76b0986d11d3cdf684c1f9f21c48ee047d65ac69db0da87068aa883c4f"]

Geth right response:
*just change localhost to this geth node: https://eth-pokt.nodies.app *

["c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2:29014e76b0986d11d3cdf684c1f9f21c48ee047d65ac69db0da87068aa883c4f"]

as you can see, the contract address before the : is missing in reth respone

Node logs

No response

Platform(s)

Linux (x86)

What version/commit are you on?

reth Version: 0.2.0-beta.6
Commit SHA: ac29b4b
Build Timestamp: 2024-05-03T11:36:14.574613897Z
Build Features: jemalloc
Build Profile: maxperf

What database version are you on?

Current database version: 2
Local database is uninitialized

Which chain / network are you on?

mainnet

What type of node are you running?

Archive (default)

What prune config do you use, if any?

No response

If you've built Reth from source, provide the full command you used

No response

Code of Conduct

  • I agree to follow the Code of Conduct
@Arvmor Arvmor added C-bug An unexpected or incorrect behavior S-needs-triage This issue needs to be labelled labels May 4, 2024
@DaniPopes DaniPopes added A-rpc Related to the RPC implementation and removed S-needs-triage This issue needs to be labelled labels May 6, 2024
@DaniPopes
Copy link
Member

DaniPopes commented May 6, 2024

Formatted JS:

{
    retVal: [],
    callStack: [],
    byte2Hex: function (byte) {
        if (byte < 0x10) return "0" + byte.toString(16);
        return byte.toString(16);
    },
    array2Hex: function (arr) {
        var retVal = "";
        for (var i = 0; i < arr.length; i++) retVal += this.byte2Hex(arr[i]);
        return retVal;
    },
    getAddr: function (log) {
        return this.array2Hex(log.contract.getAddress());
    },
    step: function (log, db) {
        var opcode = log.op.toNumber();
        if (opcode == 0x54) {
            this.retVal.push(this.getAddr(log) + ":" + log.stack.peek(0).toString(16));
        }
        if (opcode == 0x55)
            this.retVal.push(
                this.getAddr(log) +
                    ":" +
                    log.stack.peek(0).toString(16) +
                    ";" +
                    log.stack.peek(1).toString(16)
            );
    },
    fault: function (log, db) {
        this.retVal.push("FAULT: ");
    },
    result: function (ctx, db) {
        return this.retVal;
    },
}

Maybe missing log.contract.getAddress()?

Edit: should be there https://github.com/paradigmxyz/evm-inspectors/blob/089efacf72e7583630841b7027c46a3cb2f9c28b/src/tracing/js/bindings.rs#L517C30-L517C38

cc @mattsse

@mattsse
Copy link
Collaborator

mattsse commented May 6, 2024

yeah and contract is set:

https://github.com/paradigmxyz/evm-inspectors/blob/089efacf72e7583630841b7027c46a3cb2f9c28b/src/tracing/js/bindings.rs#L202-L202

looks like log.contract.getAddress() returns an empty vec? which would explain ":..."

need to debug this a bit.

@DaniPopes DaniPopes added the A-execution Related to the Execution and EVM label May 6, 2024
@Arvmor
Copy link
Author

Arvmor commented May 7, 2024 via email

@mattsse mattsse self-assigned this May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-execution Related to the Execution and EVM A-rpc Related to the RPC implementation C-bug An unexpected or incorrect behavior
Projects
Status: Todo
Development

No branches or pull requests

3 participants