├── .dockerignore ├── .envrc ├── .github ├── CODEOWNERS ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_spec.md ├── bug_report.md ├── dependabot.yml ├── pull_request_template.md └── workflows │ ├── bench.yml │ ├── codeql-analysis.yml │ ├── notify-metrics-availability.sh │ ├── publish_antithesis_images.yml │ ├── publish_docker.yml │ ├── release.yml │ ├── tests.yml │ └── trigger-antithesis.yml ├── .gitignore ├── .golangci.yml ├── .goreleaser.yml ├── .markdownlint.json ├── AUTHORS ├── COPYING ├── COPYING.LESSER ├── Dockerfile ├── LICENSE ├── README.md ├── RELEASES.md ├── SECURITY.md ├── accounts └── abi │ ├── abi.go │ ├── abi_extra_test.go │ ├── abi_test.go │ ├── argument.go │ ├── bind │ ├── auth.go │ ├── backend.go │ ├── backends │ │ └── simulated.go │ ├── base.go │ ├── base_test.go │ ├── bind.go │ ├── bind_extra.go │ ├── bind_test.go │ ├── precompilebind │ │ ├── precompile_bind.go │ │ ├── precompile_bind_test.go │ │ ├── precompile_config_template.go │ │ ├── precompile_config_test_template.go │ │ ├── precompile_contract_template.go │ │ ├── precompile_contract_test_template.go │ │ ├── precompile_event_template.go │ │ └── precompile_module_template.go │ ├── template.go │ ├── util.go │ └── util_test.go │ ├── doc.go │ ├── error.go │ ├── error_handling.go │ ├── event.go │ ├── event_test.go │ ├── method.go │ ├── method_test.go │ ├── pack.go │ ├── pack_test.go │ ├── packing_test.go │ ├── reflect.go │ ├── reflect_test.go │ ├── topics.go │ ├── topics_test.go │ ├── type.go │ ├── type_test.go │ ├── unpack.go │ ├── unpack_test.go │ └── utils.go ├── bin ├── ginkgo └── tmpnetctl ├── cmd ├── abigen │ ├── main.go │ ├── namefilter.go │ └── namefilter_test.go ├── evm │ ├── README.md │ ├── compiler.go │ ├── disasm.go │ ├── internal │ │ ├── compiler │ │ │ └── compiler.go │ │ └── t8ntool │ │ │ ├── block.go │ │ │ ├── execution.go │ │ │ ├── flags.go │ │ │ ├── gen_header.go │ │ │ ├── gen_stenv.go │ │ │ ├── tracewriter.go │ │ │ ├── transaction.go │ │ │ ├── transition.go │ │ │ ├── tx_iterator.go │ │ │ └── utils.go │ ├── main.go │ ├── runner.go │ ├── staterunner.go │ ├── t8n_test.go │ ├── testdata │ │ ├── 1 │ │ │ ├── alloc.json │ │ │ ├── env.json │ │ │ ├── exp.json │ │ │ └── txs.json │ │ ├── 3 │ │ │ ├── alloc.json │ │ │ ├── env.json │ │ │ ├── exp.json │ │ │ ├── readme.md │ │ │ └── txs.json │ │ ├── 4 │ │ │ ├── alloc.json │ │ │ ├── env.json │ │ │ ├── readme.md │ │ │ └── txs.json │ │ ├── 5 │ │ │ ├── alloc.json │ │ │ ├── env.json │ │ │ ├── exp.json │ │ │ ├── readme.md │ │ │ └── txs.json │ │ ├── 13 │ │ │ ├── alloc.json │ │ │ ├── env.json │ │ │ ├── exp.json │ │ │ ├── exp2.json │ │ │ ├── exp2.json.diff │ │ │ ├── readme.md │ │ │ ├── signed_txs.rlp │ │ │ └── txs.json │ │ ├── 14 │ │ │ ├── alloc.json │ │ │ ├── env.json │ │ │ ├── env.uncles.json │ │ │ ├── exp.json │ │ │ ├── exp2.json │ │ │ ├── exp_berlin.json │ │ │ ├── readme.md │ │ │ └── txs.json │ │ ├── 15 │ │ │ ├── blockheader.rlp │ │ │ ├── exp.json │ │ │ ├── exp2.json │ │ │ ├── exp3.json │ │ │ ├── signed_txs.rlp │ │ │ └── signed_txs.rlp.json │ │ ├── 16 │ │ │ ├── exp.json │ │ │ ├── signed_txs.rlp │ │ │ └── unsigned_txs.json │ │ ├── 17 │ │ │ ├── exp.json │ │ │ ├── rlpdata.txt │ │ │ └── signed_txs.rlp │ │ ├── 18 │ │ │ ├── README.md │ │ │ └── invalid.rlp │ │ ├── 19 │ │ │ ├── alloc.json │ │ │ ├── env.json │ │ │ ├── exp_arrowglacier.json │ │ │ ├── exp_grayglacier.json │ │ │ ├── exp_london.json │ │ │ ├── readme.md │ │ │ └── txs.json │ │ ├── 20 │ │ │ ├── exp.json │ │ │ ├── header.json │ │ │ ├── ommers.json │ │ │ ├── readme.md │ │ │ └── txs.rlp │ │ ├── 22 │ │ │ ├── exp-clique.json │ │ │ ├── exp.json │ │ │ ├── header.json │ │ │ ├── ommers.json │ │ │ ├── readme.md │ │ │ └── txs.rlp │ │ ├── 23 │ │ │ ├── alloc.json │ │ │ ├── env.json │ │ │ ├── exp.json │ │ │ ├── readme.md │ │ │ └── txs.json │ │ ├── 24 │ │ │ ├── alloc.json │ │ │ ├── env.json │ │ │ ├── exp.json │ │ │ ├── exp.json.diff │ │ │ └── txs.json │ │ ├── 25 │ │ │ ├── alloc.json │ │ │ ├── env.json │ │ │ ├── env.json.diff │ │ │ ├── exp.json │ │ │ ├── exp.json.diff │ │ │ └── txs.json │ │ ├── 28 │ │ │ ├── alloc.json │ │ │ ├── env.json │ │ │ ├── exp.json │ │ │ └── txs.rlp │ │ ├── 29 │ │ │ ├── alloc.json │ │ │ ├── env.json │ │ │ ├── exp.json │ │ │ ├── readme.md │ │ │ └── txs.json │ │ └── 30 │ │ │ ├── README.txt │ │ │ ├── alloc.json │ │ │ ├── env.json │ │ │ ├── exp.json │ │ │ ├── txs.rlp │ │ │ └── txs_more.rlp │ └── transition-test.sh ├── precompilegen │ ├── main.go │ └── template-readme.md ├── simulator │ ├── .simulator │ │ └── keys │ │ │ └── 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC │ ├── README.md │ ├── config │ │ └── flags.go │ ├── key │ │ └── key.go │ ├── load │ │ ├── funder.go │ │ ├── loader.go │ │ └── worker.go │ ├── main │ │ └── main.go │ ├── metrics │ │ └── metrics.go │ └── txs │ │ ├── agent.go │ │ └── tx_generator.go └── utils │ ├── cmd.go │ └── flags.go ├── commontype ├── fee_config.go ├── fee_config_test.go └── test_fee_config.go ├── compatibility.json ├── consensus ├── consensus.go ├── dummy │ ├── README.md │ ├── consensus.go │ └── consensus_test.go ├── errors.go └── misc │ └── eip4844 │ ├── eip4844.go │ └── eip4844_test.go ├── constants └── constants.go ├── contracts ├── .gitignore ├── .npmrc ├── .prettierrc ├── README.md ├── contracts │ ├── AllowList.sol │ ├── ERC20NativeMinter.sol │ ├── ExampleDeployerList.sol │ ├── ExampleFeeManager.sol │ ├── ExampleRewardManager.sol │ ├── ExampleTxAllowList.sol │ ├── ExampleWarp.sol │ ├── interfaces │ │ ├── IAllowList.sol │ │ ├── IFeeManager.sol │ │ ├── INativeMinter.sol │ │ ├── IRewardManager.sol │ │ └── IWarpMessenger.sol │ └── test │ │ ├── AllowListTest.sol │ │ ├── ERC20NativeMinterTest.sol │ │ ├── ExampleDeployerListTest.sol │ │ ├── ExampleFeeManagerTest.sol │ │ ├── ExampleRewardManagerTest.sol │ │ └── ExampleTxAllowListTest.sol ├── hardhat.config.ts ├── index.ts ├── package-lock.json ├── package.json ├── scripts │ ├── deployERC20NativeMinter.ts │ ├── deployExampleDeployerList.ts │ ├── deployExampleRewardManager.ts │ └── deployExampleTxAllowList.ts ├── tasks.ts ├── test │ ├── README.md │ ├── contract_deployer_allow_list.ts │ ├── contract_native_minter.ts │ ├── fee_manager.ts │ ├── reward_manager.ts │ ├── tx_allow_list.ts │ ├── utils.ts │ └── warp.ts └── tsconfig.json ├── core ├── README.md ├── TrieStressTest.abi ├── TrieStressTest.bin ├── TrieStressTest.sol ├── bench_test.go ├── block_validator.go ├── block_validator_test.go ├── blockchain.go ├── blockchain_ext.go ├── blockchain_iterator.go ├── blockchain_log_test.go ├── blockchain_reader.go ├── blockchain_repair_test.go ├── blockchain_sethead_test.go ├── blockchain_snapshot_test.go ├── blockchain_test.go ├── bloom_indexer.go ├── bloombits │ ├── doc.go │ ├── generator.go │ ├── generator_test.go │ ├── matcher.go │ ├── matcher_test.go │ ├── scheduler.go │ └── scheduler_test.go ├── bounded_buffer.go ├── chain_indexer.go ├── chain_indexer_test.go ├── chain_makers.go ├── chain_makers_test.go ├── error.go ├── events.go ├── evm.go ├── extstate │ ├── statedb.go │ └── test_statedb.go ├── fifo_cache.go ├── gaspool.go ├── gen_genesis.go ├── genesis.go ├── genesis_extra_test.go ├── genesis_test.go ├── headerchain.go ├── headerchain_test.go ├── main_test.go ├── mkalloc.go ├── predicate_check.go ├── predicate_check_test.go ├── rlp_test.go ├── sender_cacher.go ├── state │ ├── database.go │ ├── dump.go │ ├── pruner │ │ ├── bloom.go │ │ └── pruner.go │ ├── snapshot │ │ ├── context.go │ │ ├── conversion.go │ │ ├── difflayer.go │ │ ├── difflayer_test.go │ │ ├── disklayer.go │ │ ├── disklayer_test.go │ │ ├── generate.go │ │ ├── generate_test.go │ │ ├── iterator.go │ │ ├── iterator_binary.go │ │ ├── iterator_fast.go │ │ ├── iterator_test.go │ │ ├── journal.go │ │ ├── snapshot.go │ │ ├── snapshot_ext.go │ │ ├── snapshot_test.go │ │ ├── utils.go │ │ ├── wipe.go │ │ └── wipe_test.go │ ├── state_test.go │ ├── statedb.go │ └── trie_prefetcher_extra_test.go ├── state_manager.go ├── state_manager_test.go ├── state_processor.go ├── state_processor_ext.go ├── state_processor_ext_test.go ├── state_processor_test.go ├── state_transition.go ├── test_blockchain.go ├── trie_stress_bench_test.go ├── txindexer.go ├── txindexer_test.go ├── txpool │ ├── blobpool │ │ ├── blobpool.go │ │ ├── blobpool_test.go │ │ ├── config.go │ │ ├── evictheap.go │ │ ├── evictheap_test.go │ │ ├── interface.go │ │ ├── limbo.go │ │ ├── metrics.go │ │ ├── priority.go │ │ ├── priority_test.go │ │ ├── slotter.go │ │ └── slotter_test.go │ ├── errors.go │ ├── legacypool │ │ ├── journal.go │ │ ├── legacypool.go │ │ ├── legacypool2_test.go │ │ ├── legacypool_test.go │ │ ├── list.go │ │ ├── list_test.go │ │ └── noncer.go │ ├── subpool.go │ ├── txpool.go │ └── validation.go ├── types.go └── vm │ ├── runtime │ ├── doc.go │ ├── env.go │ ├── runtime.go │ ├── runtime_example_test.go │ └── runtime_test.go │ └── testdata │ ├── precompiles │ ├── blake2F.json │ ├── blsG1Add.json │ ├── blsG1Mul.json │ ├── blsG1MultiExp.json │ ├── blsG2Add.json │ ├── blsG2Mul.json │ ├── blsG2MultiExp.json │ ├── blsMapG1.json │ ├── blsMapG2.json │ ├── blsPairing.json │ ├── bn256Add.json │ ├── bn256Pairing.json │ ├── bn256ScalarMul.json │ ├── ecRecover.json │ ├── fail-blake2f.json │ ├── fail-blsG1Add.json │ ├── fail-blsG1Mul.json │ ├── fail-blsG1MultiExp.json │ ├── fail-blsG2Add.json │ ├── fail-blsG2Mul.json │ ├── fail-blsG2MultiExp.json │ ├── fail-blsMapG1.json │ ├── fail-blsMapG2.json │ ├── fail-blsPairing.json │ ├── modexp.json │ ├── modexp_eip2565.json │ └── pointEvaluation.json │ ├── testcases_add.json │ ├── testcases_and.json │ ├── testcases_byte.json │ ├── testcases_div.json │ ├── testcases_eq.json │ ├── testcases_exp.json │ ├── testcases_gt.json │ ├── testcases_lt.json │ ├── testcases_mod.json │ ├── testcases_mul.json │ ├── testcases_or.json │ ├── testcases_sar.json │ ├── testcases_sdiv.json │ ├── testcases_sgt.json │ ├── testcases_shl.json │ ├── testcases_shr.json │ ├── testcases_signext.json │ ├── testcases_slt.json │ ├── testcases_smod.json │ ├── testcases_sub.json │ └── testcases_xor.json ├── coreth-version.txt ├── docs ├── audits │ ├── Avalanche Warp Messaging - OpenZeppelin (November 16th 2023).pdf │ ├── Bridge Smart Contracts - Least Authority (July 7th 2023).pdf │ └── Subnet EVM - Least Authority (April 3rd 2023).pdf └── releasing │ └── README.md ├── eth ├── api.go ├── api_admin.go ├── api_backend.go ├── api_backend_test.go ├── api_debug.go ├── api_debug_test.go ├── backend.go ├── bloombits.go ├── chain_with_final_block.go ├── ethconfig │ ├── config.go │ └── gen_config.go ├── filters │ ├── api.go │ ├── api_test.go │ ├── bench_test.go │ ├── filter.go │ ├── filter_system.go │ ├── filter_system_test.go │ └── filter_test.go ├── gasestimator │ └── gasestimator.go ├── gasprice │ ├── fee_info_provider.go │ ├── fee_info_provider_test.go │ ├── feehistory.go │ ├── feehistory_test.go │ ├── gasprice.go │ └── gasprice_test.go ├── state_accessor.go └── tracers │ ├── api.go │ ├── api_extra_test.go │ ├── api_test.go │ ├── tracers.go │ ├── tracers_test.go │ ├── tracker.go │ └── tracker_test.go ├── ethclient ├── client_interface_test.go ├── ethclient.go ├── signer.go ├── simulated │ ├── backend.go │ ├── backend_test.go │ ├── options.go │ └── options_test.go └── subnetevmclient │ └── subnet_evm_client.go ├── examples └── sign-uptime-message │ └── main.go ├── go.mod ├── go.sum ├── interfaces └── interfaces.go ├── internal ├── blocktest │ └── test_hash.go ├── cmdtest │ └── test_cmd.go ├── debug │ ├── api.go │ ├── flags.go │ ├── loudpanic.go │ └── trace.go ├── ethapi │ ├── addrlock.go │ ├── api.go │ ├── api_extra.go │ ├── api_extra_test.go │ ├── api_test.go │ ├── backend.go │ ├── errors.go │ ├── mocks_generate_test.go │ ├── mocks_test.go │ ├── testdata │ │ ├── eth_getBlockByHash-hash-1.json │ │ ├── eth_getBlockByHash-hash-empty-fullTx.json │ │ ├── eth_getBlockByHash-hash-genesis.json │ │ ├── eth_getBlockByHash-hash-latest-1-fullTx.json │ │ ├── eth_getBlockByHash-hash-latest.json │ │ ├── eth_getBlockByHash-hash-pending-fullTx.json │ │ ├── eth_getBlockByHash-hash-pending.json │ │ ├── eth_getBlockByNumber-number-0.json │ │ ├── eth_getBlockByNumber-number-1.json │ │ ├── eth_getBlockByNumber-number-latest+1.json │ │ ├── eth_getBlockByNumber-number-latest-1.json │ │ ├── eth_getBlockByNumber-tag-latest.json │ │ ├── eth_getBlockByNumber-tag-pending-fullTx.json │ │ ├── eth_getBlockByNumber-tag-pending.json │ │ ├── eth_getBlockReceipts-block-notfound.json │ │ ├── eth_getBlockReceipts-block-with-blob-tx.json │ │ ├── eth_getBlockReceipts-block-with-contract-create-tx.json │ │ ├── eth_getBlockReceipts-block-with-dynamic-fee-tx.json │ │ ├── eth_getBlockReceipts-block-with-legacy-contract-call-tx.json │ │ ├── eth_getBlockReceipts-block-with-legacy-transfer-tx.json │ │ ├── eth_getBlockReceipts-hash-empty.json │ │ ├── eth_getBlockReceipts-hash-notfound.json │ │ ├── eth_getBlockReceipts-number-0.json │ │ ├── eth_getBlockReceipts-number-1.json │ │ ├── eth_getBlockReceipts-tag-earliest.json │ │ ├── eth_getBlockReceipts-tag-latest.json │ │ ├── eth_getHeaderByHash-hash-0.json │ │ ├── eth_getHeaderByHash-hash-1.json │ │ ├── eth_getHeaderByHash-hash-empty.json │ │ ├── eth_getHeaderByHash-hash-latest-1.json │ │ ├── eth_getHeaderByHash-hash-latest.json │ │ ├── eth_getHeaderByHash-hash-pending.json │ │ ├── eth_getHeaderByNumber-number-0.json │ │ ├── eth_getHeaderByNumber-number-1.json │ │ ├── eth_getHeaderByNumber-number-latest+1.json │ │ ├── eth_getHeaderByNumber-number-latest-1.json │ │ ├── eth_getHeaderByNumber-tag-latest.json │ │ ├── eth_getHeaderByNumber-tag-pending.json │ │ ├── eth_getTransactionReceipt-blob-tx.json │ │ ├── eth_getTransactionReceipt-create-contract-tx.json │ │ ├── eth_getTransactionReceipt-create-contract-with-access-list.json │ │ ├── eth_getTransactionReceipt-dynamic-tx-with-logs.json │ │ ├── eth_getTransactionReceipt-normal-transfer-tx.json │ │ ├── eth_getTransactionReceipt-txhash-empty.json │ │ ├── eth_getTransactionReceipt-txhash-notfound.json │ │ └── eth_getTransactionReceipt-with-logs.json │ ├── transaction_args.go │ └── transaction_args_test.go ├── flags │ ├── categories.go │ ├── flags.go │ ├── flags_test.go │ └── helpers.go ├── reexec │ ├── reexec.go │ ├── self_linux.go │ └── self_others.go ├── shutdowncheck │ └── shutdown_tracker.go ├── testutils │ ├── key.go │ └── metrics.go └── version │ ├── vcs.go │ └── version.go ├── log ├── format.go ├── handler.go └── logger.go ├── metrics └── prometheus │ ├── interfaces.go │ ├── prometheus.go │ └── prometheus_test.go ├── miner ├── README.md ├── miner.go ├── ordering.go ├── ordering_test.go └── worker.go ├── node ├── api.go ├── config.go ├── defaults.go ├── errors.go └── node.go ├── params ├── config.go ├── config_extra.go ├── config_libevm.go ├── config_test.go ├── denomination.go ├── extras │ ├── config.go │ ├── config_extra_test.go │ ├── config_test.go │ ├── network_upgrades.go │ ├── network_upgrades_test.go │ ├── precompile_config_test.go │ ├── precompile_upgrade.go │ ├── precompile_upgrade_test.go │ ├── precompiles.go │ ├── rules.go │ ├── state_upgrade.go │ └── state_upgrade_test.go ├── hooks_libevm.go ├── network_params.go ├── protocol_params_test.go └── version.go ├── peer ├── README.md ├── client.go ├── network.go ├── network_test.go ├── peer_tracker.go ├── peer_tracker_test.go ├── peertest │ └── request_id.go ├── stats │ └── stats.go └── waiting_handler.go ├── plugin ├── evm │ ├── ExampleWarp.abi │ ├── ExampleWarp.bin │ ├── README.md │ ├── admin.go │ ├── api.go │ ├── block.go │ ├── block_builder.go │ ├── block_test.go │ ├── block_verification.go │ ├── blockgascost │ │ ├── cost.go │ │ └── cost_test.go │ ├── client │ │ └── client.go │ ├── config.go │ ├── config │ │ ├── config.go │ │ └── config_test.go │ ├── customrawdb │ │ ├── accessors_metadata_ext.go │ │ ├── accessors_snapshot_ext.go │ │ ├── accessors_state_sync.go │ │ ├── accessors_state_sync_test.go │ │ ├── database_ext.go │ │ ├── database_ext_test.go │ │ └── schema_ext.go │ ├── customtypes │ │ ├── block_ext.go │ │ ├── block_ext_test.go │ │ ├── block_test.go │ │ ├── gen_header_serializable_json.go │ │ ├── gen_header_serializable_rlp.go │ │ ├── hashing.go │ │ ├── hashing_test.go │ │ ├── header_ext.go │ │ ├── header_ext_test.go │ │ ├── libevm.go │ │ ├── log_ext.go │ │ ├── rlp_fuzzer_test.go │ │ └── types_test.go │ ├── database │ │ └── wrapped_database.go │ ├── factory.go │ ├── gossip.go │ ├── gossip_test.go │ ├── gossiper_eth_gossiping_test.go │ ├── header │ │ ├── base_fee.go │ │ ├── base_fee_test.go │ │ ├── block_gas_cost.go │ │ ├── block_gas_cost_test.go │ │ ├── dynamic_fee_windower.go │ │ ├── dynamic_fee_windower_test.go │ │ ├── extra.go │ │ ├── extra_test.go │ │ ├── gas_limit.go │ │ └── gas_limit_test.go │ ├── health.go │ ├── imports_test.go │ ├── log.go │ ├── log_test.go │ ├── message │ │ ├── block_request.go │ │ ├── block_request_test.go │ │ ├── code_request.go │ │ ├── code_request_test.go │ │ ├── codec.go │ │ ├── handler.go │ │ ├── leafs_request.go │ │ ├── leafs_request_test.go │ │ ├── request.go │ │ ├── signature_request.go │ │ ├── signature_request_test.go │ │ └── syncable.go │ ├── network_handler.go │ ├── service.go │ ├── service.md │ ├── static_service.go │ ├── static_service_test.go │ ├── status.go │ ├── syncervm_client.go │ ├── syncervm_server.go │ ├── syncervm_test.go │ ├── tx_gossip_test.go │ ├── upgrade │ │ ├── legacy │ │ │ └── params.go │ │ └── subnetevm │ │ │ ├── window.go │ │ │ └── window_test.go │ ├── validators.go │ ├── validators │ │ ├── README.md │ │ ├── interfaces │ │ │ └── interfaces.go │ │ ├── locked_reader.go │ │ ├── manager.go │ │ ├── manager_test.go │ │ ├── state │ │ │ ├── codec.go │ │ │ ├── interfaces │ │ │ │ ├── mock_listener.go │ │ │ │ ├── mocks_generate_test.go │ │ │ │ └── state.go │ │ │ ├── state.go │ │ │ └── state_test.go │ │ └── uptime │ │ │ ├── interfaces │ │ │ └── interface.go │ │ │ ├── pausable_manager.go │ │ │ └── pausable_manager_test.go │ ├── version.go │ ├── version_test.go │ ├── vm.go │ ├── vm_database.go │ ├── vm_test.go │ ├── vm_upgrade_bytes_test.go │ ├── vm_validators_test.go │ ├── vm_warp_test.go │ └── vmerrors │ │ └── errors.go ├── main.go └── runner │ ├── keys.go │ ├── params.go │ └── runner.go ├── precompile ├── allowlist │ ├── allowlist.abi │ ├── allowlist.go │ ├── allowlist_test.go │ ├── config.go │ ├── config_test.go │ ├── event.go │ ├── role.go │ ├── role_test.go │ ├── test_allowlist.go │ ├── test_allowlist_config.go │ └── unpack_pack_test.go ├── contract │ ├── contract.go │ ├── interfaces.go │ ├── mocks.go │ ├── mocks_generate_test.go │ ├── test_utils.go │ ├── utils.go │ └── utils_test.go ├── contracts │ ├── deployerallowlist │ │ ├── config.go │ │ ├── config_test.go │ │ ├── contract.go │ │ ├── contract_test.go │ │ └── module.go │ ├── feemanager │ │ ├── config.go │ │ ├── config_test.go │ │ ├── contract.abi │ │ ├── contract.go │ │ ├── contract_test.go │ │ ├── event.go │ │ ├── module.go │ │ └── unpack_pack_test.go │ ├── nativeminter │ │ ├── config.go │ │ ├── config_test.go │ │ ├── contract.abi │ │ ├── contract.go │ │ ├── contract_test.go │ │ ├── event.go │ │ ├── module.go │ │ └── unpack_pack_test.go │ ├── rewardmanager │ │ ├── config.go │ │ ├── config_test.go │ │ ├── contract.abi │ │ ├── contract.go │ │ ├── contract_test.go │ │ ├── event.go │ │ └── module.go │ ├── txallowlist │ │ ├── config.go │ │ ├── config_test.go │ │ ├── contract.go │ │ ├── contract_test.go │ │ └── module.go │ └── warp │ │ ├── README.md │ │ ├── config.go │ │ ├── config_test.go │ │ ├── contract.abi │ │ ├── contract.go │ │ ├── contract_test.go │ │ ├── contract_warp_handler.go │ │ ├── module.go │ │ ├── predicate_test.go │ │ └── signature_verification_test.go ├── modules │ ├── module.go │ ├── registerer.go │ └── registerer_test.go ├── precompileconfig │ ├── config.go │ ├── mocks.go │ ├── mocks_generate_test.go │ └── upgradeable.go ├── registry │ └── registry.go └── testutils │ ├── test_config.go │ ├── test_precompile.go │ └── test_predicate.go ├── predicate ├── Predicate.md ├── Results.md ├── predicate_bytes.go ├── predicate_bytes_test.go ├── predicate_results.go ├── predicate_results_test.go ├── predicate_slots.go └── predicate_tx.go ├── rpc ├── client.go ├── client_opt.go ├── client_opt_test.go ├── client_test.go ├── context_headers.go ├── doc.go ├── errors.go ├── handler.go ├── http.go ├── http_test.go ├── inproc.go ├── json.go ├── metrics.go ├── server.go ├── server_test.go ├── service.go ├── subscription.go ├── subscription_test.go ├── testdata │ ├── internal-error.js │ ├── invalid-badid.js │ ├── invalid-badversion.js │ ├── invalid-batch-toolarge.js │ ├── invalid-batch.js │ ├── invalid-idonly.js │ ├── invalid-nonobj.js │ ├── invalid-syntax.json │ ├── reqresp-batch.js │ ├── reqresp-echo.js │ ├── reqresp-namedparam.js │ ├── reqresp-noargsrets.js │ ├── reqresp-nomethod.js │ ├── reqresp-noparam.js │ ├── reqresp-paramsnull.js │ ├── revcall.js │ ├── revcall2.js │ └── subscription.js ├── testservice_test.go ├── types.go ├── types_test.go ├── websocket.go └── websocket_test.go ├── scripts ├── actionlint.sh ├── avalanche_header.txt ├── build.sh ├── build_antithesis_images.sh ├── build_antithesis_workload.sh ├── build_bench_precompiles.sh ├── build_docker_image.sh ├── build_test.sh ├── constants.sh ├── coverage.sh ├── dev_shell.sh ├── diff_against.sh ├── eth-allowed-packages.txt ├── format_add_avalanche_header.sh ├── format_as_fork.sh ├── format_as_upstream.sh ├── generate_precompile.sh ├── install_avalanchego_release.sh ├── known_flakes.txt ├── lib_avalanchego_clone.sh ├── lint_allowed_eth_imports.sh ├── run.sh ├── run_ginkgo_load.sh ├── run_ginkgo_precompile.sh ├── run_ginkgo_warp.sh ├── run_simulator.sh ├── shellcheck.sh ├── tests.build_antithesis_images.sh ├── tests.build_docker_image.sh └── update_avalanchego_version.sh ├── signer └── core │ └── apitypes │ └── types.go ├── stateupgrade ├── interfaces.go └── state_upgrade.go ├── sync ├── README.md ├── client │ ├── client.go │ ├── client_test.go │ ├── leaf_syncer.go │ ├── mock_client.go │ ├── mock_network.go │ └── stats │ │ └── stats.go ├── handlers │ ├── block_request.go │ ├── block_request_test.go │ ├── code_request.go │ ├── code_request_test.go │ ├── handler.go │ ├── leafs_request.go │ ├── leafs_request_test.go │ ├── stats │ │ ├── mock_stats.go │ │ └── stats.go │ └── test_providers.go ├── statesync │ ├── code_syncer.go │ ├── code_syncer_test.go │ ├── state_syncer.go │ ├── sync_helpers.go │ ├── sync_test.go │ ├── test_sync.go │ ├── trie_queue.go │ ├── trie_segments.go │ ├── trie_sync_stats.go │ ├── trie_sync_stats_test.go │ └── trie_sync_tasks.go └── syncutils │ ├── iterators.go │ └── test_trie.go ├── tests ├── README.md ├── antithesis │ ├── Dockerfile.config │ ├── Dockerfile.node │ ├── Dockerfile.workload │ ├── README.md │ ├── gencomposeconfig │ │ └── main.go │ └── main.go ├── gen_stenv.go ├── gen_sttransaction.go ├── init.go ├── load │ ├── genesis │ │ └── genesis.json │ └── load_test.go ├── precompile │ ├── genesis │ │ ├── contract_deployer_allow_list.json │ │ ├── contract_native_minter.json │ │ ├── fee_manager.json │ │ ├── reward_manager.json │ │ ├── tx_allow_list.json │ │ └── warp.json │ ├── precompile_test.go │ └── solidity │ │ └── suites.go ├── rlp_test_util.go ├── state_test_util.go ├── utils │ ├── command.go │ ├── constants.go │ ├── proposervm.go │ ├── subnet.go │ └── tmpnet.go └── warp │ └── warp_test.go ├── tools.go ├── triedb ├── hashdb │ └── database.go └── pathdb │ ├── database.go │ ├── database_test.go │ ├── difflayer.go │ ├── difflayer_test.go │ ├── disklayer.go │ ├── errors.go │ ├── history.go │ ├── history_test.go │ ├── journal.go │ ├── layertree.go │ ├── metrics.go │ ├── nodebuffer.go │ └── testutils.go ├── utils ├── address_range.go ├── bounded_workers.go ├── bytes.go ├── bytes_test.go ├── denomination.go ├── metered_cache.go ├── numbers.go ├── numbers_test.go └── snow.go └── warp ├── aggregator ├── aggregator.go ├── aggregator_test.go ├── mock_signature_getter.go ├── mocks_generate_test.go └── signature_getter.go ├── backend.go ├── backend_test.go ├── client.go ├── fetcher.go ├── handlers ├── signature_request.go ├── signature_request_test.go └── stats.go ├── messages ├── codec.go ├── payload.go └── validator_uptime.go ├── service.go ├── validators ├── state.go └── state_test.go ├── verifier_backend.go ├── verifier_backend_test.go ├── verifier_stats.go └── warptest ├── block_client.go └── noop_validator_reader.go /.dockerignore: -------------------------------------------------------------------------------- 1 | .ci 2 | .github 3 | .gitignore 4 | .golangci.yml 5 | .idea 6 | .vscode 7 | 8 | LICENSE 9 | *.md 10 | -------------------------------------------------------------------------------- /.envrc: -------------------------------------------------------------------------------- 1 | # - Will execute on entry to the containing directory only if authorized with `direnv allow` 2 | # - Requires a recent version of direnv (https://direnv.net/) 3 | # - For quieter direnv output, set `export DIRENV_LOG_FORMAT=` 4 | 5 | # Determine AVALANCHE_VERSION 6 | source ./scripts/constants.sh 7 | 8 | # - Starts an avalanchego dev shell 9 | # - Requires nix (https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file#install-nix) 10 | use flake "github:ava-labs/avalanchego?ref=${AVALANCHE_VERSION}" 11 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Each line is a file pattern followed by one or more owners. 2 | 3 | # These owners will be the default code owners for everything in the repo. 4 | 5 | # Unless a later match takes precedence, these owners will be requested for 6 | 7 | # review whenever someone opens a pull request. 8 | 9 | * @ava-labs/platform-evm 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior. 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Screenshots** 20 | If applicable, add screenshots to help explain your problem. 21 | 22 | **Logs** 23 | If applicable, please include the relevant logs that indicate a problem and/or the log directory of your node. By default, this can be found at `~/.avalanchego/logs/`. 24 | 25 | **Metrics** 26 | If applicable, please include any metrics gathered from your node to assist us in diagnosing the problem. 27 | 28 | **Operating System** 29 | Which OS you used to reveal the bug. 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | 34 | Avalanche Bug Bounty program can be found [here](https://hackenproof.com/avalanche/avalanche-protocol). 35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_spec.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature specification 3 | about: Discussion on design and implementation of new features for subnet-evm. 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Context and scope** 11 | Include a short description of the context and scope of the suggested feature. 12 | Include goals the change will accomplish if relevant. 13 | 14 | **Discussion and alternatives** 15 | Include a description of the changes to be made to the code along with alternatives 16 | that were considered, including pro/con analysis where relevant. 17 | 18 | **Open questions** 19 | Questions that are still being discussed. -------------------------------------------------------------------------------- /.github/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior. 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Screenshots** 20 | If applicable, add screenshots to help explain your problem. 21 | 22 | **Logs** 23 | If applicable, please include the relevant logs that indicate a problem and/or the log directory of your node. By default, this can be found at `~/.avalanchego/logs/`. 24 | 25 | **Metrics** 26 | If applicable, please include any metrics gathered from your node to assist us in diagnosing the problem. 27 | 28 | **Operating System** 29 | Which OS you used to reveal the bug. 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Why this should be merged 2 | 3 | ## How this works 4 | 5 | ## How this was tested 6 | 7 | ## Need to be documented? 8 | 9 | ## Need to update RELEASES.md? 10 | -------------------------------------------------------------------------------- /.github/workflows/bench.yml: -------------------------------------------------------------------------------- 1 | name: Bench 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | merge_group: 7 | types: [checks_requested] 8 | 9 | jobs: 10 | bench: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v4 14 | - uses: actions/setup-go@v5 15 | with: 16 | go-version-file: "go.mod" 17 | - run: go mod download 18 | shell: bash 19 | - run: ./scripts/build_bench_precompiles.sh 20 | shell: bash 21 | -------------------------------------------------------------------------------- /.github/workflows/notify-metrics-availability.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | # Timestamps are in seconds 6 | from_timestamp="$(date '+%s')" 7 | monitoring_period=900 # 15 minutes 8 | to_timestamp="$((from_timestamp + monitoring_period))" 9 | 10 | # Grafana expects microseconds, so pad timestamps with 3 zeros 11 | metrics_url="${GRAFANA_URL}&var-filter=gh_job_id%7C%3D%7C${GH_JOB_ID}&from=${from_timestamp}000&to=${to_timestamp}000" 12 | 13 | # Optionally ensure that the link displays metrics only for the shared 14 | # network rather than mixing it with the results for private networks. 15 | if [[ -n "${FILTER_BY_OWNER:-}" ]]; then 16 | metrics_url="${metrics_url}&var-filter=network_owner%7C%3D%7C${FILTER_BY_OWNER}" 17 | fi 18 | 19 | echo "::notice links::metrics ${metrics_url}" 20 | -------------------------------------------------------------------------------- /.github/workflows/publish_antithesis_images.yml: -------------------------------------------------------------------------------- 1 | name: Publish Antithesis Images 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - master 8 | 9 | env: 10 | REGISTRY: us-central1-docker.pkg.dev 11 | REPOSITORY: molten-verve-216720/avalanche-repository 12 | 13 | jobs: 14 | antithesis: 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - name: Checkout Repository 19 | uses: actions/checkout@v4 20 | 21 | - name: Login to GAR 22 | uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 #v3.4.0 23 | with: 24 | registry: ${{ env.REGISTRY }} 25 | username: _json_key 26 | password: ${{ secrets.ANTITHESIS_GAR_JSON_KEY }} 27 | 28 | - name: Build and publish images 29 | run: bash -x ./scripts/build_antithesis_images.sh 30 | env: 31 | IMAGE_PREFIX: ${{ env.REGISTRY }}/${{ env.REPOSITORY }} 32 | IMAGE_TAG: latest 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ./main 2 | 3 | *.log 4 | *~ 5 | .DS_Store 6 | 7 | awscpu 8 | 9 | # Binaries for programs and plugins 10 | *.exe 11 | *.exe~ 12 | *.dll 13 | *.so 14 | *.dylib 15 | *.profile 16 | 17 | # Test binary, build with `go test -c` 18 | *.test 19 | 20 | # Output of the go coverage tool, specifically when used with LiteIDE 21 | *.out 22 | 23 | # ignore GoLand metafiles directory 24 | .idea/ 25 | 26 | *logs/ 27 | 28 | .vscode* 29 | workspace.code-workspace 30 | 31 | *.pb* 32 | 33 | *cpu[0-9]* 34 | *mem[0-9]* 35 | *lock[0-9]* 36 | *.profile 37 | *.swp 38 | *.aux 39 | *.fdb* 40 | *.fls 41 | *.gz 42 | *.pdf 43 | 44 | .coverage 45 | 46 | bin/ 47 | build/ 48 | 49 | cmd/evm/evm 50 | cmd/simulator/.simulator/* 51 | cmd/simulator/simulator 52 | 53 | # goreleaser 54 | dist/ 55 | 56 | # Outputs of `scripts/diff_against.sh` 57 | diffs/ 58 | 59 | # clone used for antithesis image builds 60 | avalanchego/ 61 | 62 | .direnv 63 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | # This file configures github.com/golangci/golangci-lint. 2 | 3 | run: 4 | timeout: 10m 5 | tests: true 6 | 7 | linters: 8 | disable-all: true 9 | enable: 10 | - goimports 11 | - gosimple 12 | - govet 13 | - ineffassign 14 | - misspell 15 | - unconvert 16 | - typecheck 17 | - unused 18 | # - staticcheck 19 | - bidichk 20 | - durationcheck 21 | - copyloopvar 22 | - whitespace 23 | # - revive # only certain checks enabled 24 | - durationcheck 25 | - gocheckcompilerdirectives 26 | - reassign 27 | - mirror 28 | - tenv 29 | 30 | linters-settings: 31 | gofmt: 32 | simplify: true 33 | goconst: 34 | min-len: 3 # minimum length of string constant 35 | min-occurrences: 6 # minimum number of occurrences 36 | ignore-tests: true 37 | -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | # ref. https://goreleaser.com/customization/build/ 3 | builds: 4 | - id: subnet-evm 5 | main: ./plugin 6 | binary: subnet-evm 7 | flags: 8 | - -v 9 | ldflags: -X github.com/ava-labs/subnet-evm/plugin/evm.Version=v{{.Version}} 10 | goos: 11 | - linux 12 | - darwin 13 | goarch: 14 | - amd64 15 | - arm64 16 | env: 17 | - CGO_ENABLED=1 18 | - CGO_CFLAGS=-O -D__BLST_PORTABLE__ # Set the CGO flags to use the portable version of BLST 19 | overrides: 20 | - goos: linux 21 | goarch: arm64 22 | goarm64: v8.0 23 | env: 24 | - CC=aarch64-linux-gnu-gcc 25 | - goos: darwin 26 | goarch: arm64 27 | goarm64: v8.0 28 | env: 29 | - CC=oa64-clang 30 | - goos: darwin 31 | goarch: amd64 32 | goamd64: v1 33 | env: 34 | - CC=o64-clang 35 | release: 36 | # Repo in which the release will be created. 37 | # Default is extracted from the origin remote URL or empty if its private hosted. 38 | github: 39 | owner: ava-labs 40 | name: subnet-evm 41 | 42 | git: 43 | # Avoid picking the wrong tag when there is an RC tag and a non-RC tag 44 | # pointing to the same commit. 45 | prerelease_suffix: "-rc" 46 | -------------------------------------------------------------------------------- /.markdownlint.json: -------------------------------------------------------------------------------- 1 | { 2 | "MD041": false, 3 | "MD013": false, 4 | "MD033": false 5 | } -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | Avalanche takes the security of the platform and of its users very seriously. We and our community recognize the critical role of external security researchers and developers and welcome 4 | responsible disclosures. Valid reports will be eligible for a reward (terms and conditions apply). 5 | 6 | ## Reporting a Vulnerability 7 | 8 | **Please do not file a public ticket** mentioning the vulnerability. To disclose a vulnerability submit it through our [Bug Bounty Program](https://hackenproof.com/avalanche). 9 | 10 | Vulnerabilities must be disclosed to us privately with reasonable time to respond, and avoid compromise of other users and accounts, or loss of funds that are not your own. We do not reward spam or 11 | social engineering vulnerabilities. 12 | 13 | Do not test for or validate any security issues in the live Avalanche networks (Mainnet and Fuji testnet), confirm all exploits in a local private testnet. 14 | 15 | Please refer to the [Bug Bounty Page](https://hackenproof.com/avalanche) for the most up-to-date program rules and scope. 16 | 17 | ## Supported Versions 18 | 19 | Please use the [most recently released version](https://github.com/ava-labs/subnet-evm/releases/latest) to perform testing and to validate security issues. 20 | -------------------------------------------------------------------------------- /bin/ginkgo: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | # Ensure the go command is run from the root of the repository so that its go.mod file is used 6 | REPO_ROOT=$(cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) 7 | cd "${REPO_ROOT}" 8 | 9 | # If an explicit version is not specified, go run uses the ginkgo version from go.mod 10 | go run github.com/onsi/ginkgo/v2/ginkgo "${@}" 11 | -------------------------------------------------------------------------------- /bin/tmpnetctl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | # Ensure the go command is run from the root of the repository 6 | REPO_ROOT=$(cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) 7 | cd "${REPO_ROOT}" 8 | 9 | # Set AVALANCHE_VERSION 10 | . ./scripts/versions.sh 11 | 12 | echo "Running tmpnetctl @ ${AVALANCHE_VERSION}" 13 | go run github.com/ava-labs/avalanchego/tests/fixture/tmpnet/tmpnetctl@"${AVALANCHE_VERSION}" "${@}" 14 | -------------------------------------------------------------------------------- /cmd/abigen/namefilter_test.go: -------------------------------------------------------------------------------- 1 | // (c) 2023, Ava Labs, Inc. 2 | // 3 | // This file is a derived work, based on the go-ethereum library whose original 4 | // notices appear below. 5 | // 6 | // It is distributed under a license compatible with the licensing terms of the 7 | // original code from which it is derived. 8 | // 9 | // Much love to the original authors for their work. 10 | package main 11 | 12 | import ( 13 | "testing" 14 | 15 | "github.com/stretchr/testify/assert" 16 | "github.com/stretchr/testify/require" 17 | ) 18 | 19 | func TestNameFilter(t *testing.T) { 20 | t.Parallel() 21 | _, err := newNameFilter("Foo") 22 | require.Error(t, err) 23 | _, err = newNameFilter("too/many:colons:Foo") 24 | require.Error(t, err) 25 | 26 | f, err := newNameFilter("a/path:A", "*:B", "c/path:*") 27 | require.NoError(t, err) 28 | 29 | for _, tt := range []struct { 30 | name string 31 | match bool 32 | }{ 33 | {"a/path:A", true}, 34 | {"unknown/path:A", false}, 35 | {"a/path:X", false}, 36 | {"unknown/path:X", false}, 37 | {"any/path:B", true}, 38 | {"c/path:X", true}, 39 | {"c/path:foo:B", false}, 40 | } { 41 | match := f.Matches(tt.name) 42 | if tt.match { 43 | assert.True(t, match, "expected match") 44 | } else { 45 | assert.False(t, match, "expected no match") 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /cmd/evm/testdata/1/alloc.json: -------------------------------------------------------------------------------- 1 | { 2 | "a94f5374fce5edbc8e2a8697c15331677e6ebf0b": { 3 | "balance": "0x5ffd4878be161d74", 4 | "code": "0x", 5 | "nonce": "0xac", 6 | "storage": {} 7 | }, 8 | "0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192":{ 9 | "balance": "0xfeedbead", 10 | "nonce" : "0x00" 11 | } 12 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/1/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "currentCoinbase": "0xc94f5374fce5edbc8e2a8697c15331677e6ebf0b", 3 | "currentDifficulty": "0x20000", 4 | "currentGasLimit": "0x750a163df65e8a", 5 | "currentNumber": "1", 6 | "currentTimestamp": "1000" 7 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/1/txs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "gas": "0x5208", 4 | "gasPrice": "0x2", 5 | "hash": "0x0557bacce3375c98d806609b8d5043072f0b6a8bae45ae5a67a00d3a1a18d673", 6 | "input": "0x", 7 | "nonce": "0x0", 8 | "r": "0x9500e8ba27d3c33ca7764e107410f44cbd8c19794bde214d694683a7aa998cdb", 9 | "s": "0x7235ae07e4bd6e0206d102b1f8979d6adab280466b6a82d2208ee08951f1f600", 10 | "to": "0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192", 11 | "v": "0x1b", 12 | "value": "0x1" 13 | }, 14 | { 15 | "gas": "0x5208", 16 | "gasPrice": "0x2", 17 | "hash": "0x0557bacce3375c98d806609b8d5043072f0b6a8bae45ae5a67a00d3a1a18d673", 18 | "input": "0x", 19 | "nonce": "0x0", 20 | "r": "0x9500e8ba27d3c33ca7764e107410f44cbd8c19794bde214d694683a7aa998cdb", 21 | "s": "0x7235ae07e4bd6e0206d102b1f8979d6adab280466b6a82d2208ee08951f1f600", 22 | "to": "0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192", 23 | "v": "0x1b", 24 | "value": "0x1" 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /cmd/evm/testdata/13/alloc.json: -------------------------------------------------------------------------------- 1 | { 2 | "0x1111111111111111111111111111111111111111" : { 3 | "balance" : "0x010000000000", 4 | "code" : "0xfe", 5 | "nonce" : "0x01", 6 | "storage" : { 7 | } 8 | }, 9 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 10 | "balance" : "0x010000000000", 11 | "code" : "0x", 12 | "nonce" : "0x01", 13 | "storage" : { 14 | } 15 | }, 16 | "0xd02d72e067e77158444ef2020ff2d325f929b363" : { 17 | "balance" : "0x01000000000000", 18 | "code" : "0x", 19 | "nonce" : "0x01", 20 | "storage" : { 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/13/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 3 | "currentDifficulty" : "0x020000", 4 | "currentNumber" : "0x01", 5 | "currentTimestamp" : "0x079e", 6 | "previousHash" : "0xcb23ee65a163121f640673b41788ee94633941405f95009999b502eedfbbfd4f", 7 | "currentGasLimit" : "0x40000000", 8 | "currentBaseFee" : "0x036b", 9 | "blockHashes" : { 10 | "0" : "0xcb23ee65a163121f640673b41788ee94633941405f95009999b502eedfbbfd4f" 11 | } 12 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/13/exp.json: -------------------------------------------------------------------------------- 1 | { 2 | "body": "0xf8d2b86702f864010180820fa08284d09411111111111111111111111111111111111111118080c001a0b7dfab36232379bb3d1497a4f91c1966b1f932eae3ade107bf5d723b9cb474e0a06261c359a10f2132f126d250485b90cf20f30340801244a08ef6142ab33d1904b86702f864010280820fa08284d09411111111111111111111111111111111111111118080c080a0d4ec563b6568cd42d998fc4134b36933c6568d01533b5adf08769270243c6c7fa072bf7c21eac6bbeae5143371eef26d5e279637f3bd73482b55979d76d935b1e9" 3 | } 4 | -------------------------------------------------------------------------------- /cmd/evm/testdata/13/exp2.json.diff: -------------------------------------------------------------------------------- 1 | State root differs because of SubnetEVM's fee calculations. 2 | 3 | --- a/cmd/evm/testdata/13/exp2.json 2023-08-25 07:34:20 4 | +++ b/cmd/evm/testdata/13/exp2.json 2023-08-24 14:17:32 5 | @@ -1,6 +1,6 @@ 6 | { 7 | "result": { 8 | - "stateRoot": "0xe4b924a6adb5959fccf769d5b7bb2f6359e26d1e76a2443c5a91a36d826aef61", 9 | + "stateRoot": "0x17228ad68f0ed80a362f0fe66b9307b96b115d57641f699931a0b7c3a04d1636", 10 | "txRoot": "0x013509c8563d41c0ae4bf38f2d6d19fc6512a1d0d6be045079c8c9f68bf45f9d", 11 | "receiptsRoot": "0xa532a08aa9f62431d6fe5d924951b8efb86ed3c54d06fee77788c3767dd13420", 12 | "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", 13 | -------------------------------------------------------------------------------- /cmd/evm/testdata/13/readme.md: -------------------------------------------------------------------------------- 1 | ## Input transactions in RLP form 2 | 3 | This testdata folder is used to exemplify how transaction input can be provided in rlp form. 4 | Please see the README in `evm` folder for how this is performed. -------------------------------------------------------------------------------- /cmd/evm/testdata/13/signed_txs.rlp: -------------------------------------------------------------------------------- 1 | "0xf8d2b86702f864010180820fa08284d09411111111111111111111111111111111111111118080c001a0b7dfab36232379bb3d1497a4f91c1966b1f932eae3ade107bf5d723b9cb474e0a06261c359a10f2132f126d250485b90cf20f30340801244a08ef6142ab33d1904b86702f864010280820fa08284d09411111111111111111111111111111111111111118080c080a0d4ec563b6568cd42d998fc4134b36933c6568d01533b5adf08769270243c6c7fa072bf7c21eac6bbeae5143371eef26d5e279637f3bd73482b55979d76d935b1e9" -------------------------------------------------------------------------------- /cmd/evm/testdata/13/txs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "input" : "0x", 4 | "gas" : "0x84d0", 5 | "nonce" : "0x1", 6 | "to" : "0x1111111111111111111111111111111111111111", 7 | "value" : "0x0", 8 | "v" : "0x0", 9 | "r" : "0x0", 10 | "s" : "0x0", 11 | "secretKey" : "0x41f6e321b31e72173f8ff2e292359e1862f24fba42fe6f97efaf641980eff298", 12 | "chainId" : "0x1", 13 | "type" : "0x2", 14 | "maxFeePerGas" : "0xfa0", 15 | "maxPriorityFeePerGas" : "0x0", 16 | "accessList" : [] 17 | }, 18 | { 19 | "input" : "0x", 20 | "gas" : "0x84d0", 21 | "nonce" : "0x2", 22 | "to" : "0x1111111111111111111111111111111111111111", 23 | "value" : "0x0", 24 | "v" : "0x0", 25 | "r" : "0x0", 26 | "s" : "0x0", 27 | "secretKey" : "0x41f6e321b31e72173f8ff2e292359e1862f24fba42fe6f97efaf641980eff298", 28 | "chainId" : "0x1", 29 | "type" : "0x2", 30 | "maxFeePerGas" : "0xfa0", 31 | "maxPriorityFeePerGas" : "0x0", 32 | "accessList" : [] 33 | } 34 | ] -------------------------------------------------------------------------------- /cmd/evm/testdata/14/alloc.json: -------------------------------------------------------------------------------- 1 | { 2 | "a94f5374fce5edbc8e2a8697c15331677e6ebf0b": { 3 | "balance": "0x5ffd4878be161d74", 4 | "code": "0x", 5 | "nonce": "0xac", 6 | "storage": {} 7 | }, 8 | "0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192":{ 9 | "balance": "0xfeedbead", 10 | "nonce" : "0x00" 11 | } 12 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/14/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "currentCoinbase": "0xc94f5374fce5edbc8e2a8697c15331677e6ebf0b", 3 | "currentGasLimit": "0x750a163df65e8a", 4 | "currentBaseFee": "0x500", 5 | "currentNumber": "12800000", 6 | "currentTimestamp": "100015", 7 | "parentTimestamp" : "99999", 8 | "parentDifficulty" : "0x2000000000000" 9 | } 10 | -------------------------------------------------------------------------------- /cmd/evm/testdata/14/env.uncles.json: -------------------------------------------------------------------------------- 1 | { 2 | "currentCoinbase": "0xc94f5374fce5edbc8e2a8697c15331677e6ebf0b", 3 | "currentGasLimit": "0x750a163df65e8a", 4 | "currentBaseFee": "0x500", 5 | "currentNumber": "12800000", 6 | "currentTimestamp": "100035", 7 | "parentTimestamp" : "99999", 8 | "parentDifficulty" : "0x2000000000000", 9 | "parentUncleHash" : "0x000000000000000000000000000000000000000000000000000000000000beef" 10 | } 11 | -------------------------------------------------------------------------------- /cmd/evm/testdata/14/exp.json: -------------------------------------------------------------------------------- 1 | { 2 | "result": { 3 | "stateRoot": "0x6f058887ca01549716789c380ede95aecc510e6d1fdc4dbf67d053c7c07f4bdc", 4 | "txRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 5 | "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 6 | "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", 7 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 8 | "currentDifficulty": "0x2000020000000", 9 | "receipts": [], 10 | "gasUsed": "0x0", 11 | "currentBaseFee": "0x500" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cmd/evm/testdata/14/exp2.json: -------------------------------------------------------------------------------- 1 | { 2 | "result": { 3 | "stateRoot": "0x6f058887ca01549716789c380ede95aecc510e6d1fdc4dbf67d053c7c07f4bdc", 4 | "txRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 5 | "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 6 | "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", 7 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 8 | "receipts": [], 9 | "currentDifficulty": "0x1ff8020000000", 10 | "gasUsed": "0x0", 11 | "currentBaseFee": "0x500" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cmd/evm/testdata/14/exp_berlin.json: -------------------------------------------------------------------------------- 1 | { 2 | "result": { 3 | "stateRoot": "0x6f058887ca01549716789c380ede95aecc510e6d1fdc4dbf67d053c7c07f4bdc", 4 | "txRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 5 | "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 6 | "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", 7 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 8 | "receipts": [], 9 | "currentDifficulty": "0x1ff9000000000", 10 | "gasUsed": "0x0", 11 | "currentBaseFee": "0x500" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cmd/evm/testdata/14/txs.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /cmd/evm/testdata/15/blockheader.rlp: -------------------------------------------------------------------------------- 1 | "0xf901f0a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b0101020383010203a00000000000000000000000000000000000000000000000000000000000000000880000000000000000" -------------------------------------------------------------------------------- /cmd/evm/testdata/15/exp.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "error": "transaction type not supported", 4 | "hash": "0xa98a24882ea90916c6a86da650fbc6b14238e46f0af04a131ce92be897507476" 5 | }, 6 | { 7 | "error": "transaction type not supported", 8 | "hash": "0x36bad80acce7040c45fd32764b5c2b2d2e6f778669fb41791f73f546d56e739a" 9 | } 10 | ] -------------------------------------------------------------------------------- /cmd/evm/testdata/15/exp2.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "address": "0xd02d72e067e77158444ef2020ff2d325f929b363", 4 | "hash": "0xa98a24882ea90916c6a86da650fbc6b14238e46f0af04a131ce92be897507476", 5 | "intrinsicGas": "0x5208" 6 | }, 7 | { 8 | "address": "0xd02d72e067e77158444ef2020ff2d325f929b363", 9 | "hash": "0x36bad80acce7040c45fd32764b5c2b2d2e6f778669fb41791f73f546d56e739a", 10 | "intrinsicGas": "0x5208" 11 | } 12 | ] 13 | -------------------------------------------------------------------------------- /cmd/evm/testdata/15/exp3.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "error": "transaction type not supported" 4 | }, 5 | { 6 | "error": "transaction type not supported" 7 | }, 8 | { 9 | "error": "transaction type not supported" 10 | }, 11 | { 12 | "error": "transaction type not supported" 13 | }, 14 | { 15 | "error": "transaction type not supported" 16 | }, 17 | { 18 | "error": "transaction type not supported" 19 | }, 20 | { 21 | "error": "transaction type not supported" 22 | }, 23 | { 24 | "error": "typed transaction too short" 25 | }, 26 | { 27 | "error": "typed transaction too short" 28 | }, 29 | { 30 | "error": "typed transaction too short" 31 | }, 32 | { 33 | "error": "typed transaction too short" 34 | }, 35 | { 36 | "error": "typed transaction too short" 37 | }, 38 | { 39 | "error": "rlp: expected input list for types.AccessListTx" 40 | }, 41 | { 42 | "error": "transaction type not supported" 43 | }, 44 | { 45 | "error": "transaction type not supported" 46 | } 47 | ] 48 | -------------------------------------------------------------------------------- /cmd/evm/testdata/15/signed_txs.rlp: -------------------------------------------------------------------------------- 1 | "0xf8d2b86702f864010180820fa08284d09411111111111111111111111111111111111111118080c001a0b7dfab36232379bb3d1497a4f91c1966b1f932eae3ade107bf5d723b9cb474e0a06261c359a10f2132f126d250485b90cf20f30340801244a08ef6142ab33d1904b86702f864010280820fa08284d09411111111111111111111111111111111111111118080c080a0d4ec563b6568cd42d998fc4134b36933c6568d01533b5adf08769270243c6c7fa072bf7c21eac6bbeae5143371eef26d5e279637f3bd73482b55979d76d935b1e9" -------------------------------------------------------------------------------- /cmd/evm/testdata/15/signed_txs.rlp.json: -------------------------------------------------------------------------------- 1 | { 2 | "txsRlp" : "0xf8d2b86702f864010180820fa08284d09411111111111111111111111111111111111111118080c001a0b7dfab36232379bb3d1497a4f91c1966b1f932eae3ade107bf5d723b9cb474e0a06261c359a10f2132f126d250485b90cf20f30340801244a08ef6142ab33d1904b86702f864010280820fa08284d09411111111111111111111111111111111111111118080c080a0d4ec563b6568cd42d998fc4134b36933c6568d01533b5adf08769270243c6c7fa072bf7c21eac6bbeae5143371eef26d5e279637f3bd73482b55979d76d935b1e9" 3 | } 4 | 5 | -------------------------------------------------------------------------------- /cmd/evm/testdata/16/exp.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", 4 | "hash": "0x7cc3d1a8540a44736750f03bb4d85c0113be4b3472a71bf82241a3b261b479e6", 5 | "intrinsicGas": "0x5208" 6 | }, 7 | { 8 | "error": "intrinsic gas too low: have 82, want 21000", 9 | "address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", 10 | "hash": "0x3b2d2609e4361562edb9169314f4c05afc6dbf5d706bf9dda5abe242ab76a22b", 11 | "intrinsicGas": "0x5208" 12 | } 13 | ] -------------------------------------------------------------------------------- /cmd/evm/testdata/16/signed_txs.rlp: -------------------------------------------------------------------------------- 1 | "0xf8cab86401f8610180018252089411111111111111111111111111111111111111112080c001a0937f65ef1deece46c473b99962678fb7c38425cf303d1e8fa9717eb4b9d012b5a01940c5a5647c4940217ffde1051a5fd92ec8551e275c1787f81f50a2ad84de43b86201f85f018001529411111111111111111111111111111111111111112080c001a0241c3aec732205542a87fef8c76346741e85480bce5a42d05a9a73dac892f84ca04f52e2dfce57f3a02ed10e085e1a154edf38a726da34127c85fc53b4921759c8" -------------------------------------------------------------------------------- /cmd/evm/testdata/16/unsigned_txs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "input" : "0x", 4 | "gas" : "0x5208", 5 | "nonce" : "0x0", 6 | "to" : "0x1111111111111111111111111111111111111111", 7 | "value" : "0x20", 8 | "v" : "0x0", 9 | "r" : "0x0", 10 | "s" : "0x0", 11 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", 12 | "chainId" : "0x1", 13 | "type" : "0x1", 14 | "gasPrice": "0x1", 15 | "accessList" : [ 16 | ] 17 | }, 18 | { 19 | "input" : "0x", 20 | "gas" : "0x52", 21 | "nonce" : "0x0", 22 | "to" : "0x1111111111111111111111111111111111111111", 23 | "value" : "0x20", 24 | "v" : "0x0", 25 | "r" : "0x0", 26 | "s" : "0x0", 27 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", 28 | "chainId" : "0x1", 29 | "type" : "0x1", 30 | "gasPrice": "0x1", 31 | "accessList" : [ 32 | ] 33 | } 34 | ] 35 | -------------------------------------------------------------------------------- /cmd/evm/testdata/17/exp.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "error": "value exceeds 256 bits", 4 | "address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", 5 | "hash": "0xfbd91685dcbf8172f0e8c53e2ddbb4d26707840da6b51a74371f62a33868fd82", 6 | "intrinsicGas": "0x5208" 7 | }, 8 | { 9 | "error": "gasPrice exceeds 256 bits", 10 | "address": "0x1b57ccef1fe5fb73f1e64530fb4ebd9cf1655964", 11 | "hash": "0x45dc05035cada83748e4c1fe617220106b331eca054f44c2304d5654a9fb29d5", 12 | "intrinsicGas": "0x5208" 13 | }, 14 | { 15 | "error": "invalid transaction v, r, s values", 16 | "hash": "0xf06691c2a803ab7f3c81d06a0c0a896f80f311105c599fc59a9fdbc669356d35" 17 | }, 18 | { 19 | "error": "invalid transaction v, r, s values", 20 | "hash": "0x84703b697ad5b0db25e4f1f98fb6b1adce85b9edb2232eeba9cedd8c6601694b" 21 | } 22 | ] -------------------------------------------------------------------------------- /cmd/evm/testdata/17/rlpdata.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | "", 4 | "d", 5 | 5208, 6 | d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0, 7 | 010000000000000000000000000000000000000000000000000000000000000001, 8 | "", 9 | 1b, 10 | c16787a8e25e941d67691954642876c08f00996163ae7dfadbbfd6cd436f549d, 11 | 6180e5626cae31590f40641fe8f63734316c4bfeb4cdfab6714198c1044d2e28, 12 | ], 13 | [ 14 | "", 15 | 010000000000000000000000000000000000000000000000000000000000000001, 16 | 5208, 17 | d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0, 18 | 11, 19 | "", 20 | 1b, 21 | c16787a8e25e941d67691954642876c08f00996163ae7dfadbbfd6cd436f549d, 22 | 6180e5626cae31590f40641fe8f63734316c4bfeb4cdfab6714198c1044d2e28, 23 | ], 24 | [ 25 | "", 26 | 11, 27 | 5208, 28 | d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0, 29 | 11, 30 | "", 31 | 1b, 32 | c16787a8e25e941d67691954642876c08f00996163ae7dfadbbfd6cd436f549daa, 33 | 6180e5626cae31590f40641fe8f63734316c4bfeb4cdfab6714198c1044d2e28, 34 | ], 35 | [ 36 | "", 37 | 11, 38 | 5208, 39 | d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0, 40 | 11, 41 | "", 42 | 1b, 43 | c16787a8e25e941d67691954642876c08f00996163ae7dfadbbfd6cd436f549d, 44 | 6180e5626cae31590f40641fe8f63734316c4bfeb4cdfab6714198c1044d2e28bb, 45 | ], 46 | ] 47 | -------------------------------------------------------------------------------- /cmd/evm/testdata/17/signed_txs.rlp: -------------------------------------------------------------------------------- 1 | "0xf901c8f880806482520894d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0a1010000000000000000000000000000000000000000000000000000000000000001801ba0c16787a8e25e941d67691954642876c08f00996163ae7dfadbbfd6cd436f549da06180e5626cae31590f40641fe8f63734316c4bfeb4cdfab6714198c1044d2e28f88080a101000000000000000000000000000000000000000000000000000000000000000182520894d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d011801ba0c16787a8e25e941d67691954642876c08f00996163ae7dfadbbfd6cd436f549da06180e5626cae31590f40641fe8f63734316c4bfeb4cdfab6714198c1044d2e28f860801182520894d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d011801ba1c16787a8e25e941d67691954642876c08f00996163ae7dfadbbfd6cd436f549daaa06180e5626cae31590f40641fe8f63734316c4bfeb4cdfab6714198c1044d2e28f860801182520894d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d011801ba0c16787a8e25e941d67691954642876c08f00996163ae7dfadbbfd6cd436f549da16180e5626cae31590f40641fe8f63734316c4bfeb4cdfab6714198c1044d2e28bb" -------------------------------------------------------------------------------- /cmd/evm/testdata/18/README.md: -------------------------------------------------------------------------------- 1 | # Invalid rlp 2 | 3 | This folder contains a sample of invalid RLP, and it's expected 4 | that the t9n handles this properly: 5 | 6 | ``` 7 | $ go run . t9n --input.txs=./testdata/18/invalid.rlp --state.fork=London 8 | ERROR(11): rlp: value size exceeds available input length 9 | ``` -------------------------------------------------------------------------------- /cmd/evm/testdata/18/invalid.rlp: -------------------------------------------------------------------------------- 1 | "0xf852328001825208870b9331677e6ebf0a801ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa03887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3" -------------------------------------------------------------------------------- /cmd/evm/testdata/19/alloc.json: -------------------------------------------------------------------------------- 1 | { 2 | "a94f5374fce5edbc8e2a8697c15331677e6ebf0b": { 3 | "balance": "0x5ffd4878be161d74", 4 | "code": "0x", 5 | "nonce": "0xac", 6 | "storage": {} 7 | }, 8 | "0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192":{ 9 | "balance": "0xfeedbead", 10 | "nonce" : "0x00" 11 | } 12 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/19/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "currentCoinbase": "0xc94f5374fce5edbc8e2a8697c15331677e6ebf0b", 3 | "currentGasLimit": "0x750a163df65e8a", 4 | "currentBaseFee": "0x500", 5 | "currentNumber": "13000000", 6 | "currentTimestamp": "100015", 7 | "parentTimestamp" : "99999", 8 | "parentDifficulty" : "0x2000000000000" 9 | } 10 | -------------------------------------------------------------------------------- /cmd/evm/testdata/19/exp_arrowglacier.json: -------------------------------------------------------------------------------- 1 | { 2 | "result": { 3 | "stateRoot": "0x6f058887ca01549716789c380ede95aecc510e6d1fdc4dbf67d053c7c07f4bdc", 4 | "txRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 5 | "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 6 | "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", 7 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 8 | "currentDifficulty": "0x2000000200000", 9 | "receipts": [], 10 | "gasUsed": "0x0", 11 | "currentBaseFee": "0x500" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cmd/evm/testdata/19/exp_grayglacier.json: -------------------------------------------------------------------------------- 1 | { 2 | "result": { 3 | "stateRoot": "0x6f058887ca01549716789c380ede95aecc510e6d1fdc4dbf67d053c7c07f4bdc", 4 | "txRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 5 | "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 6 | "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", 7 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 8 | "receipts": [], 9 | "currentDifficulty": "0x2000000004000", 10 | "gasUsed": "0x0", 11 | "currentBaseFee": "0x500" 12 | } 13 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/19/exp_london.json: -------------------------------------------------------------------------------- 1 | { 2 | "result": { 3 | "stateRoot": "0x6f058887ca01549716789c380ede95aecc510e6d1fdc4dbf67d053c7c07f4bdc", 4 | "txRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 5 | "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 6 | "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", 7 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 8 | "currentDifficulty": "0x2000080000000", 9 | "receipts": [], 10 | "gasUsed": "0x0", 11 | "currentBaseFee": "0x500" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cmd/evm/testdata/19/txs.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /cmd/evm/testdata/20/header.json: -------------------------------------------------------------------------------- 1 | { 2 | "parentHash": "0xd6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34e", 3 | "miner": "0xe997a23b159e2e2a5ce72333262972374b15425c", 4 | "stateRoot": "0x325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2e", 5 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 6 | "difficulty": "0x1000", 7 | "number": "0xc3be", 8 | "gasLimit": "0x50785", 9 | "gasUsed": "0x0", 10 | "timestamp": "0x55c5277e", 11 | "extraData": "0x476574682f76312e302e312f6c696e75782f676f312e342e32", 12 | "mixHash": "0x5865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf", 13 | "nonce": "0x97435673d874f7c8" 14 | } 15 | -------------------------------------------------------------------------------- /cmd/evm/testdata/20/ommers.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /cmd/evm/testdata/20/readme.md: -------------------------------------------------------------------------------- 1 | # Block building 2 | 3 | This test shows how `b11r` can be used to assemble an unsealed block. 4 | 5 | ```console 6 | $ go run . b11r --input.header=testdata/20/header.json --input.txs=testdata/20/txs.rlp --input.ommers=testdata/20/ommers.json --output.block=stdout 7 | { 8 | "rlp": "0xf90216f90211a0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794e997a23b159e2e2a5ce72333262972374b15425ca0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277e99476574682f76312e302e312f6c696e75782f676f312e342e32a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf8897435673d874f7c8c0c0", 9 | "hash": "0xaba9a3b6a4e96e9ecffcadaa5a2ae0589359455617535cd86589fe1dd26fe899" 10 | } 11 | ``` 12 | -------------------------------------------------------------------------------- /cmd/evm/testdata/20/txs.rlp: -------------------------------------------------------------------------------- 1 | "0xf8c2f85f8002825208948a8eafb1cf62bfbeb1741769dae1a9dd4799619201801ba09500e8ba27d3c33ca7764e107410f44cbd8c19794bde214d694683a7aa998cdba07235ae07e4bd6e0206d102b1f8979d6adab280466b6a82d2208ee08951f1f600f85f8002825208948a8eafb1cf62bfbeb1741769dae1a9dd4799619201801ba09500e8ba27d3c33ca7764e107410f44cbd8c19794bde214d694683a7aa998cdba07235ae07e4bd6e0206d102b1f8979d6adab280466b6a82d2208ee08951f1f600" -------------------------------------------------------------------------------- /cmd/evm/testdata/22/exp-clique.json: -------------------------------------------------------------------------------- 1 | { 2 | "rlp": "0xf9025ff9025aa0d6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942adc25665018aa1fe0e6bc666dac8fc2697ff9baa0325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082100082c3be83050785808455c5277eb861aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac540a67aaee364005841da84f488f6b6d0116dfb5103d091402c81a163d5f66666595e37f56f196d8c5c98da714dbfae68d6b7e1790cc734a20ec6ce52213ad800a05865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf88ffffffffffffffffc0c0", 3 | "hash": "0x71c59102cc805dbe8741e1210ebe229a321eff144ac7276006fefe39e8357dc7" 4 | } 5 | -------------------------------------------------------------------------------- /cmd/evm/testdata/22/header.json: -------------------------------------------------------------------------------- 1 | { 2 | "parentHash": "0xd6d785d33cbecf30f30d07e00e226af58f72efdf385d46bc3e6326c23b11e34e", 3 | "stateRoot": "0x325aea6db48e9d737cddf59034843e99f05bec269453be83c9b9a981a232cc2e", 4 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 5 | "difficulty": "0x1000", 6 | "number": "0xc3be", 7 | "gasLimit": "0x50785", 8 | "gasUsed": "0x0", 9 | "timestamp": "0x55c5277e", 10 | "mixHash": "0x5865e417635a26db6d1d39ac70d1abf373e5398b3c6fd506acd038fa1334eedf" 11 | } 12 | -------------------------------------------------------------------------------- /cmd/evm/testdata/22/txs.rlp: -------------------------------------------------------------------------------- 1 | "c0" 2 | -------------------------------------------------------------------------------- /cmd/evm/testdata/23/alloc.json: -------------------------------------------------------------------------------- 1 | { 2 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { 3 | "balance" : "0x0de0b6b3a7640000", 4 | "code" : "0x6001", 5 | "nonce" : "0x00", 6 | "storage" : { 7 | } 8 | }, 9 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 10 | "balance" : "0x0de0b6b3a7640000", 11 | "code" : "0x", 12 | "nonce" : "0x00", 13 | "storage" : { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /cmd/evm/testdata/23/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 3 | "currentDifficulty" : "0x020000", 4 | "currentGasLimit" : "0x3b9aca00", 5 | "currentNumber" : "0x05", 6 | "currentTimestamp" : "0x03e8" 7 | } 8 | -------------------------------------------------------------------------------- /cmd/evm/testdata/23/readme.md: -------------------------------------------------------------------------------- 1 | These files exemplify how to sign a transaction using the pre-EIP155 scheme. 2 | -------------------------------------------------------------------------------- /cmd/evm/testdata/23/txs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "input" : "0x", 4 | "gas" : "0x5f5e100", 5 | "gasPrice" : "0x1", 6 | "nonce" : "0x0", 7 | "to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", 8 | "value" : "0x186a0", 9 | "v" : "0x0", 10 | "r" : "0x0", 11 | "s" : "0x0", 12 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", 13 | "protected": false 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /cmd/evm/testdata/24/alloc.json: -------------------------------------------------------------------------------- 1 | { 2 | "a94f5374fce5edbc8e2a8697c15331677e6ebf0b": { 3 | "balance": "0x5ffd4878be161d74", 4 | "code": "0x", 5 | "nonce": "0xac", 6 | "storage": {} 7 | }, 8 | "0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192":{ 9 | "balance": "0xfeedbead", 10 | "nonce" : "0x00", 11 | "code" : "0x44600055", 12 | "_comment": "The code is 'sstore(0, random)'" 13 | } 14 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/24/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "currentCoinbase": "0xc94f5374fce5edbc8e2a8697c15331677e6ebf0b", 3 | "currentDifficulty": null, 4 | "currentRandom": "0xdeadc0de", 5 | "currentGasLimit": "0x750a163df65e8a", 6 | "currentBaseFee": "0x500", 7 | "currentNumber": "1", 8 | "currentTimestamp": "1000" 9 | } 10 | -------------------------------------------------------------------------------- /cmd/evm/testdata/24/exp.json.diff: -------------------------------------------------------------------------------- 1 | State root and balance differ because of SubnetEVM's fee calculations. 2 | 3 | CurrentDifficulty is 0 instead of null because the test overrides the 4 | difficulty if currentRandom is provided in the environment. 5 | 6 | --- a/cmd/evm/testdata/24/exp.json 2023-08-25 07:34:20 7 | +++ b/cmd/evm/testdata/24/exp.json 2023-08-24 14:17:32 8 | @@ -12,11 +12,11 @@ 9 | "nonce": "0xae" 10 | }, 11 | "0xc94f5374fce5edbc8e2a8697c15331677e6ebf0b": { 12 | - "balance": "0x1030600" 13 | + "balance": "0x6122400" 14 | } 15 | }, 16 | "result": { 17 | - "stateRoot": "0x9e4224c6bba343d5b0fdbe9200cc66a7ef2068240d901ae516e634c45a043c15", 18 | + "stateRoot": "0xba04fd7f80a33bfb4b0bc5c8dc1178b05b67b3e95aeca01f516db3c93e6838e2", 19 | "txRoot": "0x16cd3a7daa6686ceebadf53b7af2bc6919eccb730907f0e74a95a4423c209593", 20 | "receiptsRoot": "0x22b85cda738345a9880260b2a71e144aab1ca9485f5db4fd251008350fc124c8", 21 | "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", 22 | @@ -49,7 +49,7 @@ 23 | "transactionIndex": "0x1" 24 | } 25 | ], 26 | - "currentDifficulty": null, 27 | + "currentDifficulty": "0x0", 28 | "gasUsed": "0x10306", 29 | "currentBaseFee": "0x500" 30 | } 31 | -------------------------------------------------------------------------------- /cmd/evm/testdata/24/txs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "gas": "0x186a0", 4 | "gasPrice": "0x600", 5 | "hash": "0x0557bacce3375c98d806609b8d5043072f0b6a8bae45ae5a67a00d3a1a18d673", 6 | "input": "0x", 7 | "nonce": "0xac", 8 | "to": "0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192", 9 | "value": "0x1", 10 | "v" : "0x0", 11 | "r" : "0x0", 12 | "s" : "0x0", 13 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8" 14 | }, 15 | { 16 | "gas": "0x186a0", 17 | "gasPrice": "0x600", 18 | "hash": "0x0557bacce3375c98d806609b8d5043072f0b6a8bae45ae5a67a00d3a1a18d673", 19 | "input": "0x", 20 | "nonce": "0xad", 21 | "to": "0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192", 22 | "value": "0x1", 23 | "v" : "0x0", 24 | "r" : "0x0", 25 | "s" : "0x0", 26 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8" 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /cmd/evm/testdata/25/alloc.json: -------------------------------------------------------------------------------- 1 | { 2 | "a94f5374fce5edbc8e2a8697c15331677e6ebf0b": { 3 | "balance": "0x5ffd4878be161d74", 4 | "code": "0x", 5 | "nonce": "0xac", 6 | "storage": {} 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /cmd/evm/testdata/25/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "currentCoinbase": "0xc94f5374fce5edbc8e2a8697c15331677e6ebf0b", 3 | "currentDifficulty": null, 4 | "currentRandom": "0xdeadc0de", 5 | "currentGasLimit": "0x750a163df65e8a", 6 | "parentBaseFee": "0x500", 7 | "parentGasUsed": "0x0", 8 | "parentGasLimit": "0x750a163df65e8a", 9 | "currentNumber": "2", 10 | "currentTimestamp": "1", 11 | "minBaseFee": "0x1" 12 | } 13 | -------------------------------------------------------------------------------- /cmd/evm/testdata/25/env.json.diff: -------------------------------------------------------------------------------- 1 | This test is modified so we use a meaningful base fee calculation that shows 2 | fee adjustment. If we use block number 1, the parent will be genesis and the 3 | current base fee will be minBaseFee. 4 | The ability to set minBaseFee was added to the test, since the default minBaseFee 5 | is too high for the test tx to work. 6 | 7 | --- a/cmd/evm/testdata/25/env.json 2023-08-25 07:34:20 8 | +++ b/cmd/evm/testdata/25/env.json 2023-08-24 14:17:32 9 | @@ -6,6 +6,7 @@ 10 | "parentBaseFee": "0x500", 11 | "parentGasUsed": "0x0", 12 | "parentGasLimit": "0x750a163df65e8a", 13 | - "currentNumber": "1", 14 | - "currentTimestamp": "1000" 15 | + "currentNumber": "2", 16 | + "currentTimestamp": "1", 17 | + "minBaseFee": "0x1" 18 | } 19 | -------------------------------------------------------------------------------- /cmd/evm/testdata/25/exp.json.diff: -------------------------------------------------------------------------------- 1 | State root and balance differ because of SubnetEVM's fee calculations. 2 | 3 | CurrentDifficulty is 0xdeadc0de instead of null because the test overrides the 4 | difficulty if currentRandom is provided in the environment. 5 | 6 | --- a/cmd/evm/testdata/25/exp.json 2023-08-25 07:34:20 7 | +++ b/cmd/evm/testdata/25/exp.json 2023-08-24 14:17:32 8 | @@ -8,11 +8,11 @@ 9 | "nonce": "0xad" 10 | }, 11 | "0xc94f5374fce5edbc8e2a8697c15331677e6ebf0b": { 12 | - "balance": "0x854d00" 13 | + "balance": "0x1ec3000" 14 | } 15 | }, 16 | "result": { 17 | - "stateRoot": "0x5139609e39f4d158a7d1ad1800908eb0349cea9b500a8273a6cf0a7e4392639b", 18 | + "stateRoot": "0xb056800260ffcf459b9acdfd9b213fce174bdfa53cfeaf505f0cfa9f411db860", 19 | "txRoot": "0x572690baf4898c2972446e56ecf0aa2a027c08a863927d2dce34472f0c5496fe", 20 | "receiptsRoot": "0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2", 21 | "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", 22 | @@ -32,8 +32,8 @@ 23 | "transactionIndex": "0x0" 24 | } 25 | ], 26 | - "currentDifficulty": null, 27 | + "currentDifficulty": "0xdeadc0de", 28 | "gasUsed": "0x5208", 29 | - "currentBaseFee": "0x460" 30 | + "currentBaseFee": "0x4dd" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /cmd/evm/testdata/25/txs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "gas": "0x186a0", 4 | "gasPrice": "0x600", 5 | "hash": "0x0557bacce3375c98d806609b8d5043072f0b6a8bae45ae5a67a00d3a1a18d673", 6 | "input": "0x", 7 | "nonce": "0xac", 8 | "to": "0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192", 9 | "value": "0x1", 10 | "v" : "0x0", 11 | "r" : "0x0", 12 | "s" : "0x0", 13 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8" 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /cmd/evm/testdata/28/alloc.json: -------------------------------------------------------------------------------- 1 | { 2 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 3 | "balance" : "0x016345785d8a0000", 4 | "code" : "0x", 5 | "nonce" : "0x00", 6 | "storage" : { 7 | } 8 | }, 9 | "0xb94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 10 | "balance" : "0x016345785d8a0000", 11 | "code" : "0x60004960015500", 12 | "nonce" : "0x00", 13 | "storage" : { 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/28/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "minBaseFee" : "0x9", 3 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 4 | "currentNumber" : "0x01", 5 | "currentTimestamp" : "0x079e", 6 | "currentGasLimit" : "0x7fffffffffffffff", 7 | "previousHash" : "0x3a9b485972e7353edd9152712492f0c58d89ef80623686b6bf947a4a6dce6cb6", 8 | "currentBlobGasUsed" : "0x00", 9 | "parentTimestamp" : "0x03b6", 10 | "parentDifficulty" : "0x00", 11 | "parentUncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", 12 | "currentRandom" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 13 | "withdrawals" : [], 14 | "parentBaseFee" : "0x0a", 15 | "parentGasUsed" : "0x00", 16 | "parentGasLimit" : "0x7fffffffffffffff", 17 | "parentExcessBlobGas" : "0x00", 18 | "parentBlobGasUsed" : "0x00", 19 | "blockHashes" : { 20 | "0" : "0x3a9b485972e7353edd9152712492f0c58d89ef80623686b6bf947a4a6dce6cb6" 21 | }, 22 | "parentBeaconBlockRoot": "0x0000beac00beac00beac00beac00beac00beac00beac00beac00beac00beac00" 23 | } 24 | -------------------------------------------------------------------------------- /cmd/evm/testdata/28/txs.rlp: -------------------------------------------------------------------------------- 1 | "0xf88bb88903f8860180026483061a8094b94f5374fce5edbc8e2a8697c15331677e6ebf0b8080c00ae1a001a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d801a025e16bb498552165016751911c3608d79000ab89dc3100776e729e6ea13091c7a03acacff7fc0cff6eda8a927dec93ca17765e1ee6cbc06c5954ce102e097c01d2" -------------------------------------------------------------------------------- /cmd/evm/testdata/29/alloc.json: -------------------------------------------------------------------------------- 1 | { 2 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 3 | "balance" : "0x016345785d8a0000", 4 | "code" : "0x", 5 | "nonce" : "0x00", 6 | "storage" : { 7 | } 8 | }, 9 | "0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02" : { 10 | "balance" : "0x1", 11 | "code" : "0x3373fffffffffffffffffffffffffffffffffffffffe14604457602036146024575f5ffd5b620180005f350680545f35146037575f5ffd5b6201800001545f5260205ff35b6201800042064281555f359062018000015500", 12 | "nonce" : "0x00", 13 | "storage" : { 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/29/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "minBaseFee" : "0x9", 3 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 4 | "currentNumber" : "0x01", 5 | "currentTimestamp" : "0x079e", 6 | "currentGasLimit" : "0x7fffffffffffffff", 7 | "previousHash" : "0x3a9b485972e7353edd9152712492f0c58d89ef80623686b6bf947a4a6dce6cb6", 8 | "currentBlobGasUsed" : "0x00", 9 | "parentTimestamp" : "0x03b6", 10 | "parentDifficulty" : "0x00", 11 | "parentUncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", 12 | "currentRandom" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 13 | "withdrawals" : [ 14 | ], 15 | "parentBaseFee" : "0x0a", 16 | "parentGasUsed" : "0x00", 17 | "parentGasLimit" : "0x7fffffffffffffff", 18 | "parentExcessBlobGas" : "0x00", 19 | "parentBlobGasUsed" : "0x00", 20 | "parentBeaconBlockRoot": "0x0000beac00beac00beac00beac00beac00beac00beac00beac00beac00beac00" 21 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/29/txs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "input" : "0x", 4 | "gas" : "0x10000000", 5 | "nonce" : "0x0", 6 | "to" : "0x1111111111111111111111111111111111111111", 7 | "value" : "0x0", 8 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", 9 | "chainId" : "0x1", 10 | "type" : "0x2", 11 | "v": "0x0", 12 | "r": "0x0", 13 | "s": "0x0", 14 | "maxFeePerGas" : "0xfa0", 15 | "maxPriorityFeePerGas" : "0x0", 16 | "accessList" : [ 17 | ] 18 | } 19 | ] -------------------------------------------------------------------------------- /cmd/evm/testdata/3/alloc.json: -------------------------------------------------------------------------------- 1 | { 2 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { 3 | "balance" : "0x0de0b6b3a7640000", 4 | "code" : "0x600140", 5 | "nonce" : "0x00", 6 | "storage" : { 7 | } 8 | }, 9 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 10 | "balance" : "0x0de0b6b3a7640000", 11 | "code" : "0x", 12 | "nonce" : "0x00", 13 | "storage" : { 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/3/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 3 | "currentDifficulty" : "0x020000", 4 | "currentGasLimit" : "0x3b9aca00", 5 | "currentNumber" : "0x05", 6 | "currentTimestamp" : "0x03e8", 7 | "blockHashes" : { "1" : "0xdac58aa524e50956d0c0bae7f3f8bb9d35381365d07804dd5b48a5a297c06af4"} 8 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/3/readme.md: -------------------------------------------------------------------------------- 1 | These files exemplify a transition where a transaction (executed on block 5) requests 2 | the blockhash for block `1`. 3 | -------------------------------------------------------------------------------- /cmd/evm/testdata/3/txs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "input" : "0x", 4 | "gas" : "0x5f5e100", 5 | "gasPrice" : "0x1", 6 | "nonce" : "0x0", 7 | "to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", 8 | "value" : "0x186a0", 9 | "v" : "0x1b", 10 | "r" : "0x88544c93a564b4c28d2ffac2074a0c55fdd4658fe0d215596ed2e32e3ef7f56b", 11 | "s" : "0x7fb4075d54190f825d7c47bb820284757b34fd6293904a93cddb1d3aa961ac28", 12 | "hash" : "0x72fadbef39cd251a437eea619cfeda752271a5faaaa2147df012e112159ffb81" 13 | } 14 | ] -------------------------------------------------------------------------------- /cmd/evm/testdata/30/alloc.json: -------------------------------------------------------------------------------- 1 | { 2 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { 3 | "balance" : "0x0de0b6b3a7640000", 4 | "code" : "0x60004960005500", 5 | "nonce" : "0x00", 6 | "storage" : { 7 | } 8 | }, 9 | "0xd02d72e067e77158444ef2020ff2d325f929b363" : { 10 | "balance": "0x01000000000000", 11 | "code": "0x", 12 | "nonce": "0x01", 13 | "storage": { 14 | } 15 | }, 16 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 17 | "balance" : "0x0de0b6b3a7640000", 18 | "code" : "0x", 19 | "nonce" : "0x00", 20 | "storage" : { 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/30/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 3 | "currentNumber" : "0x01", 4 | "currentTimestamp" : "0x03e8", 5 | "currentGasLimit" : "0x1000000000", 6 | "previousHash" : "0xe4e2a30b340bec696242b67584264f878600dce98354ae0b6328740fd4ff18da", 7 | "currentDataGasUsed" : "0x2000", 8 | "parentTimestamp" : "0x00", 9 | "parentDifficulty" : "0x00", 10 | "parentUncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", 11 | "parentBeaconBlockRoot" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", 12 | "currentRandom" : "0x0000000000000000000000000000000000000000000000000000000000020000", 13 | "withdrawals" : [ 14 | ], 15 | "parentBaseFee" : "0x08", 16 | "parentGasUsed" : "0x00", 17 | "parentGasLimit" : "0x1000000000", 18 | "parentExcessBlobGas" : "0x1000", 19 | "parentBlobGasUsed" : "0x2000", 20 | "blockHashes" : { 21 | "0" : "0xe4e2a30b340bec696242b67584264f878600dce98354ae0b6328740fd4ff18da" 22 | }, 23 | "minBaseFee": "0x1" 24 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/30/txs.rlp: -------------------------------------------------------------------------------- 1 | "0xf8dbb8d903f8d601800285012a05f200833d090080830186a000f85bf85994095e7baea6a6c7c4c2dfeb977efac326af552d87f842a00000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010ae1a001a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d880a0fc12b67159a3567f8bdbc49e0be369a2e20e09d57a51c41310543a4128409464a02de0cfe5495c4f58ff60645ceda0afd67a4c90a70bc89fe207269435b35e5b67" -------------------------------------------------------------------------------- /cmd/evm/testdata/30/txs_more.rlp: -------------------------------------------------------------------------------- 1 | "0xf901adb86702f864010180820fa08284d09411111111111111111111111111111111111111118080c001a0b7dfab36232379bb3d1497a4f91c1966b1f932eae3ade107bf5d723b9cb474e0a06261c359a10f2132f126d250485b90cf20f30340801244a08ef6142ab33d1904b8d903f8d601800285012a05f200833d090080830186a000f85bf85994095e7baea6a6c7c4c2dfeb977efac326af552d87f842a00000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010ae1a001a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d880a0fc12b67159a3567f8bdbc49e0be369a2e20e09d57a51c41310543a4128409464a02de0cfe5495c4f58ff60645ceda0afd67a4c90a70bc89fe207269435b35e5b67b86702f864010280820fa08284d09411111111111111111111111111111111111111118080c080a0d4ec563b6568cd42d998fc4134b36933c6568d01533b5adf08769270243c6c7fa072bf7c21eac6bbeae5143371eef26d5e279637f3bd73482b55979d76d935b1e9" -------------------------------------------------------------------------------- /cmd/evm/testdata/4/alloc.json: -------------------------------------------------------------------------------- 1 | { 2 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { 3 | "balance" : "0x0de0b6b3a7640000", 4 | "code" : "0x600340", 5 | "nonce" : "0x00", 6 | "storage" : { 7 | } 8 | }, 9 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 10 | "balance" : "0x0de0b6b3a7640000", 11 | "code" : "0x", 12 | "nonce" : "0x00", 13 | "storage" : { 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/4/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 3 | "currentDifficulty" : "0x020000", 4 | "currentGasLimit" : "0x3b9aca00", 5 | "currentNumber" : "0x05", 6 | "currentTimestamp" : "0x03e8", 7 | "blockHashes" : { "1" : "0xdac58aa524e50956d0c0bae7f3f8bb9d35381365d07804dd5b48a5a297c06af4"} 8 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/4/readme.md: -------------------------------------------------------------------------------- 1 | These files exemplify a transition where a transaction (executed on block 5) requests 2 | the blockhash for block `4`, but where the hash for that block is missing. 3 | It's expected that executing these should cause `exit` with errorcode `4`. 4 | -------------------------------------------------------------------------------- /cmd/evm/testdata/4/txs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "input" : "0x", 4 | "gas" : "0x5f5e100", 5 | "gasPrice" : "0x1", 6 | "nonce" : "0x0", 7 | "to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", 8 | "value" : "0x186a0", 9 | "v" : "0x1b", 10 | "r" : "0x88544c93a564b4c28d2ffac2074a0c55fdd4658fe0d215596ed2e32e3ef7f56b", 11 | "s" : "0x7fb4075d54190f825d7c47bb820284757b34fd6293904a93cddb1d3aa961ac28", 12 | "hash" : "0x72fadbef39cd251a437eea619cfeda752271a5faaaa2147df012e112159ffb81" 13 | } 14 | ] -------------------------------------------------------------------------------- /cmd/evm/testdata/5/alloc.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /cmd/evm/testdata/5/env.json: -------------------------------------------------------------------------------- 1 | { 2 | "currentCoinbase": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3 | "currentDifficulty": "0x20000", 4 | "currentGasLimit": "0x750a163df65e8a", 5 | "currentNumber": "1", 6 | "currentTimestamp": "1000", 7 | "ommers": [ 8 | {"delta": 1, "address": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" }, 9 | {"delta": 2, "address": "0xcccccccccccccccccccccccccccccccccccccccc" } 10 | ] 11 | } -------------------------------------------------------------------------------- /cmd/evm/testdata/5/exp.json: -------------------------------------------------------------------------------- 1 | { 2 | "alloc": { 3 | "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa": { 4 | "balance": "0x88" 5 | }, 6 | "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb": { 7 | "balance": "0x70" 8 | }, 9 | "0xcccccccccccccccccccccccccccccccccccccccc": { 10 | "balance": "0x60" 11 | } 12 | }, 13 | "result": { 14 | "stateRoot": "0xa7312add33811645c6aa65d928a1a4f49d65d448801912c069a0aa8fe9c1f393", 15 | "txRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 16 | "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 17 | "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", 18 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 19 | "receipts": [], 20 | "currentDifficulty": "0x20000", 21 | "gasUsed": "0x0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cmd/evm/testdata/5/readme.md: -------------------------------------------------------------------------------- 1 | These files exemplify a transition where there are no transactions, two ommers, at block `N-1` (delta 1) and `N-2` (delta 2). -------------------------------------------------------------------------------- /cmd/evm/testdata/5/txs.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /cmd/simulator/.simulator/keys/0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC: -------------------------------------------------------------------------------- 1 | 56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027 2 | -------------------------------------------------------------------------------- /commontype/test_fee_config.go: -------------------------------------------------------------------------------- 1 | // (c) 2023, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package commontype 5 | 6 | import "math/big" 7 | 8 | var ValidTestFeeConfig = FeeConfig{ 9 | GasLimit: big.NewInt(8_000_000), 10 | TargetBlockRate: 2, // in seconds 11 | 12 | MinBaseFee: big.NewInt(25_000_000_000), 13 | TargetGas: big.NewInt(15_000_000), 14 | BaseFeeChangeDenominator: big.NewInt(36), 15 | 16 | MinBlockGasCost: big.NewInt(0), 17 | MaxBlockGasCost: big.NewInt(1_000_000), 18 | BlockGasCostStep: big.NewInt(200_000), 19 | } 20 | -------------------------------------------------------------------------------- /compatibility.json: -------------------------------------------------------------------------------- 1 | { 2 | "rpcChainVMProtocolVersion": { 3 | "v0.7.4": 40, 4 | "v0.7.3": 39, 5 | "v0.7.2": 39, 6 | "v0.7.1": 39, 7 | "v0.7.0": 38 8 | } 9 | } -------------------------------------------------------------------------------- /constants/constants.go: -------------------------------------------------------------------------------- 1 | // (c) 2021-2022, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package constants 5 | 6 | import "github.com/ava-labs/libevm/common" 7 | 8 | var ( 9 | BlackholeAddr = common.Address{ 10 | 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12 | } 13 | ) 14 | -------------------------------------------------------------------------------- /contracts/.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | -------------------------------------------------------------------------------- /contracts/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "overrides": [ 3 | { 4 | "files": "*.sol", 5 | "options": { 6 | "printWidth": 120, 7 | "tabWidth": 2, 8 | "useTabs": false, 9 | "singleQuote": false, 10 | "bracketSpacing": false, 11 | "explicitTypes": "always" 12 | } 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /contracts/contracts/ExampleDeployerList.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.24; 3 | 4 | import "@openzeppelin/contracts/access/Ownable.sol"; 5 | import "./interfaces/IAllowList.sol"; 6 | import "./AllowList.sol"; 7 | 8 | address constant DEPLOYER_LIST = 0x0200000000000000000000000000000000000000; 9 | 10 | // ExampleDeployerList shows how ContractDeployerAllowList precompile can be used in a smart contract 11 | // All methods of [allowList] can be directly called. There are example calls as tasks in hardhat.config.ts file. 12 | contract ExampleDeployerList is AllowList { 13 | // Precompiled Allow List Contract Address 14 | constructor() AllowList(DEPLOYER_LIST) {} 15 | 16 | function deployContract() public { 17 | new Example(); 18 | } 19 | } 20 | 21 | // This is an empty contract that can be used to test contract deployment 22 | contract Example {} 23 | -------------------------------------------------------------------------------- /contracts/contracts/ExampleRewardManager.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.24; 3 | 4 | import "./interfaces/IRewardManager.sol"; 5 | import "@openzeppelin/contracts/access/Ownable.sol"; 6 | 7 | address constant REWARD_MANAGER_ADDRESS = 0x0200000000000000000000000000000000000004; 8 | 9 | // ExampleRewardManager is a sample wrapper contract for RewardManager precompile. 10 | contract ExampleRewardManager is Ownable { 11 | IRewardManager rewardManager = IRewardManager(REWARD_MANAGER_ADDRESS); 12 | 13 | constructor() Ownable() {} 14 | 15 | function currentRewardAddress() public view returns (address) { 16 | return rewardManager.currentRewardAddress(); 17 | } 18 | 19 | function setRewardAddress(address addr) public onlyOwner { 20 | rewardManager.setRewardAddress(addr); 21 | } 22 | 23 | function allowFeeRecipients() public onlyOwner { 24 | rewardManager.allowFeeRecipients(); 25 | } 26 | 27 | function disableRewards() public onlyOwner { 28 | rewardManager.disableRewards(); 29 | } 30 | 31 | function areFeeRecipientsAllowed() public view returns (bool) { 32 | return rewardManager.areFeeRecipientsAllowed(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /contracts/contracts/ExampleTxAllowList.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.24; 3 | 4 | import "./AllowList.sol"; 5 | import "./interfaces/IAllowList.sol"; 6 | 7 | // Precompiled Allow List Contract Address 8 | address constant TX_ALLOW_LIST = 0x0200000000000000000000000000000000000002; 9 | 10 | // ExampleTxAllowList shows how TxAllowList precompile can be used in a smart contract 11 | // All methods of [allowList] can be directly called. There are example calls as tasks in hardhat.config.ts file. 12 | contract ExampleTxAllowList is AllowList { 13 | constructor() AllowList(TX_ALLOW_LIST) {} 14 | 15 | function deployContract() public { 16 | new Example(); 17 | } 18 | } 19 | 20 | contract Example {} 21 | -------------------------------------------------------------------------------- /contracts/contracts/interfaces/IAllowList.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.24; 3 | 4 | interface IAllowList { 5 | event RoleSet(uint256 indexed role, address indexed account, address indexed sender, uint256 oldRole); 6 | 7 | // Set [addr] to have the admin role over the precompile contract. 8 | function setAdmin(address addr) external; 9 | 10 | // Set [addr] to be enabled on the precompile contract. 11 | function setEnabled(address addr) external; 12 | 13 | // Set [addr] to have the manager role over the precompile contract. 14 | function setManager(address addr) external; 15 | 16 | // Set [addr] to have no role for the precompile contract. 17 | function setNone(address addr) external; 18 | 19 | // Read the status of [addr]. 20 | function readAllowList(address addr) external view returns (uint256 role); 21 | } 22 | -------------------------------------------------------------------------------- /contracts/contracts/interfaces/IFeeManager.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.24; 3 | import "./IAllowList.sol"; 4 | 5 | interface IFeeManager is IAllowList { 6 | struct FeeConfig { 7 | uint256 gasLimit; 8 | uint256 targetBlockRate; 9 | uint256 minBaseFee; 10 | uint256 targetGas; 11 | uint256 baseFeeChangeDenominator; 12 | uint256 minBlockGasCost; 13 | uint256 maxBlockGasCost; 14 | uint256 blockGasCostStep; 15 | } 16 | event FeeConfigChanged(address indexed sender, FeeConfig oldFeeConfig, FeeConfig newFeeConfig); 17 | 18 | // Set fee config fields to contract storage 19 | function setFeeConfig( 20 | uint256 gasLimit, 21 | uint256 targetBlockRate, 22 | uint256 minBaseFee, 23 | uint256 targetGas, 24 | uint256 baseFeeChangeDenominator, 25 | uint256 minBlockGasCost, 26 | uint256 maxBlockGasCost, 27 | uint256 blockGasCostStep 28 | ) external; 29 | 30 | // Get fee config from the contract storage 31 | function getFeeConfig() 32 | external 33 | view 34 | returns ( 35 | uint256 gasLimit, 36 | uint256 targetBlockRate, 37 | uint256 minBaseFee, 38 | uint256 targetGas, 39 | uint256 baseFeeChangeDenominator, 40 | uint256 minBlockGasCost, 41 | uint256 maxBlockGasCost, 42 | uint256 blockGasCostStep 43 | ); 44 | 45 | // Get the last block number changed the fee config from the contract storage 46 | function getFeeConfigLastChangedAt() external view returns (uint256 blockNumber); 47 | } 48 | -------------------------------------------------------------------------------- /contracts/contracts/interfaces/INativeMinter.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.24; 3 | import "./IAllowList.sol"; 4 | 5 | interface INativeMinter is IAllowList { 6 | event NativeCoinMinted(address indexed sender, address indexed recipient, uint256 amount); 7 | // Mint [amount] number of native coins and send to [addr] 8 | function mintNativeCoin(address addr, uint256 amount) external; 9 | } 10 | -------------------------------------------------------------------------------- /contracts/contracts/interfaces/IRewardManager.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.24; 3 | import "./IAllowList.sol"; 4 | 5 | interface IRewardManager is IAllowList { 6 | // RewardAddressChanged is the event logged whenever reward address is modified 7 | event RewardAddressChanged( 8 | address indexed sender, 9 | address indexed oldRewardAddress, 10 | address indexed newRewardAddress 11 | ); 12 | 13 | // FeeRecipientsAllowed is the event logged whenever fee recipient is modified 14 | event FeeRecipientsAllowed(address indexed sender); 15 | 16 | // RewardsDisabled is the event logged whenever rewards are disabled 17 | event RewardsDisabled(address indexed sender); 18 | 19 | // setRewardAddress sets the reward address to the given address 20 | function setRewardAddress(address addr) external; 21 | 22 | // allowFeeRecipients allows block builders to claim fees 23 | function allowFeeRecipients() external; 24 | 25 | // disableRewards disables block rewards and starts burning fees 26 | function disableRewards() external; 27 | 28 | // currentRewardAddress returns the current reward address 29 | function currentRewardAddress() external view returns (address rewardAddress); 30 | 31 | // areFeeRecipientsAllowed returns true if fee recipients are allowed 32 | function areFeeRecipientsAllowed() external view returns (bool isAllowed); 33 | } 34 | -------------------------------------------------------------------------------- /contracts/contracts/test/AllowListTest.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.24; 3 | 4 | import "../AllowList.sol"; 5 | import "ds-test/src/test.sol"; 6 | 7 | contract AllowListTest is DSTest { 8 | function assertRole(uint result, AllowList.Role role) internal { 9 | assertEq(result, uint(role)); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/index.ts: -------------------------------------------------------------------------------- 1 | export { test } from './test/utils'; 2 | -------------------------------------------------------------------------------- /contracts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@avalabs/subnet-evm-contracts", 3 | "devDependencies": { 4 | "@nomicfoundation/hardhat-chai-matchers": "^2.0.6", 5 | "@nomicfoundation/hardhat-toolbox": "^5.0.0", 6 | "@types/chai": "^4.3.16", 7 | "@types/mocha": "^9.1.1", 8 | "@types/node": "^20.12.12", 9 | "chai": "^4.4.1", 10 | "ds-test": "https://github.com/dapphub/ds-test.git", 11 | "hardhat": "^2.22.4", 12 | "prettier": "^3.2.4", 13 | "prettier-plugin-solidity": "^1.3.1", 14 | "ts-node": "^10.9.2", 15 | "typescript": "^5.4.5" 16 | }, 17 | "version": "1.2.2", 18 | "description": "", 19 | "main": "dist/index.js", 20 | "types": "dist/index.d.ts", 21 | "module": "dist/index.js", 22 | "repository": { 23 | "type": "git", 24 | "url": "https://github.com/ava-labs/subnet-evm.git", 25 | "directory": "contracts" 26 | }, 27 | "license": "BSD-3-Clause", 28 | "scripts": { 29 | "build": "rm -rf dist/ && npx hardhat compile && npx tsc -b ", 30 | "compile": "npx hardhat compile", 31 | "console": "npx hardhat console", 32 | "test": "npx hardhat test", 33 | "lint": "prettier --list-different 'contracts/**/*.sol'", 34 | "prepublish": "npm run build", 35 | "release:prepare": "rm -rf ./node_modules && npm install && npm run build" 36 | }, 37 | "dependencies": { 38 | "@avalabs/avalanchejs": "^4.0.5", 39 | "@openzeppelin/contracts": "^4.9.6" 40 | }, 41 | "engines": { 42 | "npm": ">7.0.0", 43 | "node": ">=20.13.0" 44 | } 45 | } -------------------------------------------------------------------------------- /contracts/scripts/deployERC20NativeMinter.ts: -------------------------------------------------------------------------------- 1 | import { ethers } from "hardhat" 2 | import { ERC20NativeMinter } from "typechain-types" 3 | 4 | const main = async (): Promise => { 5 | const token: ERC20NativeMinter = await ethers.deployContract("ERC20NativeMinter") 6 | await token.waitForDeployment() 7 | console.log(`Token deployed to: ${token.target}`) 8 | } 9 | 10 | main() 11 | .then(() => process.exit(0)) 12 | .catch(error => { 13 | console.error(error) 14 | process.exit(1) 15 | }) 16 | -------------------------------------------------------------------------------- /contracts/scripts/deployExampleDeployerList.ts: -------------------------------------------------------------------------------- 1 | import { ethers } from "hardhat" 2 | import { ExampleDeployerList } from "typechain-types" 3 | 4 | const main = async (): Promise => { 5 | const contract: ExampleDeployerList = await ethers.deployContract("ExampleDeployerList") 6 | await contract.waitForDeployment() 7 | console.log(`Contract deployed to: ${contract.target}`) 8 | } 9 | 10 | main() 11 | .then(() => process.exit(0)) 12 | .catch(error => { 13 | console.error(error) 14 | process.exit(1) 15 | }) 16 | -------------------------------------------------------------------------------- /contracts/scripts/deployExampleRewardManager.ts: -------------------------------------------------------------------------------- 1 | import { ethers } from "hardhat" 2 | import { ExampleRewardManager } from "typechain-types" 3 | 4 | const main = async (): Promise => { 5 | const contract: ExampleRewardManager = await ethers.deployContract("ExampleRewardManager") 6 | 7 | await contract.waitForDeployment() 8 | console.log(`Contract deployed to: ${contract.target}`) 9 | } 10 | 11 | main() 12 | .then(() => process.exit(0)) 13 | .catch(error => { 14 | console.error(error) 15 | process.exit(1) 16 | }) 17 | -------------------------------------------------------------------------------- /contracts/scripts/deployExampleTxAllowList.ts: -------------------------------------------------------------------------------- 1 | import { ethers } from "hardhat" 2 | import { ExampleTxAllowList } from "typechain-types" 3 | 4 | const main = async (): Promise => { 5 | const contract: ExampleTxAllowList = await ethers.deployContract("ExampleTxAllowList") 6 | 7 | await contract.waitForDeployment() 8 | console.log(`Contract deployed to: ${contract.target}`) 9 | } 10 | 11 | main() 12 | .then(() => process.exit(0)) 13 | .catch(error => { 14 | console.error(error) 15 | process.exit(1) 16 | }) 17 | -------------------------------------------------------------------------------- /contracts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist/", 4 | "baseUrl": ".", 5 | "module": "commonjs", 6 | "target": "es2020", 7 | "typeRoots": ["./typings/**", "./node_modules/@types"], 8 | "esModuleInterop": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "skipLibCheck": true, 11 | "resolveJsonModule": true, 12 | }, 13 | "exclude": ["node_modules", "artifacts", "cache"], 14 | "typeAcquisition": { 15 | "enable": true, 16 | "exclude": ["bn.js"] 17 | }, 18 | } 19 | -------------------------------------------------------------------------------- /core/TrieStressTest.abi: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getData","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"writeValues","outputs":[],"stateMutability":"nonpayable","type":"function"}] -------------------------------------------------------------------------------- /core/TrieStressTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | contract TrieStressTest { 5 | bytes32[] private data; 6 | 7 | function writeValues(uint value) public { 8 | bytes32 dataToPush = bytes32(uint256(uint160(msg.sender)) << 96); 9 | for (uint i = 0; i < value; i++) { 10 | data.push(dataToPush); 11 | } 12 | } 13 | 14 | function getLength() public view returns (uint) { 15 | return data.length; 16 | } 17 | 18 | function getData(uint index) public view returns (bytes32) { 19 | require(index < data.length, "Index out of bound"); 20 | return data[index]; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/blockchain_ext.go: -------------------------------------------------------------------------------- 1 | // (c) 2024 Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | package core 4 | 5 | import "github.com/ava-labs/libevm/metrics" 6 | 7 | // getOrOverrideAsRegisteredCounter searches for a metric already registered 8 | // with `name`. If a metric is found and it is a [metrics.Counter], it is returned. If a 9 | // metric is found and it is not a [metrics.Counter], it is unregistered and replaced with 10 | // a new registered [metrics.Counter]. If no metric is found, a new [metrics.Counter] is constructed 11 | // and registered. 12 | // 13 | // This is necessary for a metric defined in libevm with the same name but a 14 | // different type to what we expect. 15 | func getOrOverrideAsRegisteredCounter(name string, r metrics.Registry) metrics.Counter { 16 | if r == nil { 17 | r = metrics.DefaultRegistry 18 | } 19 | 20 | if c, ok := r.GetOrRegister(name, metrics.NewCounter).(metrics.Counter); ok { 21 | return c 22 | } 23 | // `name` must have already been registered to be any other type 24 | r.Unregister(name) 25 | return metrics.NewRegisteredCounter(name, r) 26 | } 27 | -------------------------------------------------------------------------------- /core/bloombits/doc.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2020, Ava Labs, Inc. 2 | // 3 | // This file is a derived work, based on the go-ethereum library whose original 4 | // notices appear below. 5 | // 6 | // It is distributed under a license compatible with the licensing terms of the 7 | // original code from which it is derived. 8 | // 9 | // Much love to the original authors for their work. 10 | // ********** 11 | // Copyright 2017 The go-ethereum Authors 12 | // This file is part of the go-ethereum library. 13 | // 14 | // The go-ethereum library is free software: you can redistribute it and/or modify 15 | // it under the terms of the GNU Lesser General Public License as published by 16 | // the Free Software Foundation, either version 3 of the License, or 17 | // (at your option) any later version. 18 | // 19 | // The go-ethereum library is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU Lesser General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public License 25 | // along with the go-ethereum library. If not, see . 26 | 27 | // Package bloombits implements bloom filtering on batches of data. 28 | package bloombits 29 | -------------------------------------------------------------------------------- /core/extstate/test_statedb.go: -------------------------------------------------------------------------------- 1 | // (c) 2023, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | package extstate 4 | 5 | import ( 6 | "testing" 7 | 8 | "github.com/ava-labs/libevm/common" 9 | "github.com/ava-labs/libevm/core/rawdb" 10 | "github.com/ava-labs/subnet-evm/core/state" 11 | "github.com/ava-labs/subnet-evm/precompile/contract" 12 | "github.com/stretchr/testify/require" 13 | ) 14 | 15 | func NewTestStateDB(t testing.TB) contract.StateDB { 16 | db := rawdb.NewMemoryDatabase() 17 | statedb, err := state.New(common.Hash{}, state.NewDatabase(db), nil) 18 | require.NoError(t, err) 19 | return New(statedb) 20 | } 21 | -------------------------------------------------------------------------------- /core/main_test.go: -------------------------------------------------------------------------------- 1 | // (c) 2023, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package core 5 | 6 | import ( 7 | "testing" 8 | 9 | "go.uber.org/goleak" 10 | ) 11 | 12 | // TestMain uses goleak to verify tests in this package do not leak unexpected 13 | // goroutines. 14 | func TestMain(m *testing.M) { 15 | opts := []goleak.Option{ 16 | // No good way to shut down these goroutines: 17 | goleak.IgnoreTopFunction("github.com/ava-labs/subnet-evm/core/state/snapshot.(*diskLayer).generate"), 18 | goleak.IgnoreTopFunction("github.com/ava-labs/libevm/core.(*txSenderCacher).cache"), 19 | goleak.IgnoreTopFunction("github.com/ava-labs/libevm/metrics.(*meterArbiter).tick"), 20 | goleak.IgnoreTopFunction("github.com/ava-labs/subnet-evm/metrics.(*meterArbiter).tick"), 21 | goleak.IgnoreTopFunction("github.com/syndtr/goleveldb/leveldb.(*DB).mpoolDrain"), 22 | } 23 | goleak.VerifyTestMain(m, opts...) 24 | } 25 | -------------------------------------------------------------------------------- /core/state/dump.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2020, Ava Labs, Inc. 2 | // 3 | // This file is a derived work, based on the go-ethereum library whose original 4 | // notices appear below. 5 | // 6 | // It is distributed under a license compatible with the licensing terms of the 7 | // original code from which it is derived. 8 | // 9 | // Much love to the original authors for their work. 10 | // ********** 11 | // Copyright 2014 The go-ethereum Authors 12 | // This file is part of the go-ethereum library. 13 | // 14 | // The go-ethereum library is free software: you can redistribute it and/or modify 15 | // it under the terms of the GNU Lesser General Public License as published by 16 | // the Free Software Foundation, either version 3 of the License, or 17 | // (at your option) any later version. 18 | // 19 | // The go-ethereum library is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU Lesser General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public License 25 | // along with the go-ethereum library. If not, see . 26 | 27 | package state 28 | 29 | import ( 30 | ethstate "github.com/ava-labs/libevm/core/state" 31 | ) 32 | 33 | type ( 34 | DumpConfig = ethstate.DumpConfig 35 | DumpCollector = ethstate.DumpCollector 36 | DumpAccount = ethstate.DumpAccount 37 | Dump = ethstate.Dump 38 | ) 39 | -------------------------------------------------------------------------------- /core/vm/runtime/doc.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2021, Ava Labs, Inc. 2 | // 3 | // This file is a derived work, based on the go-ethereum library whose original 4 | // notices appear below. 5 | // 6 | // It is distributed under a license compatible with the licensing terms of the 7 | // original code from which it is derived. 8 | // 9 | // Much love to the original authors for their work. 10 | // ********** 11 | // Copyright 2014 The go-ethereum Authors 12 | // This file is part of the go-ethereum library. 13 | // 14 | // The go-ethereum library is free software: you can redistribute it and/or modify 15 | // it under the terms of the GNU Lesser General Public License as published by 16 | // the Free Software Foundation, either version 3 of the License, or 17 | // (at your option) any later version. 18 | // 19 | // The go-ethereum library is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU Lesser General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public License 25 | // along with the go-ethereum library. If not, see . 26 | 27 | // Package runtime provides a basic execution model for executing EVM code. 28 | package runtime 29 | -------------------------------------------------------------------------------- /core/vm/testdata/precompiles/fail-blsMapG1.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Input": "", 4 | "ExpectedError": "invalid input length", 5 | "Name": "bls_mapg1_empty_input" 6 | }, 7 | { 8 | "Input": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 9 | "ExpectedError": "invalid input length", 10 | "Name": "bls_mapg1_short_input" 11 | }, 12 | { 13 | "Input": "00000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 14 | "ExpectedError": "invalid field element top bytes", 15 | "Name": "bls_mapg1_top_bytes" 16 | }, 17 | { 18 | "Input": "000000000000000000000000000000001a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaac", 19 | "ExpectedError": "must be less than modulus", 20 | "Name": "bls_mapg1_invalid_fq_element" 21 | } 22 | ] -------------------------------------------------------------------------------- /core/vm/testdata/precompiles/fail-blsMapG2.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Input": "", 4 | "ExpectedError": "invalid input length", 5 | "Name": "bls_mapg2_empty_input" 6 | }, 7 | { 8 | "Input": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 9 | "ExpectedError": "invalid input length", 10 | "Name": "bls_mapg2_short_input" 11 | }, 12 | { 13 | "Input": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 14 | "ExpectedError": "invalid field element top bytes", 15 | "Name": "bls_mapg2_top_bytes" 16 | }, 17 | { 18 | "Input": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaac", 19 | "ExpectedError": "must be less than modulus", 20 | "Name": "bls_mapg2_invalid_fq_element" 21 | } 22 | ] -------------------------------------------------------------------------------- /core/vm/testdata/precompiles/pointEvaluation.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Input": "01e798154708fe7789429634053cbf9f99b619f9f084048927333fce637f549b564c0a11a0f704f4fc3e8acfe0f8245f0ad1347b378fbf96e206da11a5d3630624d25032e67a7e6a4910df5834b8fe70e6bcfeeac0352434196bdf4b2485d5a18f59a8d2a1a625a17f3fea0fe5eb8c896db3764f3185481bc22f91b4aaffcca25f26936857bc3a7c2539ea8ec3a952b7873033e038326e87ed3e1276fd140253fa08e9fc25fb2d9a98527fc22a2c9612fbeafdad446cbc7bcdbdcd780af2c16a", 4 | "Expected": "000000000000000000000000000000000000000000000000000000000000100073eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001", 5 | "Name": "pointEvaluation1", 6 | "Gas": 50000, 7 | "NoBenchmark": false 8 | } 9 | ] 10 | -------------------------------------------------------------------------------- /coreth-version.txt: -------------------------------------------------------------------------------- 1 | 7316fd89b3a6b5d4f257611788f87b22f9007a26 -------------------------------------------------------------------------------- /docs/audits/Avalanche Warp Messaging - OpenZeppelin (November 16th 2023).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ava-labs/subnet-evm/487a0b5e0d9ca109ea8a9e9095a032e6a968c511/docs/audits/Avalanche Warp Messaging - OpenZeppelin (November 16th 2023).pdf -------------------------------------------------------------------------------- /docs/audits/Bridge Smart Contracts - Least Authority (July 7th 2023).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ava-labs/subnet-evm/487a0b5e0d9ca109ea8a9e9095a032e6a968c511/docs/audits/Bridge Smart Contracts - Least Authority (July 7th 2023).pdf -------------------------------------------------------------------------------- /docs/audits/Subnet EVM - Least Authority (April 3rd 2023).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ava-labs/subnet-evm/487a0b5e0d9ca109ea8a9e9095a032e6a968c511/docs/audits/Subnet EVM - Least Authority (April 3rd 2023).pdf -------------------------------------------------------------------------------- /eth/chain_with_final_block.go: -------------------------------------------------------------------------------- 1 | //nolint:unused 2 | package eth 3 | 4 | import ( 5 | "github.com/ava-labs/libevm/core/types" 6 | "github.com/ava-labs/subnet-evm/core" 7 | ) 8 | 9 | const blocksToKeep = 604_800 // Approx. 2 weeks worth of blocks assuming 2s block time 10 | 11 | type chainWithFinalBlock struct { 12 | *core.BlockChain 13 | } 14 | 15 | // CurrentFinalBlock returns the current block below which blobs should not 16 | // be maintained anymore for reorg purposes. 17 | func (c *chainWithFinalBlock) CurrentFinalBlock() *types.Header { 18 | lastAccepted := c.LastAcceptedBlock().Header().Number.Uint64() 19 | if lastAccepted <= blocksToKeep { 20 | return nil 21 | } 22 | 23 | return c.GetHeaderByNumber(lastAccepted - blocksToKeep) 24 | } 25 | -------------------------------------------------------------------------------- /ethclient/client_interface_test.go: -------------------------------------------------------------------------------- 1 | package ethclient 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | func TestInterfaceStructOneToOne(t *testing.T) { 9 | // checks struct provides at least the methods signatures in the interface 10 | var _ Client = (*client)(nil) 11 | // checks interface and struct have the same number of methods 12 | clientType := reflect.TypeOf(&client{}) 13 | ClientType := reflect.TypeOf((*Client)(nil)).Elem() 14 | if clientType.NumMethod() != ClientType.NumMethod() { 15 | t.Fatalf("no 1 to 1 compliance between struct methods (%v) and interface methods (%v)", clientType.NumMethod(), ClientType.NumMethod()) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /interfaces/interfaces.go: -------------------------------------------------------------------------------- 1 | // (c) 2025, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package interfaces 5 | 6 | import ( 7 | "context" 8 | 9 | ethereum "github.com/ava-labs/libevm" 10 | "github.com/ava-labs/libevm/common" 11 | ) 12 | 13 | // An AcceptedStateReceiver provides access to the accepted state ie. the state of the 14 | // most recently accepted block. 15 | type AcceptedStateReader interface { 16 | AcceptedCodeAt(ctx context.Context, account common.Address) ([]byte, error) 17 | AcceptedNonceAt(ctx context.Context, account common.Address) (uint64, error) 18 | } 19 | 20 | // AcceptedContractCaller can be used to perform calls against the accepted state. 21 | type AcceptedContractCaller interface { 22 | AcceptedCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error) 23 | } 24 | -------------------------------------------------------------------------------- /internal/debug/loudpanic.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2020, Ava Labs, Inc. 2 | // 3 | // This file is a derived work, based on the go-ethereum library whose original 4 | // notices appear below. 5 | // 6 | // It is distributed under a license compatible with the licensing terms of the 7 | // original code from which it is derived. 8 | // 9 | // Much love to the original authors for their work. 10 | // ********** 11 | // Copyright 2016 The go-ethereum Authors 12 | // This file is part of the go-ethereum library. 13 | // 14 | // The go-ethereum library is free software: you can redistribute it and/or modify 15 | // it under the terms of the GNU Lesser General Public License as published by 16 | // the Free Software Foundation, either version 3 of the License, or 17 | // (at your option) any later version. 18 | // 19 | // The go-ethereum library is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU Lesser General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public License 25 | // along with the go-ethereum library. If not, see . 26 | 27 | package debug 28 | 29 | import "runtime/debug" 30 | 31 | // LoudPanic panics in a way that gets all goroutine stacks printed on stderr. 32 | func LoudPanic(x interface{}) { 33 | debug.SetTraceback("all") 34 | panic(x) 35 | } 36 | -------------------------------------------------------------------------------- /internal/ethapi/mocks_generate_test.go: -------------------------------------------------------------------------------- 1 | package ethapi 2 | 3 | //go:generate go run go.uber.org/mock/mockgen -package=$GOPACKAGE -destination=mocks_test.go . Backend 4 | -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockByHash-hash-empty-fullTx.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockByHash-hash-pending-fullTx.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockByHash-hash-pending.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockByNumber-number-latest+1.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockByNumber-tag-pending-fullTx.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockByNumber-tag-pending.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockReceipts-block-notfound.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockReceipts-block-with-blob-tx.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "blobGasPrice": "0x1", 4 | "blobGasUsed": "0x20000", 5 | "blockHash": "0xff73bf27fcb39258f9c4a2f7f6eb018f7029f2d5bd960a63ebb4d7ecd8044545", 6 | "blockNumber": "0x6", 7 | "contractAddress": null, 8 | "cumulativeGasUsed": "0x5208", 9 | "effectiveGasPrice": "0x5d21dba01", 10 | "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", 11 | "gasUsed": "0x5208", 12 | "logs": [], 13 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 14 | "status": "0x1", 15 | "to": "0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e", 16 | "transactionHash": "0x7e71344129674f4bbfdaa86313d005a96581993d93ae3a30d81b13fa25579eb2", 17 | "transactionIndex": "0x0", 18 | "type": "0x3" 19 | } 20 | ] -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockReceipts-block-with-contract-create-tx.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "blockHash": "0xdcba2f7c99ad0f58002737f1393578f1b72aca3270c1722d9d0fbdc2439b0484", 4 | "blockNumber": "0x2", 5 | "contractAddress": "0xae9bea628c4ce503dcfd7e305cab4e29e7476592", 6 | "cumulativeGasUsed": "0xcf50", 7 | "effectiveGasPrice": "0x5d21dba00", 8 | "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", 9 | "gasUsed": "0xcf50", 10 | "logs": [], 11 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 12 | "status": "0x1", 13 | "to": null, 14 | "transactionHash": "0x22aa617165f83a9f8c191c2b7724ae43eeb1249bee06c98c03c7624c21d27dc8", 15 | "transactionIndex": "0x0", 16 | "type": "0x0" 17 | } 18 | ] -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockReceipts-block-with-dynamic-fee-tx.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "blockHash": "0xfa29fee1c5195fda47b23d3ce5259e314eb7578d18b76b36068d0e321db024e1", 4 | "blockNumber": "0x4", 5 | "contractAddress": null, 6 | "cumulativeGasUsed": "0x538d", 7 | "effectiveGasPrice": "0x5d21dbbf4", 8 | "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", 9 | "gasUsed": "0x538d", 10 | "logs": [], 11 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 12 | "status": "0x0", 13 | "to": "0x0000000000000000000000000000000000031ec7", 14 | "transactionHash": "0x4e1e9194ca6f9d4e1736e9e441f66104f273548ed6d91b236a5f9c2ea10fa06d", 15 | "transactionIndex": "0x0", 16 | "type": "0x2" 17 | } 18 | ] -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockReceipts-block-with-legacy-transfer-tx.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "blockHash": "0xf9081fe79fcdfd6a743577cc42fa17bec5e6cc1ebf5807b771724bf88b454b71", 4 | "blockNumber": "0x1", 5 | "contractAddress": null, 6 | "cumulativeGasUsed": "0x5208", 7 | "effectiveGasPrice": "0x5d21dba00", 8 | "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", 9 | "gasUsed": "0x5208", 10 | "logs": [], 11 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 12 | "status": "0x1", 13 | "to": "0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e", 14 | "transactionHash": "0xdf92bc7c4c0341ecbdcd2a3ca7011fe9e21df4b8553bf0c8caabe6cb4a1aee26", 15 | "transactionIndex": "0x0", 16 | "type": "0x0" 17 | } 18 | ] -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockReceipts-hash-empty.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockReceipts-hash-notfound.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockReceipts-number-0.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockReceipts-number-1.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockReceipts-tag-earliest.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getBlockReceipts-tag-latest.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "blobGasPrice": "0x1", 4 | "blobGasUsed": "0x20000", 5 | "blockHash": "0xff73bf27fcb39258f9c4a2f7f6eb018f7029f2d5bd960a63ebb4d7ecd8044545", 6 | "blockNumber": "0x6", 7 | "contractAddress": null, 8 | "cumulativeGasUsed": "0x5208", 9 | "effectiveGasPrice": "0x5d21dba01", 10 | "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", 11 | "gasUsed": "0x5208", 12 | "logs": [], 13 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 14 | "status": "0x1", 15 | "to": "0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e", 16 | "transactionHash": "0x7e71344129674f4bbfdaa86313d005a96581993d93ae3a30d81b13fa25579eb2", 17 | "transactionIndex": "0x0", 18 | "type": "0x3" 19 | } 20 | ] -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getHeaderByHash-hash-0.json: -------------------------------------------------------------------------------- 1 | { 2 | "baseFeePerGas": "0x5d21dba00", 3 | "difficulty": "0x20000", 4 | "extraData": "0x", 5 | "gasLimit": "0x47e7c4", 6 | "gasUsed": "0x0", 7 | "hash": "0xa779a1e82fd903ae98affe3a06a0a353906130052c24969b24237adf350bd03b", 8 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 9 | "miner": "0x0000000000000000000000000000000000000000", 10 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 11 | "nonce": "0x0000000000000000", 12 | "number": "0x0", 13 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 14 | "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 15 | "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", 16 | "stateRoot": "0xd883f48b83cc9c1e8389453beb4ad4e572462eec049ca4fffbe16ecefb3fe937", 17 | "timestamp": "0x0", 18 | "totalDifficulty": "0x0", 19 | "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" 20 | } -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getHeaderByHash-hash-empty.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getHeaderByHash-hash-pending.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getHeaderByNumber-number-0.json: -------------------------------------------------------------------------------- 1 | { 2 | "baseFeePerGas": "0x5d21dba00", 3 | "difficulty": "0x20000", 4 | "extraData": "0x", 5 | "gasLimit": "0x47e7c4", 6 | "gasUsed": "0x0", 7 | "hash": "0xa779a1e82fd903ae98affe3a06a0a353906130052c24969b24237adf350bd03b", 8 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 9 | "miner": "0x0000000000000000000000000000000000000000", 10 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 11 | "nonce": "0x0000000000000000", 12 | "number": "0x0", 13 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 14 | "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", 15 | "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", 16 | "stateRoot": "0xd883f48b83cc9c1e8389453beb4ad4e572462eec049ca4fffbe16ecefb3fe937", 17 | "timestamp": "0x0", 18 | "totalDifficulty": "0x0", 19 | "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" 20 | } -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getHeaderByNumber-number-latest+1.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getHeaderByNumber-tag-pending.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getTransactionReceipt-blob-tx.json: -------------------------------------------------------------------------------- 1 | { 2 | "blobGasPrice": "0x1", 3 | "blobGasUsed": "0x20000", 4 | "blockHash": "0xff73bf27fcb39258f9c4a2f7f6eb018f7029f2d5bd960a63ebb4d7ecd8044545", 5 | "blockNumber": "0x6", 6 | "contractAddress": null, 7 | "cumulativeGasUsed": "0x5208", 8 | "effectiveGasPrice": "0x5d21dba01", 9 | "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", 10 | "gasUsed": "0x5208", 11 | "logs": [], 12 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 13 | "status": "0x1", 14 | "to": "0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e", 15 | "transactionHash": "0x7e71344129674f4bbfdaa86313d005a96581993d93ae3a30d81b13fa25579eb2", 16 | "transactionIndex": "0x0", 17 | "type": "0x3" 18 | } -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getTransactionReceipt-create-contract-tx.json: -------------------------------------------------------------------------------- 1 | { 2 | "blockHash": "0xdcba2f7c99ad0f58002737f1393578f1b72aca3270c1722d9d0fbdc2439b0484", 3 | "blockNumber": "0x2", 4 | "contractAddress": "0xae9bea628c4ce503dcfd7e305cab4e29e7476592", 5 | "cumulativeGasUsed": "0xcf50", 6 | "effectiveGasPrice": "0x5d21dba00", 7 | "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", 8 | "gasUsed": "0xcf50", 9 | "logs": [], 10 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 11 | "status": "0x1", 12 | "to": null, 13 | "transactionHash": "0x22aa617165f83a9f8c191c2b7724ae43eeb1249bee06c98c03c7624c21d27dc8", 14 | "transactionIndex": "0x0", 15 | "type": "0x0" 16 | } -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getTransactionReceipt-create-contract-with-access-list.json: -------------------------------------------------------------------------------- 1 | { 2 | "blockHash": "0xea28a367715debefc3b6d9f5ed5ab5b8d3a13b956e87f05f148852d3e1e522b5", 3 | "blockNumber": "0x5", 4 | "contractAddress": "0xfdaa97661a584d977b4d3abb5370766ff5b86a18", 5 | "cumulativeGasUsed": "0xe01c", 6 | "effectiveGasPrice": "0x5d21dba00", 7 | "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", 8 | "gasUsed": "0xe01c", 9 | "logs": [], 10 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 11 | "status": "0x1", 12 | "to": null, 13 | "transactionHash": "0x8afe030574f663fe5096371d6f58a6287bfb3e0c73a5050220f5775a08e7abc9", 14 | "transactionIndex": "0x0", 15 | "type": "0x1" 16 | } -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getTransactionReceipt-dynamic-tx-with-logs.json: -------------------------------------------------------------------------------- 1 | { 2 | "blockHash": "0xfa29fee1c5195fda47b23d3ce5259e314eb7578d18b76b36068d0e321db024e1", 3 | "blockNumber": "0x4", 4 | "contractAddress": null, 5 | "cumulativeGasUsed": "0x538d", 6 | "effectiveGasPrice": "0x5d21dbbf4", 7 | "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", 8 | "gasUsed": "0x538d", 9 | "logs": [], 10 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 11 | "status": "0x0", 12 | "to": "0x0000000000000000000000000000000000031ec7", 13 | "transactionHash": "0x4e1e9194ca6f9d4e1736e9e441f66104f273548ed6d91b236a5f9c2ea10fa06d", 14 | "transactionIndex": "0x0", 15 | "type": "0x2" 16 | } -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getTransactionReceipt-normal-transfer-tx.json: -------------------------------------------------------------------------------- 1 | { 2 | "blockHash": "0xf9081fe79fcdfd6a743577cc42fa17bec5e6cc1ebf5807b771724bf88b454b71", 3 | "blockNumber": "0x1", 4 | "contractAddress": null, 5 | "cumulativeGasUsed": "0x5208", 6 | "effectiveGasPrice": "0x5d21dba00", 7 | "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", 8 | "gasUsed": "0x5208", 9 | "logs": [], 10 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 11 | "status": "0x1", 12 | "to": "0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e", 13 | "transactionHash": "0xdf92bc7c4c0341ecbdcd2a3ca7011fe9e21df4b8553bf0c8caabe6cb4a1aee26", 14 | "transactionIndex": "0x0", 15 | "type": "0x0" 16 | } -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getTransactionReceipt-txhash-empty.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /internal/ethapi/testdata/eth_getTransactionReceipt-txhash-notfound.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /internal/reexec/reexec.go: -------------------------------------------------------------------------------- 1 | // This file originates from Docker/Moby, 2 | // https://github.com/moby/moby/blob/master/pkg/reexec/reexec.go 3 | // Licensed under Apache License 2.0: https://github.com/moby/moby/blob/master/LICENSE 4 | // Copyright 2013-2018 Docker, Inc. 5 | // 6 | // Package reexec facilitates the busybox style reexec of the docker binary that 7 | // we require because of the forking limitations of using Go. Handlers can be 8 | // registered with a name and the argv 0 of the exec of the binary will be used 9 | // to find and execute custom init paths. 10 | package reexec 11 | 12 | import ( 13 | "fmt" 14 | "os" 15 | ) 16 | 17 | var registeredInitializers = make(map[string]func()) 18 | 19 | // Register adds an initialization func under the specified name 20 | func Register(name string, initializer func()) { 21 | if _, exists := registeredInitializers[name]; exists { 22 | panic(fmt.Sprintf("reexec func already registered under name %q", name)) 23 | } 24 | registeredInitializers[name] = initializer 25 | } 26 | 27 | // Init is called as the first part of the exec process and returns true if an 28 | // initialization function was called. 29 | func Init() bool { 30 | if initializer, ok := registeredInitializers[os.Args[0]]; ok { 31 | initializer() 32 | return true 33 | } 34 | return false 35 | } 36 | -------------------------------------------------------------------------------- /internal/reexec/self_linux.go: -------------------------------------------------------------------------------- 1 | // This file originates from Docker/Moby, 2 | // https://github.com/moby/moby/blob/master/pkg/reexec/ 3 | // Licensed under Apache License 2.0: https://github.com/moby/moby/blob/master/LICENSE 4 | // Copyright 2013-2018 Docker, Inc. 5 | 6 | //go:build linux 7 | 8 | package reexec 9 | 10 | // Self returns the path to the current process's binary. 11 | // Returns "/proc/self/exe". 12 | func Self() string { 13 | return "/proc/self/exe" 14 | } 15 | -------------------------------------------------------------------------------- /internal/reexec/self_others.go: -------------------------------------------------------------------------------- 1 | // This file originates from Docker/Moby, 2 | // https://github.com/moby/moby/blob/master/pkg/reexec/ 3 | // Licensed under Apache License 2.0: https://github.com/moby/moby/blob/master/LICENSE 4 | // Copyright 2013-2018 Docker, Inc. 5 | 6 | //go:build !linux 7 | 8 | package reexec 9 | 10 | import ( 11 | "os" 12 | "os/exec" 13 | "path/filepath" 14 | ) 15 | 16 | // Self returns the path to the current process's binary. 17 | // Uses os.Args[0]. 18 | func Self() string { 19 | name := os.Args[0] 20 | if filepath.Base(name) == name { 21 | if lp, err := exec.LookPath(name); err == nil { 22 | return lp 23 | } 24 | } 25 | // handle conversion of relative paths to absolute 26 | if absName, err := filepath.Abs(name); err == nil { 27 | return absName 28 | } 29 | // if we couldn't get absolute name, return original 30 | // (NOTE: Go only errors on Abs() if os.Getwd fails) 31 | return name 32 | } 33 | -------------------------------------------------------------------------------- /internal/testutils/key.go: -------------------------------------------------------------------------------- 1 | // (c) 2024-2025, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package testutils 5 | 6 | import ( 7 | "crypto/ecdsa" 8 | "crypto/rand" 9 | "testing" 10 | 11 | "github.com/ava-labs/libevm/common" 12 | "github.com/ava-labs/libevm/crypto" 13 | "github.com/stretchr/testify/require" 14 | ) 15 | 16 | // Key contains an ecdsa private key field as well as an address field 17 | // obtained from converting the ecdsa public key. 18 | type Key struct { 19 | Address common.Address 20 | PrivateKey *ecdsa.PrivateKey 21 | } 22 | 23 | // NewKey generates a new key pair and returns a pointer to a [Key]. 24 | func NewKey(t *testing.T) *Key { 25 | t.Helper() 26 | privateKeyECDSA, err := ecdsa.GenerateKey(crypto.S256(), rand.Reader) 27 | require.NoError(t, err) 28 | return &Key{ 29 | Address: crypto.PubkeyToAddress(privateKeyECDSA.PublicKey), 30 | PrivateKey: privateKeyECDSA, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /internal/testutils/metrics.go: -------------------------------------------------------------------------------- 1 | // (c) 2024-2025, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package testutils 5 | 6 | import ( 7 | "sync" 8 | "testing" 9 | 10 | "github.com/ava-labs/libevm/metrics" 11 | ) 12 | 13 | var metricsLock sync.Mutex 14 | 15 | // WithMetrics enables go-ethereum metrics globally for the test. 16 | // If the [metrics.Enabled] is already true, nothing is done. 17 | // Otherwise, it is set to true and is reverted to false when the test finishes. 18 | func WithMetrics(t *testing.T) { 19 | metricsLock.Lock() 20 | t.Cleanup(func() { 21 | metricsLock.Unlock() 22 | }) 23 | if metrics.Enabled { 24 | return 25 | } 26 | metrics.Enabled = true 27 | t.Cleanup(func() { 28 | metrics.Enabled = false 29 | }) 30 | } 31 | -------------------------------------------------------------------------------- /metrics/prometheus/interfaces.go: -------------------------------------------------------------------------------- 1 | // (c) 2025 Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | package prometheus 4 | 5 | import "github.com/ava-labs/libevm/metrics" 6 | 7 | var _ Registry = metrics.Registry(nil) 8 | 9 | type Registry interface { 10 | // Call the given function for each registered metric. 11 | Each(func(string, any)) 12 | // Get the metric by the given name or nil if none is registered. 13 | Get(string) any 14 | } 15 | -------------------------------------------------------------------------------- /node/defaults.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | package node 17 | 18 | // DefaultConfig contains reasonable default settings. 19 | var DefaultConfig = Config{ 20 | BatchRequestLimit: 1000, 21 | BatchResponseMaxSize: 25 * 1000 * 1000, 22 | } 23 | -------------------------------------------------------------------------------- /node/errors.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2020, Ava Labs, Inc. 2 | // 3 | // This file is a derived work, based on the go-ethereum library whose original 4 | // notices appear below. 5 | // 6 | // It is distributed under a license compatible with the licensing terms of the 7 | // original code from which it is derived. 8 | // 9 | // Much love to the original authors for their work. 10 | // ********** 11 | // Copyright 2015 The go-ethereum Authors 12 | // This file is part of the go-ethereum library. 13 | // 14 | // The go-ethereum library is free software: you can redistribute it and/or modify 15 | // it under the terms of the GNU Lesser General Public License as published by 16 | // the Free Software Foundation, either version 3 of the License, or 17 | // (at your option) any later version. 18 | // 19 | // The go-ethereum library is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU Lesser General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public License 25 | // along with the go-ethereum library. If not, see . 26 | 27 | package node 28 | 29 | import ( 30 | "errors" 31 | ) 32 | 33 | var ( 34 | ErrNodeStopped = errors.New("node not started") 35 | ) 36 | -------------------------------------------------------------------------------- /params/denomination.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2020, Ava Labs, Inc. 2 | // 3 | // This file is a derived work, based on the go-ethereum library whose original 4 | // notices appear below. 5 | // 6 | // It is distributed under a license compatible with the licensing terms of the 7 | // original code from which it is derived. 8 | // 9 | // Much love to the original authors for their work. 10 | // ********** 11 | // Copyright 2017 The go-ethereum Authors 12 | // This file is part of the go-ethereum library. 13 | // 14 | // The go-ethereum library is free software: you can redistribute it and/or modify 15 | // it under the terms of the GNU Lesser General Public License as published by 16 | // the Free Software Foundation, either version 3 of the License, or 17 | // (at your option) any later version. 18 | // 19 | // The go-ethereum library is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU Lesser General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public License 25 | // along with the go-ethereum library. If not, see . 26 | 27 | package params 28 | 29 | // These are the multipliers for ether denominations. 30 | // Example: To get the wei value of an amount in 'gwei', use 31 | // 32 | // new(big.Int).Mul(value, big.NewInt(params.GWei)) 33 | const ( 34 | Wei = 1 35 | GWei = 1e9 36 | Ether = 1e18 37 | ) 38 | -------------------------------------------------------------------------------- /params/extras/precompiles.go: -------------------------------------------------------------------------------- 1 | // (c) 2023 Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package extras 5 | 6 | import ( 7 | "encoding/json" 8 | 9 | "github.com/ava-labs/subnet-evm/precompile/modules" 10 | "github.com/ava-labs/subnet-evm/precompile/precompileconfig" 11 | ) 12 | 13 | type Precompiles map[string]precompileconfig.Config 14 | 15 | // UnmarshalJSON parses the JSON-encoded data into the ChainConfigPrecompiles. 16 | // ChainConfigPrecompiles is a map of precompile module keys to their 17 | // configuration. 18 | func (ccp *Precompiles) UnmarshalJSON(data []byte) error { 19 | raw := make(map[string]json.RawMessage) 20 | if err := json.Unmarshal(data, &raw); err != nil { 21 | return err 22 | } 23 | 24 | *ccp = make(Precompiles) 25 | for _, module := range modules.RegisteredModules() { 26 | key := module.ConfigKey 27 | if value, ok := raw[key]; ok { 28 | conf := module.MakeConfig() 29 | if err := json.Unmarshal(value, conf); err != nil { 30 | return err 31 | } 32 | (*ccp)[key] = conf 33 | } 34 | } 35 | return nil 36 | } 37 | -------------------------------------------------------------------------------- /params/extras/rules.go: -------------------------------------------------------------------------------- 1 | // (c) 2024 Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package extras 5 | 6 | import ( 7 | "github.com/ava-labs/libevm/common" 8 | "github.com/ava-labs/subnet-evm/precompile/precompileconfig" 9 | ) 10 | 11 | type Rules struct { 12 | // Rules for Avalanche releases 13 | AvalancheRules 14 | 15 | // Precompiles maps addresses to stateful precompiled contracts that are enabled 16 | // for this rule set. 17 | // Note: none of these addresses should conflict with the address space used by 18 | // any existing precompiles. 19 | Precompiles map[common.Address]precompileconfig.Config 20 | // Predicaters maps addresses to stateful precompile Predicaters 21 | // that are enabled for this rule set. 22 | Predicaters map[common.Address]precompileconfig.Predicater 23 | // AccepterPrecompiles map addresses to stateful precompile accepter functions 24 | // that are enabled for this rule set. 25 | AccepterPrecompiles map[common.Address]precompileconfig.Accepter 26 | } 27 | 28 | func (r *Rules) PredicatersExist() bool { 29 | return len(r.Predicaters) > 0 30 | } 31 | 32 | func (r *Rules) PredicaterExists(addr common.Address) bool { 33 | _, ok := r.Predicaters[addr] 34 | return ok 35 | } 36 | 37 | // IsPrecompileEnabled returns true if the precompile at `addr` is enabled for this rule set. 38 | func (r *Rules) IsPrecompileEnabled(addr common.Address) bool { 39 | _, ok := r.Precompiles[addr] 40 | return ok 41 | } 42 | -------------------------------------------------------------------------------- /peer/README.md: -------------------------------------------------------------------------------- 1 | # Peer Package 2 | 3 | The peer package handles networking for the VM. 4 | 5 | ## Network 6 | 7 | The `Network` interface implements the networking portion of the required VM interface. The VM utilizes the `Network` interface to: 8 | 9 | - Set an App Gossip handler for incoming VM gossip messages 10 | - Set an App Request handler for incoming VM request messages 11 | - Send App Requests to peers in the network and specify a response handler to be called upon receiving a response or failure notification 12 | - Send App Gossip messages to the network 13 | 14 | ## Client 15 | 16 | The client utilizes the `Network` interface to send requests to peers on the network and utilizes the `waitingHandler` to wait until a response or failure is received from the AvalancheGo networking layer. 17 | 18 | This allows the user of `Client` to treat it as if it were returning results from the network synchronously. 19 | 20 | ```go 21 | result, err := client.Request(nodeID, request) // Blocks until receiving a response from the network 22 | if err != nil { 23 | return err 24 | } 25 | 26 | foo(result) // do something with the result 27 | ``` 28 | -------------------------------------------------------------------------------- /peer/peertest/request_id.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2022, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package peertest 5 | 6 | const ( 7 | // TestSDKRequestID is the request ID for the SDK request, which is odd-numbered. 8 | // See peer.IsNetworkRequest for more details. 9 | TestSDKRequestID uint32 = 1 10 | 11 | // TestPeerRequestID is the request ID for the peer request, which is even-numbered. 12 | // See peer.IsNetworkRequest for more details. 13 | TestPeerRequestID uint32 = 0 14 | ) 15 | -------------------------------------------------------------------------------- /peer/stats/stats.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2022, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package stats 5 | 6 | import ( 7 | "time" 8 | 9 | "github.com/ava-labs/libevm/metrics" 10 | ) 11 | 12 | // RequestHandlerStats provides the interface for metrics for app requests. 13 | type RequestHandlerStats interface { 14 | UpdateTimeUntilDeadline(duration time.Duration) 15 | IncDeadlineDroppedRequest() 16 | } 17 | 18 | type requestHandlerStats struct { 19 | timeUntilDeadline metrics.Timer 20 | droppedRequests metrics.Counter 21 | } 22 | 23 | func (h *requestHandlerStats) IncDeadlineDroppedRequest() { 24 | h.droppedRequests.Inc(1) 25 | } 26 | 27 | func (h *requestHandlerStats) UpdateTimeUntilDeadline(duration time.Duration) { 28 | h.timeUntilDeadline.Update(duration) 29 | } 30 | 31 | func NewRequestHandlerStats() RequestHandlerStats { 32 | return &requestHandlerStats{ 33 | timeUntilDeadline: metrics.GetOrRegisterTimer("net_req_time_until_deadline", nil), 34 | droppedRequests: metrics.GetOrRegisterCounter("net_req_deadline_dropped", nil), 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /plugin/evm/api.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2020, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package evm 5 | 6 | import ( 7 | "context" 8 | "math/big" 9 | 10 | "github.com/ava-labs/libevm/common" 11 | "github.com/ava-labs/libevm/log" 12 | ) 13 | 14 | // SnowmanAPI introduces snowman specific functionality to the evm 15 | type SnowmanAPI struct{ vm *VM } 16 | 17 | // GetAcceptedFrontReply defines the reply that will be sent from the 18 | // GetAcceptedFront API call 19 | type GetAcceptedFrontReply struct { 20 | Hash common.Hash `json:"hash"` 21 | Number *big.Int `json:"number"` 22 | } 23 | 24 | // GetAcceptedFront returns the last accepted block's hash and height 25 | func (api *SnowmanAPI) GetAcceptedFront(ctx context.Context) (*GetAcceptedFrontReply, error) { 26 | blk := api.vm.blockChain.LastConsensusAcceptedBlock() 27 | return &GetAcceptedFrontReply{ 28 | Hash: blk.Hash(), 29 | Number: blk.Number(), 30 | }, nil 31 | } 32 | 33 | // IssueBlock to the chain 34 | func (api *SnowmanAPI) IssueBlock(ctx context.Context) error { 35 | log.Info("Issuing a new block") 36 | api.vm.builder.signalTxsReady() 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /plugin/evm/config.go: -------------------------------------------------------------------------------- 1 | // (c) 2025, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package evm 5 | 6 | import ( 7 | "github.com/ava-labs/subnet-evm/core/txpool/legacypool" 8 | "github.com/ava-labs/subnet-evm/plugin/evm/config" 9 | ) 10 | 11 | // defaultTxPoolConfig uses [legacypool.DefaultConfig] to make a [config.TxPoolConfig] 12 | // that can be passed to [config.Config.SetDefaults]. 13 | var defaultTxPoolConfig = config.TxPoolConfig{ 14 | PriceLimit: legacypool.DefaultConfig.PriceLimit, 15 | PriceBump: legacypool.DefaultConfig.PriceBump, 16 | AccountSlots: legacypool.DefaultConfig.AccountSlots, 17 | GlobalSlots: legacypool.DefaultConfig.GlobalSlots, 18 | AccountQueue: legacypool.DefaultConfig.AccountQueue, 19 | GlobalQueue: legacypool.DefaultConfig.GlobalQueue, 20 | Lifetime: legacypool.DefaultConfig.Lifetime, 21 | } 22 | -------------------------------------------------------------------------------- /plugin/evm/customrawdb/accessors_state_sync_test.go: -------------------------------------------------------------------------------- 1 | // (c) 2023, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package customrawdb 5 | 6 | import ( 7 | "testing" 8 | 9 | "github.com/ava-labs/libevm/common" 10 | ethrawdb "github.com/ava-labs/libevm/core/rawdb" 11 | "github.com/stretchr/testify/require" 12 | ) 13 | 14 | func TestClearPrefix(t *testing.T) { 15 | require := require.New(t) 16 | db := ethrawdb.NewMemoryDatabase() 17 | // add a key that should be cleared 18 | require.NoError(WriteSyncSegment(db, common.Hash{1}, common.Hash{})) 19 | 20 | // add a key that should not be cleared 21 | key := append(syncSegmentsPrefix, []byte("foo")...) 22 | require.NoError(db.Put(key, []byte("bar"))) 23 | 24 | require.NoError(ClearAllSyncSegments(db)) 25 | 26 | count := 0 27 | it := db.NewIterator(syncSegmentsPrefix, nil) 28 | defer it.Release() 29 | for it.Next() { 30 | count++ 31 | } 32 | require.NoError(it.Error()) 33 | require.Equal(1, count) 34 | } 35 | -------------------------------------------------------------------------------- /plugin/evm/customtypes/block_ext.go: -------------------------------------------------------------------------------- 1 | // (c) 2024, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package customtypes 5 | 6 | import ( 7 | "math/big" 8 | 9 | ethtypes "github.com/ava-labs/libevm/core/types" 10 | ) 11 | 12 | func BlockGasCost(b *ethtypes.Block) *big.Int { 13 | cost := GetHeaderExtra(b.Header()).BlockGasCost 14 | if cost == nil { 15 | return nil 16 | } 17 | return new(big.Int).Set(cost) 18 | } 19 | -------------------------------------------------------------------------------- /plugin/evm/customtypes/libevm.go: -------------------------------------------------------------------------------- 1 | // (c) 2025, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package customtypes 5 | 6 | import ( 7 | "io" 8 | 9 | ethtypes "github.com/ava-labs/libevm/core/types" 10 | "github.com/ava-labs/libevm/rlp" 11 | ) 12 | 13 | var extras = ethtypes.RegisterExtras[ 14 | HeaderExtra, *HeaderExtra, 15 | ethtypes.NOOPBlockBodyHooks, *ethtypes.NOOPBlockBodyHooks, 16 | noopStateAccountExtras, 17 | ]() 18 | 19 | type noopStateAccountExtras struct{} 20 | 21 | // EncodeRLP implements the [rlp.Encoder] interface. 22 | func (noopStateAccountExtras) EncodeRLP(w io.Writer) error { return nil } 23 | 24 | // DecodeRLP implements the [rlp.Decoder] interface. 25 | func (*noopStateAccountExtras) DecodeRLP(s *rlp.Stream) error { return nil } 26 | -------------------------------------------------------------------------------- /plugin/evm/customtypes/log_ext.go: -------------------------------------------------------------------------------- 1 | // (c) 2025, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package customtypes 5 | 6 | import ethtypes "github.com/ava-labs/libevm/core/types" 7 | 8 | // FlattenLogs converts a nested array of logs to a single array of logs. 9 | func FlattenLogs(list [][]*ethtypes.Log) []*ethtypes.Log { 10 | var flat []*ethtypes.Log 11 | for _, logs := range list { 12 | flat = append(flat, logs...) 13 | } 14 | return flat 15 | } 16 | -------------------------------------------------------------------------------- /plugin/evm/factory.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2020, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package evm 5 | 6 | import ( 7 | "github.com/ava-labs/avalanchego/ids" 8 | "github.com/ava-labs/avalanchego/utils/logging" 9 | "github.com/ava-labs/avalanchego/vms" 10 | ) 11 | 12 | var ( 13 | // ID this VM should be referenced by 14 | IDStr = "subnetevm" 15 | ID = ids.ID{'s', 'u', 'b', 'n', 'e', 't', 'e', 'v', 'm'} 16 | 17 | _ vms.Factory = &Factory{} 18 | ) 19 | 20 | type Factory struct{} 21 | 22 | func (*Factory) New(logging.Logger) (interface{}, error) { 23 | return &VM{}, nil 24 | } 25 | -------------------------------------------------------------------------------- /plugin/evm/health.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2020, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package evm 5 | 6 | import "context" 7 | 8 | // Health returns nil if this chain is healthy. 9 | // Also returns details, which should be one of: 10 | // string, []byte, map[string]string 11 | func (vm *VM) HealthCheck(context.Context) (interface{}, error) { 12 | // TODO perform actual health check 13 | return nil, nil 14 | } 15 | -------------------------------------------------------------------------------- /plugin/evm/log_test.go: -------------------------------------------------------------------------------- 1 | // (c) 2024, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package evm 5 | 6 | import ( 7 | "os" 8 | "testing" 9 | 10 | "github.com/ava-labs/libevm/log" 11 | "github.com/stretchr/testify/require" 12 | ) 13 | 14 | func TestInitLogger(t *testing.T) { 15 | require := require.New(t) 16 | _, err := InitLogger("alias", "info", true, os.Stderr) 17 | require.NoError(err) 18 | log.Info("test") 19 | } 20 | -------------------------------------------------------------------------------- /plugin/evm/message/block_request.go: -------------------------------------------------------------------------------- 1 | // (c) 2021-2022, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package message 5 | 6 | import ( 7 | "context" 8 | "fmt" 9 | 10 | "github.com/ava-labs/avalanchego/ids" 11 | 12 | "github.com/ava-labs/libevm/common" 13 | ) 14 | 15 | var ( 16 | _ Request = BlockRequest{} 17 | ) 18 | 19 | // BlockRequest is a request to retrieve Parents number of blocks starting from Hash from newest-oldest manner 20 | type BlockRequest struct { 21 | Hash common.Hash `serialize:"true"` 22 | Height uint64 `serialize:"true"` 23 | Parents uint16 `serialize:"true"` 24 | } 25 | 26 | func (b BlockRequest) String() string { 27 | return fmt.Sprintf( 28 | "BlockRequest(Hash=%s, Height=%d, Parents=%d)", 29 | b.Hash, b.Height, b.Parents, 30 | ) 31 | } 32 | 33 | func (b BlockRequest) Handle(ctx context.Context, nodeID ids.NodeID, requestID uint32, handler RequestHandler) ([]byte, error) { 34 | return handler.HandleBlockRequest(ctx, nodeID, requestID, b) 35 | } 36 | 37 | // BlockResponse is a response to a BlockRequest 38 | // Blocks is slice of RLP encoded blocks starting with the block 39 | // requested in BlockRequest.Hash. The next block is the parent, etc. 40 | // handler: handlers.BlockRequestHandler 41 | type BlockResponse struct { 42 | Blocks [][]byte `serialize:"true"` 43 | } 44 | -------------------------------------------------------------------------------- /plugin/evm/message/code_request.go: -------------------------------------------------------------------------------- 1 | // (c) 2021-2022, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package message 5 | 6 | import ( 7 | "context" 8 | "fmt" 9 | "strings" 10 | 11 | "github.com/ava-labs/avalanchego/ids" 12 | "github.com/ava-labs/libevm/common" 13 | ) 14 | 15 | var _ Request = CodeRequest{} 16 | 17 | // CodeRequest is a request to retrieve a contract code with specified Hash 18 | type CodeRequest struct { 19 | // Hashes is a list of contract code hashes 20 | Hashes []common.Hash `serialize:"true"` 21 | } 22 | 23 | func (c CodeRequest) String() string { 24 | hashStrs := make([]string, len(c.Hashes)) 25 | for i, hash := range c.Hashes { 26 | hashStrs[i] = hash.String() 27 | } 28 | return fmt.Sprintf("CodeRequest(Hashes=%s)", strings.Join(hashStrs, ", ")) 29 | } 30 | 31 | func (c CodeRequest) Handle(ctx context.Context, nodeID ids.NodeID, requestID uint32, handler RequestHandler) ([]byte, error) { 32 | return handler.HandleCodeRequest(ctx, nodeID, requestID, c) 33 | } 34 | 35 | func NewCodeRequest(hashes []common.Hash) CodeRequest { 36 | return CodeRequest{ 37 | Hashes: hashes, 38 | } 39 | } 40 | 41 | // CodeResponse is a response to a CodeRequest 42 | // crypto.Keccak256Hash of each element in Data is expected to equal 43 | // the corresponding element in CodeRequest.Hashes 44 | // handler: handlers.CodeRequestHandler 45 | type CodeResponse struct { 46 | Data [][]byte `serialize:"true"` 47 | } 48 | -------------------------------------------------------------------------------- /plugin/evm/message/request.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2022, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package message 5 | 6 | import ( 7 | "context" 8 | "fmt" 9 | 10 | "github.com/ava-labs/avalanchego/codec" 11 | "github.com/ava-labs/avalanchego/ids" 12 | ) 13 | 14 | // Request represents a Network request type 15 | type Request interface { 16 | // Requests should implement String() for logging. 17 | fmt.Stringer 18 | 19 | // Handle allows `Request` to call respective methods on handler to handle 20 | // this particular request type 21 | Handle(ctx context.Context, nodeID ids.NodeID, requestID uint32, handler RequestHandler) ([]byte, error) 22 | } 23 | 24 | // RequestToBytes marshals the given request object into bytes 25 | func RequestToBytes(codec codec.Manager, request Request) ([]byte, error) { 26 | return codec.Marshal(Version, &request) 27 | } 28 | -------------------------------------------------------------------------------- /plugin/evm/upgrade/legacy/params.go: -------------------------------------------------------------------------------- 1 | // (c) 2025, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package legacy 5 | 6 | const ( 7 | BaseFee = 225_000_000_000 8 | 9 | GasLimit = 8_000_000 10 | ) 11 | -------------------------------------------------------------------------------- /plugin/evm/validators.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2020, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package evm 5 | 6 | import ( 7 | "context" 8 | 9 | "github.com/ava-labs/avalanchego/ids" 10 | "github.com/ava-labs/avalanchego/utils/set" 11 | ) 12 | 13 | type validatorSet struct { 14 | set set.Set[ids.NodeID] 15 | } 16 | 17 | func (v *validatorSet) Has(ctx context.Context, nodeID ids.NodeID) bool { 18 | return v.set.Contains(nodeID) 19 | } 20 | -------------------------------------------------------------------------------- /plugin/evm/validators/interfaces/interfaces.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package interfaces 5 | 6 | import ( 7 | "context" 8 | "sync" 9 | "time" 10 | 11 | "github.com/ava-labs/avalanchego/ids" 12 | avalancheuptime "github.com/ava-labs/avalanchego/snow/uptime" 13 | stateinterfaces "github.com/ava-labs/subnet-evm/plugin/evm/validators/state/interfaces" 14 | ) 15 | 16 | type ValidatorReader interface { 17 | // GetValidatorAndUptime returns the calculated uptime of the validator specified by validationID 18 | // and the last updated time. 19 | // GetValidatorAndUptime holds the VM lock while performing the operation and can be called concurrently. 20 | GetValidatorAndUptime(validationID ids.ID) (stateinterfaces.Validator, time.Duration, time.Time, error) 21 | } 22 | 23 | type Manager interface { 24 | stateinterfaces.StateReader 25 | avalancheuptime.Manager 26 | // Initialize initializes the validator manager 27 | // by syncing the validator state with the current validator set 28 | // and starting the uptime tracking. 29 | Initialize(ctx context.Context) error 30 | // Shutdown stops the uptime tracking and writes the validator state to the database. 31 | Shutdown() error 32 | // DispatchSync starts the sync process 33 | DispatchSync(ctx context.Context, lock sync.Locker) 34 | } 35 | -------------------------------------------------------------------------------- /plugin/evm/validators/state/codec.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package state 5 | 6 | import ( 7 | "math" 8 | 9 | "github.com/ava-labs/avalanchego/codec" 10 | "github.com/ava-labs/avalanchego/codec/linearcodec" 11 | "github.com/ava-labs/avalanchego/utils/wrappers" 12 | ) 13 | 14 | const ( 15 | codecVersion = uint16(0) 16 | ) 17 | 18 | var vdrCodec codec.Manager 19 | 20 | func init() { 21 | vdrCodec = codec.NewManager(math.MaxInt32) 22 | c := linearcodec.NewDefault() 23 | 24 | errs := wrappers.Errs{} 25 | errs.Add( 26 | c.RegisterType(validatorData{}), 27 | 28 | vdrCodec.RegisterCodec(codecVersion, c), 29 | ) 30 | 31 | if errs.Errored() { 32 | panic(errs.Err) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /plugin/evm/validators/state/interfaces/mocks_generate_test.go: -------------------------------------------------------------------------------- 1 | package interfaces 2 | 3 | //go:generate go run go.uber.org/mock/mockgen -package=$GOPACKAGE -destination=mock_listener.go . StateCallbackListener 4 | -------------------------------------------------------------------------------- /plugin/evm/validators/uptime/interfaces/interface.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package interfaces 5 | 6 | import ( 7 | "github.com/ava-labs/avalanchego/ids" 8 | "github.com/ava-labs/avalanchego/snow/uptime" 9 | validatorsstateinterfaces "github.com/ava-labs/subnet-evm/plugin/evm/validators/state/interfaces" 10 | ) 11 | 12 | type PausableManager interface { 13 | uptime.Manager 14 | validatorsstateinterfaces.StateCallbackListener 15 | IsPaused(nodeID ids.NodeID) bool 16 | } 17 | -------------------------------------------------------------------------------- /plugin/evm/version.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2021, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package evm 5 | 6 | import ( 7 | "fmt" 8 | ) 9 | 10 | var ( 11 | // GitCommit is set by the build script 12 | GitCommit string 13 | // Version is the version of Subnet EVM 14 | Version string = "v0.7.4" 15 | ) 16 | 17 | func init() { 18 | if len(GitCommit) != 0 { 19 | Version = fmt.Sprintf("%s@%s", Version, GitCommit) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /plugin/evm/version_test.go: -------------------------------------------------------------------------------- 1 | package evm 2 | 3 | import ( 4 | "encoding/json" 5 | "os" 6 | "path/filepath" 7 | "testing" 8 | 9 | "github.com/ava-labs/avalanchego/version" 10 | "github.com/stretchr/testify/require" 11 | ) 12 | 13 | type rpcChainCompatibility struct { 14 | RPCChainVMProtocolVersion map[string]uint `json:"rpcChainVMProtocolVersion"` 15 | } 16 | 17 | const compatibilityFile = "../../compatibility.json" 18 | 19 | func TestCompatibility(t *testing.T) { 20 | compat, err := os.ReadFile(compatibilityFile) 21 | require.NoError(t, err, "reading compatibility file") 22 | 23 | var parsedCompat rpcChainCompatibility 24 | err = json.Unmarshal(compat, &parsedCompat) 25 | require.NoError(t, err, "json decoding compatibility file") 26 | 27 | rpcChainVMVersion, valueInJSON := parsedCompat.RPCChainVMProtocolVersion[Version] 28 | if !valueInJSON { 29 | t.Fatalf("%s has subnet-evm version %s missing from rpcChainVMProtocolVersion object", 30 | filepath.Base(compatibilityFile), Version) 31 | } 32 | if rpcChainVMVersion != version.RPCChainVMProtocol { 33 | t.Fatalf("%s has subnet-evm version %s stated as compatible with RPC chain VM protocol version %d but AvalancheGo protocol version is %d", 34 | filepath.Base(compatibilityFile), Version, rpcChainVMVersion, version.RPCChainVMProtocol) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /plugin/evm/vmerrors/errors.go: -------------------------------------------------------------------------------- 1 | // (c) 2025, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package vmerrors 5 | 6 | import "errors" 7 | 8 | var ( 9 | ErrInvalidCoinbase = errors.New("invalid coinbase") 10 | ErrSenderAddressNotAllowListed = errors.New("cannot issue transaction from non-allow listed address") 11 | ) 12 | -------------------------------------------------------------------------------- /plugin/main.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2020, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package main 5 | 6 | import ( 7 | "fmt" 8 | 9 | "github.com/ava-labs/avalanchego/version" 10 | "github.com/ava-labs/subnet-evm/plugin/evm" 11 | "github.com/ava-labs/subnet-evm/plugin/runner" 12 | ) 13 | 14 | func main() { 15 | versionString := fmt.Sprintf("Subnet-EVM/%s [AvalancheGo=%s, rpcchainvm=%d]", evm.Version, version.Current, version.RPCChainVMProtocol) 16 | runner.Run(versionString) 17 | } 18 | -------------------------------------------------------------------------------- /plugin/runner/keys.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2020, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package runner 5 | 6 | const ( 7 | versionKey = "version" 8 | ) 9 | -------------------------------------------------------------------------------- /plugin/runner/params.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2020, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package runner 5 | 6 | import ( 7 | "flag" 8 | 9 | "github.com/spf13/pflag" 10 | "github.com/spf13/viper" 11 | ) 12 | 13 | func subnetEVMFlagSet() *flag.FlagSet { 14 | fs := flag.NewFlagSet("subnet-evm", flag.ContinueOnError) 15 | 16 | fs.Bool(versionKey, false, "If true, print version and quit") 17 | 18 | return fs 19 | } 20 | 21 | // getViper returns the viper environment for the plugin binary 22 | func getViper() (*viper.Viper, error) { 23 | v := viper.New() 24 | 25 | fs := subnetEVMFlagSet() 26 | pflag.CommandLine.AddGoFlagSet(fs) 27 | pflag.Parse() 28 | if err := v.BindPFlags(pflag.CommandLine); err != nil { 29 | return nil, err 30 | } 31 | 32 | return v, nil 33 | } 34 | 35 | func PrintVersion() (bool, error) { 36 | v, err := getViper() 37 | if err != nil { 38 | return false, err 39 | } 40 | 41 | if v.GetBool(versionKey) { 42 | return true, nil 43 | } 44 | return false, nil 45 | } 46 | -------------------------------------------------------------------------------- /plugin/runner/runner.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2020, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package runner 5 | 6 | import ( 7 | "context" 8 | "fmt" 9 | "os" 10 | 11 | "github.com/ava-labs/avalanchego/utils/logging" 12 | "github.com/ava-labs/avalanchego/utils/ulimit" 13 | "github.com/ava-labs/avalanchego/vms/rpcchainvm" 14 | 15 | "github.com/ava-labs/subnet-evm/plugin/evm" 16 | ) 17 | 18 | func Run(versionStr string) { 19 | printVersion, err := PrintVersion() 20 | if err != nil { 21 | fmt.Printf("couldn't get config: %s", err) 22 | os.Exit(1) 23 | } 24 | if printVersion && versionStr != "" { 25 | fmt.Println(versionStr) 26 | os.Exit(0) 27 | } 28 | if err := ulimit.Set(ulimit.DefaultFDLimit, logging.NoLog{}); err != nil { 29 | fmt.Printf("failed to set fd limit correctly due to: %s", err) 30 | os.Exit(1) 31 | } 32 | rpcchainvm.Serve(context.Background(), &evm.VM{}) 33 | } 34 | -------------------------------------------------------------------------------- /precompile/allowlist/config_test.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2023, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package allowlist_test 5 | 6 | import ( 7 | "testing" 8 | 9 | . "github.com/ava-labs/subnet-evm/precompile/allowlist" 10 | "github.com/ava-labs/subnet-evm/precompile/modules" 11 | ) 12 | 13 | var testModule = modules.Module{ 14 | Address: dummyAddr, 15 | Contract: CreateAllowListPrecompile(dummyAddr), 16 | Configurator: &dummyConfigurator{}, 17 | ConfigKey: "dummy", 18 | } 19 | 20 | func TestVerifyAllowlist(t *testing.T) { 21 | VerifyPrecompileWithAllowListTests(t, testModule, nil) 22 | } 23 | 24 | func TestEqualAllowList(t *testing.T) { 25 | EqualPrecompileWithAllowListTests(t, testModule, nil) 26 | } 27 | -------------------------------------------------------------------------------- /precompile/contract/mocks_generate_test.go: -------------------------------------------------------------------------------- 1 | package contract 2 | 3 | //go:generate go run go.uber.org/mock/mockgen -package=$GOPACKAGE -destination=mocks.go . BlockContext,AccessibleState,StateDB 4 | -------------------------------------------------------------------------------- /precompile/contract/utils_test.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2020, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package contract 5 | 6 | import ( 7 | "testing" 8 | 9 | "github.com/stretchr/testify/assert" 10 | ) 11 | 12 | func TestFunctionSignatureRegex(t *testing.T) { 13 | type test struct { 14 | str string 15 | pass bool 16 | } 17 | 18 | for _, test := range []test{ 19 | { 20 | str: "getBalance()", 21 | pass: true, 22 | }, 23 | { 24 | str: "getBalance(address)", 25 | pass: true, 26 | }, 27 | { 28 | str: "getBalance(address,address)", 29 | pass: true, 30 | }, 31 | { 32 | str: "getBalance(address,address,address)", 33 | pass: true, 34 | }, 35 | { 36 | str: "getBalance(address,address,address,uint256)", 37 | pass: true, 38 | }, 39 | { 40 | str: "getBalance(address,)", 41 | pass: false, 42 | }, 43 | { 44 | str: "getBalance(address,address,)", 45 | pass: false, 46 | }, 47 | { 48 | str: "getBalance(,)", 49 | pass: false, 50 | }, 51 | { 52 | str: "(address,)", 53 | pass: false, 54 | }, 55 | { 56 | str: "()", 57 | pass: false, 58 | }, 59 | { 60 | str: "dummy", 61 | pass: false, 62 | }, 63 | } { 64 | assert.Equal(t, test.pass, functionSignatureRegex.MatchString(test.str), "unexpected result for %q", test.str) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /precompile/contracts/deployerallowlist/contract.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2020, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package deployerallowlist 5 | 6 | import ( 7 | "github.com/ava-labs/libevm/common" 8 | "github.com/ava-labs/subnet-evm/precompile/allowlist" 9 | "github.com/ava-labs/subnet-evm/precompile/contract" 10 | ) 11 | 12 | // Singleton StatefulPrecompiledContract for W/R access to the contract deployer allow list. 13 | var ContractDeployerAllowListPrecompile contract.StatefulPrecompiledContract = allowlist.CreateAllowListPrecompile(ContractAddress) 14 | 15 | // GetContractDeployerAllowListStatus returns the role of [address] for the contract deployer 16 | // allow list. 17 | func GetContractDeployerAllowListStatus(stateDB contract.StateReader, address common.Address) allowlist.Role { 18 | return allowlist.GetAllowListStatus(stateDB, ContractAddress, address) 19 | } 20 | 21 | // SetContractDeployerAllowListStatus sets the permissions of [address] to [role] for the 22 | // contract deployer allow list. 23 | // assumes [role] has already been verified as valid. 24 | func SetContractDeployerAllowListStatus(stateDB contract.StateDB, address common.Address, role allowlist.Role) { 25 | allowlist.SetAllowListRole(stateDB, ContractAddress, address, role) 26 | } 27 | -------------------------------------------------------------------------------- /precompile/contracts/deployerallowlist/contract_test.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2023, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package deployerallowlist_test 5 | 6 | import ( 7 | "testing" 8 | 9 | "github.com/ava-labs/subnet-evm/core/extstate" 10 | "github.com/ava-labs/subnet-evm/precompile/allowlist" 11 | . "github.com/ava-labs/subnet-evm/precompile/contracts/deployerallowlist" 12 | ) 13 | 14 | func TestContractDeployerAllowListRun(t *testing.T) { 15 | allowlist.RunPrecompileWithAllowListTests(t, Module, extstate.NewTestStateDB, nil) 16 | } 17 | 18 | func BenchmarkContractDeployerAllowList(b *testing.B) { 19 | allowlist.BenchPrecompileWithAllowList(b, Module, extstate.NewTestStateDB, nil) 20 | } 21 | -------------------------------------------------------------------------------- /precompile/contracts/txallowlist/contract.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2020, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package txallowlist 5 | 6 | import ( 7 | "github.com/ava-labs/libevm/common" 8 | "github.com/ava-labs/subnet-evm/precompile/allowlist" 9 | "github.com/ava-labs/subnet-evm/precompile/contract" 10 | ) 11 | 12 | // Singleton StatefulPrecompiledContract for W/R access to the tx allow list. 13 | var TxAllowListPrecompile contract.StatefulPrecompiledContract = allowlist.CreateAllowListPrecompile(ContractAddress) 14 | 15 | // GetTxAllowListStatus returns the role of [address] for the tx allow list. 16 | func GetTxAllowListStatus(stateDB contract.StateReader, address common.Address) allowlist.Role { 17 | return allowlist.GetAllowListStatus(stateDB, ContractAddress, address) 18 | } 19 | 20 | // SetTxAllowListStatus sets the permissions of [address] to [role] for the 21 | // tx allow list. 22 | // assumes [role] has already been verified as valid. 23 | func SetTxAllowListStatus(stateDB contract.StateDB, address common.Address, role allowlist.Role) { 24 | allowlist.SetAllowListRole(stateDB, ContractAddress, address, role) 25 | } 26 | -------------------------------------------------------------------------------- /precompile/contracts/txallowlist/contract_test.go: -------------------------------------------------------------------------------- 1 | // (c) 2019-2023, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package txallowlist 5 | 6 | import ( 7 | "testing" 8 | 9 | "github.com/ava-labs/subnet-evm/core/extstate" 10 | "github.com/ava-labs/subnet-evm/precompile/allowlist" 11 | ) 12 | 13 | func TestTxAllowListRun(t *testing.T) { 14 | allowlist.RunPrecompileWithAllowListTests(t, Module, extstate.NewTestStateDB, nil) 15 | } 16 | 17 | func BenchmarkTxAllowList(b *testing.B) { 18 | allowlist.BenchPrecompileWithAllowList(b, Module, extstate.NewTestStateDB, nil) 19 | } 20 | -------------------------------------------------------------------------------- /precompile/modules/module.go: -------------------------------------------------------------------------------- 1 | // (c) 2023, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package modules 5 | 6 | import ( 7 | "bytes" 8 | 9 | "github.com/ava-labs/libevm/common" 10 | "github.com/ava-labs/subnet-evm/precompile/contract" 11 | ) 12 | 13 | type Module struct { 14 | // ConfigKey is the key used in json config files to specify this precompile config. 15 | ConfigKey string 16 | // Address returns the address where the stateful precompile is accessible. 17 | Address common.Address 18 | // Contract returns a thread-safe singleton that can be used as the StatefulPrecompiledContract when 19 | // this config is enabled. 20 | Contract contract.StatefulPrecompiledContract 21 | // Configurator is used to configure the stateful precompile when the config is enabled. 22 | contract.Configurator 23 | } 24 | 25 | type moduleArray []Module 26 | 27 | func (u moduleArray) Len() int { 28 | return len(u) 29 | } 30 | 31 | func (u moduleArray) Swap(i, j int) { 32 | u[i], u[j] = u[j], u[i] 33 | } 34 | 35 | func (m moduleArray) Less(i, j int) bool { 36 | return bytes.Compare(m[i].Address.Bytes(), m[j].Address.Bytes()) < 0 37 | } 38 | -------------------------------------------------------------------------------- /precompile/precompileconfig/mocks_generate_test.go: -------------------------------------------------------------------------------- 1 | package precompileconfig 2 | 3 | //go:generate go run go.uber.org/mock/mockgen -package=$GOPACKAGE -destination=mocks.go . Predicater,Config,ChainConfig,Accepter 4 | -------------------------------------------------------------------------------- /precompile/precompileconfig/upgradeable.go: -------------------------------------------------------------------------------- 1 | // (c) 2022 Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package precompileconfig 5 | 6 | import "github.com/ava-labs/subnet-evm/utils" 7 | 8 | // Upgrade contains the timestamp for the upgrade along with 9 | // a boolean [Disable]. If [Disable] is set, the upgrade deactivates 10 | // the precompile and clears its storage. 11 | type Upgrade struct { 12 | BlockTimestamp *uint64 `json:"blockTimestamp"` 13 | Disable bool `json:"disable,omitempty"` 14 | } 15 | 16 | // Timestamp returns the timestamp this network upgrade goes into effect. 17 | func (u *Upgrade) Timestamp() *uint64 { 18 | return u.BlockTimestamp 19 | } 20 | 21 | // IsDisabled returns true if the network upgrade deactivates the precompile. 22 | func (u *Upgrade) IsDisabled() bool { 23 | return u.Disable 24 | } 25 | 26 | // Equal returns true iff [other] has the same blockTimestamp and has the 27 | // same on value for the Disable flag. 28 | func (u *Upgrade) Equal(other *Upgrade) bool { 29 | if other == nil { 30 | return false 31 | } 32 | return u.Disable == other.Disable && utils.Uint64PtrEqual(u.BlockTimestamp, other.BlockTimestamp) 33 | } 34 | -------------------------------------------------------------------------------- /predicate/Predicate.md: -------------------------------------------------------------------------------- 1 | # Predicate 2 | 3 | This package contains the predicate data structure and its encoding and helper functions to unpack/pack the data structure. 4 | 5 | ## Encoding 6 | 7 | A byte slice of size N is encoded as: 8 | 9 | 1. Slice of N bytes 10 | 2. Delimiter byte `0xff` 11 | 3. Appended 0s to the nearest multiple of 32 bytes 12 | -------------------------------------------------------------------------------- /predicate/predicate_slots.go: -------------------------------------------------------------------------------- 1 | // (c) 2023, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package predicate 5 | 6 | import ( 7 | "github.com/ava-labs/libevm/common" 8 | "github.com/ava-labs/libevm/core/types" 9 | "github.com/ava-labs/subnet-evm/utils" 10 | ) 11 | 12 | type PredicaterExistChecker interface { 13 | PredicaterExists(common.Address) bool 14 | } 15 | 16 | // PreparePredicateStorageSlots populates the predicate storage slots of a transaction's access list 17 | // Note: if an address is specified multiple times in the access list, each storage slot for that address is 18 | // appended to a slice of byte slices. Each byte slice represents a predicate, making it a slice of predicates 19 | // for each access list address, and every predicate in the slice goes through verification. 20 | func PreparePredicateStorageSlots(rules PredicaterExistChecker, list types.AccessList) map[common.Address][][]byte { 21 | predicateStorageSlots := make(map[common.Address][][]byte) 22 | for _, el := range list { 23 | if !rules.PredicaterExists(el.Address) { 24 | continue 25 | } 26 | predicateStorageSlots[el.Address] = append(predicateStorageSlots[el.Address], utils.HashSliceToBytes(el.StorageKeys)) 27 | } 28 | 29 | return predicateStorageSlots 30 | } 31 | -------------------------------------------------------------------------------- /predicate/predicate_tx.go: -------------------------------------------------------------------------------- 1 | // (c) 2023, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package predicate 5 | 6 | import ( 7 | "math/big" 8 | 9 | "github.com/ava-labs/libevm/common" 10 | "github.com/ava-labs/libevm/core/types" 11 | "github.com/ava-labs/subnet-evm/utils" 12 | ) 13 | 14 | // NewPredicateTx returns a transaction with the predicateAddress/predicateBytes tuple 15 | // packed and added to the access list of the transaction. 16 | func NewPredicateTx( 17 | chainID *big.Int, 18 | nonce uint64, 19 | to *common.Address, 20 | gas uint64, 21 | gasFeeCap *big.Int, 22 | gasTipCap *big.Int, 23 | value *big.Int, 24 | data []byte, 25 | accessList types.AccessList, 26 | predicateAddress common.Address, 27 | predicateBytes []byte, 28 | ) *types.Transaction { 29 | accessList = append(accessList, types.AccessTuple{ 30 | Address: predicateAddress, 31 | StorageKeys: utils.BytesToHashSlice(PackPredicate(predicateBytes)), 32 | }) 33 | return types.NewTx(&types.DynamicFeeTx{ 34 | ChainID: chainID, 35 | Nonce: nonce, 36 | To: to, 37 | Gas: gas, 38 | GasFeeCap: gasFeeCap, 39 | GasTipCap: gasTipCap, 40 | Value: value, 41 | Data: data, 42 | AccessList: accessList, 43 | }) 44 | } 45 | -------------------------------------------------------------------------------- /rpc/client_opt_test.go: -------------------------------------------------------------------------------- 1 | // (c) 2023, Ava Labs, Inc. 2 | // 3 | // This file is a derived work, based on the go-ethereum library whose original 4 | // notices appear below. 5 | // 6 | // It is distributed under a license compatible with the licensing terms of the 7 | // original code from which it is derived. 8 | // 9 | // Much love to the original authors for their work. 10 | // ********** 11 | package rpc_test 12 | 13 | import ( 14 | "context" 15 | "net/http" 16 | "time" 17 | 18 | "github.com/ava-labs/subnet-evm/rpc" 19 | ) 20 | 21 | // This example configures a HTTP-based RPC client with two options - one setting the 22 | // overall request timeout, the other adding a custom HTTP header to all requests. 23 | func ExampleDialOptions() { 24 | tokenHeader := rpc.WithHeader("x-token", "foo") 25 | httpClient := rpc.WithHTTPClient(&http.Client{ 26 | Timeout: 10 * time.Second, 27 | }) 28 | 29 | ctx := context.Background() 30 | c, err := rpc.DialOptions(ctx, "http://rpc.example.com", httpClient, tokenHeader) 31 | if err != nil { 32 | panic(err) 33 | } 34 | c.Close() 35 | } 36 | -------------------------------------------------------------------------------- /rpc/testdata/internal-error.js: -------------------------------------------------------------------------------- 1 | // These tests trigger various 'internal error' conditions. 2 | 3 | --> {"jsonrpc":"2.0","id":1,"method":"test_marshalError","params": []} 4 | <-- {"jsonrpc":"2.0","id":1,"error":{"code":-32603,"message":"json: error calling MarshalText for type *rpc.MarshalErrObj: marshal error"}} 5 | 6 | --> {"jsonrpc":"2.0","id":2,"method":"test_panic","params": []} 7 | <-- {"jsonrpc":"2.0","id":2,"error":{"code":-32603,"message":"method handler crashed"}} 8 | -------------------------------------------------------------------------------- /rpc/testdata/invalid-badid.js: -------------------------------------------------------------------------------- 1 | // This test checks processing of messages with invalid ID. 2 | 3 | --> {"id":[],"method":"test_foo"} 4 | <-- {"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"invalid request"}} 5 | 6 | --> {"id":{},"method":"test_foo"} 7 | <-- {"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"invalid request"}} 8 | -------------------------------------------------------------------------------- /rpc/testdata/invalid-badversion.js: -------------------------------------------------------------------------------- 1 | // This test checks processing of messages with invalid Version. 2 | 3 | --> {"jsonrpc":"2.0","id":1,"method":"test_echo","params":["x", 3]} 4 | <-- {"jsonrpc":"2.0","id":1,"result":{"String":"x","Int":3,"Args":null}} 5 | 6 | --> {"jsonrpc":"2.1","id":1,"method":"test_echo","params":["x", 3]} 7 | <-- {"jsonrpc":"2.0","id":1,"error":{"code":-32600,"message":"invalid request"}} 8 | 9 | --> {"jsonrpc":"go-ethereum","id":1,"method":"test_echo","params":["x", 3]} 10 | <-- {"jsonrpc":"2.0","id":1,"error":{"code":-32600,"message":"invalid request"}} 11 | 12 | --> {"jsonrpc":1,"id":1,"method":"test_echo","params":["x", 3]} 13 | <-- {"jsonrpc":"2.0","id":1,"error":{"code":-32600,"message":"invalid request"}} 14 | 15 | --> {"jsonrpc":2.0,"id":1,"method":"test_echo","params":["x", 3]} 16 | <-- {"jsonrpc":"2.0","id":1,"error":{"code":-32600,"message":"invalid request"}} 17 | 18 | --> {"id":1,"method":"test_echo","params":["x", 3]} 19 | <-- {"jsonrpc":"2.0","id":1,"error":{"code":-32600,"message":"invalid request"}} 20 | -------------------------------------------------------------------------------- /rpc/testdata/invalid-batch-toolarge.js: -------------------------------------------------------------------------------- 1 | // This file checks the behavior of the batch item limit code. 2 | // In tests, the batch item limit is set to 4. So to trigger the error, 3 | // all batches in this file have 5 elements. 4 | 5 | // For batches that do not contain any calls, a response message with "id" == null 6 | // is returned. 7 | 8 | --> [{"jsonrpc":"2.0","method":"test_echo","params":["x",99]},{"jsonrpc":"2.0","method":"test_echo","params":["x",99]},{"jsonrpc":"2.0","method":"test_echo","params":["x",99]},{"jsonrpc":"2.0","method":"test_echo","params":["x",99]},{"jsonrpc":"2.0","method":"test_echo","params":["x",99]}] 9 | <-- [{"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"batch too large"}}] 10 | 11 | // For batches with at least one call, the call's "id" is used. 12 | --> [{"jsonrpc":"2.0","method":"test_echo","params":["x",99]},{"jsonrpc":"2.0","id":3,"method":"test_echo","params":["x",99]},{"jsonrpc":"2.0","method":"test_echo","params":["x",99]},{"jsonrpc":"2.0","method":"test_echo","params":["x",99]},{"jsonrpc":"2.0","method":"test_echo","params":["x",99]}] 13 | <-- [{"jsonrpc":"2.0","id":3,"error":{"code":-32600,"message":"batch too large"}}] 14 | -------------------------------------------------------------------------------- /rpc/testdata/invalid-batch.js: -------------------------------------------------------------------------------- 1 | // This test checks the behavior of batches with invalid elements. 2 | // Empty batches are not allowed. Batches may contain junk. 3 | 4 | --> [] 5 | <-- {"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"empty batch"}} 6 | 7 | --> [1] 8 | <-- [{"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"invalid request"}}] 9 | 10 | --> [1,2,3] 11 | <-- [{"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"invalid request"}},{"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"invalid request"}},{"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"invalid request"}}] 12 | 13 | --> [null] 14 | <-- [{"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"invalid request"}}] 15 | 16 | --> [{"jsonrpc":"2.0","id":1,"method":"test_echo","params":["foo",1]},55,{"jsonrpc":"2.0","id":2,"method":"unknown_method"},{"foo":"bar"}] 17 | <-- [{"jsonrpc":"2.0","id":1,"result":{"String":"foo","Int":1,"Args":null}},{"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"invalid request"}},{"jsonrpc":"2.0","id":2,"error":{"code":-32601,"message":"the method unknown_method does not exist/is not available"}},{"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"invalid request"}}] 18 | -------------------------------------------------------------------------------- /rpc/testdata/invalid-idonly.js: -------------------------------------------------------------------------------- 1 | // This test checks processing of messages that contain just the ID and nothing else. 2 | 3 | --> {"id":1} 4 | <-- {"jsonrpc":"2.0","id":1,"error":{"code":-32600,"message":"invalid request"}} 5 | 6 | --> {"jsonrpc":"2.0","id":1} 7 | <-- {"jsonrpc":"2.0","id":1,"error":{"code":-32600,"message":"invalid request"}} 8 | -------------------------------------------------------------------------------- /rpc/testdata/invalid-nonobj.js: -------------------------------------------------------------------------------- 1 | // This test checks behavior for invalid requests. 2 | 3 | --> 1 4 | <-- {"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"invalid request"}} 5 | 6 | --> null 7 | <-- {"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"invalid request"}} 8 | -------------------------------------------------------------------------------- /rpc/testdata/invalid-syntax.json: -------------------------------------------------------------------------------- 1 | // This test checks that an error is written for invalid JSON requests. 2 | 3 | --> 'f 4 | <-- {"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"invalid character '\\'' looking for beginning of value"}} 5 | 6 | -------------------------------------------------------------------------------- /rpc/testdata/reqresp-batch.js: -------------------------------------------------------------------------------- 1 | // There is no response for all-notification batches. 2 | 3 | --> [{"jsonrpc":"2.0","method":"test_echo","params":["x",99]}] 4 | 5 | // This test checks regular batch calls. 6 | 7 | --> [{"jsonrpc":"2.0","id":2,"method":"test_echo","params":[]}, {"jsonrpc":"2.0","id": 3,"method":"test_echo","params":["x",3]}] 8 | <-- [{"jsonrpc":"2.0","id":2,"error":{"code":-32602,"message":"missing value for required argument 0"}},{"jsonrpc":"2.0","id":3,"result":{"String":"x","Int":3,"Args":null}}] 9 | -------------------------------------------------------------------------------- /rpc/testdata/reqresp-echo.js: -------------------------------------------------------------------------------- 1 | // This test calls the test_echo method. 2 | 3 | --> {"jsonrpc": "2.0", "id": 2, "method": "test_echo", "params": []} 4 | <-- {"jsonrpc":"2.0","id":2,"error":{"code":-32602,"message":"missing value for required argument 0"}} 5 | 6 | --> {"jsonrpc": "2.0", "id": 2, "method": "test_echo", "params": ["x"]} 7 | <-- {"jsonrpc":"2.0","id":2,"error":{"code":-32602,"message":"missing value for required argument 1"}} 8 | 9 | --> {"jsonrpc": "2.0", "id": 2, "method": "test_echo", "params": ["x", 3]} 10 | <-- {"jsonrpc":"2.0","id":2,"result":{"String":"x","Int":3,"Args":null}} 11 | 12 | --> {"jsonrpc": "2.0", "id": 2, "method": "test_echo", "params": ["x", 3, {"S": "foo"}]} 13 | <-- {"jsonrpc":"2.0","id":2,"result":{"String":"x","Int":3,"Args":{"S":"foo"}}} 14 | 15 | --> {"jsonrpc": "2.0", "id": 2, "method": "test_echoWithCtx", "params": ["x", 3, {"S": "foo"}]} 16 | <-- {"jsonrpc":"2.0","id":2,"result":{"String":"x","Int":3,"Args":{"S":"foo"}}} 17 | -------------------------------------------------------------------------------- /rpc/testdata/reqresp-namedparam.js: -------------------------------------------------------------------------------- 1 | // This test checks that an error response is sent for calls 2 | // with named parameters. 3 | 4 | --> {"jsonrpc":"2.0","method":"test_echo","params":{"int":23},"id":3} 5 | <-- {"jsonrpc":"2.0","id":3,"error":{"code":-32602,"message":"non-array args"}} 6 | -------------------------------------------------------------------------------- /rpc/testdata/reqresp-noargsrets.js: -------------------------------------------------------------------------------- 1 | // This test calls the test_noArgsRets method. 2 | 3 | --> {"jsonrpc": "2.0", "id": "foo", "method": "test_noArgsRets", "params": []} 4 | <-- {"jsonrpc":"2.0","id":"foo","result":null} 5 | -------------------------------------------------------------------------------- /rpc/testdata/reqresp-nomethod.js: -------------------------------------------------------------------------------- 1 | // This test calls a method that doesn't exist. 2 | 3 | --> {"jsonrpc": "2.0", "id": 2, "method": "invalid_method", "params": [2, 3]} 4 | <-- {"jsonrpc":"2.0","id":2,"error":{"code":-32601,"message":"the method invalid_method does not exist/is not available"}} 5 | -------------------------------------------------------------------------------- /rpc/testdata/reqresp-noparam.js: -------------------------------------------------------------------------------- 1 | // This test checks that calls with no parameters work. 2 | 3 | --> {"jsonrpc":"2.0","method":"test_noArgsRets","id":3} 4 | <-- {"jsonrpc":"2.0","id":3,"result":null} 5 | -------------------------------------------------------------------------------- /rpc/testdata/reqresp-paramsnull.js: -------------------------------------------------------------------------------- 1 | // This test checks that calls with "params":null work. 2 | 3 | --> {"jsonrpc":"2.0","method":"test_noArgsRets","params":null,"id":3} 4 | <-- {"jsonrpc":"2.0","id":3,"result":null} 5 | -------------------------------------------------------------------------------- /rpc/testdata/revcall.js: -------------------------------------------------------------------------------- 1 | // This test checks reverse calls. 2 | 3 | --> {"jsonrpc":"2.0","id":2,"method":"test_callMeBack","params":["foo",[1]]} 4 | <-- {"jsonrpc":"2.0","id":1,"method":"foo","params":[1]} 5 | --> {"jsonrpc":"2.0","id":1,"result":"my result"} 6 | <-- {"jsonrpc":"2.0","id":2,"result":"my result"} 7 | -------------------------------------------------------------------------------- /rpc/testdata/revcall2.js: -------------------------------------------------------------------------------- 1 | // This test checks reverse calls. 2 | 3 | --> {"jsonrpc":"2.0","id":2,"method":"test_callMeBackLater","params":["foo",[1]]} 4 | <-- {"jsonrpc":"2.0","id":2,"result":null} 5 | <-- {"jsonrpc":"2.0","id":1,"method":"foo","params":[1]} 6 | --> {"jsonrpc":"2.0","id":1,"result":"my result"} 7 | 8 | -------------------------------------------------------------------------------- /rpc/testdata/subscription.js: -------------------------------------------------------------------------------- 1 | // This test checks basic subscription support. 2 | 3 | --> {"jsonrpc":"2.0","id":1,"method":"nftest_subscribe","params":["someSubscription",5,1]} 4 | <-- {"jsonrpc":"2.0","id":1,"result":"0x1"} 5 | <-- {"jsonrpc":"2.0","method":"nftest_subscription","params":{"subscription":"0x1","result":1}} 6 | <-- {"jsonrpc":"2.0","method":"nftest_subscription","params":{"subscription":"0x1","result":2}} 7 | <-- {"jsonrpc":"2.0","method":"nftest_subscription","params":{"subscription":"0x1","result":3}} 8 | <-- {"jsonrpc":"2.0","method":"nftest_subscription","params":{"subscription":"0x1","result":4}} 9 | <-- {"jsonrpc":"2.0","method":"nftest_subscription","params":{"subscription":"0x1","result":5}} 10 | 11 | --> {"jsonrpc":"2.0","id":2,"method":"nftest_echo","params":[11]} 12 | <-- {"jsonrpc":"2.0","id":2,"result":11} 13 | -------------------------------------------------------------------------------- /scripts/actionlint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.1 "${@}" 6 | -------------------------------------------------------------------------------- /scripts/avalanche_header.txt: -------------------------------------------------------------------------------- 1 | // (c) 2024, Ava Labs, Inc. 2 | // 3 | // This file is a derived work, based on the go-ethereum library whose original 4 | // notices appear below. 5 | // 6 | // It is distributed under a license compatible with the licensing terms of the 7 | // original code from which it is derived. 8 | // 9 | // Much love to the original authors for their work. 10 | // ********** 11 | -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | set -o pipefail 6 | 7 | # Root directory 8 | SUBNET_EVM_PATH=$( 9 | cd "$(dirname "${BASH_SOURCE[0]}")" 10 | cd .. && pwd 11 | ) 12 | 13 | # Load the constants 14 | source "$SUBNET_EVM_PATH"/scripts/constants.sh 15 | 16 | if [[ $# -eq 1 ]]; then 17 | BINARY_PATH=$1 18 | elif [[ $# -eq 0 ]]; then 19 | BINARY_PATH="$DEFAULT_PLUGIN_DIR/$DEFAULT_VM_ID" 20 | else 21 | echo "Invalid arguments to build subnet-evm. Requires zero (default binary path) or one argument to specify the binary path." 22 | exit 1 23 | fi 24 | 25 | # Build Subnet EVM, which is run as a subprocess 26 | echo "Building Subnet EVM @ GitCommit: $SUBNET_EVM_COMMIT at $BINARY_PATH" 27 | go build -ldflags "-X github.com/ava-labs/subnet-evm/plugin/evm.GitCommit=$SUBNET_EVM_COMMIT $STATIC_LD_FLAGS" -o "$BINARY_PATH" "plugin/"*.go 28 | -------------------------------------------------------------------------------- /scripts/build_antithesis_workload.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | # Directory above this script 6 | SUBNET_EVM_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) 7 | # Load the constants 8 | source "$SUBNET_EVM_PATH"/scripts/constants.sh 9 | 10 | echo "Building Workload..." 11 | go build -o "$SUBNET_EVM_PATH/build/workload" "$SUBNET_EVM_PATH/tests/antithesis/"*.go 12 | -------------------------------------------------------------------------------- /scripts/build_bench_precompiles.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | set -o pipefail 6 | 7 | # Root directory 8 | SUBNET_EVM_PATH=$( 9 | cd "$(dirname "${BASH_SOURCE[0]}")" 10 | cd .. && pwd 11 | ) 12 | 13 | # Load the constants 14 | source "$SUBNET_EVM_PATH"/scripts/constants.sh 15 | 16 | go test ./precompile/contracts/... -bench=./... -timeout="10m" "$@" 17 | -------------------------------------------------------------------------------- /scripts/coverage.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | set -o pipefail 6 | 7 | if [ ! -f "coverage.out" ]; then 8 | echo "no coverage file" 9 | exit 0 10 | fi 11 | 12 | totalCoverage=$(go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+') 13 | echo "Current test coverage : $totalCoverage %" 14 | echo "========================================" 15 | 16 | go tool cover -func=coverage.out 17 | -------------------------------------------------------------------------------- /scripts/dev_shell.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | # Requires nix to be installed. The determinate systems installer is recommended: 6 | # 7 | # https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file#install-nix 8 | # 9 | 10 | # Load AVALANCHE_VERSION 11 | SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) 12 | # shellcheck source=/scripts/constants.sh 13 | source "$SCRIPT_DIR"/constants.sh 14 | 15 | # Start a dev shell with the avalanchego flake 16 | FLAKE="github:ava-labs/avalanchego?ref=${AVALANCHE_VERSION}" 17 | echo "Starting nix shell for ${FLAKE}" 18 | nix develop "${FLAKE}" "${@}" 19 | -------------------------------------------------------------------------------- /scripts/diff_against.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Usage: scripts/diff_against.sh {geth_commit} 5 | # 6 | # Per-file diffs will be written to `diffs/{geth_commit}`. 7 | # 8 | # Example: `scripts/diff_against.sh b20b4a71598481443d60b261d3e5dcb37f8a0d82` to compare with v1.13.8. 9 | # 10 | # *NOTE* Before running this script: 11 | # 1. Run `scripts/format_as_upstream.sh` to reformat this repo as `ethereum/go-ethereum`. 12 | # 2. Add geth as a remote: `git remote add -f geth git@github.com:ethereum/go-ethereum.git`. 13 | # 3. Find the geth commit for the latest version merged into this repo. 14 | # 15 | 16 | set -e; 17 | set -u; 18 | 19 | ROOT=$(git rev-parse --show-toplevel); 20 | cd "${ROOT}"; 21 | 22 | BASE="${1}"; 23 | 24 | # The diffs/ directory is in .gitignore to avoid recursive diffiffiffs. 25 | mkdir -p "diffs/${BASE}"; 26 | 27 | git diff "${BASE}" --name-only | while read -r f 28 | do 29 | echo "${f}"; 30 | DIR=$(dirname "${f}"); 31 | mkdir -p "diffs/${BASE}/${DIR}"; 32 | git diff "${BASE}" -- "${f}" > "diffs/${BASE}/${f}.diff"; 33 | done 34 | -------------------------------------------------------------------------------- /scripts/format_add_avalanche_header.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | set -o pipefail 6 | set -x 7 | 8 | script_dir=$(dirname "$0") 9 | 10 | sed_command="1{/The go-ethereum Authors/{r ${script_dir}/avalanche_header.txt 11 | N 12 | } 13 | }" 14 | sed -i '' -e "${sed_command}" "$@" -------------------------------------------------------------------------------- /scripts/generate_precompile.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # This script generates a Stateful Precompile stub based off of a Solidity ABI file. 5 | # It first sets the necessary CGO_FLAGs for the BLST library used in AvalancheGo and 6 | # then runs PrecompileGen. 7 | if ! [[ "$0" =~ scripts/generate_precompile.sh ]]; then 8 | echo "must be run from repository root, but got $0" 9 | exit 255 10 | fi 11 | 12 | SUBNET_EVM_PATH=$( 13 | cd "$(dirname "${BASH_SOURCE[0]}")" 14 | cd .. && pwd 15 | ) 16 | 17 | # Load the constants 18 | source "$SUBNET_EVM_PATH"/scripts/constants.sh 19 | 20 | go run ./cmd/precompilegen/main.go "$@" 21 | -------------------------------------------------------------------------------- /scripts/known_flakes.txt: -------------------------------------------------------------------------------- 1 | TestChainIndexerWithChildren 2 | TestClientCancelWebsocket 3 | TestExampleOpenTSB 4 | TestExpDecaySampleNanosecondRegression 5 | TestGolangBindings 6 | TestMempoolEthTxsAppGossipHandling 7 | TestResumeSyncAccountsTrieInterrupted 8 | TestResyncNewRootAfterDeletes 9 | TestTimedUnlock 10 | TestTransactionSkipIndexing 11 | TestVMShutdownWhileSyncing 12 | TestWaitDeployedCornerCases 13 | TestWalletNotifications 14 | TestWebsocketLargeRead -------------------------------------------------------------------------------- /scripts/lib_avalanchego_clone.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | # Defines functions for interacting with git clones of the avalanchego repo. 6 | 7 | if [[ -z "${SUBNET_EVM_PATH}" ]]; then 8 | echo "SUBNET_EVM_PATH must be set" 9 | exit 1 10 | fi 11 | 12 | export AVALANCHEGO_CLONE_PATH=${AVALANCHEGO_CLONE_PATH:-${SUBNET_EVM_PATH}/avalanchego} 13 | 14 | # Clones the avalanchego repo to the configured path and checks out the specified version. 15 | function clone_avalanchego { 16 | local avalanche_version="$1" 17 | 18 | echo "checking out target avalanchego version ${avalanche_version} to ${AVALANCHEGO_CLONE_PATH}" 19 | if [[ -d "${AVALANCHEGO_CLONE_PATH}" ]]; then 20 | echo "updating existing clone" 21 | cd "${AVALANCHEGO_CLONE_PATH}" 22 | git fetch 23 | else 24 | echo "creating new clone" 25 | git clone https://github.com/ava-labs/avalanchego.git "${AVALANCHEGO_CLONE_PATH}" 26 | cd "${AVALANCHEGO_CLONE_PATH}" 27 | fi 28 | # Branch will be reset to $avalanche_version if it already exists 29 | git checkout -B "test-${avalanche_version}" "${avalanche_version}" 30 | cd "${SUBNET_EVM_PATH}" 31 | } 32 | 33 | # Derives an image tag from the current state of the avalanchego clone 34 | function avalanchego_image_tag_from_clone { 35 | local commit_hash 36 | commit_hash="$(git --git-dir="${AVALANCHEGO_CLONE_PATH}/.git" rev-parse HEAD)" 37 | echo "${commit_hash::8}" 38 | } 39 | -------------------------------------------------------------------------------- /scripts/lint_allowed_eth_imports.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | set -o pipefail 6 | 7 | # Ensure that there are no eth imports that are not marked as explicitly allowed via ./scripts/eth-allowed-packages.txt 8 | # 1. Recursively search through all go files for any lines that include a direct import from libevm 9 | # 2. Ignore lines that import libevm with a named import starting with "eth" or by _ import. 10 | # 3. Sort the unique results 11 | # 4. Print out the difference between the search results and the list of specified allowed package imports from libevm. 12 | libevm_regexp='"github.com/ava-labs/libevm/.*"' 13 | extra_imports=$(find . -type f \( -name "*.go" \) ! -name "mocks.go" ! -path "simulator" ! -path "./core/main_test.go" ! -name "gen_*.go" -print0 | 14 | xargs -0 grep "${libevm_regexp}" | 15 | grep -v 'eth\w\+ "' | 16 | grep -v '_ "' | 17 | grep -o "${libevm_regexp}" | 18 | sort -u | comm -23 - ./scripts/eth-allowed-packages.txt) 19 | if [ -n "${extra_imports}" ]; then 20 | echo "new ethereum imports should be added to ./scripts/eth-allowed-packages.txt to prevent accidental imports:" 21 | echo "${extra_imports}" 22 | exit 1 23 | fi 24 | 25 | extra_imports=$(grep -r --include='*.go' '"github.com/ava-labs/coreth/.*"' -o -h || true | sort -u) 26 | if [ -n "${extra_imports}" ]; then 27 | echo "subnet-evm should not import packages from coreth:" 28 | echo "${extra_imports}" 29 | exit 1 30 | fi 31 | -------------------------------------------------------------------------------- /scripts/run_ginkgo_load.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # This script assumes that an AvalancheGo and Subnet-EVM binaries are available in the standard location 5 | # within the $GOPATH 6 | # The AvalancheGo and PluginDir paths can be specified via the environment variables used in ./scripts/run.sh. 7 | 8 | SUBNET_EVM_PATH=$( 9 | cd "$(dirname "${BASH_SOURCE[0]}")" 10 | cd .. && pwd 11 | ) 12 | 13 | source "$SUBNET_EVM_PATH"/scripts/constants.sh 14 | 15 | EXTRA_ARGS=() 16 | AVALANCHEGO_BUILD_PATH="${AVALANCHEGO_BUILD_PATH:-}" 17 | if [[ -n "${AVALANCHEGO_BUILD_PATH}" ]]; then 18 | EXTRA_ARGS=("--avalanchego-path=${AVALANCHEGO_BUILD_PATH}/avalanchego") 19 | echo "Running with extra args:" "${EXTRA_ARGS[@]}" 20 | fi 21 | 22 | "${SUBNET_EVM_PATH}"/bin/ginkgo -vv --label-filter="${GINKGO_LABEL_FILTER:-}" ./tests/load -- "${EXTRA_ARGS[@]}" 23 | -------------------------------------------------------------------------------- /scripts/run_ginkgo_precompile.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # This script assumes that an AvalancheGo and Subnet-EVM binaries are available in the standard location 5 | # within the $GOPATH 6 | # The AvalancheGo and PluginDir paths can be specified via the environment variables used in ./scripts/run.sh. 7 | 8 | SUBNET_EVM_PATH=$( 9 | cd "$(dirname "${BASH_SOURCE[0]}")" 10 | cd .. && pwd 11 | ) 12 | 13 | source "$SUBNET_EVM_PATH"/scripts/constants.sh 14 | 15 | TEST_SOURCE_ROOT=$(pwd) 16 | 17 | # By default, it runs all e2e test cases! 18 | # Use "--ginkgo.skip" to skip tests. 19 | # Use "--ginkgo.focus" to select tests. 20 | TEST_SOURCE_ROOT="$TEST_SOURCE_ROOT" "${SUBNET_EVM_PATH}"/bin/ginkgo run -procs=5 tests/precompile \ 21 | --ginkgo.vv \ 22 | --ginkgo.label-filter="${GINKGO_LABEL_FILTER:-""}" 23 | -------------------------------------------------------------------------------- /scripts/run_ginkgo_warp.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | # This script assumes that an AvalancheGo and Subnet-EVM binaries are available in the standard location 6 | # within the $GOPATH 7 | # The AvalancheGo and PluginDir paths can be specified via the environment variables used in ./scripts/run.sh. 8 | 9 | SUBNET_EVM_PATH=$( 10 | cd "$(dirname "${BASH_SOURCE[0]}")" 11 | cd .. && pwd 12 | ) 13 | 14 | source "$SUBNET_EVM_PATH"/scripts/constants.sh 15 | 16 | EXTRA_ARGS=() 17 | AVALANCHEGO_BUILD_PATH="${AVALANCHEGO_BUILD_PATH:-}" 18 | if [[ -n "${AVALANCHEGO_BUILD_PATH}" ]]; then 19 | EXTRA_ARGS=("--avalanchego-path=${AVALANCHEGO_BUILD_PATH}/avalanchego") 20 | echo "Running with extra args:" "${EXTRA_ARGS[@]}" 21 | fi 22 | 23 | "${SUBNET_EVM_PATH}"/bin/ginkgo -vv --label-filter="${GINKGO_LABEL_FILTER:-}" ./tests/warp -- "${EXTRA_ARGS[@]}" 24 | -------------------------------------------------------------------------------- /scripts/run_simulator.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This script runs a 30s load simulation using RPC_ENDPOINTS environment variable to specify 3 | # which RPC endpoints to hit. 4 | 5 | set -e 6 | 7 | echo "Beginning simulator script" 8 | 9 | if ! [[ "$0" =~ scripts/run_simulator.sh ]]; then 10 | echo "must be run from repository root, but got $0" 11 | exit 255 12 | fi 13 | 14 | SUBNET_EVM_PATH=$( 15 | cd "$(dirname "${BASH_SOURCE[0]}")" 16 | cd .. && pwd 17 | ) 18 | # Load the constants 19 | source "$SUBNET_EVM_PATH"/scripts/constants.sh 20 | 21 | run_simulator() { 22 | ################################# 23 | echo "building simulator" 24 | pushd ./cmd/simulator 25 | go build -o ./simulator main/*.go 26 | echo 27 | 28 | popd 29 | echo "running simulator from $PWD" 30 | ./cmd/simulator/simulator \ 31 | --endpoints="$RPC_ENDPOINTS" \ 32 | --key-dir=./cmd/simulator/.simulator/keys \ 33 | --timeout=300s \ 34 | --workers=1 \ 35 | --txs-per-worker=50000 \ 36 | --batch-size=50000 \ 37 | --max-fee-cap=1000000 \ 38 | --max-tip-cap=10000 39 | } 40 | 41 | run_simulator 42 | -------------------------------------------------------------------------------- /scripts/tests.build_antithesis_images.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | # Validates the construction of the antithesis images by: 6 | # 7 | # 1. Building the antithesis test images 8 | # 2. Extracting the docker compose configuration from the config image 9 | # 3. Running the workload and its target network without error for a minute 10 | # 4. Stopping the workload and its target network 11 | # 12 | 13 | # e.g., 14 | # ./scripts/tests.build_antithesis_images.sh # Test build of antithesis images 15 | # DEBUG=1 ./scripts/tests.build_antithesis_images.sh # Retain the temporary compose path for troubleshooting 16 | 17 | SUBNET_EVM_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) 18 | 19 | # Discover the default tag that will be used for the image 20 | source "${SUBNET_EVM_PATH}"/scripts/constants.sh 21 | export IMAGE_TAG="${DOCKERHUB_TAG}" 22 | 23 | # Build the images 24 | bash -x "${SUBNET_EVM_PATH}"/scripts/build_antithesis_images.sh 25 | 26 | # Test the images 27 | AVALANCHEGO_CLONE_PATH="${AVALANCHEGO_CLONE_PATH:-${SUBNET_EVM_PATH}/avalanchego}" 28 | export IMAGE_NAME="antithesis-subnet-evm-config" 29 | export DEBUG="${DEBUG:-}" 30 | set -x 31 | # shellcheck source=/dev/null 32 | . "${AVALANCHEGO_CLONE_PATH}"/scripts/lib_test_antithesis_images.sh 33 | -------------------------------------------------------------------------------- /stateupgrade/interfaces.go: -------------------------------------------------------------------------------- 1 | // (c) 2023 Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package stateupgrade 5 | 6 | import ( 7 | "math/big" 8 | 9 | "github.com/ava-labs/libevm/common" 10 | "github.com/holiman/uint256" 11 | ) 12 | 13 | // StateDB is the interface for accessing EVM state in state upgrades 14 | type StateDB interface { 15 | SetState(common.Address, common.Hash, common.Hash) 16 | SetCode(common.Address, []byte) 17 | AddBalance(common.Address, *uint256.Int) 18 | 19 | GetNonce(common.Address) uint64 20 | SetNonce(common.Address, uint64) 21 | 22 | CreateAccount(common.Address) 23 | Exist(common.Address) bool 24 | } 25 | 26 | // ChainContext defines an interface that provides information to a state upgrade 27 | // about the chain configuration. 28 | type ChainContext interface { 29 | IsEIP158(num *big.Int) bool 30 | } 31 | 32 | // BlockContext defines an interface that provides information to a state upgrade 33 | // about the block that activates the upgrade. 34 | type BlockContext interface { 35 | Number() *big.Int 36 | } 37 | -------------------------------------------------------------------------------- /sync/handlers/handler.go: -------------------------------------------------------------------------------- 1 | // (c) 2021-2022, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package handlers 5 | 6 | import ( 7 | "github.com/ava-labs/libevm/common" 8 | "github.com/ava-labs/libevm/core/types" 9 | "github.com/ava-labs/subnet-evm/core/state/snapshot" 10 | ) 11 | 12 | type BlockProvider interface { 13 | GetBlock(common.Hash, uint64) *types.Block 14 | } 15 | 16 | type SnapshotProvider interface { 17 | Snapshots() *snapshot.Tree 18 | } 19 | 20 | type SyncDataProvider interface { 21 | BlockProvider 22 | SnapshotProvider 23 | } 24 | -------------------------------------------------------------------------------- /sync/handlers/test_providers.go: -------------------------------------------------------------------------------- 1 | // (c) 2021-2022, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package handlers 5 | 6 | import ( 7 | "github.com/ava-labs/libevm/common" 8 | "github.com/ava-labs/libevm/core/types" 9 | "github.com/ava-labs/subnet-evm/core/state/snapshot" 10 | ) 11 | 12 | var ( 13 | _ BlockProvider = &TestBlockProvider{} 14 | _ SnapshotProvider = &TestSnapshotProvider{} 15 | ) 16 | 17 | type TestBlockProvider struct { 18 | GetBlockFn func(common.Hash, uint64) *types.Block 19 | } 20 | 21 | func (t *TestBlockProvider) GetBlock(hash common.Hash, number uint64) *types.Block { 22 | return t.GetBlockFn(hash, number) 23 | } 24 | 25 | type TestSnapshotProvider struct { 26 | Snapshot *snapshot.Tree 27 | } 28 | 29 | func (t *TestSnapshotProvider) Snapshots() *snapshot.Tree { 30 | return t.Snapshot 31 | } 32 | -------------------------------------------------------------------------------- /sync/statesync/trie_sync_stats_test.go: -------------------------------------------------------------------------------- 1 | // (c) 2024, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package statesync 5 | 6 | import ( 7 | "testing" 8 | "time" 9 | 10 | "github.com/ava-labs/libevm/metrics" 11 | "github.com/stretchr/testify/require" 12 | ) 13 | 14 | func TestETAShouldNotOverflow(t *testing.T) { 15 | require := require.New(t) 16 | now := time.Now() 17 | start := now.Add(-6 * time.Hour) 18 | 19 | stats := &trieSyncStats{ 20 | triesStartTime: start, 21 | triesSynced: 100_000, 22 | triesRemaining: 450_000, 23 | leafsRateGauge: metrics.NilGauge{}, 24 | } 25 | require.Positive(stats.updateETA(time.Minute, now)) 26 | } 27 | -------------------------------------------------------------------------------- /tests/antithesis/Dockerfile.config: -------------------------------------------------------------------------------- 1 | FROM scratch AS execution 2 | 3 | # Copy config artifacts from the build path. For simplicity, artifacts 4 | # are built outside of the docker image. 5 | COPY ./build/antithesis/docker-compose.yml / 6 | COPY ./build/antithesis/volumes /volumes 7 | -------------------------------------------------------------------------------- /tests/antithesis/Dockerfile.node: -------------------------------------------------------------------------------- 1 | # BUILDER_IMAGE_TAG should identify the builder image 2 | ARG BUILDER_IMAGE_TAG 3 | 4 | # AVALANCHEGO_NODE_IMAGE needs to identify an existing avalanchego node image and should include the tag 5 | ARG AVALANCHEGO_NODE_IMAGE 6 | 7 | # ============= Compilation Stage ================ 8 | FROM antithesis-subnet-evm-builder:$BUILDER_IMAGE_TAG AS builder 9 | 10 | # The builder workdir will vary between instrumented and non-instrumented builders 11 | ARG BUILDER_WORKDIR 12 | 13 | WORKDIR $BUILDER_WORKDIR 14 | 15 | # Build the VM 16 | RUN ./scripts/build.sh /build/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy 17 | 18 | # ============= Cleanup Stage ================ 19 | FROM $AVALANCHEGO_NODE_IMAGE AS execution 20 | 21 | # Copy identifying information into the container. This will replace 22 | # the avalanchego commit hash in the base image. 23 | COPY --from=builder /build/commit_hash.txt /avalanchego/build/commit_hash.txt 24 | 25 | # Copy the antithesis dependencies into the container 26 | COPY --from=builder /instrumented/symbols /symbols 27 | 28 | # Configure the node with the location of the plugin 29 | ENV AVAGO_PLUGIN_DIR=/avalanchego/build/plugins 30 | 31 | # Copy the executable into the container 32 | COPY --from=builder $BUILDER_WORKDIR/build/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy\ 33 | $AVAGO_PLUGIN_DIR/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy 34 | 35 | # The node image's entrypoint will be reused. 36 | -------------------------------------------------------------------------------- /tests/antithesis/Dockerfile.workload: -------------------------------------------------------------------------------- 1 | # BUILDER_IMAGE_TAG should identify the builder image 2 | ARG BUILDER_IMAGE_TAG 3 | 4 | # AVALANCHEGO_NODE_IMAGE needs to identify an existing avalanchego node image and should include the tag 5 | ARG AVALANCHEGO_NODE_IMAGE 6 | 7 | # ============= Compilation Stage ================ 8 | FROM antithesis-subnet-evm-builder:$BUILDER_IMAGE_TAG AS builder 9 | 10 | # The builder workdir will vary between instrumented and non-instrumented builders 11 | ARG BUILDER_WORKDIR 12 | 13 | WORKDIR $BUILDER_WORKDIR 14 | 15 | # Build the workload 16 | RUN ./scripts/build_antithesis_workload.sh 17 | 18 | # ============= Cleanup Stage ================ 19 | # Base the workflow on the node image to support bootstrap testing 20 | FROM $AVALANCHEGO_NODE_IMAGE AS execution 21 | 22 | # The builder workdir will vary between instrumented and non-instrumented builders 23 | ARG BUILDER_WORKDIR 24 | 25 | # Copy the executable into the container 26 | COPY --from=builder $BUILDER_WORKDIR/build/workload ./workload 27 | 28 | CMD [ "./workload" ] 29 | -------------------------------------------------------------------------------- /tests/antithesis/README.md: -------------------------------------------------------------------------------- 1 | # Antithesis Testing 2 | 3 | This package supports testing with 4 | [Antithesis](https://antithesis.com/docs/introduction/introduction.html), 5 | a SaaS offering that enables deployment of distributed systems (such 6 | as Avalanche) to a deterministic and simulated environment that 7 | enables discovery and reproduction of anomalous behavior. 8 | 9 | See avalanchego's 10 | [documentation](https://github.com/ava-labs/avalanchego/blob/master/tests/antithesis/README.md) 11 | for more details. 12 | -------------------------------------------------------------------------------- /tests/antithesis/gencomposeconfig/main.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package main 5 | 6 | import ( 7 | "log" 8 | "os" 9 | "path/filepath" 10 | 11 | "github.com/ava-labs/avalanchego/tests/antithesis" 12 | "github.com/ava-labs/avalanchego/tests/fixture/tmpnet" 13 | 14 | "github.com/ava-labs/subnet-evm/tests/utils" 15 | ) 16 | 17 | const baseImageName = "antithesis-subnet-evm" 18 | 19 | // Creates docker-compose.yml and its associated volumes in the target path. 20 | func main() { 21 | // Assume the working directory is the root of the repository 22 | cwd, err := os.Getwd() 23 | if err != nil { 24 | log.Fatalf("failed to get current working directory: %s", err) 25 | } 26 | 27 | genesisPath := filepath.Join(cwd, "tests/load/genesis/genesis.json") 28 | 29 | // Create a network with a subnet-evm subnet 30 | network := tmpnet.LocalNetworkOrPanic() 31 | network.Subnets = []*tmpnet.Subnet{ 32 | utils.NewTmpnetSubnet("subnet-evm", genesisPath, utils.DefaultChainConfig, network.Nodes...), 33 | } 34 | 35 | if err := antithesis.GenerateComposeConfig(network, baseImageName); err != nil { 36 | log.Fatalf("failed to generate compose config: %v", err) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tests/load/genesis/genesis.json: -------------------------------------------------------------------------------- 1 | { 2 | "config": { 3 | "chainId": 99999, 4 | "feeConfig": { 5 | "gasLimit": 200000000, 6 | "minBaseFee": 1000000000, 7 | "targetGas": 400000000, 8 | "baseFeeChangeDenominator": 48, 9 | "minBlockGasCost": 0, 10 | "maxBlockGasCost": 10000000, 11 | "targetBlockRate": 2, 12 | "blockGasCostStep": 500000 13 | } 14 | }, 15 | "alloc": { 16 | "8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": { 17 | "balance": "0x52B7D2DCC80CD2E4000000" 18 | }, 19 | "0x0Fa8EA536Be85F32724D57A37758761B86416123": { 20 | "balance": "0x52B7D2DCC80CD2E4000000" 21 | } 22 | }, 23 | "nonce": "0x0", 24 | "timestamp": "0x5FCB13D0", 25 | "extraData": "0x00", 26 | "gasLimit": "0xBEBC200", 27 | "difficulty": "0x0", 28 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 29 | "coinbase": "0x0000000000000000000000000000000000000000", 30 | "number": "0x0", 31 | "gasUsed": "0x0", 32 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" 33 | } 34 | -------------------------------------------------------------------------------- /tests/precompile/genesis/warp.json: -------------------------------------------------------------------------------- 1 | { 2 | "config": { 3 | "chainId": 99999, 4 | "homesteadBlock": 0, 5 | "eip150Block": 0, 6 | "eip155Block": 0, 7 | "eip158Block": 0, 8 | "byzantiumBlock": 0, 9 | "constantinopleBlock": 0, 10 | "petersburgBlock": 0, 11 | "istanbulBlock": 0, 12 | "muirGlacierBlock": 0, 13 | "feeConfig": { 14 | "gasLimit": 20000000, 15 | "minBaseFee": 1000000000, 16 | "targetGas": 100000000, 17 | "baseFeeChangeDenominator": 48, 18 | "minBlockGasCost": 0, 19 | "maxBlockGasCost": 10000000, 20 | "targetBlockRate": 2, 21 | "blockGasCostStep": 500000 22 | }, 23 | "warpConfig": { 24 | "blockTimestamp": 1607144400 25 | } 26 | }, 27 | "alloc": { 28 | "8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": { 29 | "balance": "0x52B7D2DCC80CD2E4000000" 30 | }, 31 | "0x0Fa8EA536Be85F32724D57A37758761B86416123": { 32 | "balance": "0x52B7D2DCC80CD2E4000000" 33 | } 34 | }, 35 | "nonce": "0x0", 36 | "timestamp": "0x5FCB13D0", 37 | "extraData": "0x00", 38 | "gasLimit": "0x1312D00", 39 | "difficulty": "0x0", 40 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 41 | "coinbase": "0x0000000000000000000000000000000000000000", 42 | "number": "0x0", 43 | "gasUsed": "0x0", 44 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" 45 | } 46 | -------------------------------------------------------------------------------- /tests/precompile/precompile_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package precompile 5 | 6 | import ( 7 | "os" 8 | "testing" 9 | 10 | ginkgo "github.com/onsi/ginkgo/v2" 11 | 12 | // Import the solidity package, so that ginkgo maps out the tests declared within the package 13 | "github.com/ava-labs/subnet-evm/tests/precompile/solidity" 14 | ) 15 | 16 | func TestE2E(t *testing.T) { 17 | if basePath := os.Getenv("TEST_SOURCE_ROOT"); basePath != "" { 18 | os.Chdir(basePath) 19 | } 20 | solidity.RegisterAsyncTests() 21 | ginkgo.RunSpecs(t, "subnet-evm precompile ginkgo test suite") 22 | } 23 | -------------------------------------------------------------------------------- /tests/utils/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019-2022, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package utils 5 | 6 | import "time" 7 | 8 | const ( 9 | // Timeout to boot the AvalancheGo node 10 | BootAvalancheNodeTimeout = 5 * time.Minute 11 | 12 | // Timeout for the health API to check the AvalancheGo is ready 13 | HealthCheckTimeout = 5 * time.Second 14 | 15 | DefaultLocalNodeURI = "http://127.0.0.1:9650" 16 | ) 17 | -------------------------------------------------------------------------------- /tools.go: -------------------------------------------------------------------------------- 1 | // (c) 2025, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | //go:build tools 5 | 6 | package subnetevm 7 | 8 | import ( 9 | _ "github.com/fjl/gencodec" 10 | _ "golang.org/x/mod/modfile" // golang.org/x/mod to satisfy requirement for go.uber.org/mock/mockgen@v0.4 11 | ) 12 | -------------------------------------------------------------------------------- /utils/address_range.go: -------------------------------------------------------------------------------- 1 | // (c) 2021-2023, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package utils 5 | 6 | import ( 7 | "bytes" 8 | 9 | "github.com/ava-labs/libevm/common" 10 | ) 11 | 12 | // AddressRange represents a continuous range of addresses 13 | type AddressRange struct { 14 | Start common.Address 15 | End common.Address 16 | } 17 | 18 | // Contains returns true iff [addr] is contained within the (inclusive) 19 | // range of addresses defined by [a]. 20 | func (a *AddressRange) Contains(addr common.Address) bool { 21 | addrBytes := addr.Bytes() 22 | return bytes.Compare(addrBytes, a.Start[:]) >= 0 && bytes.Compare(addrBytes, a.End[:]) <= 0 23 | } 24 | -------------------------------------------------------------------------------- /utils/bytes.go: -------------------------------------------------------------------------------- 1 | // (c) 2021-2022, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package utils 5 | 6 | import "github.com/ava-labs/libevm/common" 7 | 8 | // IncrOne increments bytes value by one 9 | func IncrOne(bytes []byte) { 10 | index := len(bytes) - 1 11 | for index >= 0 { 12 | if bytes[index] < 255 { 13 | bytes[index]++ 14 | break 15 | } else { 16 | bytes[index] = 0 17 | index-- 18 | } 19 | } 20 | } 21 | 22 | // HashSliceToBytes serializes a []common.Hash into a tightly packed byte array. 23 | func HashSliceToBytes(hashes []common.Hash) []byte { 24 | bytes := make([]byte, common.HashLength*len(hashes)) 25 | for i, hash := range hashes { 26 | copy(bytes[i*common.HashLength:], hash[:]) 27 | } 28 | return bytes 29 | } 30 | 31 | // BytesToHashSlice packs [b] into a slice of hash values with zero padding 32 | // to the right if the length of b is not a multiple of 32. 33 | func BytesToHashSlice(b []byte) []common.Hash { 34 | var ( 35 | numHashes = (len(b) + 31) / 32 36 | hashes = make([]common.Hash, numHashes) 37 | ) 38 | 39 | for i := range hashes { 40 | start := i * common.HashLength 41 | copy(hashes[i][:], b[start:]) 42 | } 43 | return hashes 44 | } 45 | -------------------------------------------------------------------------------- /utils/denomination.go: -------------------------------------------------------------------------------- 1 | // (c) 2025, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package utils 5 | 6 | const ( 7 | Wei = 1 8 | GWei = 1_000_000_000 * Wei 9 | Ether = 1_000_000_000 * GWei 10 | ) 11 | -------------------------------------------------------------------------------- /warp/aggregator/mocks_generate_test.go: -------------------------------------------------------------------------------- 1 | package aggregator 2 | 3 | //go:generate go run go.uber.org/mock/mockgen -package=$GOPACKAGE -source=signature_getter.go -destination=mock_signature_getter.go -exclude_interfaces=NetworkClient 4 | -------------------------------------------------------------------------------- /warp/messages/codec.go: -------------------------------------------------------------------------------- 1 | // (c) 2024, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package messages 5 | 6 | import ( 7 | "errors" 8 | 9 | "github.com/ava-labs/avalanchego/codec" 10 | "github.com/ava-labs/avalanchego/codec/linearcodec" 11 | "github.com/ava-labs/avalanchego/utils/units" 12 | ) 13 | 14 | const ( 15 | CodecVersion = 0 16 | 17 | MaxMessageSize = 24 * units.KiB 18 | ) 19 | 20 | var Codec codec.Manager 21 | 22 | func init() { 23 | Codec = codec.NewManager(MaxMessageSize) 24 | lc := linearcodec.NewDefault() 25 | 26 | err := errors.Join( 27 | lc.RegisterType(&ValidatorUptime{}), 28 | Codec.RegisterCodec(CodecVersion, lc), 29 | ) 30 | if err != nil { 31 | panic(err) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /warp/messages/payload.go: -------------------------------------------------------------------------------- 1 | // (c) 2024, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package messages 5 | 6 | import ( 7 | "errors" 8 | "fmt" 9 | ) 10 | 11 | var errWrongType = errors.New("wrong payload type") 12 | 13 | // Payload provides a common interface for all payloads implemented by this 14 | // package. 15 | type Payload interface { 16 | // Bytes returns the binary representation of this payload. 17 | Bytes() []byte 18 | 19 | // initialize the payload with the provided binary representation. 20 | initialize(b []byte) 21 | } 22 | 23 | func Parse(bytes []byte) (Payload, error) { 24 | var payload Payload 25 | if _, err := Codec.Unmarshal(bytes, &payload); err != nil { 26 | return nil, err 27 | } 28 | payload.initialize(bytes) 29 | return payload, nil 30 | } 31 | 32 | func initialize(p Payload) error { 33 | bytes, err := Codec.Marshal(CodecVersion, &p) 34 | if err != nil { 35 | return fmt.Errorf("couldn't marshal %T payload: %w", p, err) 36 | } 37 | p.initialize(bytes) 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /warp/verifier_stats.go: -------------------------------------------------------------------------------- 1 | // (c) 2023, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | package warp 5 | 6 | import ( 7 | "github.com/ava-labs/libevm/metrics" 8 | ) 9 | 10 | type verifierStats struct { 11 | messageParseFail metrics.Counter 12 | // AddressedCall metrics 13 | addressedCallValidationFail metrics.Counter 14 | // BlockRequest metrics 15 | blockValidationFail metrics.Counter 16 | // Uptime metrics 17 | uptimeValidationFail metrics.Counter 18 | } 19 | 20 | func newVerifierStats() *verifierStats { 21 | return &verifierStats{ 22 | messageParseFail: metrics.NewRegisteredCounter("warp_backend_message_parse_fail", nil), 23 | addressedCallValidationFail: metrics.NewRegisteredCounter("warp_backend_addressed_call_validation_fail", nil), 24 | blockValidationFail: metrics.NewRegisteredCounter("warp_backend_block_validation_fail", nil), 25 | uptimeValidationFail: metrics.NewRegisteredCounter("warp_backend_uptime_validation_fail", nil), 26 | } 27 | } 28 | 29 | func (h *verifierStats) IncAddressedCallValidationFail() { 30 | h.addressedCallValidationFail.Inc(1) 31 | } 32 | 33 | func (h *verifierStats) IncBlockValidationFail() { 34 | h.blockValidationFail.Inc(1) 35 | } 36 | 37 | func (h *verifierStats) IncMessageParseFail() { 38 | h.messageParseFail.Inc(1) 39 | } 40 | 41 | func (h *verifierStats) IncUptimeValidationFail() { 42 | h.uptimeValidationFail.Inc(1) 43 | } 44 | -------------------------------------------------------------------------------- /warp/warptest/block_client.go: -------------------------------------------------------------------------------- 1 | // (c) 2024, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | // warptest exposes common functionality for testing the warp package. 5 | package warptest 6 | 7 | import ( 8 | "context" 9 | "slices" 10 | 11 | "github.com/ava-labs/avalanchego/database" 12 | "github.com/ava-labs/avalanchego/ids" 13 | "github.com/ava-labs/avalanchego/snow/consensus/snowman" 14 | "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" 15 | "github.com/ava-labs/avalanchego/snow/snowtest" 16 | ) 17 | 18 | // EmptyBlockClient returns an error if a block is requested 19 | var EmptyBlockClient BlockClient = MakeBlockClient() 20 | 21 | type BlockClient func(ctx context.Context, blockID ids.ID) (snowman.Block, error) 22 | 23 | func (f BlockClient) GetAcceptedBlock(ctx context.Context, blockID ids.ID) (snowman.Block, error) { 24 | return f(ctx, blockID) 25 | } 26 | 27 | // MakeBlockClient returns a new BlockClient that returns the provided blocks. 28 | // If a block is requested that isn't part of the provided blocks, an error is 29 | // returned. 30 | func MakeBlockClient(blkIDs ...ids.ID) BlockClient { 31 | return func(_ context.Context, blkID ids.ID) (snowman.Block, error) { 32 | if !slices.Contains(blkIDs, blkID) { 33 | return nil, database.ErrNotFound 34 | } 35 | 36 | return &snowmantest.Block{ 37 | Decidable: snowtest.Decidable{ 38 | IDV: blkID, 39 | Status: snowtest.Accepted, 40 | }, 41 | }, nil 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /warp/warptest/noop_validator_reader.go: -------------------------------------------------------------------------------- 1 | // (c) 2024, Ava Labs, Inc. All rights reserved. 2 | // See the file LICENSE for licensing terms. 3 | 4 | // warptest exposes common functionality for testing the warp package. 5 | package warptest 6 | 7 | import ( 8 | "time" 9 | 10 | "github.com/ava-labs/avalanchego/ids" 11 | "github.com/ava-labs/subnet-evm/plugin/evm/validators/interfaces" 12 | stateinterfaces "github.com/ava-labs/subnet-evm/plugin/evm/validators/state/interfaces" 13 | ) 14 | 15 | var _ interfaces.ValidatorReader = &NoOpValidatorReader{} 16 | 17 | type NoOpValidatorReader struct{} 18 | 19 | func (NoOpValidatorReader) GetValidatorAndUptime(ids.ID) (stateinterfaces.Validator, time.Duration, time.Time, error) { 20 | return stateinterfaces.Validator{}, 0, time.Time{}, nil 21 | } 22 | --------------------------------------------------------------------------------