Skip to content

Commit

Permalink
Problem: no time in Transaction (#531)
Browse files Browse the repository at this point in the history
* Problem: no time in Transaction

* update deps
  • Loading branch information
mmsqe committed Sep 25, 2024
1 parent f2a562b commit 9755333
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
github.com/cockroachdb/pebble => github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811
// release/v1.11.x
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240425065928-ebb09502e7a7
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240925072350-e05e994a492f
// Fix upstream GHSA-h395-qcrw-5vmq vulnerability.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20240911084450-6870ba130be2 h
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20240911084450-6870ba130be2/go.mod h1:RTiTs4hkXG6IvYGknvB8p79YgjYJdcbzLUOGJChsPnY=
github.com/crypto-org-chain/go-block-stm v0.0.0-20240912024944-1cd89976aa5e h1:FFpE6+Y4o5GxkeGwUcETM6amgohh7msWvWf1MDqueVc=
github.com/crypto-org-chain/go-block-stm v0.0.0-20240912024944-1cd89976aa5e/go.mod h1:iwQTX9xMX8NV9k3o2BiWXA0SswpsZrDk5q3gA7nWYiE=
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240425065928-ebb09502e7a7 h1:V43F3JFcqG4MUThf9W/DytnPblpR6CcaLBw2Wx6zTgE=
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240425065928-ebb09502e7a7/go.mod h1:+a8pUj1tOyJ2RinsNQD4326YS+leSoKGiG/uVVb0x6Y=
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240925072350-e05e994a492f h1:jR3nEDZMhGtZODqWFVbaTJ2X26k5r7nkiRk39i+SJ10=
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240925072350-e05e994a492f/go.mod h1:+a8pUj1tOyJ2RinsNQD4326YS+leSoKGiG/uVVb0x6Y=
github.com/danieljoos/wincred v1.2.0 h1:ozqKHaLK0W/ii4KVbbvluM91W2H3Sh0BncbUNPS7jLE=
github.com/danieljoos/wincred v1.2.0/go.mod h1:FzQLLMKBFdvu+osBrnFODiv32YGwCfx0SkRa/eYHgec=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
4 changes: 2 additions & 2 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ schema = 3
version = "v1.6.1"
hash = "sha256-zOpoaepCfPLmU9iQji/Ait+SVEHI9eF3rwtW0h/8lho="
[mod."github.com/ethereum/go-ethereum"]
version = "v1.10.20-0.20240425065928-ebb09502e7a7"
hash = "sha256-lE4G5FaRb3MVi9FFVn+WlwsSTOB4SbjmVboKyQ5yB0A="
version = "v1.10.20-0.20240925072350-e05e994a492f"
hash = "sha256-lDIqRLUrXYCb9mmFBY/+WW+ee69+IkxOgqjHVyo4ij0="
replaced = "github.com/crypto-org-chain/go-ethereum"
[mod."github.com/fatih/color"]
version = "v1.16.0"
Expand Down
10 changes: 9 additions & 1 deletion rpc/backend/blocks_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package backend

import (
"encoding/json"
"fmt"
"math/big"

Expand Down Expand Up @@ -1177,7 +1178,14 @@ func (suite *BackendTestSuite) TestEthMsgsFromTendermintBlock() {
suite.SetupTest() // reset test and queries

msgs := suite.backend.EthMsgsFromTendermintBlock(tc.resBlock, tc.blockRes)
suite.Require().Equal(tc.expMsgs, msgs)
suite.Require().Equal(len(tc.expMsgs), len(msgs))
for i, expMsg := range tc.expMsgs {
expBytes, err := json.Marshal(expMsg)
suite.Require().Nil(err)
bytes, err := json.Marshal(msgs[i])
suite.Require().Nil(err)
suite.Require().Equal(expBytes, bytes)
}
})
}
}
Expand Down
55 changes: 52 additions & 3 deletions rpc/backend/evm_query_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"slices"
"strconv"
"testing"

Expand Down Expand Up @@ -35,13 +36,48 @@ var _ evmtypes.QueryClient = &mocks.EVMQueryClient{}
func RegisterTraceTransactionWithPredecessors(queryClient *mocks.EVMQueryClient, msgEthTx *evmtypes.MsgEthereumTx, predecessors []*evmtypes.MsgEthereumTx) {
data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d}
queryClient.On("TraceTx", rpc.ContextWithHeight(1),
&evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, Predecessors: predecessors, ChainId: 9000}).
mock.MatchedBy(func(req *evmtypes.QueryTraceTxRequest) bool {
if req.BlockNumber != 1 {
return false
}
bytes, _ := json.Marshal(msgEthTx)
bytes2, _ := json.Marshal(req.Msg)
if slices.Compare(bytes, bytes2) != 0 {
return false
}
if len(req.Predecessors) != len(predecessors) {
return false
}
bytes, _ = json.Marshal(req.Predecessors)
bytes2, _ = json.Marshal(predecessors)
if slices.Compare(bytes, bytes2) != 0 {
return false
}
if req.ChainId != 9000 {
return false
}
return true
})).
Return(&evmtypes.QueryTraceTxResponse{Data: data}, nil)
}

func RegisterTraceTransaction(queryClient *mocks.EVMQueryClient, msgEthTx *evmtypes.MsgEthereumTx) {
data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d}
queryClient.On("TraceTx", rpc.ContextWithHeight(1), &evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, ChainId: 9000}).
queryClient.On("TraceTx", rpc.ContextWithHeight(1),
mock.MatchedBy(func(req *evmtypes.QueryTraceTxRequest) bool {
if req.BlockNumber != 1 {
return false
}
bytes, _ := json.Marshal(msgEthTx)
bytes2, _ := json.Marshal(req.Msg)
if slices.Compare(bytes, bytes2) != 0 {
return false
}
if req.ChainId != 9000 {
return false
}
return true
})).
Return(&evmtypes.QueryTraceTxResponse{Data: data}, nil)
}

Expand All @@ -54,7 +90,20 @@ func RegisterTraceTransactionError(queryClient *mocks.EVMQueryClient, msgEthTx *
func RegisterTraceBlock(queryClient *mocks.EVMQueryClient, txs []*evmtypes.MsgEthereumTx) {
data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d}
queryClient.On("TraceBlock", rpc.ContextWithHeight(1),
&evmtypes.QueryTraceBlockRequest{Txs: txs, BlockNumber: 1, TraceConfig: &evmtypes.TraceConfig{}, ChainId: 9000}).
mock.MatchedBy(func(req *evmtypes.QueryTraceBlockRequest) bool {
if req.BlockNumber != 1 {
return false
}
bytes, _ := json.Marshal(txs)
bytes2, _ := json.Marshal(req.Txs)
if slices.Compare(bytes, bytes2) != 0 {
return false
}
if req.ChainId != 9000 {
return false
}
return true
})).
Return(&evmtypes.QueryTraceBlockResponse{Data: data}, nil)
}

Expand Down

0 comments on commit 9755333

Please sign in to comment.