Skip to content

Commit 6f49e3c

Browse files
yihuangmmsqe
andauthored
Problem: new evm tx format not integrated (#1414)
* Problem: new evm tx format not integrated * Update CHANGELOG.md Signed-off-by: yihuang <[email protected]> * update deps * update go * use rly * less users * fix * update deps --------- Signed-off-by: yihuang <[email protected]> Co-authored-by: mmsqe <[email protected]>
1 parent f0d4032 commit 6f49e3c

14 files changed

+39
-51
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* [#1377](https://github.com/crypto-org-chain/cronos/pull/1377) Upgrade sdk to 0.50, and integrate block-stm parallel tx execution.
88
* [#1394](https://github.com/crypto-org-chain/cronos/pull/1394) Add icahost wirings but disable in parameters.
99
* [#1407](https://github.com/crypto-org-chain/cronos/pull/1407) Add end-to-end encryption module.
10+
* [#1414](https://github.com/crypto-org-chain/cronos/pull/1414) Integrate new evm tx format.
1011

1112
### Improvements
1213

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ replace (
274274
// dgrijalva/jwt-go is deprecated and doesn't receive security updates.
275275
// TODO: remove it: https://github.com/cosmos/cosmos-sdk/issues/13134
276276
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
277-
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e
277+
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240425065928-ebb09502e7a7
278278
// block-stm branch
279-
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20240419013511-775ac80b75c7
279+
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20240502052908-179e436703b3
280280
// Fix upstream GHSA-h395-qcrw-5vmq and GHSA-3vp4-m3rf-835h vulnerabilities.
281281
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
282282
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,12 @@ github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20240415105151-0108877a3201
429429
github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20240415105151-0108877a3201/go.mod h1:lfuLI1f4o+0SGtlHQS4x5qsjRcZZfYqG8bp3k8hM0M8=
430430
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20240415105151-0108877a3201 h1:DbCOM19ywdL5K+bOy4h+0MppzcPgI2guHnYCfDNnAcM=
431431
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20240415105151-0108877a3201/go.mod h1:CBCU6fsRVz23QGFIQBb1DNX2DztJCf3jWyEkHY2nJQ0=
432-
github.com/crypto-org-chain/ethermint v0.6.1-0.20240419013511-775ac80b75c7 h1:tawNK/e1F1AexRdhxC9o6M70IIrbCuvM6C8F/ujHwTY=
433-
github.com/crypto-org-chain/ethermint v0.6.1-0.20240419013511-775ac80b75c7/go.mod h1:OSFT4cvzHl0g2DizYR9vIy5/xRYAvFJrnRydAmgCqyM=
432+
github.com/crypto-org-chain/ethermint v0.6.1-0.20240502052908-179e436703b3 h1:YYmMJowZyiyioNHYnps5hw3XkV1zcXSC3jy/xzqK2Rg=
433+
github.com/crypto-org-chain/ethermint v0.6.1-0.20240502052908-179e436703b3/go.mod h1:9MVSajfKloRP8h2chP78LhCKx5u9O2pCMBvxrmx6+0s=
434434
github.com/crypto-org-chain/go-block-stm v0.0.0-20240408011717-9f11af197bde h1:sQIHTJfVt5VTrF7po9eZiFkZiPjlHbFvnXtGCOoBjNM=
435435
github.com/crypto-org-chain/go-block-stm v0.0.0-20240408011717-9f11af197bde/go.mod h1:iwQTX9xMX8NV9k3o2BiWXA0SswpsZrDk5q3gA7nWYiE=
436-
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e h1:vnyepPQ/m25+19xcTuBUdRxmltZ/EjVWNqEjhg7Ummk=
437-
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e/go.mod h1:+a8pUj1tOyJ2RinsNQD4326YS+leSoKGiG/uVVb0x6Y=
436+
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240425065928-ebb09502e7a7 h1:V43F3JFcqG4MUThf9W/DytnPblpR6CcaLBw2Wx6zTgE=
437+
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240425065928-ebb09502e7a7/go.mod h1:+a8pUj1tOyJ2RinsNQD4326YS+leSoKGiG/uVVb0x6Y=
438438
github.com/danieljoos/wincred v1.2.0 h1:ozqKHaLK0W/ii4KVbbvluM91W2H3Sh0BncbUNPS7jLE=
439439
github.com/danieljoos/wincred v1.2.0/go.mod h1:FzQLLMKBFdvu+osBrnFODiv32YGwCfx0SkRa/eYHgec=
440440
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

gomod2nix.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,12 @@ schema = 3
258258
version = "v1.6.1"
259259
hash = "sha256-zOpoaepCfPLmU9iQji/Ait+SVEHI9eF3rwtW0h/8lho="
260260
[mod."github.com/ethereum/go-ethereum"]
261-
version = "v1.10.20-0.20231207063621-43cf32d91c3e"
262-
hash = "sha256-lDIqRLUrXYCb9mmFBY/+WW+ee69+IkxOgqjHVyo4ij0="
261+
version = "v1.10.20-0.20240425065928-ebb09502e7a7"
262+
hash = "sha256-lE4G5FaRb3MVi9FFVn+WlwsSTOB4SbjmVboKyQ5yB0A="
263263
replaced = "github.com/crypto-org-chain/go-ethereum"
264264
[mod."github.com/evmos/ethermint"]
265-
version = "v0.6.1-0.20240419013511-775ac80b75c7"
266-
hash = "sha256-94bgC0Z+VD8w9j8+mwW/7PJSZlpKdtdR87C1E8hg3T4="
265+
version = "v0.6.1-0.20240502052908-179e436703b3"
266+
hash = "sha256-Qc5A89wi+KCKfFdyvZit5MI4yKDhDvvSjkiYL0EIzNA="
267267
replaced = "github.com/crypto-org-chain/ethermint"
268268
[mod."github.com/fatih/color"]
269269
version = "v1.16.0"

integration_tests/ibc_utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,8 @@ def get_balances(chain, addr):
333333

334334
def ibc_multi_transfer(ibc):
335335
chains = [ibc.cronos.cosmos_cli(), ibc.chainmain.cosmos_cli()]
336-
users = [f"user{i}" for i in range(1, 21)]
336+
# FIXME: more users after batch fix
337+
users = [f"user{i}" for i in range(1, 2)]
337338
addrs0 = [chains[0].address(user) for user in users]
338339
addrs1 = [chains[1].address(user) for user in users]
339340
denom0 = "basetcro"

integration_tests/test_ibc_rly.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
cronos_transfer_source_tokens,
1212
cronos_transfer_source_tokens_with_proxy,
1313
get_balance,
14-
hermes_transfer,
1514
ibc_denom,
1615
ibc_incentivized_transfer,
1716
ibc_multi_transfer,
1817
prepare_network,
18+
rly_transfer,
1919
)
2020
from .utils import (
2121
ADDRS,
@@ -54,7 +54,7 @@ def ibc(request, tmp_path_factory):
5454
yield from prepare_network(
5555
path,
5656
name,
57-
relayer=cluster.Relayer.HERMES.value,
57+
relayer=cluster.Relayer.RLY.value,
5858
)
5959

6060

@@ -232,7 +232,7 @@ def test_ibc(ibc):
232232
w3 = ibc.cronos.w3
233233
wait_for_new_blocks(ibc.cronos.cosmos_cli(), 1)
234234
start = w3.eth.get_block_number()
235-
hermes_transfer(ibc)
235+
rly_transfer(ibc)
236236
denom = ibc_denom(channel, src_denom)
237237
dst_addr = eth_to_bech32(cronos_signer2)
238238
old_dst_balance = get_balance(ibc.cronos, dst_addr, dst_denom)

nix/default.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ import sources.nixpkgs {
4747
cosmovisor = pkgs.callPackage ./cosmovisor.nix { };
4848
})
4949
(_: pkgs: {
50-
rly = pkgs.buildGo120Module rec {
50+
rly = pkgs.buildGo121Module rec {
5151
name = "rly";
5252
src = sources.relayer;
5353
subPackages = [ "." ];
54-
vendorHash = "sha256-5s5URiAZk59mOfZdUcqYAB/IvzFuBiQH5jDBuh6huTE=";
54+
vendorHash = "sha256-dwKZZu9wKOo2u1/8AAWFx89iC9pWZbCxAERMMAOFsts=";
5555
doCheck = false;
5656
GOWORK = "off";
5757
postInstall = ''

nix/sources.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@
126126
"homepage": "https://github.com/crypto-org-chain/relayer",
127127
"owner": "crypto-org-chain",
128128
"repo": "relayer",
129-
"rev": "bd88a2cba9154450924837ecda915688ff8f9e04",
130-
"sha256": "106mf4mc2ag4a5d21lcqpsq7ixvq70097jglw862jz4g9lbxyv8f",
129+
"rev": "9479327b768a0a0e527c1b34eca353afebac5d15",
130+
"sha256": "0ksxv4al8fjq7p8j3s28h23rr1qzn8fv7gmhcpchwz1536jx2kk4",
131131
"type": "tarball",
132-
"url": "https://github.com/crypto-org-chain/relayer/archive/bd88a2cba9154450924837ecda915688ff8f9e04.tar.gz",
132+
"url": "https://github.com/crypto-org-chain/relayer/archive/9479327b768a0a0e527c1b34eca353afebac5d15.tar.gz",
133133
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
134134
}
135135
}

x/cronos/keeper/evm.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const DefaultGasCap uint64 = 25000000
2222
// CallEVM execute an evm message from native module
2323
func (k Keeper) CallEVM(ctx sdk.Context, to *common.Address, data []byte, value *big.Int, gasLimit uint64) (*core.Message, *evmtypes.MsgEthereumTxResponse, error) {
2424
nonce := k.evmKeeper.GetNonce(ctx, types.EVMModuleAddress)
25-
msg := core.Message{
25+
msg := &core.Message{
2626
From: types.EVMModuleAddress,
2727
To: to,
2828
Nonce: nonce,
@@ -47,7 +47,7 @@ func (k Keeper) CallEVM(ctx sdk.Context, to *common.Address, data []byte, value
4747
}
4848
}
4949

50-
return &msg, ret, nil
50+
return msg, ret, nil
5151
}
5252

5353
// CallModuleCRC21 call a method of ModuleCRC21 contract

x/cronos/keeper/evm_hooks.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func NewLogProcessEvmHook(handlers ...types.EvmLogHandler) *LogProcessEvmHook {
2626
}
2727

2828
// PostTxProcessing implements EvmHook interface
29-
func (h LogProcessEvmHook) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error {
29+
func (h LogProcessEvmHook) PostTxProcessing(ctx sdk.Context, _ *core.Message, receipt *ethtypes.Receipt) error {
3030
addLogToReceiptFunc := newFuncAddLogToReceipt(receipt)
3131
for _, log := range receipt.Logs {
3232
if len(log.Topics) == 0 {

x/cronos/keeper/evm_hooks_test.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
sdkmath "cosmossdk.io/math"
88
"github.com/ethereum/go-ethereum/common"
9-
"github.com/ethereum/go-ethereum/core"
109
ethtypes "github.com/ethereum/go-ethereum/core/types"
1110

1211
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -42,7 +41,7 @@ func (suite *KeeperTestSuite) TestEvmHooks() {
4241
receipt := &ethtypes.Receipt{
4342
Logs: logs,
4443
}
45-
err := suite.app.EvmKeeper.PostTxProcessing(suite.ctx, core.Message{}, receipt)
44+
err := suite.app.EvmKeeper.PostTxProcessing(suite.ctx, nil, receipt)
4645
suite.Require().NoError(err)
4746
},
4847
},
@@ -64,7 +63,7 @@ func (suite *KeeperTestSuite) TestEvmHooks() {
6463
receipt := &ethtypes.Receipt{
6564
Logs: logs,
6665
}
67-
err = suite.app.EvmKeeper.PostTxProcessing(suite.ctx, core.Message{}, receipt)
66+
err = suite.app.EvmKeeper.PostTxProcessing(suite.ctx, nil, receipt)
6867
suite.Require().Error(err)
6968
},
7069
},
@@ -94,7 +93,7 @@ func (suite *KeeperTestSuite) TestEvmHooks() {
9493
receipt := &ethtypes.Receipt{
9594
Logs: logs,
9695
}
97-
err = suite.app.EvmKeeper.PostTxProcessing(suite.ctx, core.Message{}, receipt)
96+
err = suite.app.EvmKeeper.PostTxProcessing(suite.ctx, nil, receipt)
9897
suite.Require().NoError(err)
9998

10099
balance = suite.app.BankKeeper.GetBalance(suite.ctx, sdk.AccAddress(contract.Bytes()), denom)
@@ -144,7 +143,7 @@ func (suite *KeeperTestSuite) TestEvmHooks() {
144143
receipt := &ethtypes.Receipt{
145144
Logs: logs,
146145
}
147-
err = suite.app.EvmKeeper.PostTxProcessing(suite.ctx, core.Message{}, receipt)
146+
err = suite.app.EvmKeeper.PostTxProcessing(suite.ctx, nil, receipt)
148147
// should fail, because of not ibc denom name
149148
suite.Require().Error(err)
150149
},

x/cronos/keeper/grpc_query.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,11 @@ func (k Keeper) ReplayBlock(goCtx context.Context, req *types.ReplayBlockRequest
7575
// we assume the message executions are successful, they are filtered in json-rpc api
7676
for _, msg := range req.Msgs {
7777
// deduct fee
78-
txData, err := evmtypes.UnpackTxData(msg.Data)
79-
if err != nil {
80-
return nil, err
81-
}
82-
8378
// populate the `From` field
8479
if _, err := msg.GetSenderLegacy(ethtypes.LatestSignerForChainID(chainID)); err != nil {
8580
return nil, err
8681
}
87-
fees, err := evmkeeper.VerifyFee(txData, evmDenom, baseFee, homestead, istanbul, shanghai, ctx.IsCheckTx())
82+
fees, err := evmkeeper.VerifyFee(msg, evmDenom, baseFee, homestead, istanbul, shanghai, ctx.IsCheckTx())
8883
if err != nil {
8984
return nil, errorsmod.Wrapf(err, "failed to verify the fees")
9085
}

x/cronos/rpc/api.go

+9-17
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,7 @@ func (api *CronosAPI) GetTransactionReceiptsByBlock(blockNrOrHash rpctypes.Block
159159
return nil, fmt.Errorf("invalid tx type: %T", msg)
160160
}
161161

162-
txData, err := evmtypes.UnpackTxData(ethMsg.Data)
163-
if err != nil {
164-
api.logger.Error("failed to unpack tx data", "error", err.Error())
165-
return nil, err
166-
}
167-
162+
txData := ethMsg.AsTransaction()
168163
parsedTx := parsedTxs.GetTxByMsgIndex(msgIndex)
169164

170165
// Get the transaction result from the log
@@ -179,7 +174,7 @@ func (api *CronosAPI) GetTransactionReceiptsByBlock(blockNrOrHash rpctypes.Block
179174
return nil, err
180175
}
181176

182-
logs, err := evmtypes.DecodeMsgLogsFromEvents(txResult.Data, parsedTx.MsgIndex, uint64(blockRes.Height))
177+
logs, err := evmtypes.DecodeMsgLogsFromEvents(txResult.Data, txResult.Events, parsedTx.MsgIndex, uint64(blockRes.Height))
183178
if err != nil {
184179
api.logger.Debug("failed to parse logs", "block", resBlock.Block.Height, "txIndex", txIndex, "msgIndex", msgIndex, "error", err.Error())
185180
}
@@ -197,7 +192,7 @@ func (api *CronosAPI) GetTransactionReceiptsByBlock(blockNrOrHash rpctypes.Block
197192

198193
// Implementation fields: These fields are added by geth when processing a transaction.
199194
// They are stored in the chain database.
200-
"transactionHash": ethMsg.Hash,
195+
"transactionHash": txData.Hash(),
201196
"contractAddress": nil,
202197
"gasUsed": hexutil.Uint64(parsedTx.GasUsed),
203198

@@ -209,21 +204,18 @@ func (api *CronosAPI) GetTransactionReceiptsByBlock(blockNrOrHash rpctypes.Block
209204

210205
// sender and receiver (contract or EOA) addreses
211206
"from": from,
212-
"to": txData.GetTo(),
213-
"type": hexutil.Uint(ethMsg.AsTransaction().Type()),
207+
"to": txData.To(),
208+
"type": hexutil.Uint(txData.Type()),
214209
}
215210

216211
// If the to is empty, assume it is a contract creation
217-
if txData.GetTo() == nil {
218-
receipt["contractAddress"] = crypto.CreateAddress(from, txData.GetNonce())
212+
if txData.To() == nil {
213+
receipt["contractAddress"] = crypto.CreateAddress(from, txData.Nonce())
219214
}
220-
221-
if dynamicTx, ok := txData.(*evmtypes.DynamicFeeTx); ok {
222-
receipt["effectiveGasPrice"] = hexutil.Big(*dynamicTx.EffectiveGasPrice(baseFee))
215+
if txData.Type() == ethtypes.DynamicFeeTxType {
216+
receipt["effectiveGasPrice"] = hexutil.Big(*ethMsg.GetEffectiveGasPrice(baseFee))
223217
}
224-
225218
receipts = append(receipts, receipt)
226-
227219
txIndex++
228220
}
229221
cumulativeGasUsed += msgCumulativeGasUsed

x/cronos/types/interfaces.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type EvmLogHandler interface {
6262
// EvmKeeper defines the interface for evm keeper
6363
type EvmKeeper interface {
6464
GetNonce(ctx sdk.Context, addr common.Address) uint64
65-
ApplyMessage(ctx sdk.Context, msg core.Message, tracer vm.EVMLogger, commit bool) (*evmtypes.MsgEthereumTxResponse, error)
65+
ApplyMessage(ctx sdk.Context, msg *core.Message, tracer vm.EVMLogger, commit bool) (*evmtypes.MsgEthereumTxResponse, error)
6666
GetParams(ctx sdk.Context) evmtypes.Params
6767

6868
// to replay the messages

0 commit comments

Comments
 (0)