Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

fix: align filter rule for debug trace block #1688

Merged
merged 11 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (deps) [#1168](https://github.com/evmos/ethermint/pull/1168) Upgrade Cosmos SDK to [`v0.46.6`]

### Bug Fixes

* (rpc) [#1688](https://github.com/evmos/ethermint/pull/1688) Align filter rule for `debug_traceBlockByNumber`

## [v0.21.0] - 2023-01-26

### State Machine Breaking
Expand Down
103 changes: 56 additions & 47 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ schema = 3

[mod]
[mod."cloud.google.com/go"]
version = "v0.105.0"
hash = "sha256-2nYtHjuN9ghGcM6aPlOxyNNarHebHtj0Xec48sWwdaI="
version = "v0.107.0"
hash = "sha256-sb3SjuWj84ZUtIGYIioOmycfHLL0KZSYt/Y1zzfcd5M="
[mod."cloud.google.com/go/compute"]
version = "v1.14.0"
hash = "sha256-Ay0oTR0I/ROajIiBSuZ1LfVVio142f8mUa64tGwreG8="
version = "v1.15.1"
hash = "sha256-F63wL70xdjxzFUKn8FEcBSI7FB94v1lo0f/aLDHiwMA="
[mod."cloud.google.com/go/compute/metadata"]
version = "v0.2.3"
hash = "sha256-kYB1FTQRdTDqCqJzSU/jJYbVUGyxbkASUKbEs36FUyU="
Expand All @@ -20,8 +20,8 @@ schema = 3
version = "v1.0.0-beta.7"
hash = "sha256-XblGvIx6Wvvq6wggXjp+KbeJGXoe7AZH7hXEdauCezU="
[mod."cosmossdk.io/math"]
version = "v1.0.0-beta.4"
hash = "sha256-UYdq/46EubyjxkldGike8FlwJLWGCB576VB7th285ao="
version = "v1.0.0-beta.6"
hash = "sha256-u7oA14c9o3kVNKFaoTQJBOWFX4rJHf+884qG+4ocBfM="
[mod."filippo.io/edwards25519"]
version = "v1.0.0-rc.1"
hash = "sha256-3DboBqby2ejRU33FG96Z8JF5AJ8HP2rC/v++VyoQ2LQ="
Expand All @@ -45,8 +45,8 @@ schema = 3
version = "v0.4.1"
hash = "sha256-usxTUHA0QQMdM6sHi2z51nmnEKMbA0qUilxJFpWHlYE="
[mod."github.com/aws/aws-sdk-go"]
version = "v1.40.45"
hash = "sha256-7m4jOfXs356SUZG9tR+z3Yfa/O0CorkSkOXg/AmbqRM="
version = "v1.44.122"
hash = "sha256-bzkXf4Sf+6y6on7iulGtXkPdj0XoevkHYGQYPTNL7To="
[mod."github.com/beorn7/perks"]
version = "v1.0.1"
hash = "sha256-h75GUqfwJKngCJQVE5Ao5wnO3cfKD9lSIteoLp/3xJ4="
Expand Down Expand Up @@ -75,8 +75,8 @@ schema = 3
version = "v1.1.0"
hash = "sha256-nVDTtXH9PC3yJ0THaQZEN243UP9xgLi/clt5xRqj3+M="
[mod."github.com/cespare/xxhash/v2"]
version = "v2.1.2"
hash = "sha256-YV9SmXDtmmgQylQUfrUgQLAPfqYexcHxegMBT+IX9qM="
version = "v2.2.0"
hash = "sha256-nPufwYQfTkyrEkbBrpqM3C2vnMxfIz6tAaBmiUP7vd4="
[mod."github.com/chzyer/readline"]
version = "v0.0.0-20180603132655-2972be24d48e"
hash = "sha256-2Uj5LGpHEbLQG3d/7z9AL8DknUBZyoTAMs4j+VVDmIA="
Expand All @@ -93,17 +93,17 @@ schema = 3
version = "v1.0.5"
hash = "sha256-t572Sr5iiHcuMKLMWa2i+LBAt192oa+G1oA371tG/eI="
[mod."github.com/cosmos/cosmos-proto"]
version = "v1.0.0-beta.1"
hash = "sha256-oATkuj+fM5eBn+ywO+w/tL0AFSIEkx0J3Yz+VhVe0QA="
version = "v1.0.0-beta.3"
hash = "sha256-V0/ZhRdqK7Cqcv8X30gr33/hlI54bRXeHhI9LZKyLt8="
[mod."github.com/cosmos/cosmos-sdk"]
version = "v0.46.8"
hash = "sha256-jETbixsZq5XJ1pl1XaVJvD5jkcygBrEcHRK/L0+XI68="
[mod."github.com/cosmos/go-bip39"]
version = "v1.0.0"
hash = "sha256-Qm2aC2vaS8tjtMUbHmlBSagOSqbduEEDwc51qvQaBmA="
[mod."github.com/cosmos/gogoproto"]
version = "v1.4.3"
hash = "sha256-Y/NL76ay/oAl8mS3skkK5ula0/xudqbwW1o22lZjKRg="
version = "v1.4.6"
hash = "sha256-9SCEKBJyK1FHkKyeaBjDT3GURRAtsIoeiDkNwH8a9Co="
[mod."github.com/cosmos/gorocksdb"]
version = "v1.2.0"
hash = "sha256-209TcVuXc5s/TcOvNlaQ1HEJAUDTEK3nxPhs+d8TEcY="
Expand Down Expand Up @@ -189,8 +189,11 @@ schema = 3
version = "v2.1.3+incompatible"
hash = "sha256-eXhXPPLnAy/rmt/zDgeqni2G3o58UtnHjR8vHLXvISI="
[mod."github.com/go-stack/stack"]
version = "v1.8.0"
hash = "sha256-26RlTEcAkbewMUtmirKrDGQ1WJlNousp69v7HMopYnI="
version = "v1.8.1"
hash = "sha256-ixcJ2RrK1ZH3YWGQZF9QFBo02NOuLeSp9wJ7gniipgY="
[mod."github.com/go-task/slim-sprig"]
version = "v0.0.0-20210107165309-348f09dbbbc0"
hash = "sha256-jgza4peLzeJlwmMh/c1gNkmtwA9YtSdGaBzBUDXhIZo="
[mod."github.com/godbus/dbus"]
version = "v0.0.0-20190726142602-4481cbc300e2"
hash = "sha256-R7Gb9+Zjy80FbQSDGketoVEqfdOQKuOVTfWRjQ5kxZY="
Expand All @@ -208,8 +211,8 @@ schema = 3
version = "v0.0.0-20210331224755-41bb18bfe9da"
hash = "sha256-7Gs7CS9gEYZkbu5P4hqPGBpeGZWC64VDwraSKFF+VR0="
[mod."github.com/golang/protobuf"]
version = "v1.5.2"
hash = "sha256-IVwooaIo46iq7euSSVWTBAdKd+2DUaJ67MtBao1DpBI="
version = "v1.5.3"
hash = "sha256-svogITcP4orUIsJFjMtp+Uv1+fKJv2Q5Zwf2dMqnpOQ="
[mod."github.com/golang/snappy"]
version = "v0.0.4"
hash = "sha256-Umx+5xHAQCN/Gi4HbtMhnDCSPFAXSsjVbXd8n5LhjAA="
Expand All @@ -222,6 +225,9 @@ schema = 3
[mod."github.com/google/orderedcode"]
version = "v0.0.1"
hash = "sha256-KrExYovtUQrHGI1mPQf57jGw8soz7eWOC2xqEaV0uGk="
[mod."github.com/google/pprof"]
version = "v0.0.0-20210720184732-4bb14d4b1be1"
hash = "sha256-m6l2Yay3iCu7Ses6nmwXifyztNqfP1B/MX81/tDK4Hw="
[mod."github.com/google/uuid"]
version = "v1.3.0"
hash = "sha256-QoR55eBtA94T2tBszyxfDtO7/pjZZSGb5vm7U0Xhs0Y="
Expand Down Expand Up @@ -259,8 +265,8 @@ schema = 3
version = "v0.5.2"
hash = "sha256-N9GOKYo7tK6XQUFhvhImtL7PZW/mr4C4Manx/yPVvcQ="
[mod."github.com/hashicorp/go-getter"]
version = "v1.6.1"
hash = "sha256-WPCbbfFbE617EIUXxq81p3XrvhkSvYOeuiaR7n23nr0="
version = "v1.7.0"
hash = "sha256-kjXfacmxofi5mtyh9wpPeo3yBHNJMcTrfyEbYEAzLfs="
[mod."github.com/hashicorp/go-immutable-radix"]
version = "v1.3.1"
hash = "sha256-65+A2HiVfS/GV9G+6/TkXXjzXhI/V98e6RlJWjxy+mg="
Expand Down Expand Up @@ -346,8 +352,8 @@ schema = 3
version = "v1.1.0"
hash = "sha256-oduBKXHAQG8X6aqLEpqZHs5DOKe84u6WkBwi4W6cv3k="
[mod."github.com/mitchellh/go-testing-interface"]
version = "v1.0.0"
hash = "sha256-/Dpv/4i5xuK8hDH+q8YTdF6Jg6NNtfO4Wqig2JCWgrY="
version = "v1.14.1"
hash = "sha256-TMGi38D13BEVN5cpeKDzKRIgLclm4ErOG+JEyqJrN/c="
[mod."github.com/mitchellh/mapstructure"]
version = "v1.5.0"
hash = "sha256-ztVhGQXs67MF8UadVvG72G3ly0ypQW0IRDdOOkjYwoE="
Expand All @@ -358,11 +364,11 @@ schema = 3
version = "v0.0.5"
hash = "sha256-/5i70IkH/qSW5KjGzv8aQNKh9tHoz98tqtL0K2DMFn4="
[mod."github.com/onsi/ginkgo/v2"]
version = "v2.7.0"
hash = "sha256-BKqQKCsPA73FaQwYpAY+QsWFHIncrG5jgRhC2IiNmCk="
version = "v2.9.0"
hash = "sha256-mA85ECIXYSFc60wIfbKpcE/VKC4PZC24fwouqY51kxA="
[mod."github.com/onsi/gomega"]
version = "v1.26.0"
hash = "sha256-B18jsoJHK/oE+wudT0dOsUb41s5+ZIAu/ZBzQ5djOLE="
version = "v1.27.2"
hash = "sha256-w2pKmh0tra4bsFoIWOhH3z+WNEndOcjQ4DGGjwlcoss="
[mod."github.com/pelletier/go-toml/v2"]
version = "v2.0.6"
hash = "sha256-BxAeApnn5H+OLlH3TXGvIbtC6LmbRnjwbcfT1qMZ4PE="
Expand Down Expand Up @@ -433,14 +439,14 @@ schema = 3
version = "v1.15.0"
hash = "sha256-FvpbekXegcdWNbek/vs2zakgRsT5FROF8O8fhn5DNpI="
[mod."github.com/status-im/keycard-go"]
version = "v0.0.0-20200402102358-957c09536969"
hash = "sha256-yddXXuu6mEFEO2/K6c1tWymeBKzOcvLQnNsFGRjtfXk="
version = "v0.2.0"
hash = "sha256-UUiGmlgaIZDeMUJv3fdZBoQ9hJeSsg2ixRGmm6TgHug="
[mod."github.com/stretchr/objx"]
version = "v0.5.0"
hash = "sha256-nY4mvP0f0Ry1IKMKQAYNuioA5h4red4mmQqeGZw6EF0="
[mod."github.com/stretchr/testify"]
version = "v1.8.1"
hash = "sha256-3e0vOJLgCMAan+GfaGN8RGZdarh5iCavM6flf6YMNPk="
version = "v1.8.2"
hash = "sha256-n32PGyJL6VLtwOGEbS0lFchxunNU9nlol7OSEZlrKUM="
[mod."github.com/subosito/gotenv"]
version = "v1.4.2"
hash = "sha256-LnrDR1k/AoCFWBMcU7vQsoQLkZ65evT2hoQHLDudTsg="
Expand Down Expand Up @@ -469,8 +475,8 @@ schema = 3
version = "v1.1.0"
hash = "sha256-3YhWBtSwRLGwm7vNwqumphZG3uLBW1vwT9QkQ8JuSjU="
[mod."github.com/ulikunitz/xz"]
version = "v0.5.8"
hash = "sha256-bfG3dssBUn+mSOAuKL+a/DTGGLUA+eASgLoGv/Gkqs0="
version = "v0.5.10"
hash = "sha256-bogOwQNmQVS7W+C7wci7XEUeYm9TB7PnxnyBIXKYbm0="
[mod."github.com/zondax/hid"]
version = "v0.9.1"
hash = "sha256-hSVmN/f/lQHFhF60o6ej78ELC0MMoqQgqIX2hHjdTXg="
Expand All @@ -487,26 +493,29 @@ schema = 3
version = "v0.3.0"
hash = "sha256-Un9wPqz8u/xpV98T4IqE6RMXIPhGCIm2prsNkHP3cjg="
[mod."golang.org/x/exp"]
version = "v0.0.0-20220722155223-a9213eeb770e"
hash = "sha256-kNgzydWRpjm0sZl4uXEs3LX5L0xjJtJRAFf/CTlYUN4="
version = "v0.0.0-20230131160201-f062dba9d201"
hash = "sha256-sxLT/VOe93v0h3miChJSHS9gscTZS/B71+390ju/e20="
[mod."golang.org/x/net"]
version = "v0.5.0"
hash = "sha256-HpbIAiLs7S1+tVsaSSdbCPw1IK43A0bFFuSzPSyjLbo="
version = "v0.8.0"
hash = "sha256-2cOtqa7aJ5mn64kZ+8+PVjJ4uGbhpXTpC1vm/+iaZzM="
[mod."golang.org/x/oauth2"]
version = "v0.0.0-20221014153046-6fdb5e3db783"
hash = "sha256-IoygidVNqyAZmN+3macDeIefK8hhJToygpcqlwehdYQ="
version = "v0.4.0"
hash = "sha256-Dj9wHbSbs0Ghr9Hef0hSfanaR8L0GShI18jGBT3yNn8="
[mod."golang.org/x/sync"]
version = "v0.1.0"
hash = "sha256-Hygjq9euZ0qz6TvHYQwOZEjNiTbTh1nSLRAWZ6KFGR8="
[mod."golang.org/x/sys"]
version = "v0.4.0"
hash = "sha256-jchMzHCH5dg+IL/F+LqaX/fyAcB/nvHQpfBjqwaRJH0="
version = "v0.6.0"
hash = "sha256-zAgxiTuL24sGhbXrna9R1UYqLQh46ldztpumOScmduY="
[mod."golang.org/x/term"]
version = "v0.4.0"
hash = "sha256-wQKxHV10TU4vCU8Re2/hFmAbur/jRWEOB8QXBzgTFNY="
version = "v0.6.0"
hash = "sha256-Ao0yXpwY8GyG+/23dVfJUYrfEfNUTES3RF45v1VhUAk="
[mod."golang.org/x/text"]
version = "v0.8.0"
hash = "sha256-hgWFnT01DRmywBEXKYEVaOee7i6z8Ydz7zGbjcWwOgI="
[mod."golang.org/x/tools"]
version = "v0.6.0"
hash = "sha256-+bpeRWR3relKACdal6NPj+eP5dnWCplTViArSN7/qA4="
hash = "sha256-J0q+C3WDTK9yyHX90FV6qr6n9H07YglYg1p4H3MqyH4="
[mod."golang.org/x/xerrors"]
version = "v0.0.0-20220907171357-04be3eba64a2"
hash = "sha256-6+zueutgefIYmgXinOflz8qGDDDj0Zhv+2OkGhBTKno="
Expand All @@ -517,11 +526,11 @@ schema = 3
version = "v1.6.7"
hash = "sha256-zIxGRHiq4QBvRqkrhMGMGCaVL4iM4TtlYpAi/hrivS4="
[mod."google.golang.org/genproto"]
version = "v0.0.0-20221227171554-f9683d7f8bef"
hash = "sha256-vvYjJcG73odJwPUb3sZIz4MSHnzK1Jj2uo0CwZ8S8rQ="
version = "v0.0.0-20230110181048-76db0878b65f"
hash = "sha256-Jc90F9KU+ZKI0ynF/p3Vwl7TJPb7/MxDFs0ebagty2s="
[mod."google.golang.org/grpc"]
version = "v1.52.3"
hash = "sha256-vVkuG0kKgnh62f63unpk4JDa9rIu6kk0qtnPJOiew2M="
version = "v1.53.0"
hash = "sha256-LkB13k1JaQ7e4nGpCoEA9q4T8oIV0KvkFIDZmHhDr08="
[mod."google.golang.org/protobuf"]
version = "v1.28.2-0.20220831092852-f930b1dc76e8"
hash = "sha256-li5hXlXwTJ5LIZ8bVki1AZ6UFI2gXHl33JwdX1dOrtM="
Expand Down
11 changes: 10 additions & 1 deletion rpc/backend/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
rpctypes "github.com/evmos/ethermint/rpc/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/pkg/errors"
Expand Down Expand Up @@ -142,11 +143,19 @@ func (b *Backend) TraceBlock(height rpctypes.BlockNumber,
// If there are no transactions return empty array
return []*evmtypes.TxTraceResult{}, nil
}

blockRes, err := b.TendermintBlockResultByNumber(&block.Block.Height)
if err != nil {
b.logger.Debug("block result not found", "height", block.Block.Height, "error", err.Error())
return nil, nil
}
txDecoder := b.clientCtx.TxConfig.TxDecoder()

var txsMessages []*evmtypes.MsgEthereumTx
for i, tx := range txs {
if !rpctypes.TxSuccessOrExceedsBlockGasLimit(blockRes.TxsResults[i]) {
b.logger.Debug("invalid tx result code", "cosmos-hash", hexutil.Encode(tx.Hash()))
continue
}
decodedTx, err := txDecoder(tx)
if err != nil {
b.logger.Error("failed to decode transaction", "hash", txs[i].Hash(), "error", err.Error())
Expand Down
2 changes: 2 additions & 0 deletions rpc/backend/tracing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ func (suite *BackendTestSuite) TestTraceBlock() {
func() {
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
RegisterTraceBlock(queryClient, []*evmtypes.MsgEthereumTx{msgEthTx})
client := suite.backend.clientCtx.Client.(*mocks.Client)
RegisterBlockResults(client, 1)
},
[]*evmtypes.TxTraceResult{},
&resBlockFilled,
Expand Down
16 changes: 3 additions & 13 deletions tests/integration_tests/test_account.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import os

import pytest
from eth_account import Account
from web3 import Web3

from .network import setup_ethermint
from .utils import ADDRS, w3_wait_for_new_blocks
from .utils import ADDRS, derive_new_account, w3_wait_for_new_blocks


@pytest.fixture(scope="module")
Expand All @@ -32,19 +29,12 @@ def cluster(request, custom_ethermint, geth):
raise NotImplementedError


def derive_new_address(n=1):
# derive a new address
account_path = f"m/44'/60'/0'/0/{n}"
mnemonic = os.getenv("COMMUNITY_MNEMONIC")
return (Account.from_mnemonic(mnemonic, account_path=account_path)).address


def test_get_transaction_count(cluster):
w3: Web3 = cluster.w3
blk = hex(w3.eth.block_number)
sender = ADDRS["validator"]

receiver = derive_new_address()
receiver = derive_new_account().address
n0 = w3.eth.get_transaction_count(receiver, blk)
# ensure transaction send in new block
w3_wait_for_new_blocks(w3, 1, sleep=0.1)
Expand All @@ -64,7 +54,7 @@ def test_get_transaction_count(cluster):

def test_query_future_blk(cluster):
w3: Web3 = cluster.w3
acc = derive_new_address(2)
acc = derive_new_account(2).address
current = w3.eth.block_number
future = current + 1000
with pytest.raises(ValueError) as exc:
Expand Down
51 changes: 51 additions & 0 deletions tests/integration_tests/test_debug_trace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import requests
from pystarport import ports

from .utils import (
derive_new_account,
send_transaction,
sign_transaction,
wait_for_new_blocks,
)


def test_trace_blk(ethermint):
w3 = ethermint.w3
cli = ethermint.cosmos_cli()
acc = derive_new_account(3)
sender = acc.address
# fund new sender
fund = 3000000000000000000
tx = {"to": sender, "value": fund, "gasPrice": w3.eth.gas_price}
send_transaction(w3, tx)
assert w3.eth.get_balance(sender, "latest") == fund
nonce = w3.eth.get_transaction_count(sender)
blk = wait_for_new_blocks(cli, 1, sleep=0.1)
txhashes = []
total = 3
for n in range(total):
tx = {
"to": "0x2956c404227Cc544Ea6c3f4a36702D0FD73d20A2",
"value": fund // total,
"gas": 21000,
"maxFeePerGas": 6556868066901,
"maxPriorityFeePerGas": 1500000000,
"nonce": nonce + n,
}
signed = sign_transaction(w3, tx, acc.key)
txhash = w3.eth.send_raw_transaction(signed.rawTransaction)
txhashes.append(txhash)
for txhash in txhashes[0 : total - 1]:
res = w3.eth.wait_for_transaction_receipt(txhash)
assert res.status == 1

url = f"http://127.0.0.1:{ports.evmrpc_port(ethermint.base_port(0))}"
params = {
"method": "debug_traceBlockByNumber",
"params": [hex(blk + 1)],
"id": 1,
"jsonrpc": "2.0",
}
rsp = requests.post(url, json=params)
assert rsp.status_code == 200
assert len(rsp.json()["result"]) == 2
7 changes: 7 additions & 0 deletions tests/integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,10 @@ def parse_events(logs):
ev["type"]: {attr["key"]: attr["value"] for attr in ev["attributes"]}
for ev in logs[0]["events"]
}


def derive_new_account(n=1):
# derive a new address
account_path = f"m/44'/60'/0'/0/{n}"
mnemonic = os.getenv("COMMUNITY_MNEMONIC")
return Account.from_mnemonic(mnemonic, account_path=account_path)