Skip to content

Commit 13d9296

Browse files
committed
Merge branch 'main' into releases/v2.0.0
2 parents 227e309 + b1aac01 commit 13d9296

File tree

14 files changed

+769
-174
lines changed

14 files changed

+769
-174
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
115115
- [#2017](https://github.com/NibiruChain/nibiru/pull/2017) - fix(evm): Fix DynamicFeeTx gas cap parameters
116116
- [#2019](https://github.com/NibiruChain/nibiru/pull/2019) - chore(evm): enabled debug rpc api on localnet.
117117
- [#2020](https://github.com/NibiruChain/nibiru/pull/2020) - test(evm): e2e tests for debug namespace
118+
- [#2022](https://github.com/NibiruChain/nibiru/pull/2022) - feat(evm): debug_traceCall method implemented
118119
- [#2023](https://github.com/NibiruChain/nibiru/pull/2023) - fix(evm)!: adjusted generation and parsing of the block bloom events
119120

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

e2e/evm/test/debug_queries.test.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { describe, expect, it, beforeAll } from "@jest/globals"
22
import { TransactionReceipt, parseEther } from "ethers"
33
import { provider } from "./setup"
4-
import { alice, deployContractTestERC20 } from "./utils"
4+
import { alice, deployContractTestERC20, hexify } from "./utils"
5+
import { TestERC20Compiled__factory } from "../types/ethers-contracts"
56

67
describe("debug queries", () => {
78
let contractAddress: string
@@ -28,16 +29,15 @@ describe("debug queries", () => {
2829
blockHash = receipt.blockHash
2930
}, 20e3)
3031

31-
// TODO: impl in EVM: remove skip
32-
it.skip("debug_traceBlockByNumber", async () => {
32+
it("debug_traceBlockByNumber", async () => {
3333
const traceResult = await provider.send("debug_traceBlockByNumber", [
3434
blockNumber,
3535
])
3636
expectTrace(traceResult)
3737
})
3838

3939
// TODO: impl in EVM: remove skip
40-
it.skip("debug_traceBlockByHash", async () => {
40+
it("debug_traceBlockByHash", async () => {
4141
const traceResult = await provider.send("debug_traceBlockByHash", [
4242
blockHash,
4343
])
@@ -50,6 +50,22 @@ describe("debug queries", () => {
5050
expectTrace([{ result: traceResult }])
5151
})
5252

53+
it("debug_traceCall", async () => {
54+
const contractInterface = TestERC20Compiled__factory.createInterface()
55+
const callData = contractInterface.encodeFunctionData("totalSupply")
56+
const tx = {
57+
to: contractAddress,
58+
data: callData,
59+
gas: hexify(1000_000),
60+
}
61+
const traceResult = await provider.send("debug_traceCall", [
62+
tx,
63+
"latest",
64+
{},
65+
])
66+
expectTrace([{ result: traceResult }])
67+
})
68+
5369
// TODO: impl in EVM: remove skip
5470
it.skip("debug_getBadBlocks", async () => {
5571
const traceResult = await provider.send("debug_getBadBlocks", [txHash])

eth/rpc/backend/backend.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ type EVMBackend interface {
122122
config *evm.TraceConfig,
123123
block *tmrpctypes.ResultBlock,
124124
) ([]*evm.TxTraceResult, error)
125+
TraceCall(
126+
txArgs evm.JsonTxArgs,
127+
contextHeight rpc.BlockNumber,
128+
config *evm.TraceConfig,
129+
) (interface{}, error)
125130
}
126131

127132
var _ BackendI = (*Backend)(nil)

eth/rpc/backend/evm_query_client_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,24 @@ func RegisterTraceTransaction(
5757
Return(&evm.QueryTraceTxResponse{Data: data}, nil)
5858
}
5959

60+
func RegisterTraceCall(
61+
queryClient *mocks.EVMQueryClient, msgEthTx *evm.MsgEthereumTx,
62+
) {
63+
data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d}
64+
queryClient.On(
65+
"TraceCall",
66+
rpc.NewContextWithHeight(1),
67+
&evm.QueryTraceTxRequest{
68+
Msg: msgEthTx,
69+
BlockNumber: 1,
70+
ChainId: TEST_CHAIN_ID_NUMBER(),
71+
BlockMaxGas: -1,
72+
TraceConfig: &evm.TraceConfig{},
73+
},
74+
).
75+
Return(&evm.QueryTraceTxResponse{Data: data}, nil)
76+
}
77+
6078
func RegisterTraceTransactionError(
6179
queryClient *mocks.EVMQueryClient, msgEthTx *evm.MsgEthereumTx,
6280
) {

eth/rpc/backend/mocks/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Mocks Generation
2+
3+
To generate mocks, install `mockery` tool:
4+
https://vektra.github.io/mockery/latest/installation/
5+
6+
```bash
7+
cd x/evm
8+
mockery \
9+
--name QueryClient \
10+
--filename evm_query_client.go \
11+
--output ../../eth/rpc/backend/mocks \
12+
--structname EVMQueryClient
13+
```

0 commit comments

Comments
 (0)