Skip to content

Commit

Permalink
fix(evm): debug calls with custom tracer and tracer options (#2031)
Browse files Browse the repository at this point in the history
  • Loading branch information
onikonychev authored Sep 12, 2024
1 parent 64beba7 commit 6ba79bb
Show file tree
Hide file tree
Showing 6 changed files with 314 additions and 105 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#2020](https://github.com/NibiruChain/nibiru/pull/2020) - test(evm): e2e tests for debug namespace
- [#2022](https://github.com/NibiruChain/nibiru/pull/2022) - feat(evm): debug_traceCall method implemented
- [#2023](https://github.com/NibiruChain/nibiru/pull/2023) - fix(evm)!: adjusted generation and parsing of the block bloom events
- [#2031](https://github.com/NibiruChain/nibiru/pull/2031) - fix(evm): debug calls with custom tracer and tracer options

#### Dapp modules: perp, spot, oracle, etc

Expand Down
3 changes: 3 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"

// force call init() of the geth tracers
_ "github.com/ethereum/go-ethereum/eth/tracers/native"
)

const (
Expand Down
37 changes: 30 additions & 7 deletions e2e/evm/test/debug_queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ describe("debug queries", () => {
it("debug_traceBlockByNumber", async () => {
const traceResult = await provider.send("debug_traceBlockByNumber", [
blockNumber,
{
tracer: "callTracer",
timeout: "3000s",
tracerConfig: { onlyTopCall: false },
},
])
expectTrace(traceResult)
})
Expand All @@ -40,13 +45,24 @@ describe("debug queries", () => {
it("debug_traceBlockByHash", async () => {
const traceResult = await provider.send("debug_traceBlockByHash", [
blockHash,
{
tracer: "callTracer",
timeout: "3000s",
tracerConfig: { onlyTopCall: false },
},
])
expectTrace(traceResult)
})

// TODO: impl in EVM: remove skip
it.skip("debug_traceTransaction", async () => {
const traceResult = await provider.send("debug_traceTransaction", [txHash])
it("debug_traceTransaction", async () => {
const traceResult = await provider.send("debug_traceTransaction", [
txHash,
{
tracer: "callTracer",
timeout: "3000s",
tracerConfig: { onlyTopCall: false },
},
])
expectTrace([{ result: traceResult }])
})

Expand All @@ -61,7 +77,11 @@ describe("debug queries", () => {
const traceResult = await provider.send("debug_traceCall", [
tx,
"latest",
{},
{
tracer: "callTracer",
timeout: "3000s",
tracerConfig: { onlyTopCall: false },
},
])
expectTrace([{ result: traceResult }])
})
Expand Down Expand Up @@ -90,8 +110,11 @@ const expectTrace = (traceResult: any[]) => {
expect(traceResult.length).toBeGreaterThan(0)

const trace = traceResult[0]["result"]
expect(trace).toHaveProperty("failed", false)
expect(trace).toHaveProperty("from")
expect(trace).toHaveProperty("to")
expect(trace).toHaveProperty("gas")
expect(trace).toHaveProperty("returnValue")
expect(trace).toHaveProperty("structLogs")
expect(trace).toHaveProperty("gasUsed")
expect(trace).toHaveProperty("input")
expect(trace).toHaveProperty("output")
expect(trace).toHaveProperty("type", "CALL")
}
9 changes: 7 additions & 2 deletions proto/eth/evm/v1/evm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ message AccessTuple {
repeated string storage_keys = 2 [ (gogoproto.jsontag) = "storageKeys" ];
}

// TracerConfig stores additional tracer args. For geth it's only one attr: onlyTopCall
message TracerConfig {
bool only_top_call = 1 [ (gogoproto.jsontag) = "onlyTopCall" ];
}

// TraceConfig holds extra parameters to trace functions.
message TraceConfig {
// DEPRECATED: DisableMemory and DisableReturnData have been renamed to
Expand Down Expand Up @@ -173,6 +178,6 @@ message TraceConfig {
bool enable_memory = 11 [ (gogoproto.jsontag) = "enableMemory" ];
// enable_return_data switches the capture of return data
bool enable_return_data = 12 [ (gogoproto.jsontag) = "enableReturnData" ];
// tracer_json_config configures the tracer using a JSON string
string tracer_json_config = 13 [ (gogoproto.jsontag) = "tracerConfig" ];
// tracer_config configures the tracer options
TracerConfig tracer_config = 13 [ (gogoproto.jsontag) = "tracerConfig" ];
}
Loading

0 comments on commit 6ba79bb

Please sign in to comment.