Skip to content

Commit 1f80cb2

Browse files
authored
fix: Add default value of CancunTime and PragueTime in chain config (#1851)
* fix: Add default value of CancunTime and PragueTime in chain config * fix: chain config * fix: changelog * fix: tests * test: separate test cases to test pre EIP-6780 and post EIP-6780 * fix: wrong addr format * fix: lint
1 parent cde48ef commit 1f80cb2

File tree

9 files changed

+103
-9
lines changed

9 files changed

+103
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010

1111

1212
### Improvements
13+
1314
* [#1841](https://github.com/crypto-org-chain/cronos/pull/1841) Ci: use `golangci-lint run --fix`.
1415
* [#1779](https://github.com/crypto-org-chain/cronos/pull/1779) Upgrade rocksdb to `v9.11.2`.
1516
* [#1824](https://github.com/crypto-org-chain/cronos/pull/1824) Rework on github actions.
1617
* [#1826](https://github.com/crypto-org-chain/cronos/pull/1826) Update linter and tidy up code.
1718
* [#1807](https://github.com/crypto-org-chain/cronos/pull/1807) Update go-ethereum version to [v1.15.11](https://github.com/ethereum/go-ethereum/releases/tag/v1.15.11).
1819
* [#1840](https://github.com/crypto-org-chain/cronos/pull/1840) Tx replacement support.
20+
* [#1851](https://github.com/crypto-org-chain/cronos/pull/1850) Add default value of CancunTime and PragueTime in chain config.
1921

2022
*Jun 20, 2025*
2123

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ replace (
305305
// release/v1.15
306306
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.20-0.20250815065500-a4fbafcae0dd
307307
// develop
308-
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20250819081101-9a03795ec96b
308+
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20250820110050-d940a537fb81
309309
// Fix upstream GHSA-h395-qcrw-5vmq and GHSA-3vp4-m3rf-835h vulnerabilities.
310310
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
311311
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,8 +910,8 @@ github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20241217090828-cfbca9fe8254
910910
github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20241217090828-cfbca9fe8254/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
911911
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20241217090828-cfbca9fe8254 h1:JzLOFRiKsDtLJt5h0M0jkEIPDKvFFyja7VEp7gG6O9U=
912912
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20241217090828-cfbca9fe8254/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
913-
github.com/crypto-org-chain/ethermint v0.6.1-0.20250819081101-9a03795ec96b h1:Tm6Hm2id0PRMc8LNQduNY3bA6nvEz/qXoAyTpnEHCHA=
914-
github.com/crypto-org-chain/ethermint v0.6.1-0.20250819081101-9a03795ec96b/go.mod h1:pilxRzYqGqlhVBDXcBYfDbFy6vkiqxwc8zHDPYXLnOQ=
913+
github.com/crypto-org-chain/ethermint v0.6.1-0.20250820110050-d940a537fb81 h1:WCfAxy31LBHVwcAlJfU4XEGlUppoeJSn+fRcdIQfiuA=
914+
github.com/crypto-org-chain/ethermint v0.6.1-0.20250820110050-d940a537fb81/go.mod h1:pilxRzYqGqlhVBDXcBYfDbFy6vkiqxwc8zHDPYXLnOQ=
915915
github.com/crypto-org-chain/go-block-stm v0.0.0-20241213061541-7afe924fb4a6 h1:6KPEi8dWkDSBddQb4NAvEXmNnTXymF3yVeTaT4Hz1iU=
916916
github.com/crypto-org-chain/go-block-stm v0.0.0-20241213061541-7afe924fb4a6/go.mod h1:iwQTX9xMX8NV9k3o2BiWXA0SswpsZrDk5q3gA7nWYiE=
917917
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20250815065500-a4fbafcae0dd h1:ebSnzvM9yKVGFjvoGly7LFQQCS2HuOWMCvQyByJ52Gs=

gomod2nix.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ schema = 3
314314
version = "v0.2.2"
315315
hash = "sha256-0MLfSJKdeK3Z7tWAXTdzwB4091dmyxIX38S5SKH5QAw="
316316
[mod."github.com/evmos/ethermint"]
317-
version = "v0.6.1-0.20250819081101-9a03795ec96b"
318-
hash = "sha256-AbomdzYu7acbuQooMZwqe8vh08Q2jBYtRAMaZF3Yg+4="
317+
version = "v0.6.1-0.20250820110050-d940a537fb81"
318+
hash = "sha256-IiOutLdexw9kqigNKbQYqRvIuMj9V7HD2LLDubJ7XJQ="
319319
replaced = "github.com/crypto-org-chain/ethermint"
320320
[mod."github.com/fatih/color"]
321321
version = "v1.17.0"

integration_tests/contracts/contracts/TestSuicide.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ contract Destroyee {
55
function destroy() public {
66
selfdestruct(payable(msg.sender));
77
}
8+
9+
receive() external payable {}
810
}
911

1012
contract Destroyer {
@@ -17,4 +19,6 @@ contract Destroyer {
1719
}
1820
require(_size > 0);
1921
}
22+
23+
receive() external payable {}
2024
}

integration_tests/test_basic.py

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
contract_path,
2626
deploy_contract,
2727
derive_new_account,
28+
fund_acc,
2829
get_account_nonce,
2930
get_expedited_params,
3031
get_receipts_by_block,
3132
get_sync_info,
3233
modify_command_in_supervisor_config,
34+
remove_cancun_prague_params,
3335
replace_transaction,
3436
send_transaction,
3537
send_txs,
@@ -669,13 +671,14 @@ def test_message_call(cronos):
669671
assert len(receipt.logs) == iterations
670672

671673

672-
def test_suicide(cluster):
674+
def test_suicide_pre_cancun(cronos):
673675
"""
674676
test compliance of contract suicide
675677
- within the tx, after contract suicide, the code is still available.
676678
- after the tx, the code is not available.
677679
"""
678-
w3 = cluster.w3
680+
remove_cancun_prague_params(cronos)
681+
w3 = cronos.w3
679682
destroyee = deploy_contract(
680683
w3,
681684
contract_path("Destroyee", "TestSuicide.sol"),
@@ -696,6 +699,42 @@ def test_suicide(cluster):
696699
assert len(w3.eth.get_code(destroyee.address)) == 0
697700

698701

702+
def test_suicide_post_cancun(cluster):
703+
"""
704+
after EIP-6780, SELFDESTRUCT will recover all funds to the target
705+
but not delete the account, except when called in the same transaction as creation
706+
"""
707+
w3 = cluster.w3
708+
destroyee = deploy_contract(
709+
w3,
710+
contract_path("Destroyee", "TestSuicide.sol"),
711+
)
712+
destroyer = deploy_contract(
713+
w3,
714+
contract_path("Destroyer", "TestSuicide.sol"),
715+
)
716+
717+
balance_wanted = 1000000000000000000
718+
fund_acc(w3, destroyee, balance_wanted)
719+
assert w3.eth.get_balance(destroyee.address) == balance_wanted
720+
assert w3.eth.get_balance(destroyer.address) == 0
721+
722+
old_code_destroyee = w3.eth.get_code(destroyee.address)
723+
old_code_destroyer = w3.eth.get_code(destroyer.address)
724+
assert len(old_code_destroyee) > 0
725+
assert len(old_code_destroyer) > 0
726+
727+
tx = destroyer.functions.check_codesize_after_suicide(
728+
destroyee.address
729+
).build_transaction()
730+
receipt = send_transaction(w3, tx)
731+
assert receipt.status == 1
732+
733+
assert w3.eth.get_code(destroyee.address) == old_code_destroyee
734+
assert w3.eth.get_balance(destroyee.address) == 0
735+
assert w3.eth.get_balance(destroyer.address) == balance_wanted
736+
737+
699738
def test_batch_tx(cronos):
700739
"send multiple eth txs in single cosmos tx"
701740
w3 = cronos.w3

integration_tests/test_gov_update_params.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def test_evm_update_param(cronos, tmp_path):
1717
p = cli.query_params("evm")
1818
del p["chain_config"]["merge_netsplit_block"]
1919
del p["chain_config"]["shanghai_time"]
20+
del p["chain_config"]["cancun_time"]
21+
del p["chain_config"]["prague_time"]
2022
authority = module_address("gov")
2123
msg = "/ethermint.evm.v1.MsgUpdateParams"
2224
submit_gov_proposal(
@@ -33,6 +35,8 @@ def test_evm_update_param(cronos, tmp_path):
3335
p = cli.query_params("evm")
3436
assert not p["chain_config"]["merge_netsplit_block"]
3537
assert not p["chain_config"]["shanghai_time"]
38+
assert not p["chain_config"]["cancun_time"]
39+
assert not p["chain_config"]["prague_time"]
3640
invalid_msg = "invalid opcode: PUSH0"
3741
with pytest.raises(ValueError) as e_info:
3842
contract.caller.randomTokenId()

integration_tests/utils.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,3 +846,36 @@ def assert_gov_params(cli, old_param):
846846
expedited_param = get_expedited_params(old_param)
847847
for key, value in expedited_param.items():
848848
assert param[key] == value, param
849+
850+
851+
def fund_acc(w3, acc, fund=3000000000000000000):
852+
addr = acc.address
853+
if w3.eth.get_balance(addr, "latest") == 0:
854+
tx = {"to": addr, "value": fund, "gasPrice": w3.eth.gas_price}
855+
send_transaction(w3, tx)
856+
assert w3.eth.get_balance(addr, "latest") == fund
857+
858+
859+
def remove_cancun_prague_params(cronos):
860+
from .cosmoscli import module_address as cosmos_module_address
861+
862+
cli = cronos.cosmos_cli()
863+
p = cli.query_params("evm")
864+
del p["chain_config"]["cancun_time"]
865+
del p["chain_config"]["prague_time"]
866+
authority = cosmos_module_address("gov")
867+
msg = "/ethermint.evm.v1.MsgUpdateParams"
868+
submit_gov_proposal(
869+
cronos,
870+
msg,
871+
messages=[
872+
{
873+
"@type": msg,
874+
"authority": authority,
875+
"params": p,
876+
}
877+
],
878+
)
879+
p = cli.query_params("evm")
880+
assert not p["chain_config"]["cancun_time"]
881+
assert not p["chain_config"]["prague_time"]

scripts/geth-genesis.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,20 @@
1515
"yoloV3Block": 0,
1616
"londonBlock": 0,
1717
"shanghaiTime": 0,
18-
"cancunTime": null,
19-
"pragueTime": null,
18+
"cancunTime": 0,
19+
"pragueTime": 0,
20+
"blobSchedule": {
21+
"cancun": {
22+
"target": 3,
23+
"max": 6,
24+
"baseFeeUpdateFraction": 3338477
25+
},
26+
"prague": {
27+
"target": 3,
28+
"max": 6,
29+
"baseFeeUpdateFraction": 3338477
30+
}
31+
},
2032
"terminalTotalDifficulty": 0,
2133
"clique": {
2234
"period": 2,

0 commit comments

Comments
 (0)