Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
## UNRELEASED

* [#1869](https://github.com/crypto-org-chain/cronos/pull/1869) Add missing tx context during vm initialisation
* [#1872](https://github.com/crypto-org-chain/cronos/pull/1872) fix(evm): support 4byteTracer for tracer
* [#1875](https://github.com/crypto-org-chain/cronos/pull/1875) Add integration tests for preinstalls
* [#1872](https://github.com/crypto-org-chain/cronos/pull/1872) Support 4byteTracer for tracer
* [#1875](https://github.com/crypto-org-chain/cronos/pull/1875) Support for preinstalls
* [#1882](https://github.com/crypto-org-chain/cronos/pull/1882) Support for eip2935

*Sep 4, 2025*

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ replace (
// release/v1.15
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.20-0.20250815065500-a4fbafcae0dd
// develop
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.22.1-0.20251002045626-63f3de0a10b2
github.com/evmos/ethermint => github.com/thomas-nguy/ethermint v0.4.2-0.20251003145706-7847a6e9c1aa
// 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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,6 @@ github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20241217090828-cfbca9fe8254
github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20241217090828-cfbca9fe8254/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20241217090828-cfbca9fe8254 h1:JzLOFRiKsDtLJt5h0M0jkEIPDKvFFyja7VEp7gG6O9U=
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20241217090828-cfbca9fe8254/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
github.com/crypto-org-chain/ethermint v0.22.1-0.20251002045626-63f3de0a10b2 h1://0sA+PCGB9hyaX22kI7CaVcBJ+b4uV7rqo/BhTHi58=
github.com/crypto-org-chain/ethermint v0.22.1-0.20251002045626-63f3de0a10b2/go.mod h1:CsJ9yDOjuoVWNOxSIiTJhiYziDyCx3pk2hlnj97eGJU=
github.com/crypto-org-chain/go-block-stm v0.0.0-20241213061541-7afe924fb4a6 h1:6KPEi8dWkDSBddQb4NAvEXmNnTXymF3yVeTaT4Hz1iU=
github.com/crypto-org-chain/go-block-stm v0.0.0-20241213061541-7afe924fb4a6/go.mod h1:iwQTX9xMX8NV9k3o2BiWXA0SswpsZrDk5q3gA7nWYiE=
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20250815065500-a4fbafcae0dd h1:ebSnzvM9yKVGFjvoGly7LFQQCS2HuOWMCvQyByJ52Gs=
Expand Down Expand Up @@ -1717,6 +1715,8 @@ github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2l
github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE=
github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU=
github.com/thomas-nguy/ethermint v0.4.2-0.20251003145706-7847a6e9c1aa h1:eaJhKreQ81kuDNah9Sb+jIeHVbreIT6AZcoISQWz47s=
github.com/thomas-nguy/ethermint v0.4.2-0.20251003145706-7847a6e9c1aa/go.mod h1:CsJ9yDOjuoVWNOxSIiTJhiYziDyCx3pk2hlnj97eGJU=
github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
Expand Down
6 changes: 3 additions & 3 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ schema = 3
version = "v0.2.2"
hash = "sha256-0MLfSJKdeK3Z7tWAXTdzwB4091dmyxIX38S5SKH5QAw="
[mod."github.com/evmos/ethermint"]
version = "v0.22.1-0.20251002045626-63f3de0a10b2"
hash = "sha256-lpXYx7Q2NZnhmnT4Z9V7EMxovVZrV1cLjj5hLhtl5/w="
replaced = "github.com/crypto-org-chain/ethermint"
version = "v0.4.2-0.20251003145706-7847a6e9c1aa"
hash = "sha256-zxxGmCv6SkiELUOYHWJF571+nJ9pgLGXDSnRMHyu0DU="
replaced = "github.com/thomas-nguy/ethermint"
[mod."github.com/fatih/color"]
version = "v1.17.0"
hash = "sha256-QsKMy3MsvjbYNcA9jP8w6c3wpmWDZ0079bybAEzmXR0="
Expand Down
153 changes: 153 additions & 0 deletions integration_tests/configs/eip2935.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
{
dotenv: '../../scripts/.env',
'cronos_777-1': {
cmd: 'cronosd',
'start-flags': '--trace',
config: {
db_backend: 'rocksdb',
mempool: {
version: 'v1',
},
},
'app-config': {
chain_id: 'cronos_777-1',
'app-db-backend': 'rocksdb',
'minimum-gas-prices': '0basetcro',
'index-events': ['ethereum_tx.ethereumTxHash'],
'iavl-lazy-loading': true,
'json-rpc': {
address: '127.0.0.1:{EVMRPC_PORT}',
'ws-address': '127.0.0.1:{EVMRPC_PORT_WS}',
api: 'eth,net,web3,debug,cronos',
'feehistory-cap': 100,
'block-range-cap': 10000,
'logs-cap': 10000,
},
evm: {
'block-executor': 'sequential',
},
mempool: {
'max-txs': 1000,
},
},
validators: [{
coins: '1000000000000000000stake,10000000000000000000000basetcro',
staked: '1000000000000000000stake',
mnemonic: '${VALIDATOR1_MNEMONIC}',
client_config: {
'broadcast-mode': 'sync',
},
'app-config': {
memiavl: {
enable: true,
'zero-copy': true,
'snapshot-interval': 5,
'cache-size': 0,
'async-commit-buffer': 5,
},
versiondb: {
enable: true,
},
evm: {
'block-executor': 'block-stm',
'block-stm-workers': 32,
},
},
}, {
coins: '1000000000000000000stake,10000000000000000000000basetcro',
staked: '1000000000000000000stake',
mnemonic: '${VALIDATOR2_MNEMONIC}',
client_config: {
'broadcast-mode': 'sync',
},
config: {
db_backend: 'pebbledb',
},
'app-config': {
'app-db-backend': 'pebbledb',
},
}, {
coins: '1000000000000000000stake,10000000000000000000000basetcro',
staked: '1000000000000000000stake',
mnemonic: '${VALIDATOR3_MNEMONIC}',
client_config: {
'broadcast-mode': 'sync',
},
config: {
db_backend: 'goleveldb',
},
'app-config': {
'app-db-backend': 'goleveldb',
},
}],
accounts: [{
name: 'community',
coins: '10000000000000000000000basetcro',
mnemonic: '${COMMUNITY_MNEMONIC}',
}, {
name: 'signer1',
coins: '20000000000000000000000basetcro',
mnemonic: '${SIGNER1_MNEMONIC}',
}, {
name: 'signer2',
coins: '30000000000000000000000basetcro',
mnemonic: '${SIGNER2_MNEMONIC}',
}],
genesis: {
consensus: {
params: {
block: {
max_bytes: '1048576',
max_gas: '81500000',
},
},
},
app_state: {
evm: {
params: {
evm_denom: 'basetcro',
header_hash_num: '5',
},
},
cronos: {
params: {
cronos_admin: '${CRONOS_ADMIN}',
enable_auto_deployment: true,
ibc_cro_denom: '${IBC_CRO_DENOM}',
},
},
e2ee: {
keys: [{
address: 'crc16z0herz998946wr659lr84c8c556da55dc34hh',
key: 'age1k3mpspxytgvx6e0jja0xgrtzz7vw2p00c2a3xmq5ygfzhwh4wg0s35z4c8',
}],
},
gov: {
params: {
expedited_voting_period: '1s',
voting_period: '10s',
max_deposit_period: '10s',
min_deposit: [
{
denom: 'basetcro',
amount: '1',
},
],
},
},
transfer: {
params: {
receive_enabled: true,
send_enabled: true,
},
},
feemarket: {
params: {
no_base_fee: false,
base_fee: '100000000000',
},
},
},
},
},
}
9 changes: 9 additions & 0 deletions integration_tests/contracts/contracts/TestEip2935.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.28;

contract TestEip2935 {
// helper that returns blockhash opcode result (to demonstrate opcode unchanged)
function blockhashOpcode(uint256 blk) public view returns (bytes32) {
return blockhash(blk);
}
}
81 changes: 81 additions & 0 deletions integration_tests/test_eip2935.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
from pathlib import Path

import pytest
from hexbytes import HexBytes

from .cosmoscli import module_address
from .network import Cronos, setup_custom_cronos
from .utils import CONTRACTS, deploy_contract, submit_gov_proposal, w3_wait_for_block


@pytest.fixture(scope="module")
def cronos_eip2935(tmp_path_factory):
"""start-cronos
set evm's param header_hash_num to 5
"""
yield from setup_custom_cronos(
tmp_path_factory.mktemp("eip2935"),
27000,
Path(__file__).parent / "configs/eip2935.jsonnet",
)


def test_eip2935(cronos_eip2935: Cronos):
"""
check eip2935
"""
w3 = cronos_eip2935.w3

# Set header_hash_num to 5 in genesis, e.g we persist only the latest 5 block hashes
# Check that there is no history if query < current_block_number - 5
contract = deploy_contract(
w3,
CONTRACTS["TestEip2935"],
)
start = w3.eth.block_number
w3_wait_for_block(w3, start + 10, timeout=30)
for i in range(0, 4):
stored = contract.caller.blockhashOpcode(start + i)
assert HexBytes(stored) == HexBytes(b"\x00" * 32)

Check failure on line 39 in integration_tests/test_eip2935.py

View workflow job for this annotation

GitHub Actions / integration_tests (unmarked)

test_eip2935 AssertionError: assert HexBytes('0xb346729a356506e1648fdb00f0bd839d29dfe14b330e3400cc7a1d729e2db3c5') == HexBytes('0x0000000000000000000000000000000000000000000000000000000000000000') At index 0 diff: HexBytes('0xb3') != HexBytes('0x00') Full diff: - HexBytes('0x0000000000000000000000000000000000000000000000000000000000000000') + HexBytes('0xb346729a356506e1648fdb00f0bd839d29dfe14b330e3400cc7a1d729e2db3c5')

# Deploy history storage contract
history_storage_address = "0x0000F90827F1C53a10cb7A02335B175320002935"
history_storage_code = w3.eth.get_code(history_storage_address)
assert history_storage_code == HexBytes("0x")

expected_history_storage_code = (
"0x3373fffffffffffffffffffffffffffffffffffffffe14604657602036036042575f356001"
"43038111604257611fff81430311604257611fff9006545f5260205ff35b5f5ffd5b5f35611f"
"ff60014303065500"
)
history_storage_preinstall = {
"name": "HistoryStorage",
"address": history_storage_address,
"code": expected_history_storage_code,
}

msg = "/ethermint.evm.v1.MsgRegisterPreinstalls"
authority = module_address("gov")
submit_gov_proposal(
cronos_eip2935,
msg,
messages=[
{
"@type": msg,
"authority": authority,
"preinstalls": [history_storage_preinstall],
}
],
)

history_storage_code = w3.eth.get_code(history_storage_address)
assert history_storage_code == HexBytes(expected_history_storage_code)

# Check that history < current_block_number - 5 is available
w3_wait_for_block(w3, w3.eth.block_number + 10, timeout=30)
start = w3.eth.block_number
w3_wait_for_block(w3, start + 10, timeout=30)
for i in range(0, 9):
block = w3.eth.get_block(start + i)
stored = contract.caller.blockhashOpcode(start + i)
assert stored == block.hash
1 change: 1 addition & 0 deletions integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"Simple7702Counter": "Simple7702Counter.sol",
"Utils": "Utils.sol",
"Counter": "Counter.sol",
"TestEip2935": "TestEip2935.sol",
}


Expand Down
2 changes: 2 additions & 0 deletions third_party/proto/ethermint/evm/v1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ message Params {
bool allow_unprotected_txs = 6;
// header_hash_num is the number of header hash to persist.
uint64 header_hash_num = 7;
// historyServeWindow for EIP 2935
uint64 history_serve_window = 8;
}
Loading