Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: new evm tx format not integrated #1414

Merged
merged 10 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [#1377](https://github.com/crypto-org-chain/cronos/pull/1377) Upgrade sdk to 0.50, and integrate block-stm parallel tx execution.
mmsqe marked this conversation as resolved.
Show resolved Hide resolved
* [#1394](https://github.com/crypto-org-chain/cronos/pull/1394) Add icahost wirings but disable in parameters.
* [#1407](https://github.com/crypto-org-chain/cronos/pull/1407) Add end-to-end encryption module.
* [#1414](https://github.com/crypto-org-chain/cronos/pull/1414) Integrate new evm tx format.

### Improvements

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ replace (
// dgrijalva/jwt-go is deprecated and doesn't receive security updates.
// TODO: remove it: https://github.com/cosmos/cosmos-sdk/issues/13134
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240425065928-ebb09502e7a7
// block-stm branch
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20240419013511-775ac80b75c7
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20240429025959-aa05efccfeee
// Fix upstream GHSA-h395-qcrw-5vmq and GHSA-3vp4-m3rf-835h vulnerabilities.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,12 @@ github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20240415105151-0108877a3201
github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20240415105151-0108877a3201/go.mod h1:lfuLI1f4o+0SGtlHQS4x5qsjRcZZfYqG8bp3k8hM0M8=
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20240415105151-0108877a3201 h1:DbCOM19ywdL5K+bOy4h+0MppzcPgI2guHnYCfDNnAcM=
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20240415105151-0108877a3201/go.mod h1:CBCU6fsRVz23QGFIQBb1DNX2DztJCf3jWyEkHY2nJQ0=
github.com/crypto-org-chain/ethermint v0.6.1-0.20240419013511-775ac80b75c7 h1:tawNK/e1F1AexRdhxC9o6M70IIrbCuvM6C8F/ujHwTY=
github.com/crypto-org-chain/ethermint v0.6.1-0.20240419013511-775ac80b75c7/go.mod h1:OSFT4cvzHl0g2DizYR9vIy5/xRYAvFJrnRydAmgCqyM=
github.com/crypto-org-chain/ethermint v0.6.1-0.20240429025959-aa05efccfeee h1:5eoRnEGxLtrO35t+Bgqv/VBCkomAE7uLxDL4Vmv4Fs0=
github.com/crypto-org-chain/ethermint v0.6.1-0.20240429025959-aa05efccfeee/go.mod h1:9MVSajfKloRP8h2chP78LhCKx5u9O2pCMBvxrmx6+0s=
github.com/crypto-org-chain/go-block-stm v0.0.0-20240408011717-9f11af197bde h1:sQIHTJfVt5VTrF7po9eZiFkZiPjlHbFvnXtGCOoBjNM=
github.com/crypto-org-chain/go-block-stm v0.0.0-20240408011717-9f11af197bde/go.mod h1:iwQTX9xMX8NV9k3o2BiWXA0SswpsZrDk5q3gA7nWYiE=
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e h1:vnyepPQ/m25+19xcTuBUdRxmltZ/EjVWNqEjhg7Ummk=
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e/go.mod h1:+a8pUj1tOyJ2RinsNQD4326YS+leSoKGiG/uVVb0x6Y=
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/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
8 changes: 4 additions & 4 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,12 @@ schema = 3
version = "v1.6.1"
hash = "sha256-zOpoaepCfPLmU9iQji/Ait+SVEHI9eF3rwtW0h/8lho="
[mod."github.com/ethereum/go-ethereum"]
version = "v1.10.20-0.20231207063621-43cf32d91c3e"
hash = "sha256-lDIqRLUrXYCb9mmFBY/+WW+ee69+IkxOgqjHVyo4ij0="
version = "v1.10.20-0.20240425065928-ebb09502e7a7"
hash = "sha256-lE4G5FaRb3MVi9FFVn+WlwsSTOB4SbjmVboKyQ5yB0A="
replaced = "github.com/crypto-org-chain/go-ethereum"
[mod."github.com/evmos/ethermint"]
version = "v0.6.1-0.20240419013511-775ac80b75c7"
hash = "sha256-94bgC0Z+VD8w9j8+mwW/7PJSZlpKdtdR87C1E8hg3T4="
version = "v0.6.1-0.20240429025959-aa05efccfeee"
hash = "sha256-AT9cdXrI3kHcXKEVN0uXcIQiLzNLYPG5zSr5ziuhpFc="
replaced = "github.com/crypto-org-chain/ethermint"
[mod."github.com/fatih/color"]
version = "v1.16.0"
Expand Down
3 changes: 2 additions & 1 deletion integration_tests/ibc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ def get_balances(chain, addr):

def ibc_multi_transfer(ibc):
chains = [ibc.cronos.cosmos_cli(), ibc.chainmain.cosmos_cli()]
users = [f"user{i}" for i in range(1, 21)]
# FIXME: more users after batch fix
users = [f"user{i}" for i in range(1, 2)]
mmsqe marked this conversation as resolved.
Show resolved Hide resolved
addrs0 = [chains[0].address(user) for user in users]
addrs1 = [chains[1].address(user) for user in users]
denom0 = "basetcro"
Expand Down
6 changes: 3 additions & 3 deletions integration_tests/test_ibc_rly.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
cronos_transfer_source_tokens,
cronos_transfer_source_tokens_with_proxy,
get_balance,
hermes_transfer,
ibc_denom,
ibc_incentivized_transfer,
ibc_multi_transfer,
prepare_network,
rly_transfer,
)
from .utils import (
ADDRS,
Expand Down Expand Up @@ -54,7 +54,7 @@ def ibc(request, tmp_path_factory):
yield from prepare_network(
path,
name,
relayer=cluster.Relayer.HERMES.value,
relayer=cluster.Relayer.RLY.value,
)


Expand Down Expand Up @@ -232,7 +232,7 @@ def test_ibc(ibc):
w3 = ibc.cronos.w3
wait_for_new_blocks(ibc.cronos.cosmos_cli(), 1)
start = w3.eth.get_block_number()
hermes_transfer(ibc)
rly_transfer(ibc)
denom = ibc_denom(channel, src_denom)
dst_addr = eth_to_bech32(cronos_signer2)
old_dst_balance = get_balance(ibc.cronos, dst_addr, dst_denom)
Expand Down
4 changes: 2 additions & 2 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ import sources.nixpkgs {
cosmovisor = pkgs.callPackage ./cosmovisor.nix { };
})
(_: pkgs: {
rly = pkgs.buildGo120Module rec {
rly = pkgs.buildGo121Module rec {
name = "rly";
src = sources.relayer;
subPackages = [ "." ];
vendorHash = "sha256-5s5URiAZk59mOfZdUcqYAB/IvzFuBiQH5jDBuh6huTE=";
vendorHash = "sha256-dwKZZu9wKOo2u1/8AAWFx89iC9pWZbCxAERMMAOFsts=";
doCheck = false;
GOWORK = "off";
postInstall = ''
Expand Down
6 changes: 3 additions & 3 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@
"homepage": "https://github.com/crypto-org-chain/relayer",
"owner": "crypto-org-chain",
"repo": "relayer",
"rev": "bd88a2cba9154450924837ecda915688ff8f9e04",
"sha256": "106mf4mc2ag4a5d21lcqpsq7ixvq70097jglw862jz4g9lbxyv8f",
"rev": "f054a463bfddc3cdee9a9d4cc063209fe7503611",
"sha256": "0yr7w9101xrnf612dzv5gy825mlmm7s9hm7zysg09b1djmp546i4",
"type": "tarball",
"url": "https://github.com/crypto-org-chain/relayer/archive/bd88a2cba9154450924837ecda915688ff8f9e04.tar.gz",
"url": "https://github.com/mmsqe/relayer/archive/f054a463bfddc3cdee9a9d4cc063209fe7503611.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
4 changes: 2 additions & 2 deletions x/cronos/keeper/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const DefaultGasCap uint64 = 25000000
// CallEVM execute an evm message from native module
func (k Keeper) CallEVM(ctx sdk.Context, to *common.Address, data []byte, value *big.Int, gasLimit uint64) (*core.Message, *evmtypes.MsgEthereumTxResponse, error) {
nonce := k.evmKeeper.GetNonce(ctx, types.EVMModuleAddress)
msg := core.Message{
msg := &core.Message{
From: types.EVMModuleAddress,
To: to,
Nonce: nonce,
Expand All @@ -47,7 +47,7 @@ func (k Keeper) CallEVM(ctx sdk.Context, to *common.Address, data []byte, value
}
}

return &msg, ret, nil
return msg, ret, nil
}

// CallModuleCRC21 call a method of ModuleCRC21 contract
Expand Down
2 changes: 1 addition & 1 deletion x/cronos/keeper/evm_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func NewLogProcessEvmHook(handlers ...types.EvmLogHandler) *LogProcessEvmHook {
}

// PostTxProcessing implements EvmHook interface
func (h LogProcessEvmHook) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error {
func (h LogProcessEvmHook) PostTxProcessing(ctx sdk.Context, _ *core.Message, receipt *ethtypes.Receipt) error {
addLogToReceiptFunc := newFuncAddLogToReceipt(receipt)
for _, log := range receipt.Logs {
if len(log.Topics) == 0 {
Expand Down
9 changes: 4 additions & 5 deletions x/cronos/keeper/evm_hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

sdkmath "cosmossdk.io/math"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
ethtypes "github.com/ethereum/go-ethereum/core/types"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -42,7 +41,7 @@ func (suite *KeeperTestSuite) TestEvmHooks() {
receipt := &ethtypes.Receipt{
Logs: logs,
}
err := suite.app.EvmKeeper.PostTxProcessing(suite.ctx, core.Message{}, receipt)
err := suite.app.EvmKeeper.PostTxProcessing(suite.ctx, nil, receipt)
suite.Require().NoError(err)
},
},
Expand All @@ -64,7 +63,7 @@ func (suite *KeeperTestSuite) TestEvmHooks() {
receipt := &ethtypes.Receipt{
Logs: logs,
}
err = suite.app.EvmKeeper.PostTxProcessing(suite.ctx, core.Message{}, receipt)
err = suite.app.EvmKeeper.PostTxProcessing(suite.ctx, nil, receipt)
suite.Require().Error(err)
},
},
Expand Down Expand Up @@ -94,7 +93,7 @@ func (suite *KeeperTestSuite) TestEvmHooks() {
receipt := &ethtypes.Receipt{
Logs: logs,
}
err = suite.app.EvmKeeper.PostTxProcessing(suite.ctx, core.Message{}, receipt)
err = suite.app.EvmKeeper.PostTxProcessing(suite.ctx, nil, receipt)
suite.Require().NoError(err)

balance = suite.app.BankKeeper.GetBalance(suite.ctx, sdk.AccAddress(contract.Bytes()), denom)
Expand Down Expand Up @@ -144,7 +143,7 @@ func (suite *KeeperTestSuite) TestEvmHooks() {
receipt := &ethtypes.Receipt{
Logs: logs,
}
err = suite.app.EvmKeeper.PostTxProcessing(suite.ctx, core.Message{}, receipt)
err = suite.app.EvmKeeper.PostTxProcessing(suite.ctx, nil, receipt)
// should fail, because of not ibc denom name
suite.Require().Error(err)
},
Expand Down
7 changes: 1 addition & 6 deletions x/cronos/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,11 @@ func (k Keeper) ReplayBlock(goCtx context.Context, req *types.ReplayBlockRequest
// we assume the message executions are successful, they are filtered in json-rpc api
for _, msg := range req.Msgs {
// deduct fee
txData, err := evmtypes.UnpackTxData(msg.Data)
if err != nil {
return nil, err
}

// populate the `From` field
if _, err := msg.GetSenderLegacy(ethtypes.LatestSignerForChainID(chainID)); err != nil {
return nil, err
}
fees, err := evmkeeper.VerifyFee(txData, evmDenom, baseFee, homestead, istanbul, shanghai, ctx.IsCheckTx())
fees, err := evmkeeper.VerifyFee(msg, evmDenom, baseFee, homestead, istanbul, shanghai, ctx.IsCheckTx())
if err != nil {
return nil, errorsmod.Wrapf(err, "failed to verify the fees")
}
Expand Down
2 changes: 1 addition & 1 deletion x/cronos/types/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type EvmLogHandler interface {
// EvmKeeper defines the interface for evm keeper
type EvmKeeper interface {
GetNonce(ctx sdk.Context, addr common.Address) uint64
ApplyMessage(ctx sdk.Context, msg core.Message, tracer vm.EVMLogger, commit bool) (*evmtypes.MsgEthereumTxResponse, error)
ApplyMessage(ctx sdk.Context, msg *core.Message, tracer vm.EVMLogger, commit bool) (*evmtypes.MsgEthereumTxResponse, error)
GetParams(ctx sdk.Context) evmtypes.Params

// to replay the messages
Expand Down
Loading