From 8a50b30c3ea81b8a703420d98e1038a6c89dd92f Mon Sep 17 00:00:00 2001 From: mmsqe Date: Tue, 22 Oct 2024 12:55:45 +0800 Subject: [PATCH 1/4] Problem: fix of state overwrite in debug trace is not included (#1655) --- CHANGELOG.md | 1 + go.mod | 2 +- go.sum | 4 ++-- gomod2nix.toml | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94f55c8c26..5d36264fde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * (testground)[1649](https://github.com/crypto-org-chain/cronos/pull/1649) Fix running single validator benchmark locally. * (cli)[#1647](https://github.com/crypto-org-chain/cronos/pull/1647) Fix node can't shutdown by signal. * (testground)[#1652](https://github.com/crypto-org-chain/cronos/pull/1652) Remove unexpected conflicts in benchmark transactions. +* [#1655](https://github.com/crypto-org-chain/cronos/pull/1655) Fix state overwrite in debug trace APIs. ### Improvements diff --git a/go.mod b/go.mod index df2bb91564..525960b41d 100644 --- a/go.mod +++ b/go.mod @@ -273,7 +273,7 @@ replace ( 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.20240926023215-d2275b4afb9a // develop - github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20241017130935-816389c76eac + github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20241022025636-430068294727 // 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 diff --git a/go.sum b/go.sum index 0da36aff13..03b1db312a 100644 --- a/go.sum +++ b/go.sum @@ -428,8 +428,8 @@ github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20241018012743-d78d66e74712 github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20241018012743-d78d66e74712/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM= github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20241018012743-d78d66e74712 h1:vvN3FqhFTakKy4jgVC1GoEtHW52zQg49uNE/e16Scu8= github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20241018012743-d78d66e74712/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= -github.com/crypto-org-chain/ethermint v0.6.1-0.20241017130935-816389c76eac h1:tSgcMmugbp5h5Xi2rRZBCwP37EfqxM6jmNv9qO/aNrI= -github.com/crypto-org-chain/ethermint v0.6.1-0.20241017130935-816389c76eac/go.mod h1:LUv3b8+dRjqAI9UTml5XzjExT2ANyvjtkFssi7lIRb0= +github.com/crypto-org-chain/ethermint v0.6.1-0.20241022025636-430068294727 h1:vMY/xLOa4kBZahv6JgIeJPLeaiNfKsgRirKRFzd+oeg= +github.com/crypto-org-chain/ethermint v0.6.1-0.20241022025636-430068294727/go.mod h1:LUv3b8+dRjqAI9UTml5XzjExT2ANyvjtkFssi7lIRb0= github.com/crypto-org-chain/go-block-stm v0.0.0-20240919080136-6c49aef68716 h1:OvD5Rm0B6LHUJk6z858UgwdP72jU2DuUdXeclRyKpDI= github.com/crypto-org-chain/go-block-stm v0.0.0-20240919080136-6c49aef68716/go.mod h1:iwQTX9xMX8NV9k3o2BiWXA0SswpsZrDk5q3gA7nWYiE= github.com/crypto-org-chain/go-ethereum v1.10.20-0.20240926023215-d2275b4afb9a h1:IUPD+dg1YQl8cLocxQ/Mbx/ObTgAgcrZlcBhFjsLO40= diff --git a/gomod2nix.toml b/gomod2nix.toml index f1be8f6123..dec9b33381 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -262,8 +262,8 @@ schema = 3 hash = "sha256-ozwVS2BhAoz+OOisAyMhgg+lq8FdQjf90xoOq9cxtGw=" replaced = "github.com/crypto-org-chain/go-ethereum" [mod."github.com/evmos/ethermint"] - version = "v0.6.1-0.20241017130935-816389c76eac" - hash = "sha256-DD2uiTxQKEwKP5tCETMZNX8it7G7e+MBFFMG3YpW6RA=" + version = "v0.6.1-0.20241022025636-430068294727" + hash = "sha256-BLzVdTWu6We25O2DRCAyB5ShbBEnw4aKzWY9vDVSRok=" replaced = "github.com/crypto-org-chain/ethermint" [mod."github.com/fatih/color"] version = "v1.16.0" From 572aae7f022d5f581e4cbbce7cf5dd611f888eaf Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 23 Oct 2024 10:25:30 +0800 Subject: [PATCH 2/4] Problem: test_tx_inclusion is flaky when nodes halt due to different gas_wanted (#1657) * Problem: test_tx_inclusion is flaky when nodes halt due to different gas_wanted wait longer to avoid nodes start with different max_gas_wanted * add max timeout * cleanup --- integration_tests/test_basic.py | 6 +++++- integration_tests/utils.py | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/integration_tests/test_basic.py b/integration_tests/test_basic.py index 7089b6c9d1..b267746806 100644 --- a/integration_tests/test_basic.py +++ b/integration_tests/test_basic.py @@ -866,7 +866,12 @@ def fn(cmd): cronos.base_dir / "tasks.ini", lambda cmd: fn(cmd), ) + cli = cronos.cosmos_cli() + # update right after a new block start + wait_for_new_blocks(cli, 1, sleep=0.1) cronos.supervisorctl("update") + # ensure nodes stop and start at the same time + time.sleep(2) wait_for_port(ports.evmrpc_port(cronos.base_port(0))) # reset to origin_cmd only @@ -874,7 +879,6 @@ def fn(cmd): return w3 = cronos.w3 - cli = cronos.cosmos_cli() block_gas_limit = 81500000 tx_gas_limit = 80000000 max_tx_in_block = block_gas_limit // min(max_gas_wanted, tx_gas_limit) diff --git a/integration_tests/utils.py b/integration_tests/utils.py index adbdaa2bf9..c4474d8ce6 100644 --- a/integration_tests/utils.py +++ b/integration_tests/utils.py @@ -122,11 +122,14 @@ def wait_for_block(cli, height, timeout=240): raise TimeoutError(f"wait for block {height} timeout") -def wait_for_new_blocks(cli, n, sleep=0.5): +def wait_for_new_blocks(cli, n, sleep=0.5, timeout=240): cur_height = begin_height = int(get_sync_info(cli.status())["latest_block_height"]) + start_time = time.time() while cur_height - begin_height < n: time.sleep(sleep) cur_height = int(get_sync_info(cli.status())["latest_block_height"]) + if time.time() - start_time > timeout: + raise TimeoutError(f"wait for block {begin_height + n} timeout") return cur_height From 8a698f415e0f78da756c0317ca9ce00a42a32481 Mon Sep 17 00:00:00 2001 From: yihuang Date: Wed, 23 Oct 2024 13:26:16 +0800 Subject: [PATCH 3/4] Problem: performance is not optimal when blocklist is empty (#1658) * Problem: performance is not optimal when blocklist is empty * Update CHANGELOG.md Signed-off-by: yihuang --------- Signed-off-by: yihuang --- CHANGELOG.md | 1 + app/proposal.go | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d36264fde..b8da07261a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * [#1648](https://github.com/crypto-org-chain/cronos/pull/1648) Add abort OE in PrepareProposal. * (testground)[#1651](https://github.com/crypto-org-chain/cronos/pull/1651) Benchmark use cosmos broadcast rpc. * (testground)[#1650](https://github.com/crypto-org-chain/cronos/pull/1650) Benchmark support batch mode. +* [#1658](https://github.com/crypto-org-chain/cronos/pull/1658) Optimize when block-list is empty. *Oct 14, 2024* diff --git a/app/proposal.go b/app/proposal.go index 8a755941c5..3e4465b084 100644 --- a/app/proposal.go +++ b/app/proposal.go @@ -124,6 +124,11 @@ func (h *ProposalHandler) SetBlockList(blob []byte) error { } func (h *ProposalHandler) ValidateTransaction(tx sdk.Tx) error { + if len(h.blocklist) == 0 { + // fast path, accept all txs + return nil + } + sigTx, ok := tx.(signing.SigVerifiableTx) if !ok { return fmt.Errorf("tx of type %T does not implement SigVerifiableTx", tx) @@ -147,6 +152,11 @@ func (h *ProposalHandler) ValidateTransaction(tx sdk.Tx) error { func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler { return func(ctx sdk.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { + if len(h.blocklist) == 0 { + // fast path, accept all txs + return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil + } + for _, txBz := range req.Txs { memTx, err := h.TxDecoder(txBz) if err != nil { From 1ae61b41edf5ea91c76d5cb149d0a57c3d1c57ab Mon Sep 17 00:00:00 2001 From: yihuang Date: Wed, 23 Oct 2024 15:12:58 +0800 Subject: [PATCH 4/4] Problem: don't support skipping check-tx in benchmark (#1659) * Problem: don't support skipping check-tx in benchmark * Update CHANGELOG.md Signed-off-by: yihuang --------- Signed-off-by: yihuang --- CHANGELOG.md | 1 + app/app.go | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8da07261a..1ecb6b2c69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ * (testground)[#1651](https://github.com/crypto-org-chain/cronos/pull/1651) Benchmark use cosmos broadcast rpc. * (testground)[#1650](https://github.com/crypto-org-chain/cronos/pull/1650) Benchmark support batch mode. * [#1658](https://github.com/crypto-org-chain/cronos/pull/1658) Optimize when block-list is empty. +* (testground)[#1659](https://github.com/crypto-org-chain/cronos/pull/1659) Support skip check-tx in benchmark. *Oct 14, 2024* diff --git a/app/app.go b/app/app.go index b8905c4170..2ef656b0d5 100644 --- a/app/app.go +++ b/app/app.go @@ -188,6 +188,7 @@ const ( FlagBlockedAddresses = "blocked-addresses" FlagUnsafeIgnoreBlockListFailure = "unsafe-ignore-block-list-failure" + FlagUnsafeDummyCheckTx = "unsafe-dummy-check-tx" ) var Forks = []Fork{} @@ -289,6 +290,7 @@ type App struct { // encoding cdc *codec.LegacyAmino txConfig client.TxConfig + txDecoder sdk.TxDecoder appCodec codec.Codec interfaceRegistry types.InterfaceRegistry @@ -352,6 +354,9 @@ type App struct { qms storetypes.RootMultiStore blockProposalHandler *ProposalHandler + + // unsafe to set for validator, used for testing + dummyCheckTx bool } // New returns a reference to an initialized chain. @@ -456,6 +461,7 @@ func New( BaseApp: bApp, cdc: cdc, txConfig: txConfig, + txDecoder: txDecoder, appCodec: appCodec, interfaceRegistry: interfaceRegistry, invCheckPeriod: invCheckPeriod, @@ -464,6 +470,7 @@ func New( okeys: okeys, memKeys: memKeys, blockProposalHandler: blockProposalHandler, + dummyCheckTx: cast.ToBool(appOpts.Get(FlagUnsafeDummyCheckTx)), } app.SetDisableBlockGasMeter(true) @@ -1466,3 +1473,21 @@ func (app *App) Close() error { func maxParallelism() int { return min(stdruntime.GOMAXPROCS(0), stdruntime.NumCPU()) } + +func (app *App) CheckTx(req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) { + if app.dummyCheckTx { + tx, err := app.txDecoder(req.Tx) + if err != nil { + return nil, err + } + + feeTx, ok := tx.(sdk.FeeTx) + if !ok { + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "tx must be FeeTx") + } + + return &abci.ResponseCheckTx{Code: abci.CodeTypeOK, GasWanted: int64(feeTx.GetGas())}, nil + } + + return app.BaseApp.CheckTx(req) +}