Skip to content

Commit

Permalink
Problem: app hash mismatch in block-stm (#1539)
Browse files Browse the repository at this point in the history
* Problem: app hash mismatch in block-stm

Solution:
- try to reproduce in integration test first

* Update integration_tests/test_basic.py

Co-authored-by: mmsqe <mavis@crypto.com>
Signed-off-by: yihuang <huang@crypto.com>

* fix import

* enable memiavl for easier debugging

* cleanup

* fix

* Revert "enable memiavl for easier debugging"

This reverts commit 903bc2b.

* changelog

---------

Signed-off-by: yihuang <huang@crypto.com>
Co-authored-by: mmsqe <mavis@crypto.com>
  • Loading branch information
yihuang and mmsqe committed Aug 6, 2024
1 parent cb8366b commit bb51671
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
### Bug Fixes

* [#1520](https://github.com/crypto-org-chain/cronos/pull/1520) Avoid invalid chain id for signer error when rpc call before chain id set in BeginBlock.
* [#1539](https://github.com/crypto-org-chain/cronos/pull/1539) Fix go-block-stm bug that causes app hash mismatch.

*Jun 18, 2024*

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ require (
github.com/99designs/keyring v1.2.2
github.com/cometbft/cometbft v0.38.10-0.20240709120009-0792c8bdda44
github.com/cosmos/cosmos-db v1.0.3-0.20240408151834-e75f6e4b28d8
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.7
github.com/cosmos/gogoproto v1.4.12
github.com/cosmos/ibc-go/modules/apps/callbacks v0.0.0-20240410121711-d89cb0895b1e
Expand Down Expand Up @@ -88,6 +87,7 @@ require (
github.com/coinbase/rosetta-sdk-go/types v1.0.0 // indirect
github.com/cometbft/cometbft-db v0.9.1 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v1.1.2 // indirect
Expand All @@ -97,7 +97,7 @@ require (
github.com/creachadair/atomicfile v0.3.1 // indirect
github.com/creachadair/tomledit v0.0.24 // indirect
github.com/crypto-org-chain/cronos/memiavl v0.0.4 // indirect
github.com/crypto-org-chain/go-block-stm v0.0.0-20240408011717-9f11af197bde // indirect
github.com/crypto-org-chain/go-block-stm v0.0.0-20240806075927-09a64748f883 // indirect
github.com/danieljoos/wincred v1.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,8 @@ github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20240722033504-50f1fa0c49d1 h
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20240722033504-50f1fa0c49d1/go.mod h1:RTiTs4hkXG6IvYGknvB8p79YgjYJdcbzLUOGJChsPnY=
github.com/crypto-org-chain/ethermint v0.6.1-0.20240729070824-350955227f14 h1:ZVIlVCtx5X6sckKyMhc8nPBjXvr+/CzmXYqh7e/287I=
github.com/crypto-org-chain/ethermint v0.6.1-0.20240729070824-350955227f14/go.mod h1:Xap56y3WoiP7DyNammmB6N7P+Y83QQd6363RHGuaYV0=
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-block-stm v0.0.0-20240806075927-09a64748f883 h1:Oj7VvlK8iXRaugnpGA8CBXGrgkyigji+Ae5weSRD85I=
github.com/crypto-org-chain/go-block-stm v0.0.0-20240806075927-09a64748f883/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/danieljoos/wincred v1.2.0 h1:ozqKHaLK0W/ii4KVbbvluM91W2H3Sh0BncbUNPS7jLE=
Expand Down
4 changes: 2 additions & 2 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ schema = 3
version = "v0.0.24"
hash = "sha256-4vUukHONOjNn0qfQr4esK6TWfPWsIp+rbdz65og84lw="
[mod."github.com/crypto-org-chain/go-block-stm"]
version = "v0.0.0-20240408011717-9f11af197bde"
hash = "sha256-+UTSUoh4DxkWPQEc/j0atak1Oxq3tdP8r6ZMmB0k5KE="
version = "v0.0.0-20240806075927-09a64748f883"
hash = "sha256-DuqcnTqpUVRxV+I+CaBuDg/1CLmMeXdw4VEFeuCsUbU="
[mod."github.com/danieljoos/wincred"]
version = "v1.2.0"
hash = "sha256-LHcvTJCc8++bFndbd8ZgMSTe4L5h2C4rN+cSWHCz54Y="
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/configs/default.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
evm: {
'block-executor': 'block-stm',
'block-stm-workers': 16,
'block-stm-workers': 32,
},
},
}, {
Expand Down
40 changes: 40 additions & 0 deletions integration_tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@
contract_address,
contract_path,
deploy_contract,
derive_new_account,
eth_to_bech32,
get_receipts_by_block,
get_sync_info,
modify_command_in_supervisor_config,
send_transaction,
send_txs,
sign_transaction,
submit_any_proposal,
w3_wait_for_block,
wait_for_block,
wait_for_new_blocks,
wait_for_port,
Expand Down Expand Up @@ -934,3 +937,40 @@ def test_submit_send_enabled(cronos, tmp_path):
approve_proposal(cronos, rsp["events"])
print("check params have been updated now")
assert cli.query_bank_send(*denoms) == send_enable


def test_block_stm_delete(cronos):
"""
this test case revealed a bug in block-stm,
see: https://github.com/crypto-org-chain/go-block-stm/pull/11
"""
w3 = cronos.w3
cli = cronos.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)
wait_for_new_blocks(cli, 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
w3_wait_for_block(w3, w3.eth.block_number + 3, timeout=30)

0 comments on commit bb51671

Please sign in to comment.