-
Notifications
You must be signed in to change notification settings - Fork 276
feat: support eip2935 #1882
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
Merged
Merged
feat: support eip2935 #1882
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bd51e6b
eip2935 support
thomas-nguy 66c7add
add test
thomas-nguy 70f4edf
add changelog
thomas-nguy 41ac132
fix lint
thomas-nguy 4565c2b
remove wait
thomas-nguy 73a7aeb
fix tests
thomas-nguy 50092fe
change base port
thomas-nguy d233314
use latest ethermint
thomas-nguy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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', | ||
| }, | ||
thomas-nguy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| 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', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
|
||
|
|
||
| # 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.