├── DEVELOPMENT.md ├── hvm ├── vm │ ├── __init__.py │ ├── logic │ │ ├── __init__.py │ │ ├── invalid.py │ │ ├── sha3.py │ │ ├── block.py │ │ ├── duplication.py │ │ ├── swap.py │ │ └── memory.py │ ├── forks │ │ ├── frontier │ │ │ ├── transaction_context.py │ │ │ ├── constants.py │ │ │ └── validation.py │ │ ├── homestead │ │ │ ├── constants.py │ │ │ ├── validation.py │ │ │ ├── state.py │ │ │ ├── blocks.py │ │ │ ├── opcodes.py │ │ │ └── __init__.py │ │ ├── helios_testnet │ │ │ ├── transaction_context.py │ │ │ ├── constants.py │ │ │ └── headers.py │ │ ├── boson │ │ │ ├── utils.py │ │ │ ├── transaction_context.py │ │ │ ├── transactions.py │ │ │ ├── headers.py │ │ │ ├── computation.py │ │ │ ├── constants.py │ │ │ ├── opcodes.py │ │ │ ├── state.py │ │ │ └── validation.py │ │ ├── byzantium │ │ │ ├── state.py │ │ │ ├── constants.py │ │ │ ├── blocks.py │ │ │ ├── transactions.py │ │ │ └── computation.py │ │ ├── tangerine_whistle │ │ │ ├── state.py │ │ │ ├── constants.py │ │ │ ├── __init__.py │ │ │ └── computation.py │ │ ├── spurious_dragon │ │ │ ├── constants.py │ │ │ ├── blocks.py │ │ │ ├── __init__.py │ │ │ ├── opcodes.py │ │ │ └── state.py │ │ └── __init__.py │ └── execution_context.py ├── rlp │ ├── __init__.py │ ├── sedes.py │ ├── logs.py │ └── collations.py ├── tools │ ├── __init__.py │ ├── _utils │ │ ├── __init__.py │ │ ├── git.py │ │ ├── hashing.py │ │ ├── vyper.py │ │ └── mappings.py │ ├── builder │ │ └── __init__.py │ ├── fixtures │ │ ├── fillers │ │ │ ├── __init__.py │ │ │ └── main.py │ │ ├── __init__.py │ │ └── _utils.py │ ├── logging.py │ ├── mining.py │ └── rlp.py ├── utils │ ├── __init__.py │ ├── empty.py │ ├── chain_head_db.py │ ├── pickle.py │ ├── address.py │ ├── logging.py │ ├── profile.py │ ├── hexadecimal.py │ ├── bn128.py │ ├── db.py │ └── state.py ├── consensus │ └── __init__.py ├── db │ ├── backends │ │ ├── __init__.py │ │ └── memory.py │ ├── hash_trie.py │ ├── read_only.py │ ├── cache.py │ └── keymap.py ├── types.py ├── chains │ ├── mainnet │ │ └── constants.py │ ├── testnet │ │ └── constants.py │ ├── __init__.py │ ├── ropsten │ │ └── constants.py │ └── ethereum_mainnet │ │ └── constants.py ├── precompiles │ ├── __init__.py │ ├── identity.py │ ├── sha256.py │ ├── ripemd160.py │ ├── ecmul.py │ └── ecadd.py ├── estimators │ └── __init__.py └── __init__.py ├── tests ├── __init__.py ├── hvm │ ├── predefined_databases │ │ ├── talamus_test │ │ │ ├── LOCK │ │ │ ├── 000096.log │ │ │ ├── CURRENT │ │ │ ├── 000005.ldb │ │ │ ├── MANIFEST-000095 │ │ │ ├── LOG │ │ │ └── LOG.old │ │ └── talamus_test_save_hash │ │ │ ├── LOCK │ │ │ ├── 000029.log │ │ │ ├── CURRENT │ │ │ ├── 000005.ldb │ │ │ ├── 000010.ldb │ │ │ ├── MANIFEST-000028 │ │ │ ├── LOG │ │ │ └── LOG.old │ ├── contract_data │ │ ├── erc20_compiled.pkl │ │ ├── airdrop_compiled.pkl │ │ └── talamus_compiled.pkl │ ├── plots │ │ ├── staking_score_vs_latency.png │ │ ├── staking_score_vs_failed_requests.png │ │ └── staking_score_vs_time_since_last_reward.png │ └── padding.py └── rlp │ └── test_rlp.py ├── docs ├── contributing.rst ├── quickstart.rst ├── introduction.rst ├── dev_random.rst ├── guides │ ├── index.rst │ └── helios │ │ └── index.rst ├── api │ └── index.rst ├── index.rst ├── Makefile └── rpc │ ├── net.rst │ └── admin.rst ├── helios ├── db │ └── __init__.py ├── p2p │ └── __init__.py ├── sync │ ├── __init__.py │ ├── full │ │ ├── __init__.py │ │ └── constants.py │ ├── common │ │ ├── __init__.py │ │ └── constants.py │ └── light │ │ └── __init__.py ├── nodes │ ├── __init__.py │ ├── mainnet.py │ ├── testnet.py │ └── ropsten.py ├── plugins │ ├── __init__.py │ └── builtin │ │ ├── __init__.py │ │ ├── attach │ │ ├── __init__.py │ │ └── plugin.py │ │ ├── ethstats │ │ └── __init__.py │ │ ├── json_rpc │ │ └── __init__.py │ │ ├── tx_pool │ │ └── __init__.py │ │ ├── peer_blacklist │ │ ├── __init__.py │ │ ├── events.py │ │ └── plugin.py │ │ ├── fix_unclean_shutdown │ │ ├── __init__.py │ │ └── plugin.py │ │ ├── rebuild_historical_chain │ │ └── __init__.py │ │ ├── rpc_http_proxy_through_ipc_socket │ │ ├── __init__.py │ │ └── plugin.py │ │ ├── rpc_websocket_proxy_through_ipc_socket │ │ ├── __init__.py │ │ └── plugin.py │ │ └── light_peer_chain_bridge │ │ └── __init__.py ├── protocol │ ├── __init__.py │ ├── common │ │ ├── boot.py │ │ ├── __init__.py │ │ ├── commands.py │ │ ├── normalizers.py │ │ ├── types.py │ │ └── context.py │ ├── hls │ │ ├── __init__.py │ │ ├── constants.py │ │ └── handlers.py │ └── les │ │ ├── __init__.py │ │ ├── handlers.py │ │ ├── constants.py │ │ ├── normalizers.py │ │ ├── validators.py │ │ └── trackers.py ├── tools │ ├── __init__.py │ └── timed_cache.py ├── utils │ ├── __init__.py │ ├── les.py │ ├── decorators.py │ ├── log_messages.py │ ├── async_errors.py │ ├── async_dispatch.py │ ├── timer.py │ ├── async_iter.py │ ├── version.py │ ├── mp.py │ ├── chain_proxy.py │ ├── db.py │ ├── headers.py │ ├── xdg.py │ ├── blockchain_db_health.py │ ├── db_proxy.py │ ├── verification.py │ └── shutdown.py ├── keystore │ └── .gitkeep ├── rlp_templates │ ├── __init__.py │ └── sedes.py ├── debug_tools │ └── rebuild_historical_chain.py ├── rpc │ ├── __init__.py │ ├── modules │ │ ├── eth.py │ │ ├── __init__.py │ │ ├── web3.py │ │ ├── admin.py │ │ ├── net.py │ │ ├── main.py │ │ └── evm.py │ └── constants.py ├── launch_node ├── run_chain_process ├── run_database_process ├── events.py ├── chains │ ├── testnet.py │ ├── mainnet.py │ └── ropsten.py ├── constants.py ├── extensibility │ ├── exceptions.py │ └── __init__.py ├── helios_config_template.py ├── README.md └── __init__.py ├── hp2p ├── tools │ ├── __init__.py │ ├── factories │ │ ├── socket.py │ │ ├── cancel_token.py │ │ ├── __init__.py │ │ ├── keys.py │ │ └── kademlia.py │ └── paragon │ │ ├── __init__.py │ │ ├── commands.py │ │ ├── proto.py │ │ └── peer.py ├── __init__.py └── cancellable.py ├── old_tests ├── __init__.py ├── dev │ ├── test │ │ ├── leveldb │ │ │ ├── LOCK │ │ │ ├── CURRENT │ │ │ ├── 000041.log │ │ │ ├── 000042.ldb │ │ │ ├── MANIFEST-000039 │ │ │ ├── LOG.old │ │ │ └── LOG │ │ ├── leveldb_multiprocess2 │ │ │ ├── LOCK │ │ │ ├── CURRENT │ │ │ ├── 000009.log │ │ │ ├── MANIFEST-000008 │ │ │ ├── LOG │ │ │ └── LOG.old │ │ └── leveldb_multiprocess3 │ │ │ ├── LOCK │ │ │ ├── 000027.log │ │ │ ├── CURRENT │ │ │ ├── 000005.ldb │ │ │ ├── 000008.ldb │ │ │ ├── 000013.ldb │ │ │ ├── 000016.ldb │ │ │ ├── MANIFEST-000026 │ │ │ ├── LOG │ │ │ └── LOG.old │ ├── main_test │ ├── pickle_test │ ├── keystore │ │ ├── instance_0 │ │ ├── instance_1 │ │ ├── instance_10 │ │ ├── instance_11 │ │ ├── instance_12 │ │ ├── instance_13 │ │ ├── instance_14 │ │ ├── instance_15 │ │ ├── instance_16 │ │ ├── instance_17 │ │ ├── instance_18 │ │ ├── instance_19 │ │ ├── instance_2 │ │ ├── instance_20 │ │ ├── instance_21 │ │ ├── instance_22 │ │ ├── instance_23 │ │ ├── instance_24 │ │ ├── instance_25 │ │ ├── instance_26 │ │ ├── instance_27 │ │ ├── instance_28 │ │ ├── instance_29 │ │ ├── instance_3 │ │ ├── instance_30 │ │ ├── instance_31 │ │ ├── instance_32 │ │ ├── instance_33 │ │ ├── instance_34 │ │ ├── instance_4 │ │ ├── instance_5 │ │ ├── instance_6 │ │ ├── instance_7 │ │ ├── instance_8 │ │ └── instance_9 │ ├── keyBox.py │ ├── test.py │ └── mp.py ├── fillers │ ├── __init__.py │ └── vm_fillers │ │ └── __init__.py ├── p2p │ ├── fixtures │ │ ├── __init__.py │ │ ├── README │ │ └── sample_1000_headers_rlp │ ├── conftest.py │ ├── test_peer_subscriber.py │ └── test_peer_collect_sub_proto_msgs.py ├── helios │ ├── integration │ │ └── fixtures │ │ │ └── geth_lightchain_datadir │ │ │ └── geth │ │ │ ├── LOCK │ │ │ ├── chaindata │ │ │ ├── LOCK │ │ │ ├── CURRENT │ │ │ ├── 000014.ldb │ │ │ ├── 000015.ldb │ │ │ ├── 000018.ldb │ │ │ ├── 000021.ldb │ │ │ ├── 000022.log │ │ │ └── MANIFEST-000023 │ │ │ ├── transactions.rlp │ │ │ └── nodekey │ └── core │ │ ├── utils │ │ └── test_version.py │ │ ├── chain-management │ │ ├── test_light_peer_chain.py │ │ ├── test_initialize_database.py │ │ └── test_is_database_initialized.py │ │ ├── filesystem-utils │ │ └── test_is_under_path.py │ │ └── cli │ │ └── test_trinity_repl.py └── core │ ├── numeric-utils │ ├── test_get_highest_bit_length.py │ └── test_int_to_bytes32.py │ ├── blake-utils │ └── test_blake.py │ ├── padding-utils │ └── test_padding.py │ ├── env-utils │ ├── test_get.py │ ├── test_env_float.py │ └── test_env_string.py │ ├── consensus │ └── test_pow_mining.py │ └── vm │ └── test_vm_state.py ├── stubs ├── eth_keys │ ├── utils │ │ ├── __init__.pyi │ │ ├── address.pyi │ │ └── module_loading.pyi │ ├── __init__.pyi │ ├── backends │ │ ├── native │ │ │ ├── __init__.pyi │ │ │ ├── main.pyi │ │ │ ├── jacobian.pyi │ │ │ └── ecdsa.pyi │ │ ├── __init__.pyi │ │ ├── coincurve.pyi │ │ └── base.pyi │ ├── validation.pyi │ └── main.pyi └── README.md ├── .gitmodules ├── pytest.ini ├── MANIFEST.in ├── .readthedocs.yml ├── .github ├── PULL_REQUEST_TEMPLATE.md └── ISSUE_TEMPLATE.md ├── SOLIDITY_NOTES.rst ├── .bumpversion.cfg ├── .circleci └── merge_pr.sh ├── .gitignore ├── setup_trinity.py └── LICENSE /DEVELOPMENT.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hvm/vm/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/contributing.rst: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/quickstart.rst: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/db/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/p2p/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/sync/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hp2p/tools/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hvm/rlp/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hvm/tools/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hvm/utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /old_tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/nodes/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/plugins/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/protocol/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/sync/full/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/tools/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hvm/consensus/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hvm/db/backends/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hvm/tools/_utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hvm/vm/logic/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/keystore/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /helios/protocol/common/boot.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/protocol/hls/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/protocol/les/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/rlp_templates/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/sync/common/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/sync/full/constants.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/sync/light/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hvm/tools/builder/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb/LOCK: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /old_tests/fillers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stubs/eth_keys/utils/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/plugins/builtin/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/protocol/common/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /old_tests/p2p/fixtures/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/plugins/builtin/attach/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/plugins/builtin/ethstats/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/plugins/builtin/json_rpc/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/plugins/builtin/tx_pool/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /old_tests/fillers/vm_fillers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/debug_tools/rebuild_historical_chain.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb_multiprocess2/LOCK: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb_multiprocess3/LOCK: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/hvm/predefined_databases/talamus_test/LOCK: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/plugins/builtin/peer_blacklist/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb_multiprocess3/000027.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/plugins/builtin/fix_unclean_shutdown/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb/CURRENT: -------------------------------------------------------------------------------- 1 | MANIFEST-000039 2 | -------------------------------------------------------------------------------- /tests/hvm/predefined_databases/talamus_test/000096.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/hvm/predefined_databases/talamus_test_save_hash/LOCK: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/plugins/builtin/rebuild_historical_chain/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/plugins/builtin/rpc_http_proxy_through_ipc_socket/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/rpc/__init__.py: -------------------------------------------------------------------------------- 1 | from .main import RPCServer # noqa: F401 2 | -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb_multiprocess2/CURRENT: -------------------------------------------------------------------------------- 1 | MANIFEST-000008 2 | -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb_multiprocess3/CURRENT: -------------------------------------------------------------------------------- 1 | MANIFEST-000026 2 | -------------------------------------------------------------------------------- /tests/hvm/predefined_databases/talamus_test_save_hash/000029.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /helios/plugins/builtin/rpc_websocket_proxy_through_ipc_socket/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/LOCK: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/hvm/predefined_databases/talamus_test/CURRENT: -------------------------------------------------------------------------------- 1 | MANIFEST-000095 2 | -------------------------------------------------------------------------------- /helios/rpc/modules/eth.py: -------------------------------------------------------------------------------- 1 | from .hls import Hls 2 | 3 | class Eth(Hls): 4 | pass -------------------------------------------------------------------------------- /old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/chaindata/LOCK: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/transactions.rlp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stubs/eth_keys/__init__.pyi: -------------------------------------------------------------------------------- 1 | from .main import KeyAPI 2 | 3 | 4 | keys: KeyAPI 5 | -------------------------------------------------------------------------------- /stubs/eth_keys/backends/native/__init__.pyi: -------------------------------------------------------------------------------- 1 | from .main import NativeECCBackend 2 | -------------------------------------------------------------------------------- /tests/hvm/predefined_databases/talamus_test_save_hash/CURRENT: -------------------------------------------------------------------------------- 1 | MANIFEST-000028 2 | -------------------------------------------------------------------------------- /hvm/types.py: -------------------------------------------------------------------------------- 1 | from typing import NewType 2 | 3 | Timestamp = NewType('Timestamp', int) -------------------------------------------------------------------------------- /hvm/utils/empty.py: -------------------------------------------------------------------------------- 1 | class Empty(object): 2 | pass 3 | 4 | 5 | empty = Empty() 6 | -------------------------------------------------------------------------------- /hvm/chains/mainnet/constants.py: -------------------------------------------------------------------------------- 1 | HELIOS_TESTNET_TIMESTAMP = 0 2 | BOSON_TIMESTAMP = 1558393257 -------------------------------------------------------------------------------- /hvm/chains/testnet/constants.py: -------------------------------------------------------------------------------- 1 | HELIOS_TESTNET_TIMESTAMP = 0 2 | BOSON_TIMESTAMP = 1558393257 -------------------------------------------------------------------------------- /helios/launch_node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/helios/launch_node -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "fixtures"] 2 | path = fixtures 3 | url = https://github.com/ethereum/tests.git 4 | -------------------------------------------------------------------------------- /old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/chaindata/CURRENT: -------------------------------------------------------------------------------- 1 | MANIFEST-000023 2 | -------------------------------------------------------------------------------- /stubs/eth_keys/utils/address.pyi: -------------------------------------------------------------------------------- 1 | def public_key_bytes_to_address(public_key_bytes: bytes) -> bytes: ... 2 | -------------------------------------------------------------------------------- /old_tests/dev/main_test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/dev/main_test -------------------------------------------------------------------------------- /tests/rlp/test_rlp.py: -------------------------------------------------------------------------------- 1 | import rlp 2 | 3 | #test_byte_string = b'a'*2**40 4 | 5 | #rlp.decode(None) 6 | 7 | 8 | -------------------------------------------------------------------------------- /helios/run_chain_process: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/helios/run_chain_process -------------------------------------------------------------------------------- /old_tests/dev/pickle_test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/dev/pickle_test -------------------------------------------------------------------------------- /pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | addopts= --showlocals 3 | python_paths= . 4 | xfail_strict=true 5 | norecursedirs=old_tests -------------------------------------------------------------------------------- /helios/run_database_process: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/helios/run_database_process -------------------------------------------------------------------------------- /docs/introduction.rst: -------------------------------------------------------------------------------- 1 | These guides are from the Ethereum VM and are no longer accurate. We will add guides later in development. -------------------------------------------------------------------------------- /helios/events.py: -------------------------------------------------------------------------------- 1 | from lahja import ( 2 | BaseEvent 3 | ) 4 | 5 | 6 | class ShutdownRequest(BaseEvent): 7 | pass 8 | -------------------------------------------------------------------------------- /old_tests/p2p/fixtures/README: -------------------------------------------------------------------------------- 1 | sample_1000_headers_rlp: First 1000 headers from mainnet, stored as CountableList(BlockHeader) 2 | -------------------------------------------------------------------------------- /hp2p/__init__.py: -------------------------------------------------------------------------------- 1 | # This is to ensure we call setup_trace_logging() before anything else. 2 | import hvm as _eth_module # noqa: F401 3 | -------------------------------------------------------------------------------- /old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/nodekey: -------------------------------------------------------------------------------- 1 | 6cb1a5fc574fd8e1353d2f90aec20695db7d7917d8e6ade739bc36872c88eb0f -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb/000041.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/dev/test/leveldb/000041.log -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb/000042.ldb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/dev/test/leveldb/000042.ldb -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb/MANIFEST-000039: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/dev/test/leveldb/MANIFEST-000039 -------------------------------------------------------------------------------- /stubs/eth_keys/utils/module_loading.pyi: -------------------------------------------------------------------------------- 1 | def import_string(dotted_path: str) -> type: ... 2 | def split_at_longest_importable_path(dotted_path): ... 3 | -------------------------------------------------------------------------------- /tests/hvm/contract_data/erc20_compiled.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/tests/hvm/contract_data/erc20_compiled.pkl -------------------------------------------------------------------------------- /old_tests/p2p/fixtures/sample_1000_headers_rlp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/p2p/fixtures/sample_1000_headers_rlp -------------------------------------------------------------------------------- /tests/hvm/contract_data/airdrop_compiled.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/tests/hvm/contract_data/airdrop_compiled.pkl -------------------------------------------------------------------------------- /tests/hvm/contract_data/talamus_compiled.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/tests/hvm/contract_data/talamus_compiled.pkl -------------------------------------------------------------------------------- /tests/hvm/plots/staking_score_vs_latency.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/tests/hvm/plots/staking_score_vs_latency.png -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb_multiprocess2/000009.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/dev/test/leveldb_multiprocess2/000009.log -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb_multiprocess3/000005.ldb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/dev/test/leveldb_multiprocess3/000005.ldb -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb_multiprocess3/000008.ldb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/dev/test/leveldb_multiprocess3/000008.ldb -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb_multiprocess3/000013.ldb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/dev/test/leveldb_multiprocess3/000013.ldb -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb_multiprocess3/000016.ldb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/dev/test/leveldb_multiprocess3/000016.ldb -------------------------------------------------------------------------------- /helios/utils/les.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from eth_utils import big_endian_to_int 4 | 5 | 6 | def gen_request_id() -> int: 7 | return big_endian_to_int(os.urandom(8)) 8 | -------------------------------------------------------------------------------- /tests/hvm/plots/staking_score_vs_failed_requests.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/tests/hvm/plots/staking_score_vs_failed_requests.png -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include VERSION 3 | include README.md 4 | include requirements.txt 5 | 6 | recursive-exclude * __pycache__ 7 | recursive-exclude * *.py[co] 8 | -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb_multiprocess2/MANIFEST-000008: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/dev/test/leveldb_multiprocess2/MANIFEST-000008 -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb_multiprocess3/MANIFEST-000026: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/dev/test/leveldb_multiprocess3/MANIFEST-000026 -------------------------------------------------------------------------------- /tests/hvm/predefined_databases/talamus_test/000005.ldb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/tests/hvm/predefined_databases/talamus_test/000005.ldb -------------------------------------------------------------------------------- /tests/hvm/plots/staking_score_vs_time_since_last_reward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/tests/hvm/plots/staking_score_vs_time_since_last_reward.png -------------------------------------------------------------------------------- /tests/hvm/predefined_databases/talamus_test/MANIFEST-000095: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/tests/hvm/predefined_databases/talamus_test/MANIFEST-000095 -------------------------------------------------------------------------------- /helios/plugins/builtin/light_peer_chain_bridge/__init__.py: -------------------------------------------------------------------------------- 1 | from .light_peer_chain_bridge import ( # noqa: F401 2 | EventBusLightPeerChain, 3 | LightPeerChainEventBusHandler, 4 | ) 5 | -------------------------------------------------------------------------------- /hvm/db/hash_trie.py: -------------------------------------------------------------------------------- 1 | from eth_hash.auto import keccak 2 | 3 | from hvm.db.keymap import ( 4 | KeyMapDB, 5 | ) 6 | 7 | 8 | class HashTrie(KeyMapDB): 9 | keymap = keccak 10 | -------------------------------------------------------------------------------- /hvm/vm/forks/frontier/transaction_context.py: -------------------------------------------------------------------------------- 1 | from hvm.vm.transaction_context import BaseTransactionContext 2 | 3 | 4 | class FrontierTransactionContext(BaseTransactionContext): 5 | pass 6 | -------------------------------------------------------------------------------- /tests/hvm/predefined_databases/talamus_test_save_hash/000005.ldb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/tests/hvm/predefined_databases/talamus_test_save_hash/000005.ldb -------------------------------------------------------------------------------- /tests/hvm/predefined_databases/talamus_test_save_hash/000010.ldb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/tests/hvm/predefined_databases/talamus_test_save_hash/000010.ldb -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | # https://docs.readthedocs.io/en/latest/yaml-config.html 2 | build: 3 | image: latest 4 | python: 5 | version: 3.6 6 | pip_install: True 7 | extra_requirements: 8 | - doc 9 | -------------------------------------------------------------------------------- /hvm/vm/forks/homestead/constants.py: -------------------------------------------------------------------------------- 1 | # 2 | # Difficulty 3 | # 4 | HOMESTEAD_DIFFICULTY_ADJUSTMENT_CUTOFF = 10 5 | 6 | 7 | # 8 | # Gas Costs and Refunds 9 | # 10 | GAS_CODEDEPOSIT = 200 11 | -------------------------------------------------------------------------------- /hvm/vm/forks/helios_testnet/transaction_context.py: -------------------------------------------------------------------------------- 1 | from hvm.vm.transaction_context import BaseTransactionContext 2 | 3 | 4 | class HeliosTestnetTransactionContext(BaseTransactionContext): 5 | pass 6 | -------------------------------------------------------------------------------- /tests/hvm/predefined_databases/talamus_test_save_hash/MANIFEST-000028: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/tests/hvm/predefined_databases/talamus_test_save_hash/MANIFEST-000028 -------------------------------------------------------------------------------- /hvm/vm/forks/boson/utils.py: -------------------------------------------------------------------------------- 1 | from hvm.vm.forks.helios_testnet.utils import collect_touched_accounts 2 | 3 | def boson_collect_touched_accounts(computation): 4 | return collect_touched_accounts(computation) 5 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### What was wrong? 2 | 3 | 4 | 5 | ### How was it fixed? 6 | 7 | 8 | 9 | #### Cute Animal Picture 10 | 11 | ![put a cute animal picture link inside the parentheses]() 12 | -------------------------------------------------------------------------------- /hvm/vm/forks/boson/transaction_context.py: -------------------------------------------------------------------------------- 1 | from hvm.vm.forks.helios_testnet.transaction_context import HeliosTestnetTransactionContext 2 | 3 | class BosonTransactionContext(HeliosTestnetTransactionContext): 4 | pass 5 | -------------------------------------------------------------------------------- /helios/chains/testnet.py: -------------------------------------------------------------------------------- 1 | from hvm import ( 2 | TestnetChain 3 | ) 4 | 5 | from helios.chains.coro import AsyncChainMixin 6 | 7 | 8 | class TestnetFullChain(TestnetChain, AsyncChainMixin): 9 | pass 10 | 11 | -------------------------------------------------------------------------------- /helios/utils/decorators.py: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Any, 3 | ) 4 | 5 | 6 | class classproperty(property): 7 | def __get__(self, obj: Any, objtype: Any = None) -> Any: 8 | return super().__get__(objtype) 9 | -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb_multiprocess2/LOG: -------------------------------------------------------------------------------- 1 | 2019/04/17-16:32:33.591708 7f62bf6e8440 Recovering log #7 2 | 2019/04/17-16:32:33.599472 7f62bf6e8440 Delete type=0 #7 3 | 2019/04/17-16:32:33.599601 7f62bf6e8440 Delete type=3 #6 4 | -------------------------------------------------------------------------------- /hvm/tools/_utils/git.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | from eth_utils import to_text 4 | 5 | 6 | def get_version_from_git(): 7 | version = subprocess.check_output(["git", "describe"]).strip() 8 | return to_text(version) 9 | -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb_multiprocess2/LOG.old: -------------------------------------------------------------------------------- 1 | 2019/04/17-16:30:32.632911 7f19c034c440 Recovering log #5 2 | 2019/04/17-16:30:32.637838 7f19c034c440 Delete type=0 #5 3 | 2019/04/17-16:30:32.637948 7f19c034c440 Delete type=3 #4 4 | -------------------------------------------------------------------------------- /tests/hvm/predefined_databases/talamus_test/LOG: -------------------------------------------------------------------------------- 1 | 2019/08/16-20:25:48.149679 7f1f4c545440 Recovering log #94 2 | 2019/08/16-20:25:48.154445 7f1f4c545440 Delete type=0 #94 3 | 2019/08/16-20:25:48.154583 7f1f4c545440 Delete type=3 #93 4 | -------------------------------------------------------------------------------- /tests/hvm/predefined_databases/talamus_test/LOG.old: -------------------------------------------------------------------------------- 1 | 2019/07/30-19:03:28.918189 7fbc14590440 Recovering log #92 2 | 2019/07/30-19:03:28.925355 7fbc14590440 Delete type=0 #92 3 | 2019/07/30-19:03:28.925454 7fbc14590440 Delete type=3 #91 4 | -------------------------------------------------------------------------------- /old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/chaindata/000014.ldb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/chaindata/000014.ldb -------------------------------------------------------------------------------- /old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/chaindata/000015.ldb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/chaindata/000015.ldb -------------------------------------------------------------------------------- /old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/chaindata/000018.ldb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/chaindata/000018.ldb -------------------------------------------------------------------------------- /old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/chaindata/000021.ldb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/chaindata/000021.ldb -------------------------------------------------------------------------------- /old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/chaindata/000022.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/chaindata/000022.log -------------------------------------------------------------------------------- /tests/hvm/predefined_databases/talamus_test_save_hash/LOG: -------------------------------------------------------------------------------- 1 | 2019/08/16-20:25:48.326747 7f1f4c545440 Recovering log #27 2 | 2019/08/16-20:25:48.331149 7f1f4c545440 Delete type=0 #27 3 | 2019/08/16-20:25:48.331246 7f1f4c545440 Delete type=3 #26 4 | -------------------------------------------------------------------------------- /tests/hvm/predefined_databases/talamus_test_save_hash/LOG.old: -------------------------------------------------------------------------------- 1 | 2019/07/30-19:03:28.945438 7fbc14590440 Recovering log #25 2 | 2019/07/30-19:03:28.951275 7fbc14590440 Delete type=0 #25 3 | 2019/07/30-19:03:28.951367 7fbc14590440 Delete type=3 #24 4 | -------------------------------------------------------------------------------- /helios/nodes/mainnet.py: -------------------------------------------------------------------------------- 1 | from helios.chains.mainnet import ( 2 | MainnetFullChain, 3 | ) 4 | from helios.nodes.full import FullNode 5 | 6 | 7 | class MainnetFullNode(FullNode): 8 | chain_class = MainnetFullChain 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /helios/nodes/testnet.py: -------------------------------------------------------------------------------- 1 | from helios.chains.testnet import ( 2 | TestnetFullChain, 3 | ) 4 | from helios.nodes.full import FullNode 5 | 6 | 7 | class TestnetFullNode(FullNode): 8 | chain_class = TestnetFullChain 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/chaindata/MANIFEST-000023: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Helios-Protocol/py-helios-node/HEAD/old_tests/helios/integration/fixtures/geth_lightchain_datadir/geth/chaindata/MANIFEST-000023 -------------------------------------------------------------------------------- /docs/dev_random.rst: -------------------------------------------------------------------------------- 1 | 2 | How to profile 3 | 4 | .. code:: bash 5 | 6 | I just tried running trinity --profile and it produces two profile dumps and after installing cprofilev I can simply run cprofilev -f to start inspecting. 7 | -------------------------------------------------------------------------------- /hvm/utils/chain_head_db.py: -------------------------------------------------------------------------------- 1 | from hvm.constants import TIME_BETWEEN_HEAD_HASH_SAVE 2 | import time 3 | 4 | def round_down_to_nearest_historical_window(number: int) -> int: 5 | return int(int(number/TIME_BETWEEN_HEAD_HASH_SAVE)*TIME_BETWEEN_HEAD_HASH_SAVE) -------------------------------------------------------------------------------- /old_tests/helios/core/utils/test_version.py: -------------------------------------------------------------------------------- 1 | from helios.utils.version import construct_trinity_client_identifier 2 | 3 | 4 | def test_construct_trinity_client_identifier(): 5 | assert construct_trinity_client_identifier().startswith('Trinity/') 6 | -------------------------------------------------------------------------------- /hvm/vm/forks/byzantium/state.py: -------------------------------------------------------------------------------- 1 | from hvm.vm.forks.spurious_dragon.state import SpuriousDragonState 2 | 3 | from .computation import ByzantiumComputation 4 | 5 | 6 | class ByzantiumState(SpuriousDragonState): 7 | computation_class = ByzantiumComputation 8 | -------------------------------------------------------------------------------- /helios/chains/mainnet.py: -------------------------------------------------------------------------------- 1 | from hvm.chains.mainnet import ( 2 | BaseMainnetChain, 3 | MainnetChain 4 | ) 5 | 6 | from helios.chains.coro import AsyncChainMixin 7 | 8 | 9 | class MainnetFullChain(MainnetChain, AsyncChainMixin): 10 | pass 11 | 12 | -------------------------------------------------------------------------------- /hvm/vm/forks/tangerine_whistle/state.py: -------------------------------------------------------------------------------- 1 | from hvm.vm.forks.homestead.state import HomesteadState 2 | 3 | from .computation import TangerineWhistleComputation 4 | 5 | 6 | class TangerineWhistleState(HomesteadState): 7 | computation_class = TangerineWhistleComputation 8 | -------------------------------------------------------------------------------- /hp2p/tools/factories/socket.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | 4 | def get_open_port() -> int: 5 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 6 | s.bind(("", 0)) 7 | s.listen(1) 8 | port = s.getsockname()[1] 9 | s.close() 10 | return port 11 | -------------------------------------------------------------------------------- /hvm/utils/pickle.py: -------------------------------------------------------------------------------- 1 | 2 | import pickle as pickle_lib 3 | 4 | def hp_encode(obj, sedes = None): 5 | #here we can use the sedes to check the types of obj. will implement in future 6 | return pickle_lib.dumps(obj) 7 | 8 | def hp_decode(encoded): 9 | return pickle_lib.loads(encoded) -------------------------------------------------------------------------------- /hp2p/tools/factories/cancel_token.py: -------------------------------------------------------------------------------- 1 | import factory 2 | 3 | from cancel_token import CancelToken 4 | 5 | 6 | class CancelTokenFactory(factory.Factory): 7 | class Meta: 8 | model = CancelToken 9 | 10 | name = factory.Sequence(lambda n: "test-token-{}".format(n)) 11 | -------------------------------------------------------------------------------- /hvm/db/read_only.py: -------------------------------------------------------------------------------- 1 | from hvm.db.journal import JournalDB 2 | 3 | 4 | class ReadOnlyDB(JournalDB): 5 | """ 6 | Read only db. Stores changes in a temporary dictionary that is not written to the harddrive 7 | """ 8 | 9 | def commit(self, changeset_id) -> None: 10 | pass 11 | -------------------------------------------------------------------------------- /hvm/vm/forks/byzantium/constants.py: -------------------------------------------------------------------------------- 1 | from eth_utils import denoms 2 | 3 | # 4 | # Difficulty 5 | # 6 | BYZANTIUM_DIFFICULTY_ADJUSTMENT_CUTOFF = 9 7 | 8 | 9 | EIP649_BLOCK_REWARD = 3 * denoms.ether 10 | 11 | EIP658_TRANSACTION_STATUS_CODE_FAILURE = b'' 12 | EIP658_TRANSACTION_STATUS_CODE_SUCCESS = b'\x01' 13 | -------------------------------------------------------------------------------- /hvm/vm/forks/spurious_dragon/constants.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gas Costs and Refunds 3 | # 4 | GAS_CODEDEPOSIT = 200 5 | 6 | 7 | # https://github.com/ethereum/EIPs/issues/160 8 | GAS_EXP_EIP160 = 10 9 | GAS_EXPBYTE_EIP160 = 50 10 | 11 | 12 | # https://github.com/ethereum/EIPs/issues/170 13 | EIP170_CODE_SIZE_LIMIT = 24577 14 | -------------------------------------------------------------------------------- /hvm/vm/forks/boson/transactions.py: -------------------------------------------------------------------------------- 1 | 2 | from hvm.vm.forks.helios_testnet import HeliosTestnetTransaction, HeliosTestnetReceiveTransaction 3 | 4 | 5 | class BosonTransaction(HeliosTestnetTransaction): 6 | pass 7 | 8 | class BosonReceiveTransaction(HeliosTestnetReceiveTransaction): 9 | pass 10 | 11 | 12 | -------------------------------------------------------------------------------- /helios/protocol/hls/constants.py: -------------------------------------------------------------------------------- 1 | # Max number of items we can ask for in ETH requests. These are the values used 2 | # in geth and if we ask for more than this the peers will disconnect from us. 3 | MAX_STATE_FETCH = 384 4 | MAX_BODIES_FETCH = 128 5 | MAX_RECEIPTS_FETCH = 256 6 | MAX_HEADERS_FETCH = 192 7 | MAX_BLOCKS_FETCH = 128 8 | -------------------------------------------------------------------------------- /helios/constants.py: -------------------------------------------------------------------------------- 1 | SYNC_FULL = 'full' 2 | SYNC_LIGHT = 'light' 3 | 4 | MAIN_EVENTBUS_ENDPOINT = 'main' 5 | NETWORKING_EVENTBUS_ENDPOINT = 'networking' 6 | 7 | MAXIMUM_OBJECT_MEMORY_BYTES = 10000000 8 | 9 | # 10 | # For RPC admin password authentication 11 | # 12 | SCRYPT_N = int(2**14) 13 | SCRYPT_R = 8 14 | SCRYPT_P = 1 15 | -------------------------------------------------------------------------------- /helios/rpc/constants.py: -------------------------------------------------------------------------------- 1 | # Allow blocks importing from rpc that are at most this number of seconds old. 2 | MAX_ALLOWED_AGE_OF_NEW_RPC_BLOCK = 60 3 | # Once the import queue reaches this length, the node will reject rpc blocks and transactions and respond by saying 4 | # that we are still syncing 5 | MAX_ALLOWED_LENGTH_BLOCK_IMPORT_QUEUE = 3 -------------------------------------------------------------------------------- /hvm/vm/forks/tangerine_whistle/constants.py: -------------------------------------------------------------------------------- 1 | # 2 | # EIP150 Mainnet Block 3 | # 4 | TANGERINE_WHISTLE_MAINNET_BLOCK = 2463000 5 | 6 | 7 | # 8 | # Gas Costs and Refunds 9 | # 10 | GAS_SELFDESTRUCT_EIP150 = 5000 11 | GAS_CALL_EIP150 = 700 12 | GAS_EXTCODE_EIP150 = 700 13 | GAS_BALANCE_EIP150 = 400 14 | GAS_SLOAD_EIP150 = 200 15 | -------------------------------------------------------------------------------- /docs/guides/index.rst: -------------------------------------------------------------------------------- 1 | Guides 2 | ====== 3 | 4 | This section aims to provide hands-on guides to demonstrate how to use Trinity and the Py-EVM. If you are looking for detailed API descriptions check out the `API section `_. 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | :name: toc-guides 9 | 10 | trinity/index 11 | evm/index 12 | -------------------------------------------------------------------------------- /helios/rpc/modules/__init__.py: -------------------------------------------------------------------------------- 1 | from .main import RPCModule # noqa: F401 2 | 3 | from .eth import Eth # noqa: F401 4 | from .hls import Hls 5 | from .personal import Personal 6 | from .evm import EVM # noqa: F401 7 | from .net import Net # noqa: F401 8 | from .web3 import Web3 # noqa: F401 9 | from .dev import Dev 10 | from .admin import Admin 11 | -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb/LOG.old: -------------------------------------------------------------------------------- 1 | 2019/04/17-20:23:55.846128 7f8f67cde440 Recovering log #35 2 | 2019/04/17-20:23:55.846321 7f8f67cde440 Level-0 table #37: started 3 | 2019/04/17-20:23:55.848366 7f8f67cde440 Level-0 table #37: 3424 bytes OK 4 | 2019/04/17-20:23:55.851159 7f8f67cde440 Delete type=0 #35 5 | 2019/04/17-20:23:55.851245 7f8f67cde440 Delete type=3 #33 6 | -------------------------------------------------------------------------------- /stubs/README.md: -------------------------------------------------------------------------------- 1 | This is a temporary placeholder for [typeshed](https://github.com/python/typeshed) stubs we write 2 | for the libraries we depend on. They should all eventually be submitted to typeshed, but it makes 3 | sense to keep them here for a while until our libs' APIs are stable and we work out any rough 4 | edges on the type definitions in the stubs themselves. 5 | -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb_multiprocess3/LOG: -------------------------------------------------------------------------------- 1 | 2019/04/17-20:24:54.349704 7f269f48f440 Recovering log #25 2 | 2019/04/17-20:24:54.354731 7f269f48f440 Delete type=0 #25 3 | 2019/04/17-20:24:54.354838 7f269f48f440 Delete type=3 #24 4 | 2019/04/17-20:24:54.355017 7f2697d69700 Compacting 4@0 + 0@1 files 5 | 2019/04/17-20:24:54.355496 7f2697d69700 compacted to: files[ 4 0 0 0 0 0 0 ] 6 | -------------------------------------------------------------------------------- /SOLIDITY_NOTES.rst: -------------------------------------------------------------------------------- 1 | =================================== 2 | Helios Protocol Node Solidity Notes 3 | =================================== 4 | 5 | These are some notes on the helios solidity implementation, and how it differs from ethereum. 6 | 7 | Depreciated global variables 8 | ---------------------------- 9 | 10 | - blockhash(uint blockNumber) returns (bytes32) 11 | 12 | -------------------------------------------------------------------------------- /hvm/chains/__init__.py: -------------------------------------------------------------------------------- 1 | from .base import ( # noqa: F401 2 | Chain, 3 | ) 4 | from .mainnet import ( # noqa: F401 5 | MainnetChain, 6 | ) 7 | from .testnet import ( # noqa: F401 8 | TestnetChain, 9 | ) 10 | #from .ropsten import ( # noqa: F401 11 | # RopstenChain, 12 | #) 13 | #from .tester import ( # noqa: F401 14 | # MainnetTesterChain, 15 | #) 16 | -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb_multiprocess3/LOG.old: -------------------------------------------------------------------------------- 1 | 2019/04/17-20:23:54.371869 7f8f67cde440 Recovering log #23 2 | 2019/04/17-20:23:54.374461 7f8f67cde440 Delete type=0 #23 3 | 2019/04/17-20:23:54.374533 7f8f67cde440 Delete type=3 #22 4 | 2019/04/17-20:23:54.374670 7f8f605b8700 Compacting 4@0 + 0@1 files 5 | 2019/04/17-20:23:54.374992 7f8f605b8700 compacted to: files[ 4 0 0 0 0 0 0 ] 6 | -------------------------------------------------------------------------------- /helios/protocol/les/handlers.py: -------------------------------------------------------------------------------- 1 | from helios.protocol.common.handlers import ( 2 | BaseExchangeHandler, 3 | ) 4 | 5 | from .exchanges import GetBlockHeadersExchange 6 | 7 | 8 | class LESExchangeHandler(BaseExchangeHandler): 9 | _exchange_config = { 10 | 'get_block_headers': GetBlockHeadersExchange, 11 | } 12 | 13 | get_block_headers: GetBlockHeadersExchange 14 | -------------------------------------------------------------------------------- /hvm/tools/fixtures/fillers/__init__.py: -------------------------------------------------------------------------------- 1 | from .vm import ( # noqa: F401 2 | fill_vm_test, 3 | ) 4 | from .state import ( # noqa: F401 5 | fill_state_test, 6 | ) 7 | from .common import ( # noqa: F401 8 | execution, 9 | expect, 10 | pre_state, 11 | setup_filler, 12 | setup_main_filler, 13 | ) 14 | from .main import ( # noqa: F401 15 | fill_test, 16 | ) 17 | -------------------------------------------------------------------------------- /hvm/precompiles/__init__.py: -------------------------------------------------------------------------------- 1 | from .sha256 import sha256 # noqa: F401 2 | from .identity import identity # noqa: F401 3 | from .ecrecover import ecrecover # noqa: F401 4 | from .ripemd160 import ripemd160 # noqa: F401 5 | from .modexp import modexp # noqa: F401 6 | from .ecadd import ecadd # noqa: F401 7 | from .ecmul import ecmul # noqa: F401 8 | from .ecpairing import ecpairing # noqa: F401 9 | -------------------------------------------------------------------------------- /docs/guides/helios/index.rst: -------------------------------------------------------------------------------- 1 | Helios 2 | ====== 3 | 4 | This section aims to provide hands-on guides to demonstrate how to use Helios. If you are looking for detailed API descriptions check out the `API section `_. 5 | 6 | .. note:: 7 | 8 | Ooops. Nothing to see here yet. Bear with us. We're just getting started. In the future you'll find hands-on guides on how to use Helios in this section. -------------------------------------------------------------------------------- /helios/nodes/ropsten.py: -------------------------------------------------------------------------------- 1 | from helios.chains.ropsten import ( 2 | RopstenFullChain, 3 | RopstenLightDispatchChain, 4 | ) 5 | from helios.nodes.light import LightNode 6 | from helios.nodes.full import FullNode 7 | 8 | 9 | class RopstenFullNode(FullNode): 10 | chain_class = RopstenFullChain 11 | 12 | 13 | class RopstenLightNode(LightNode): 14 | chain_class = RopstenLightDispatchChain 15 | -------------------------------------------------------------------------------- /helios/utils/log_messages.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | 4 | def create_missing_ipc_error_message(ipc_path: Path) -> str: 5 | log_message = ( 6 | "The IPC path at {0} is not found. \n" 7 | "Please run " 8 | "'helios --data-dir attach' " 9 | "to specify the IPC path." 10 | ).format(str(ipc_path)) 11 | return log_message 12 | -------------------------------------------------------------------------------- /stubs/eth_keys/backends/__init__.pyi: -------------------------------------------------------------------------------- 1 | from .base import BaseECCBackend 2 | from .coincurve import CoinCurveECCBackend, is_coincurve_available 3 | from .native import NativeECCBackend 4 | from typing import Optional 5 | 6 | def get_default_backend_class() -> str: ... 7 | def get_backend_class(import_path: Optional[str]=...) -> type: ... 8 | def get_backend(import_path: Optional[str]=...) -> BaseECCBackend: ... 9 | -------------------------------------------------------------------------------- /helios/chains/ropsten.py: -------------------------------------------------------------------------------- 1 | from hvm.chains.ropsten import ( 2 | BaseRopstenChain, 3 | RopstenChain 4 | ) 5 | 6 | from helios.chains.coro import AsyncChainMixin 7 | from helios.chains.light import LightDispatchChain 8 | 9 | 10 | class RopstenFullChain(RopstenChain, AsyncChainMixin): 11 | pass 12 | 13 | 14 | class RopstenLightDispatchChain(BaseRopstenChain, LightDispatchChain): 15 | pass 16 | -------------------------------------------------------------------------------- /hvm/estimators/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | from typing import Callable 3 | 4 | from hvm.utils.module_loading import ( 5 | import_string, 6 | ) 7 | 8 | 9 | def get_gas_estimator() -> Callable: 10 | import_path = os.environ.get( 11 | 'GAS_ESTIMATOR_BACKEND_FUNC', 12 | 'hvm.estimators.gas.binary_gas_search_intrinsic_tolerance', 13 | ) 14 | return import_string(import_path) 15 | -------------------------------------------------------------------------------- /hvm/vm/forks/frontier/constants.py: -------------------------------------------------------------------------------- 1 | from eth_typing import ( 2 | Address 3 | ) 4 | 5 | CREATE_CONTRACT_ADDRESS = Address(b'') 6 | 7 | 8 | # 9 | # Difficulty 10 | # 11 | FRONTIER_DIFFICULTY_ADJUSTMENT_CUTOFF = 13 12 | 13 | 14 | # 15 | # Stack Limit 16 | # 17 | STACK_DEPTH_LIMIT = 1024 18 | 19 | 20 | # 21 | # Gas Costs and Refunds 22 | # 23 | REFUND_SELFDESTRUCT = 24000 24 | GAS_CODEDEPOSIT = 200 25 | -------------------------------------------------------------------------------- /hvm/utils/address.py: -------------------------------------------------------------------------------- 1 | import rlp_cython as rlp 2 | 3 | from eth_hash.auto import keccak 4 | 5 | 6 | def force_bytes_to_address(value: bytes) -> bytes: 7 | trimmed_value = value[-20:] 8 | padded_value = trimmed_value.rjust(20, b'\x00') 9 | return padded_value 10 | 11 | 12 | def generate_contract_address(address: bytes, nonce: bytes) -> bytes: 13 | return keccak(rlp.encode([address, nonce]))[-20:] 14 | -------------------------------------------------------------------------------- /docs/api/index.rst: -------------------------------------------------------------------------------- 1 | API 2 | ===== 3 | 4 | This section aims to provide a detailed description of all APIs. If you are looking for something more hands-on or higher-level check out the existing `guides `_. 5 | 6 | .. warning:: 7 | 8 | We expect each alpha release to have breaking changes to the API. 9 | 10 | .. toctree:: 11 | :maxdepth: 3 12 | :name: toc-api 13 | 14 | trinity/index 15 | evm/index 16 | -------------------------------------------------------------------------------- /hvm/chains/ropsten/constants.py: -------------------------------------------------------------------------------- 1 | # 2 | # Byzantium Block 3 | # 4 | BYZANTIUM_ROPSTEN_BLOCK = 1700000 5 | 6 | 7 | # 8 | # DAO Block 9 | # 10 | DAO_FORK_ROPSTEN_BLOCK = 0 11 | 12 | 13 | # 14 | # Tangerine Whistle Block 15 | # 16 | TANGERINE_WHISTLE_ROPSTEN_BLOCK = 0 17 | 18 | 19 | # 20 | # Homestead Block 21 | # 22 | HOMESTEAD_ROPSTEN_BLOCK = 0 23 | 24 | 25 | # 26 | # Spurious Dragon Block 27 | # 28 | SPURIOUS_DRAGON_ROPSTEN_BLOCK = 10 29 | -------------------------------------------------------------------------------- /hvm/vm/forks/boson/headers.py: -------------------------------------------------------------------------------- 1 | from hvm.vm.forks.helios_testnet import create_helios_testnet_header_from_parent, configure_helios_testnet_header 2 | 3 | 4 | def create_boson_header_from_parent(parent_header, **header_params): 5 | return create_helios_testnet_header_from_parent(parent_header, **header_params) 6 | 7 | 8 | def configure_boson_header(vm, **header_params): 9 | return configure_helios_testnet_header(vm, **header_params) 10 | -------------------------------------------------------------------------------- /hvm/precompiles/identity.py: -------------------------------------------------------------------------------- 1 | from hvm import constants 2 | from hvm.utils.numeric import ( 3 | ceil32, 4 | ) 5 | 6 | 7 | def identity(computation): 8 | word_count = ceil32(len(computation.msg.data)) // 32 9 | gas_fee = constants.GAS_IDENTITY + word_count * constants.GAS_IDENTITYWORD 10 | 11 | computation.consume_gas(gas_fee, reason="Identity Precompile") 12 | 13 | computation.output = computation.msg.data 14 | return computation 15 | -------------------------------------------------------------------------------- /hvm/vm/forks/tangerine_whistle/__init__.py: -------------------------------------------------------------------------------- 1 | from typing import Type # noqa: F401 2 | from hvm.vm.state import BaseState # noqa: F401 3 | 4 | from hvm.vm.forks.homestead import HomesteadVM 5 | 6 | from .state import TangerineWhistleState 7 | 8 | 9 | class TangerineWhistleVM(HomesteadVM): 10 | # fork name 11 | fork = 'tangerine-whistle' # type: str 12 | 13 | # classes 14 | _state_class = TangerineWhistleState # type: Type[BaseState] 15 | -------------------------------------------------------------------------------- /helios/extensibility/exceptions.py: -------------------------------------------------------------------------------- 1 | from helios.exceptions import ( 2 | BaseHeliosError, 3 | ) 4 | 5 | 6 | class UnsuitableShutdownError(BaseHeliosError): 7 | """ 8 | Raised when `shutdown` was called on a ``PluginManager`` instance that operates 9 | in the ``MainAndIsolatedProcessScope`` or when ``shutdown_blocking`` was called on a 10 | ``PluginManager`` instance that operates in the ``SharedProcessScope``. 11 | """ 12 | pass 13 | -------------------------------------------------------------------------------- /helios/protocol/les/constants.py: -------------------------------------------------------------------------------- 1 | # Max number of items we can ask for in LES requests. These are the values used in geth and if we 2 | # ask for more than this the peers will disconnect from us. 3 | MAX_HEADERS_FETCH = 192 4 | MAX_BODIES_FETCH = 32 5 | MAX_RECEIPTS_FETCH = 128 6 | MAX_CODE_FETCH = 64 7 | MAX_PROOFS_FETCH = 64 8 | MAX_HEADER_PROOFS_FETCH = 64 9 | 10 | # Types of LES Announce messages 11 | LES_ANNOUNCE_SIMPLE = 1 12 | LES_ANNOUNCE_SIGNED = 2 13 | -------------------------------------------------------------------------------- /hvm/rlp/sedes.py: -------------------------------------------------------------------------------- 1 | from rlp_cython.sedes import ( 2 | BigEndianInt, 3 | Binary, 4 | ) 5 | 6 | from hvm.constants import ( 7 | COLLATION_SIZE, 8 | ) 9 | 10 | 11 | address = Binary.fixed_length(20, allow_empty=True) 12 | collation_body = Binary.fixed_length(COLLATION_SIZE) 13 | hash32 = Binary.fixed_length(32) 14 | int32 = BigEndianInt(32) 15 | int256 = BigEndianInt(256) 16 | trie_root = Binary.fixed_length(32, allow_empty=True) 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. include:: introduction.rst 2 | 3 | 4 | Table of contents 5 | ============================== 6 | 7 | .. toctree:: 8 | :maxdepth: 1 9 | :caption: General 10 | 11 | introduction 12 | quickstart 13 | 14 | .. toctree:: 15 | :maxdepth: 1 16 | :caption: Fundamentals 17 | 18 | guides/index 19 | api/index 20 | 21 | .. toctree:: 22 | :maxdepth: 1 23 | :caption: Community 24 | 25 | contributing 26 | code_of_conduct 27 | -------------------------------------------------------------------------------- /helios/utils/async_errors.py: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Awaitable, 3 | Optional, 4 | Tuple, 5 | TypeVar, 6 | ) 7 | 8 | 9 | TReturn = TypeVar("TReturn") 10 | 11 | 12 | async def await_and_wrap_errors( 13 | awaitable: Awaitable[TReturn]) -> Tuple[Optional[TReturn], Optional[Exception]]: 14 | try: 15 | val = await awaitable 16 | except Exception as e: 17 | return None, e 18 | else: 19 | return val, None 20 | -------------------------------------------------------------------------------- /hvm/tools/_utils/hashing.py: -------------------------------------------------------------------------------- 1 | from eth_hash.auto import keccak 2 | 3 | import rlp_cython as rlp 4 | 5 | from hvm.rlp.logs import Log 6 | 7 | 8 | def hash_log_entries(log_entries): 9 | """ 10 | Helper function for computing the RLP hash of the logs from transaction 11 | execution. 12 | """ 13 | logs = [Log(*entry) for entry in log_entries] 14 | encoded_logs = rlp.encode(logs) 15 | logs_hash = keccak(encoded_logs) 16 | return logs_hash 17 | -------------------------------------------------------------------------------- /hvm/chains/ethereum_mainnet/constants.py: -------------------------------------------------------------------------------- 1 | # 2 | # Byzantium Block 3 | # 4 | BYZANTIUM_MAINNET_BLOCK = 4370000 5 | 6 | 7 | # 8 | # DAO Block 9 | # 10 | DAO_FORK_MAINNET_BLOCK = 1920000 11 | 12 | 13 | # 14 | # Tangerine Whistle Block 15 | # 16 | TANGERINE_WHISTLE_MAINNET_BLOCK = 2463000 17 | 18 | 19 | # 20 | # Homestead Block 21 | # 22 | HOMESTEAD_MAINNET_BLOCK = 1150000 23 | 24 | 25 | # 26 | # Spurious Dragon Block 27 | # 28 | SPURIOUS_DRAGON_MAINNET_BLOCK = 2675000 29 | -------------------------------------------------------------------------------- /helios/protocol/common/commands.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | from typing import Tuple 3 | 4 | from hvm.rlp.headers import BlockHeader 5 | 6 | from hp2p.protocol import ( 7 | Command, 8 | _DecodedMsgType, 9 | ) 10 | 11 | 12 | class BaseBlockHeaders(ABC, Command): 13 | 14 | @abstractmethod 15 | def extract_headers(self, msg: _DecodedMsgType) -> Tuple[BlockHeader, ...]: 16 | raise NotImplementedError("Must be implemented by subclasses") 17 | -------------------------------------------------------------------------------- /hvm/vm/forks/tangerine_whistle/computation.py: -------------------------------------------------------------------------------- 1 | from ..homestead.computation import HomesteadComputation 2 | 3 | from .opcodes import TANGERINE_WHISTLE_OPCODES 4 | 5 | 6 | class TangerineWhistleComputation(HomesteadComputation): 7 | """ 8 | A class for all execution computations in the ``TangerineWhistle`` fork. 9 | Inherits from :class:`~hvm.vm.forks.homestead.computation.HomesteadComputation` 10 | """ 11 | # Override 12 | opcodes = TANGERINE_WHISTLE_OPCODES 13 | -------------------------------------------------------------------------------- /old_tests/core/numeric-utils/test_get_highest_bit_length.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from hvm.utils.numeric import ( 4 | get_highest_bit_index, 5 | ) 6 | 7 | 8 | @pytest.mark.parametrize( 9 | 'value,expected', 10 | ( 11 | (1, 0), 12 | (2, 1), 13 | (3, 1), 14 | (255, 7), 15 | (256, 8), 16 | ) 17 | ) 18 | def test_get_highest_bit_index(value, expected): 19 | actual = get_highest_bit_index(value) 20 | assert actual == expected 21 | -------------------------------------------------------------------------------- /hvm/vm/forks/__init__.py: -------------------------------------------------------------------------------- 1 | #from .tangerine_whistle import ( # noqa: F401 2 | # TangerineWhistleVM, 3 | #) 4 | #from .frontier import ( # noqa: F401 5 | # FrontierVM, 6 | #) 7 | #from .homestead import ( # noqa: F401 8 | # HomesteadVM, 9 | #) 10 | #from .spurious_dragon import ( # noqa: F401 11 | # SpuriousDragonVM, 12 | #) 13 | #from .byzantium import ( # noqa: F401 14 | # ByzantiumVM, 15 | #) 16 | from .helios_testnet import ( # noqa: F401 17 | HeliosTestnetVM, 18 | ) 19 | -------------------------------------------------------------------------------- /hp2p/tools/factories/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | import factory # noqa: F401 3 | except ImportError: 4 | raise ImportError("The `p2p.tools.factories` module requires the `factory-boy` library") 5 | from .cancel_token import CancelTokenFactory # noqa: F401 6 | from .discovery import ( # noqa: F401 7 | DiscoveryProtocolFactory, 8 | ) 9 | from .kademlia import AddressFactory, NodeFactory # noqa: F401 10 | from .keys import ( # noqa: F401 11 | PrivateKeyFactory, 12 | PublicKeyFactory, 13 | ) -------------------------------------------------------------------------------- /hvm/tools/logging.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from typing import Any 3 | 4 | TRACE_LEVEL_NUM = 5 5 | 6 | 7 | class TraceLogger(logging.Logger): 8 | 9 | def trace(self, message: str, *args: Any, **kwargs: Any) -> None: 10 | self.log(TRACE_LEVEL_NUM, message, *args, **kwargs) 11 | 12 | 13 | def setup_trace_logging() -> None: 14 | logging.setLoggerClass(TraceLogger) 15 | logging.addLevelName(TRACE_LEVEL_NUM, 'TRACE') 16 | setattr(logging, 'TRACE', TRACE_LEVEL_NUM) # typing: ignore 17 | -------------------------------------------------------------------------------- /old_tests/core/blake-utils/test_blake.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | pytest.importorskip('hls.utils.blake') # noqa E402 4 | from hvm.utils.blake import blake 5 | from tests.core.helpers import ( 6 | greater_equal_python36, 7 | ) 8 | 9 | 10 | @greater_equal_python36 11 | def test_blake(): 12 | output = blake(b'helloworld') 13 | assert len(output) == 32 14 | assert output == b'\xf2@\xa8\x02\x04\x1b_\xaf\x89E\x02\xd42I\xe0\x80\xd5\xd3\xf7\xe2\xd4Q\xf2\xcf\xc9;#|\xb5\xd2\xeeo' # noqa: E501 15 | -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_0: -------------------------------------------------------------------------------- 1 | {"address": "9c8b20e830c0db83862892fc141808ea6a51fea2", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "7b2b98201b495ada27c77b097cb012a0"}, "ciphertext": "87a5d2e99b036a445ec21fd2bfc3a0381a91d9bb222dcdf4f5140db1561701b4", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "713d95f6e2de5d752259b29f2887b7e4"}, "mac": "5d34b00ae0c635a16c510737de3fae3effd27cd8c9dd71e31962770f9ce6bede"}, "id": "6663038b-219b-4576-9817-e08421365320", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_1: -------------------------------------------------------------------------------- 1 | {"address": "0d1630cb77c00d95f7fa32bccfe80043639681be", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "a95eca4138b7aba2a9a3c45a58e2eac6"}, "ciphertext": "869714cba59da1c61e404ccba9f350ce35a78787878880ff2a517ed8c70cd6ca", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "44d2d8180a2dba6e60bdbf4c639abc05"}, "mac": "6fcec4d05475f8091c775566afd6b204587013b96f8b285da1e306ccc91451ea"}, "id": "0b94687d-384a-4023-b37c-36bce2b3d053", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_10: -------------------------------------------------------------------------------- 1 | {"address": "0045e931b74eba8d8ec38ca4328d2b40894995ad", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "cb97bf09ed9434f1f92bfa478c9302bb"}, "ciphertext": "b485a43f829352bcecb5b13027a9ade5626ac5adba617490d15bc91bd69c9fcb", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "9248c7db493e7173f7b8ffc260f15608"}, "mac": "d19e95f1e4067f9ded52c2538f9936aff9c643069c125f95867782fb274aa88b"}, "id": "9a001c04-da02-4209-89a4-e970db01d288", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_11: -------------------------------------------------------------------------------- 1 | {"address": "fc89e5ba946cc4279edf2b090b5e9258c3a11fbb", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "db9b35b34ac26a9f0d954047af948a5d"}, "ciphertext": "0b415f5ecdba312fbe2e08c35ee32f990cc30f65b570ff1f0880fe51c7d9432d", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "f7a5ef4e0238f347248febd724de0b51"}, "mac": "775fdbaa52d02f1fbd4865695f930e21bfc8004e4df57e7f85bd90e58999556c"}, "id": "b6cde364-4a09-4585-8216-7b8db722ae3f", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_12: -------------------------------------------------------------------------------- 1 | {"address": "f40b0b7eb6cfcbba76d55dc41037964cf68e8e71", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "4897b76bac82bd9d01f4a6e7d23d3362"}, "ciphertext": "075730964d55207aea17ef09cd7af74dd28c86640f4b16abc02a3c7b0aafd4f6", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "6057ed86ccbb1c72231a7aa91da0a88f"}, "mac": "3aea6e53044062e86fa30646106b9b63349b2df9e160f880c6cdaa738c00d10c"}, "id": "86647ee2-04fb-49ab-9b88-3b6bdccedab5", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_13: -------------------------------------------------------------------------------- 1 | {"address": "9f81d4e9400f972ddf166ae39b1ff3c4607fea89", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "53b4cd12323e7576ed9d09ee6af6c8b1"}, "ciphertext": "c944ab388df75bc399568cf9cec5f84727a17bbd6f4170b5e73e3726e422fbe2", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "cd85bb63cd9f55228b6831702b83c20f"}, "mac": "3cb7d976f85e751c578405996ae98d19edc896ced6dfc60ce303d24d1b157920"}, "id": "25d3b073-6ad4-4a05-a470-685549420312", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_14: -------------------------------------------------------------------------------- 1 | {"address": "037f64987cdd77f6f0aa2b3b544a2a7333b516dd", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "f32d6c85817e514df506e1a5d5ca7fe3"}, "ciphertext": "0e2c57710a04f1f2f321c48163dfb8488bd4f714c5c7fea843661ab5dcea17a7", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "aeb1dea4b23ad3fa5aee859ffbcd0048"}, "mac": "c178cf8a964f27479a5ac34a1b540002ab05a90cc0ca9fe4b7f34b1bc24dd9cd"}, "id": "4f12b3e2-07cd-44a2-ae22-ca76460a31f1", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_15: -------------------------------------------------------------------------------- 1 | {"address": "e0802c8ed79e0d66d655bd05ba3862046920240e", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "9fa43a8cbcb3c248b9bfa8ab689b8b83"}, "ciphertext": "0ae4d9d3490a16acb2f861d82466ae1cda0848084551d3f5d500e6423e82117a", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "9af76c473a205687be87451bbf1c0385"}, "mac": "c651d720584789c0fe6224a039370b32b75620eb101b6338208ca34de05e5a06"}, "id": "fa23c70f-7c81-48c1-8014-7bf45036f4e9", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_16: -------------------------------------------------------------------------------- 1 | {"address": "00c352f5d4842c0e8c6d94bf377775ffd9a2a216", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "0d7c9b6269c49d1289e4e9b957463ec1"}, "ciphertext": "0c7a31aa36a55af839b3d419210aa7aa5c2d779508e773608e7718fe297a6155", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "955b2a903037f54ecf5656b7270c7368"}, "mac": "8318279993081a2ddaf64b4177b9fed090e30e67a635c38c90b527c8f931d42a"}, "id": "0a494325-969b-45ee-8e65-161b978f315c", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_17: -------------------------------------------------------------------------------- 1 | {"address": "9d2b5b36b929fb077407ad9a6f3a7b1e292864ef", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "8667976d70571f2376826dc9f82e1c46"}, "ciphertext": "99dd74bb37ea60b02ba46f3cd090e3d68394ea1c68cf42bcbcfb9de7d9b19b4a", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "fc537eb712d9cb116011fb3b6932d618"}, "mac": "f3e141344c4dfae54edf3fb0265d10ac4ddf6acb4c97334c05ba12f20dfa8eb0"}, "id": "6d5f8541-41ae-4419-ba0a-2dc03eab4c25", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_18: -------------------------------------------------------------------------------- 1 | {"address": "08cf29ca5f98a1ba32058e23875828af8768f466", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "cbb927e8e23001ceb083101d878736f7"}, "ciphertext": "dbfe2517daeddd57bf2b61e7ca6bbf64077690c8e21a7575ac5503c9a8024057", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "2d4a06411966e3d4ca722d5de27cc4e8"}, "mac": "4dfe4c3c1ba391ea9cdae9643d045531246c7be329ad1f9e05cd704c6c436e8f"}, "id": "ed3057b9-6484-474d-af6b-f8f3ba62f394", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_19: -------------------------------------------------------------------------------- 1 | {"address": "f76eac4faae31632570b886fb27cdf7c9da368ef", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "5f090ade62f08043705a1e081a8a364a"}, "ciphertext": "97e9ae2126f98e674781dcb2dab15e1bd65b806df3e6f4535f3d24a9d66b9589", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "7df7197995e37293d07c832e11507baf"}, "mac": "1a31f70539578c1072134c3030c435605774d5cfe5b05f01611fbbfb5256f7ac"}, "id": "85044a35-175f-4554-8dd4-14092a6df3d2", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_2: -------------------------------------------------------------------------------- 1 | {"address": "d68f3ebecded46bcc8e14a901c237bc46642c806", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "4c7f85f86f26e7169f194d48b292f79d"}, "ciphertext": "5fda4266824dbf18827d3b23e63f33475d2a59eb24bba8e9cb79b0c0f7f9035d", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "7171e6e6983ccfd7332ac8d9b5c3814d"}, "mac": "80e2899096e64025c0193e19538f82b2732b476d27587659ed063526c86db77a"}, "id": "a2f533db-aeb9-41a9-a774-75bb9290c3dc", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_20: -------------------------------------------------------------------------------- 1 | {"address": "3b6cc8f3446c4650c3a3a23754439acc38b8dc2c", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "b8457c93577addf711891bb82b788667"}, "ciphertext": "2ff0fc91543ad52b03ef5053c93bb0b900e9d3c714c3292afd2887b3841ac622", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "d31f3a640f8204d0aa172785a9f4235d"}, "mac": "f3556abb2b937c55c49940283167c27106f6a6e9a4aa796c25efa8a2f3caf571"}, "id": "caf9401e-98fc-4312-a196-626ee77d2fbc", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_21: -------------------------------------------------------------------------------- 1 | {"address": "1f02a32645f7aa5f8f93e592d34077906dfea8ce", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "7429b03d4b14ce541c5516d3e3c7e071"}, "ciphertext": "521201482dcd9adfd61ce5212e928706a09e88bb4c69cdff756dfbd7c91a4e79", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "59ac20ef692a9893b9147692e871f45d"}, "mac": "98c01b148584af3428551765b9201d8e4fa9af391f42dc31bc02039423268af0"}, "id": "74735a98-659b-4424-b87e-dea6da1d016a", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_22: -------------------------------------------------------------------------------- 1 | {"address": "d4f83d1d238484917783c9ff1df8053c8e54deaa", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "8a5f3485c451e09d415e4d092682d0a4"}, "ciphertext": "9eec533bf642f67a97c092d66d7c35141b819bf9a3874c36be57477931da515a", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "28c3cd957174451d62c4d2fd1d07b886"}, "mac": "a37fef3c0bfaba615461cfd2290fc88cb7689bf9dd87c934acbb11239c20c1df"}, "id": "51230414-8983-4952-b960-d59906a1eb50", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_23: -------------------------------------------------------------------------------- 1 | {"address": "46b94da67eb2f22334349d2182e95a6fd6e118fb", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "fa9aca1b7143e0acabd4687b0bde1516"}, "ciphertext": "2f489e1244a5abdc9ac77f4cd5f920708b9220fcc43400921016a89caf748cd5", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "bb2da7324d0ff243d0926af2a3b51c1e"}, "mac": "ef892391fe36ca559b2b16a15c799209e2a2d28c70609520fe94dee967646363"}, "id": "b0e4336d-bcf7-4ca1-92ee-f5115c3de437", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_24: -------------------------------------------------------------------------------- 1 | {"address": "dc12e64a08effd4710f48a81b5c248f9b2980e96", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "350ccc1d31c3c6dd906e52387c7a678c"}, "ciphertext": "004769de3c5b773bd3c9be9e6a1610b0bbc1942df4e52793699146e38e7f6b44", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "435924790e80d676d37f1c2672bc21ea"}, "mac": "a4456840dda85dfcd16b769897db02fd090ad59f17c2d3ed44caac62dfcb0d9b"}, "id": "28ca7ca3-7c25-4336-a0d1-58d3647d9282", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_25: -------------------------------------------------------------------------------- 1 | {"address": "885ab3a6cf9f3ccd71a834d5be2eabd08b089e00", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "51c7a100a8099b556ff09e6a719389da"}, "ciphertext": "9fe741f0d0366e408c910a427e0faa22ba2b62c927f71830cde85f8c9619d3bf", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "31736b768bd41ac8a6dcd8f8c5829b12"}, "mac": "e5e8d8528924871d5f52b052b9b4b493f0d17158e68de5eb482dfba0b3dfc5c5"}, "id": "fe6f0e45-bb6f-4019-9853-2f8622447072", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_26: -------------------------------------------------------------------------------- 1 | {"address": "f074cdc02c23fc809d060ec67e52a562d7175338", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "466506dfd1d124acb53526093483fb18"}, "ciphertext": "8af01d180e15b1a126108d6c899620fa9e506c65d165aef28b2f942537fd3bf4", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "3d43003c84cdd7c8cf0161b9ab3a560c"}, "mac": "5a64a39b373485f60941e2956e606c3318686f1869e771675f7b657d01167805"}, "id": "dfaba70d-18b1-48a4-afd2-2ace148bfe75", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_27: -------------------------------------------------------------------------------- 1 | {"address": "2a3c46042c29f727caceb3dc757c9afdf3b2ad27", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "074cd4703a8a4d7f541fb72991d6fbfe"}, "ciphertext": "4b69c51db67309b3055ce7d6ebc6cdb8565f8345b7aee3ef4165fccef317971f", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "b56712e9cc62c7e3233d437b88ababd4"}, "mac": "196e47c287420c3336b242e3fd1861717f2cabb4e010f9abd571ef9323d7c4ad"}, "id": "69dee11c-dd0d-4fff-88f2-beec9cbdd25b", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_28: -------------------------------------------------------------------------------- 1 | {"address": "721dbce1169dca20838a7892e2620b377b263714", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "e8020fa01cfc9ccc9807b2ff70f15327"}, "ciphertext": "78a9c4ec599eb619b961a2e9d5b7f3c3bba997ad0d35bf5304b7567829a79010", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "77732f1f9795f0922658c977c86f044b"}, "mac": "9f94c7f8d2d1528bccd5d0bf0aa3b046b14518d49574b67c1db05fdc71296e6a"}, "id": "c39a04bc-e067-4ee4-a127-43d7b036c665", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_29: -------------------------------------------------------------------------------- 1 | {"address": "eddb19a2dd68bddf353b1a8f43be14a90e5af404", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "ba6c3f9e47233efa1d898700c9ff2c2d"}, "ciphertext": "ad36bae7657cf89622f72245835c3f6a7edad67e2fcd4c65482f4c1fe2f5b502", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "6aac8af2584674f1a3acf3d1d1a03017"}, "mac": "0b65802345e06df15a874fa22cf9aa4663d60fe7393d2a94e1c36b54e0473979"}, "id": "3158066a-98dc-440a-b34a-68986351457c", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_3: -------------------------------------------------------------------------------- 1 | {"address": "df2446a213e5402add0852da24561afb1469db28", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "ffd9622b387c3cfc1c58660bbb276e8b"}, "ciphertext": "50a9d48993f3202535209201eed7873561457a3a318e0ae04424915870fcb8be", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "6029c31aafa27db4091a696c5e420349"}, "mac": "e66bc994b8459f3a2a365a58333db14c554ee4841404d218d60aa9b44204cb0a"}, "id": "f1536711-d007-4f72-97b0-f44a85754593", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_30: -------------------------------------------------------------------------------- 1 | {"address": "a08cd9093c941cd7af63391f0695f8ba400198fa", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "837cc2b04be7832bc8e7c84cc6612624"}, "ciphertext": "aec8305943f4d7137a3f01f0ef777d034235b1ff671b61364bb55e1164a2df2d", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "9921f458895f9062974fa8781b2d2625"}, "mac": "2726b6947d51ba6d6ca40d0a92fe3052730dd825c96cc05114da90aa700fa9a6"}, "id": "ed70ebf0-bbee-4d45-92b0-8c813d63a639", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_31: -------------------------------------------------------------------------------- 1 | {"address": "6d77462d3a19361e3c0ec4fb19454f6fb74f2747", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "ebb654dd483237a1870d71cbd6097683"}, "ciphertext": "1645bc96b44a2e9e1d21e7fa5a3ab1bbfc8f375a8b1a763dc005bf6d5c98a535", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "70b478512cc498489756845121686470"}, "mac": "4bf68511126a27cc3de07b36a89fc5cc9aa47319a922e0afd1774cafbb3cdf8f"}, "id": "cadae1e5-9c59-42f1-8e19-ba9792cb4ed1", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_32: -------------------------------------------------------------------------------- 1 | {"address": "05a96928fc02faa83f14eb72b59c914aa3d1e35c", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "9c873fc6b10828cd1caccf3c5f77f8ea"}, "ciphertext": "4fe5f9f271184530e9d84788b0af958b76dd35218d8189376d9b346243e2b546", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "58f77dc1bb99d78d05d3465fe916da49"}, "mac": "01981a1bf293c15f8c0e5d05da00a222f00e54b6cbe1e9bb4091c7ad53320eb9"}, "id": "3ff1ba9f-51b7-416d-ac1f-bca1579afa0f", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_33: -------------------------------------------------------------------------------- 1 | {"address": "7b70ec7dce01690a3e5c0ac63096a12d984ba14a", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "6d70329ff1a968098d24dd31be024d64"}, "ciphertext": "b03d89c9aa49d91fd6fb01fdfb3b7c95ed7a90bc0cb99f3ab38859485f129a38", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "3aaafe70e88f61e5c866ada7114c5dbf"}, "mac": "15ee54b23a40b03a3a1460dd4c277ebc3377965c4ee822d526fd6fb728843daf"}, "id": "53d1e6cd-a82e-4083-9404-e7226110c789", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_34: -------------------------------------------------------------------------------- 1 | {"address": "71b01722c5a87274cb8b90d66bf427dae46660b6", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "7f2061883ff209079adc3bd4d16c6b30"}, "ciphertext": "aab5b621b5dab0e3bc6507966d31e88b3e0c73502bb1588c9f7192a17961fe40", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "fd2d3088e70d9939faf416ca86eb58b3"}, "mac": "9afa286705afa08998ae089ecd9ea26eded3ab312bbce514ccd3ce59ed0a1e98"}, "id": "f38cabdb-e44a-409a-9189-a8b5223bb440", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_4: -------------------------------------------------------------------------------- 1 | {"address": "01034fe77ff8d466426ed8428b71c0bb0d35adeb", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "97bf9072fed2ff9970e848177e16b9fd"}, "ciphertext": "8cf398e9e49ce0c71ed0b3d50fc92a4216da1ae007a8673ecba8babb87659597", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "df3654a5ddfd73d85b1f7a24cc181b07"}, "mac": "b77bf445f1507c5bc0979eb0fd4ba4bf0fd8e630acb0c93e29f8a16c824898b1"}, "id": "13d2ae15-4f24-4521-8558-5f0be9731bdf", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_5: -------------------------------------------------------------------------------- 1 | {"address": "e505161ad3e805fbd17cb34b672c350d0ac71439", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "9874e73a8000fe5a3d3a92f0bf2028a8"}, "ciphertext": "926c3d4662824d0916783a67dc61a4d0aeb97a038567f98d8473292b05fd784a", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "9f7050b03f7ee71fabee4b702b0705ea"}, "mac": "48d8a8536e99623047e3024e2d72d89fed4a7872b8829256365ce83687433222"}, "id": "b0620bad-aab1-4ef1-9f5a-a408dfea2dd0", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_6: -------------------------------------------------------------------------------- 1 | {"address": "bb3f9d7d88231533a2373cfdfc2e574556aed597", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "38b4067f3fdaed5d47197c53bbd361c9"}, "ciphertext": "19a2f2a2375aa3db5ddb5e65c7cecbfea012c27e67de9f5fe924306074c3dab4", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "f740c5764e7f80d37f75d6c2e8bfbf8c"}, "mac": "6054a21209d64ee4fcad364c5aec3e1c7d4fb152664b9c940e3934ab6d79b6c5"}, "id": "a89c8ec9-6e67-4e3a-9e0f-051cdc06b5c5", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_7: -------------------------------------------------------------------------------- 1 | {"address": "6e895e602059c6655b6def4a62483940a1cb221a", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "eb0cf3d4a3435c491b409127a0dcadd8"}, "ciphertext": "6c60e9ff75a4e3356ac0a2bc0e063912b734317cd4569ff893d45bb26ffadc44", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "f1b0183eb54a9d47156289a8f8dd7299"}, "mac": "78e5f74e6cc1e1f30193a5705ad2214ed589badff6d5cca523d5211a08c91039"}, "id": "fa6c9fb6-864f-475a-b0d3-9bd4f928112b", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_8: -------------------------------------------------------------------------------- 1 | {"address": "ce37a69da0fde7158652c5a19b70b1cef8097cdf", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "7c33724c7aaf3085b48b92057ab850a0"}, "ciphertext": "8f05a80876647a2dc6689648bfeb6a6a19f3001f1d837cd46a906d1937d82594", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "0664ab26302e3a89227228c2e504b3e9"}, "mac": "c6b4d3e9598070a824969abb852d44940cc829c8c6a231013c8874af26f705f6"}, "id": "b100a676-7a5f-461d-bdb5-189eed8a05ab", "version": 3} -------------------------------------------------------------------------------- /old_tests/dev/keystore/instance_9: -------------------------------------------------------------------------------- 1 | {"address": "d14b5c99078701937cd9c8bda6774358be31be4b", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "38a06e701053934b4c1edd852a2424ee"}, "ciphertext": "b8d639d115df5805f36cdd28a1e2465241b771f3e149e4562d8b67c6f6725166", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "ee6371f4d6cc63c72b061f7f6da460a0"}, "mac": "4eee9756e2bad096b31d3243e24d2ec810188bac320265abd93e5c326d4f0035"}, "id": "a26af69f-fde8-4bd3-857d-03a5e78beeb6", "version": 3} -------------------------------------------------------------------------------- /hp2p/tools/paragon/__init__.py: -------------------------------------------------------------------------------- 1 | from .commands import ( # noqa: F401 2 | BroadcastData, 3 | GetSum, 4 | Sum, 5 | ) 6 | from .proto import ( # noqa: F401 7 | ParagonProtocol, 8 | ) 9 | from .peer import ( # noqa: F401 10 | ParagonContext, 11 | ParagonPeer, 12 | ParagonPeerFactory, 13 | ParagonPeerPool, 14 | ) 15 | from .helpers import ( # noqa: F401 16 | get_directly_connected_streams, 17 | get_directly_linked_peers, 18 | get_directly_linked_peers_without_handshake, 19 | ) 20 | -------------------------------------------------------------------------------- /hvm/vm/forks/homestead/validation.py: -------------------------------------------------------------------------------- 1 | from hvm.constants import ( 2 | SECPK1_N, 3 | ) 4 | from hvm.exceptions import ( 5 | ValidationError, 6 | ) 7 | 8 | from hvm.vm.forks.frontier.validation import ( 9 | validate_frontier_transaction, 10 | ) 11 | 12 | 13 | def validate_homestead_transaction(account_db, transaction): 14 | if transaction.s > SECPK1_N // 2 or transaction.s == 0: 15 | raise ValidationError("Invalid signature S value") 16 | 17 | validate_frontier_transaction(account_db, transaction) 18 | -------------------------------------------------------------------------------- /hvm/vm/logic/invalid.py: -------------------------------------------------------------------------------- 1 | from hvm.exceptions import InvalidInstruction 2 | from hvm.vm.opcode import Opcode 3 | 4 | 5 | class InvalidOpcode(Opcode): 6 | mnemonic = "INVALID" 7 | gas_cost = 0 8 | 9 | def __init__(self, value): 10 | self.value = value 11 | super(InvalidOpcode, self).__init__() 12 | 13 | def __call__(self, computation): 14 | raise InvalidInstruction("Invalid opcode 0x{0:x} @ {1}".format( 15 | self.value, 16 | computation.code.pc - 1, 17 | )) 18 | -------------------------------------------------------------------------------- /old_tests/dev/keyBox.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class keyBox: 4 | def __init__(self): 5 | self.wallet_addresses = [] 6 | self.private_keys = [] 7 | 8 | #for testing 9 | self.private_keys.append(b'p.Oids\xedb\xa3\x93\xc5\xad\xb9\x8d\x92\x94\x00\x06\xb9\x82\xde\xb9\xbdBg\\\x82\xd4\x90W\xd0\xd5') 10 | self.private_keys.append(b'\x16\xc3\xb37\xb8\x8aG`\xdf\xad\xe3},\x9a\xb4~\xff7&?\xab\x80\x03\xf8\x9fo/:c\x18\xaa>') 11 | # test = keyBoxClass() 12 | # print(test.private_keys[b"\xdbL\xa4&\xd5;Y\xf6\x03p'O\xfb\x19\xf2&\x8d\xc3=\xdf"]) -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | * py-evm Version: x.x.x 2 | * OS: osx/linux/win 3 | * Python Version (python --version): 4 | * Environment (output of `pip freeze`): 5 | 6 | ### What is wrong? 7 | 8 | Please include information like: 9 | 10 | * full output of the error you received 11 | * what command you ran 12 | * the code that caused the failure (see [this link](https://help.github.com/articles/basic-writing-and-formatting-syntax/) for help with formatting code) 13 | 14 | 15 | ### How can it be fixed 16 | 17 | Fill this in if you know how to fix it. 18 | -------------------------------------------------------------------------------- /helios/utils/async_dispatch.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import functools 3 | from typing import ( 4 | Any, 5 | Awaitable, 6 | Callable 7 | ) 8 | 9 | 10 | def async_method(method_name: str) -> Callable[..., Any]: 11 | async def method(self: Any, *args: Any, **kwargs: Any) -> Awaitable[Any]: 12 | loop = asyncio.get_event_loop() 13 | 14 | func = getattr(self, method_name) 15 | pfunc = functools.partial(func, *args, **kwargs) 16 | 17 | return await loop.run_in_executor(None, pfunc) 18 | return method 19 | 20 | -------------------------------------------------------------------------------- /hvm/precompiles/sha256.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | 3 | from hvm import constants 4 | 5 | from hvm.utils.numeric import ( 6 | ceil32, 7 | ) 8 | 9 | 10 | def sha256(computation): 11 | word_count = ceil32(len(computation.msg.data)) // 32 12 | gas_fee = constants.GAS_SHA256 + word_count * constants.GAS_SHA256WORD 13 | 14 | computation.consume_gas(gas_fee, reason="SHA256 Precompile") 15 | input_bytes = computation.msg.data 16 | hash = hashlib.sha256(input_bytes).digest() 17 | computation.output = hash 18 | return computation 19 | -------------------------------------------------------------------------------- /helios/extensibility/__init__.py: -------------------------------------------------------------------------------- 1 | from helios.extensibility.events import ( # noqa: F401 2 | BaseEvent 3 | ) 4 | from helios.extensibility.plugin import ( # noqa: F401 5 | BaseAsyncStopPlugin, 6 | BaseMainProcessPlugin, 7 | BaseIsolatedPlugin, 8 | BasePlugin, 9 | BaseSyncStopPlugin, 10 | DebugPlugin, 11 | PluginContext, 12 | ) 13 | from helios.extensibility.plugin_manager import ( # noqa: F401 14 | BaseManagerProcessScope, 15 | MainAndIsolatedProcessScope, 16 | PluginManager, 17 | SharedProcessScope, 18 | ) 19 | -------------------------------------------------------------------------------- /stubs/eth_keys/validation.pyi: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | 3 | def validate_integer(value: int) -> None: ... 4 | def validate_bytes(value: bytes) -> None: ... 5 | def validate_gte(value: int, minimum: int) -> None: ... 6 | def validate_lte(value: int, maximum: int) -> None: ... 7 | 8 | validate_lt_secpk1n: Any 9 | 10 | def validate_message_hash(value: bytes) -> None: ... 11 | def validate_public_key_bytes(value: bytes) -> None: ... 12 | def validate_private_key_bytes(value: bytes) -> None: ... 13 | def validate_signature_bytes(value: bytes) -> None: ... 14 | -------------------------------------------------------------------------------- /hp2p/tools/paragon/commands.py: -------------------------------------------------------------------------------- 1 | from rlp_cython import sedes 2 | 3 | from hp2p.protocol import ( 4 | Command, 5 | ) 6 | 7 | 8 | class BroadcastData(Command): 9 | _cmd_id = 0 10 | structure = [ 11 | ('data', sedes.binary), 12 | ] 13 | 14 | 15 | class GetSum(Command): 16 | _cmd_id = 2 17 | structure = [ 18 | ('a', sedes.big_endian_int), 19 | ('b', sedes.big_endian_int), 20 | ] 21 | 22 | 23 | class Sum(Command): 24 | _cmd_id = 3 25 | structure = [ 26 | ('result', sedes.big_endian_int), 27 | ] 28 | -------------------------------------------------------------------------------- /hvm/tools/mining.py: -------------------------------------------------------------------------------- 1 | from hvm.consensus import pow 2 | 3 | 4 | class POWMiningMixin: 5 | """ 6 | A VM that does POW mining as well. Should be used only in tests, when we 7 | need to programatically populate a ChainDB. 8 | """ 9 | def finalize_block(self, block): 10 | block = super().finalize_block(block) # type: ignore 11 | nonce, mix_hash = pow.mine_pow_nonce( 12 | block.number, block.header.mining_hash, block.header.difficulty) 13 | return block.copy(header=block.header.copy(nonce=nonce, mix_hash=mix_hash)) 14 | -------------------------------------------------------------------------------- /hvm/utils/logging.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from logging import Logger 3 | from typing import Any 4 | 5 | TRACE_LEVEL_NUM = 5 6 | 7 | 8 | class TraceLogger(Logger): 9 | 10 | def init(self, name: str, level: int) -> None: 11 | Logger.__init__(self, name, level) 12 | 13 | def trace(self, message: str, *args: Any, **kwargs: Any) -> None: 14 | self.log(TRACE_LEVEL_NUM, message, *args, **kwargs) 15 | 16 | 17 | def setup_trace_logging() -> None: 18 | logging.setLoggerClass(TraceLogger) 19 | logging.addLevelName(TRACE_LEVEL_NUM, 'TRACE') 20 | -------------------------------------------------------------------------------- /hvm/__init__.py: -------------------------------------------------------------------------------- 1 | import pkg_resources 2 | import sys 3 | 4 | from hvm.utils.logging import ( 5 | setup_trace_logging 6 | ) 7 | 8 | # 9 | # Setup TRACE level logging. 10 | # 11 | # This needs to be done before the other imports 12 | setup_trace_logging() 13 | 14 | from hvm.chains import ( # noqa: F401 15 | Chain, 16 | MainnetChain, 17 | TestnetChain, 18 | ) 19 | 20 | # 21 | # Ensure we can reach 1024 frames of recursion 22 | # 23 | sys.setrecursionlimit(1024 * 10) 24 | 25 | 26 | __version__ = pkg_resources.get_distribution("py-helios-node").version 27 | -------------------------------------------------------------------------------- /hvm/vm/forks/homestead/state.py: -------------------------------------------------------------------------------- 1 | from hvm.vm.forks.frontier.state import ( 2 | FrontierState, 3 | FrontierTransactionExecutor, 4 | ) 5 | 6 | from .computation import HomesteadComputation 7 | from .validation import validate_homestead_transaction 8 | 9 | 10 | class HomesteadState(FrontierState): 11 | computation_class = HomesteadComputation 12 | 13 | def validate_transaction(self, transaction): 14 | validate_homestead_transaction(self.account_db, transaction) 15 | 16 | 17 | class HomesteadTransactionExecutor(FrontierTransactionExecutor): 18 | pass 19 | -------------------------------------------------------------------------------- /.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 0.2.0-alpha.18 3 | commit = True 4 | tag = True 5 | parse = (?P\d+)\.(?P\d+)\.(?P\d+)(-(?P[^.]*)\.(?P\d+))? 6 | serialize = 7 | {major}.{minor}.{patch}-{stage}.{devnum} 8 | {major}.{minor}.{patch} 9 | 10 | [bumpversion:part:stage] 11 | optional_value = stable 12 | first_value = stable 13 | values = 14 | alpha 15 | beta 16 | stable 17 | 18 | [bumpversion:part:devnum] 19 | 20 | [bumpversion:file:setup.py] 21 | search = version='{current_version}', 22 | replace = version='{new_version}', 23 | 24 | -------------------------------------------------------------------------------- /helios/helios_config_template.py: -------------------------------------------------------------------------------- 1 | #set this to the name of the keystore file containing the private key for this node. 2 | #Make sure that keystore file is in the keystore directory. That directory should be in the same location as this file. 3 | KEYSTORE_FILENAME_TO_USE = '' 4 | 5 | WEBSOCKET_USE_SSL = False 6 | # The absolute path to your PEM format certificate file. 7 | WEBSOCKET_SSL_CERT_FILE_PATH = '' 8 | # The absolute path to your certificate keyfile. 9 | WEBSOCKET_SSL_KEY_FILE_PATH = '' 10 | 11 | # When you are done configuring this file, save it as helios_config.py in this directory. -------------------------------------------------------------------------------- /hvm/vm/forks/homestead/blocks.py: -------------------------------------------------------------------------------- 1 | from rlp_cython.sedes import ( 2 | CountableList, 3 | ) 4 | from hvm.rlp.headers import ( 5 | BlockHeader, 6 | ) 7 | from hvm.vm.forks.frontier.blocks import ( 8 | FrontierBlock, 9 | ) 10 | from .transactions import ( 11 | HomesteadTransaction, 12 | ) 13 | 14 | 15 | class HomesteadBlock(FrontierBlock): 16 | transaction_class = HomesteadTransaction 17 | fields = [ 18 | ('header', BlockHeader), 19 | ('transactions', CountableList(transaction_class)), 20 | ('uncles', CountableList(BlockHeader)) 21 | ] 22 | -------------------------------------------------------------------------------- /helios/sync/common/constants.py: -------------------------------------------------------------------------------- 1 | UNKNOWN_SYNC_STAGE_ID = 0 2 | FAST_SYNC_STAGE_ID = 1 3 | CONSENSUS_MATCH_SYNC_STAGE_ID = 2 4 | ADDITIVE_SYNC_STAGE_ID = 3 5 | FULLY_SYNCED_STAGE_ID = 4 6 | 7 | CHRONOLOGICAL_BLOCK_HASH_FRAGMENT_TYPE_ID = 1 8 | CHAIN_HEAD_BLOCK_HASH_FRAGMENT_TYPE_ID = 2 9 | 10 | # Number of seconds that the syncer will remember which blocks have been imported to prevent it from requesting 11 | # the same blocks repeatedly. 12 | SYNCER_CACHE_TO_PREVENT_MULTIPLE_IMPORTS_OF_SAME_BLOCKS_EXPIRE_TIME = 10 13 | 14 | SYNCER_RECENTLY_IMPORTED_BLOCK_MEMORY_EXPIRE_CHECK_LOOP_PERIOD = 2 15 | -------------------------------------------------------------------------------- /stubs/eth_keys/backends/native/main.pyi: -------------------------------------------------------------------------------- 1 | from .ecdsa import ecdsa_raw_recover, ecdsa_raw_sign, private_key_to_public_key 2 | from eth_keys.backends.base import BaseECCBackend 3 | from eth_keys.datatypes import PrivateKey, PublicKey, Signature 4 | from typing import Optional 5 | 6 | class NativeECCBackend(BaseECCBackend): 7 | def ecdsa_sign(self, msg_hash: bytes, private_key: PrivateKey) -> Signature: ... 8 | def ecdsa_recover(self, msg_hash: bytes, signature: Signature) -> Optional[PublicKey]: ... 9 | def private_key_to_public_key(self, private_key: PrivateKey) -> PublicKey: ... 10 | -------------------------------------------------------------------------------- /helios/protocol/les/normalizers.py: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Any, 3 | Dict, 4 | Tuple, 5 | TypeVar, 6 | ) 7 | 8 | from hvm.rlp.headers import BlockHeader 9 | 10 | from helios.protocol.common.normalizers import BaseNormalizer 11 | 12 | TResult = TypeVar('TResult') 13 | LESNormalizer = BaseNormalizer[Dict[str, Any], TResult] 14 | 15 | 16 | class BlockHeadersNormalizer(LESNormalizer[Tuple[BlockHeader, ...]]): 17 | @staticmethod 18 | def normalize_result(message: Dict[str, Any]) -> Tuple[BlockHeader, ...]: 19 | result = message['headers'] 20 | return result 21 | -------------------------------------------------------------------------------- /hvm/vm/forks/spurious_dragon/blocks.py: -------------------------------------------------------------------------------- 1 | from rlp_cython.sedes import ( 2 | CountableList, 3 | ) 4 | from hvm.rlp.headers import ( 5 | BlockHeader, 6 | ) 7 | from hvm.vm.forks.homestead.blocks import ( 8 | HomesteadBlock, 9 | ) 10 | from .transactions import ( 11 | SpuriousDragonTransaction, 12 | ) 13 | 14 | 15 | class SpuriousDragonBlock(HomesteadBlock): 16 | transaction_class = SpuriousDragonTransaction 17 | fields = [ 18 | ('header', BlockHeader), 19 | ('transactions', CountableList(transaction_class)), 20 | ('uncles', CountableList(BlockHeader)) 21 | ] 22 | -------------------------------------------------------------------------------- /hvm/vm/forks/byzantium/blocks.py: -------------------------------------------------------------------------------- 1 | from rlp_cython.sedes import ( 2 | CountableList, 3 | ) 4 | from hvm.rlp.headers import ( 5 | BlockHeader, 6 | ) 7 | from hvm.vm.forks.spurious_dragon.blocks import ( 8 | SpuriousDragonBlock, 9 | ) 10 | 11 | from .transactions import ( 12 | ByzantiumTransaction, 13 | ) 14 | 15 | 16 | class ByzantiumBlock(SpuriousDragonBlock): 17 | transaction_class = ByzantiumTransaction 18 | fields = [ 19 | ('header', BlockHeader), 20 | ('transactions', CountableList(transaction_class)), 21 | ('uncles', CountableList(BlockHeader)) 22 | ] 23 | -------------------------------------------------------------------------------- /stubs/eth_keys/backends/native/jacobian.pyi: -------------------------------------------------------------------------------- 1 | from typing import Tuple 2 | 3 | def inv(a: int, n: int) -> int: ... 4 | def to_jacobian(p: Tuple[int, int]) -> Tuple[int, int, int]: ... 5 | def jacobian_double(p: Tuple[int, int, int]) -> Tuple[int, int, int]: ... 6 | def jacobian_add(p: Tuple[int, int, int], q: Tuple[int, int, int]) -> Tuple[int, int, int]: ... 7 | def from_jacobian(p: Tuple[int, int, int]) -> Tuple[int, int]: ... 8 | def jacobian_multiply(a: Tuple[int, int, int], n: int) -> Tuple[int, int, int]: ... 9 | def fast_multiply(a: Tuple[int, int], n: int) -> Tuple[int, int]: ... 10 | def fast_add(a, b): ... 11 | -------------------------------------------------------------------------------- /hvm/vm/forks/spurious_dragon/__init__.py: -------------------------------------------------------------------------------- 1 | from typing import Type # noqa: F401 2 | from hvm.rlp.blocks import BaseBlock # noqa: F401 3 | from hvm.vm.state import BaseState # noqa: F401 4 | 5 | from ..tangerine_whistle import TangerineWhistleVM 6 | 7 | from .blocks import SpuriousDragonBlock 8 | from .state import SpuriousDragonState 9 | 10 | 11 | class SpuriousDragonVM(TangerineWhistleVM): 12 | # fork name 13 | fork = 'spurious-dragon' # type: str 14 | 15 | # classes 16 | block_class = SpuriousDragonBlock # type: Type[BaseBlock] 17 | _state_class = SpuriousDragonState # type: Type[BaseState] 18 | -------------------------------------------------------------------------------- /stubs/eth_keys/backends/coincurve.pyi: -------------------------------------------------------------------------------- 1 | from .base import BaseECCBackend 2 | from eth_keys.datatypes import PrivateKey, PublicKey, Signature 3 | from typing import Any, Optional 4 | 5 | def is_coincurve_available() -> bool: ... 6 | 7 | class CoinCurveECCBackend(BaseECCBackend): 8 | keys: Any = ... 9 | ecdsa: Any = ... 10 | def __init__(self) -> None: ... 11 | def ecdsa_sign(self, msg_hash: bytes, private_key: PrivateKey) -> Signature: ... 12 | def ecdsa_recover(self, msg_hash: bytes, signature: Signature) -> Optional[PublicKey]: ... 13 | def private_key_to_public_key(self, private_key: PrivateKey) -> PublicKey: ... 14 | -------------------------------------------------------------------------------- /hvm/utils/profile.py: -------------------------------------------------------------------------------- 1 | 2 | import cProfile, pstats, io 3 | 4 | def profile(sortby='cumulative'): 5 | def profile_inner(fnc): 6 | """A decorator that uses cProfile to profile a function""" 7 | 8 | def inner(*args, **kwargs): 9 | pr = cProfile.Profile() 10 | pr.enable() 11 | retval = fnc(*args, **kwargs) 12 | pr.disable() 13 | s = io.StringIO() 14 | ps = pstats.Stats(pr, stream=s).sort_stats(sortby) 15 | ps.print_stats() 16 | print(s.getvalue()) 17 | return retval 18 | 19 | return inner 20 | return profile_inner -------------------------------------------------------------------------------- /helios/protocol/les/validators.py: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Any, 3 | Dict, 4 | ) 5 | 6 | from eth_utils import ( 7 | ValidationError, 8 | ) 9 | 10 | from helios.protocol.common.validators import ( 11 | BaseBlockHeadersValidator, 12 | ) 13 | from . import constants 14 | 15 | 16 | class GetBlockHeadersValidator(BaseBlockHeadersValidator): 17 | protocol_max_request_size = constants.MAX_HEADERS_FETCH 18 | 19 | 20 | def match_payload_request_id(request: Dict[str, Any], response: Dict[str, Any]) -> None: 21 | if request['request_id'] != response['request_id']: 22 | raise ValidationError("Request `id` does not match") 23 | -------------------------------------------------------------------------------- /old_tests/dev/test.py: -------------------------------------------------------------------------------- 1 | from hvm.utils.hexadecimal import pad_hex 2 | from eth_utils import remove_0x_prefix 3 | 4 | import itertools 5 | import time 6 | 7 | start = time.time() 8 | test = [] 9 | for i in range(1000): 10 | test.append(1) 11 | end_time = time.time() 12 | print("Took {}".format(end_time-start)) 13 | print(test) 14 | 15 | start = time.time() 16 | test = list(itertools.repeat(1,1000)) 17 | end_time = time.time() 18 | print("Took {}".format(end_time-start)) 19 | print(test) 20 | 21 | 22 | start = time.time() 23 | test = [1]*1000 24 | end_time = time.time() 25 | print("Took {}".format(end_time-start)) 26 | print(test) 27 | 28 | 29 | -------------------------------------------------------------------------------- /hvm/vm/forks/boson/computation.py: -------------------------------------------------------------------------------- 1 | 2 | from hvm.vm.forks.helios_testnet import HeliosTestnetComputation 3 | from hvm.vm.forks.helios_testnet.computation import HELIOS_TESTNET_PRECOMPILES 4 | 5 | from .opcodes import BOSON_OPCODES 6 | 7 | 8 | BOSON_PRECOMPILES = HELIOS_TESTNET_PRECOMPILES 9 | 10 | class BosonComputation(HeliosTestnetComputation): 11 | """ 12 | A class for all execution computations in the ``Byzantium`` fork. 13 | Inherits from :class:`~hvm.vm.forks.spurious_dragon.computation.SpuriousDragonComputation` 14 | """ 15 | # Override 16 | opcodes = BOSON_OPCODES 17 | _precompiles = BOSON_PRECOMPILES 18 | 19 | 20 | -------------------------------------------------------------------------------- /.circleci/merge_pr.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then 4 | PR_INFO_URL=https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/$CIRCLE_PR_NUMBER 5 | PR_BASE_BRANCH=$(curl -L "$PR_INFO_URL" | python -c 'import json, sys; obj = json.load(sys.stdin); sys.stdout.write(obj["base"]["ref"])') 6 | git fetch origin +"$PR_BASE_BRANCH":circleci/pr-base 7 | # We need these config values or git complains when creating the 8 | # merge commit 9 | git config --global user.name "Circle CI" 10 | git config --global user.email "circleci@example.com" 11 | git merge --no-edit circleci/pr-base 12 | fi 13 | -------------------------------------------------------------------------------- /hvm/vm/forks/homestead/opcodes.py: -------------------------------------------------------------------------------- 1 | import copy 2 | 3 | from cytoolz import merge 4 | 5 | from hvm import constants 6 | from hvm.vm import mnemonics 7 | from hvm.vm import opcode_values 8 | from hvm.vm.logic import ( 9 | call, 10 | ) 11 | 12 | from hvm.vm.forks.frontier.opcodes import FRONTIER_OPCODES 13 | 14 | 15 | NEW_OPCODES = { 16 | opcode_values.DELEGATECALL: call.DelegateCall.configure( 17 | __name__='opcode:DELEGATECALL', 18 | mnemonic=mnemonics.DELEGATECALL, 19 | gas_cost=constants.GAS_CALL, 20 | )(), 21 | } 22 | 23 | 24 | HOMESTEAD_OPCODES = merge( 25 | copy.deepcopy(FRONTIER_OPCODES), 26 | NEW_OPCODES 27 | ) 28 | -------------------------------------------------------------------------------- /helios/rpc/modules/web3.py: -------------------------------------------------------------------------------- 1 | from eth_hash.auto import keccak 2 | from eth_utils import decode_hex, encode_hex 3 | 4 | from helios.utils.version import construct_helios_client_identifier 5 | 6 | from helios.rpc.modules import ( 7 | RPCModule, 8 | ) 9 | 10 | 11 | class Web3(RPCModule): 12 | async def clientVersion(self) -> str: 13 | """ 14 | Returns the current client version. 15 | """ 16 | return construct_helios_client_identifier() 17 | 18 | async def sha3(self, data: str) -> str: 19 | """ 20 | Returns Keccak-256 of the given data. 21 | """ 22 | return encode_hex(keccak(decode_hex(data))) 23 | -------------------------------------------------------------------------------- /hvm/utils/hexadecimal.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | 3 | import codecs 4 | 5 | from eth_utils import remove_0x_prefix 6 | 7 | def encode_hex(value): 8 | return '0x' + codecs.decode(codecs.encode(value, 'hex'), 'utf8') 9 | 10 | 11 | def decode_hex(value): 12 | _, _, hex_part = value.rpartition('x') 13 | return codecs.decode(hex_part, 'hex') 14 | 15 | def pad_hex(value, length_in_bytes): 16 | prefix_removed_value = remove_0x_prefix(value) 17 | num_pad_required = length_in_bytes * 2 - len(prefix_removed_value) 18 | padding = '0' * num_pad_required 19 | result = '0x' + padding + prefix_removed_value 20 | return result 21 | -------------------------------------------------------------------------------- /helios/utils/timer.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | 4 | class Timer: 5 | _start: float = None 6 | 7 | def __init__(self, auto_start: bool = True) -> None: 8 | if auto_start: 9 | self.start() 10 | 11 | def start(self) -> None: 12 | self._start = time.perf_counter() 13 | 14 | def pop_elapsed(self) -> float: 15 | """Return time elapsed since last start, and start the timer over""" 16 | now = time.perf_counter() 17 | elapsed = now - self._start 18 | self._start = now 19 | return elapsed 20 | 21 | @property 22 | def elapsed(self) -> float: 23 | return time.perf_counter() - self._start 24 | -------------------------------------------------------------------------------- /tests/hvm/padding.py: -------------------------------------------------------------------------------- 1 | from hvm.utils.padding import propogate_timestamp_item_list_to_present 2 | 3 | 4 | def test_propogate_timestamp_item_list_to_present_1(): 5 | test_data = [[100,1], [200,1],[300,1],[400,1],[500,2]] 6 | 7 | fixed_data = propogate_timestamp_item_list_to_present(test_data, 100, 900) 8 | 9 | print(fixed_data) 10 | 11 | # test_propogate_timestamp_item_list_to_present_1() 12 | 13 | 14 | def test_propogate_timestamp_item_list_to_present_2(): 15 | test_data = [[100,1]] 16 | 17 | fixed_data = propogate_timestamp_item_list_to_present(test_data, 100, 900) 18 | 19 | print(fixed_data) 20 | 21 | # test_propogate_timestamp_item_list_to_present_2() -------------------------------------------------------------------------------- /hvm/vm/logic/sha3.py: -------------------------------------------------------------------------------- 1 | from eth_hash.auto import keccak 2 | 3 | from hvm import constants 4 | from hvm.utils.numeric import ( 5 | ceil32, 6 | ) 7 | 8 | 9 | def sha3(computation): 10 | start_position, size = computation.stack_pop(num_items=2, type_hint=constants.UINT256) 11 | 12 | computation.extend_memory(start_position, size) 13 | 14 | sha3_bytes = computation.memory_read(start_position, size) 15 | word_count = ceil32(len(sha3_bytes)) // 32 16 | 17 | gas_cost = constants.GAS_SHA3WORD * word_count 18 | computation.consume_gas(gas_cost, reason="SHA3: word gas cost") 19 | 20 | result = keccak(sha3_bytes) 21 | 22 | computation.stack_push(result) 23 | -------------------------------------------------------------------------------- /stubs/eth_keys/backends/base.pyi: -------------------------------------------------------------------------------- 1 | from eth_keys import datatypes 2 | from typing import Any 3 | 4 | class BaseECCBackend: 5 | PublicKey: Any = ... 6 | PrivateKey: Any = ... 7 | Signature: Any = ... 8 | def __init__(self) -> None: ... 9 | def ecdsa_sign(self, msg_hash: bytes, private_key: PrivateKey) -> datatypes.Signature: ... 10 | def ecdsa_verify(self, msg_hash: bytes, signature: datatypes.Signature, public_key: datatypes.PublicKey) -> bool: ... 11 | def ecdsa_recover(self, msg_hash: bytes, signature: datatypes.Signature) -> datatypes.PublicKey: ... 12 | def private_key_to_public_key(self, private_key: datatypes.PrivateKey) -> datatypes.PublicKey: ... 13 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = py-evm 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /hvm/tools/fixtures/__init__.py: -------------------------------------------------------------------------------- 1 | from .loading import ( # noqa: F401 2 | find_fixtures, 3 | filter_fixtures, 4 | load_fixture, 5 | ) 6 | from .generation import ( # noqa: F401 7 | generate_fixture_tests, 8 | ) 9 | from .helpers import ( # noqa: F401 10 | new_chain_from_fixture, 11 | genesis_params_from_fixture, 12 | apply_fixture_block_to_chain, 13 | setup_account_db, 14 | should_run_slow_tests, 15 | verify_account_db, 16 | ) 17 | from .normalization import ( # noqa: F401 18 | normalize_block, 19 | normalize_blockchain_fixtures, 20 | normalize_statetest_fixture, 21 | normalize_transactiontest_fixture, 22 | normalize_vmtest_fixture, 23 | ) 24 | -------------------------------------------------------------------------------- /hvm/precompiles/ripemd160.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | 3 | from hvm import constants 4 | 5 | from hvm.utils.numeric import ( 6 | ceil32, 7 | ) 8 | from hvm.utils.padding import ( 9 | pad32, 10 | ) 11 | 12 | 13 | def ripemd160(computation): 14 | word_count = ceil32(len(computation.msg.data)) // 32 15 | gas_fee = constants.GAS_RIPEMD160 + word_count * constants.GAS_RIPEMD160WORD 16 | 17 | computation.consume_gas(gas_fee, reason="RIPEMD160 Precompile") 18 | 19 | # TODO: this only works if openssl is installed. 20 | hash = hashlib.new('ripemd160', computation.msg.data).digest() 21 | padded_hash = pad32(hash) 22 | computation.output = padded_hash 23 | return computation 24 | -------------------------------------------------------------------------------- /hvm/vm/execution_context.py: -------------------------------------------------------------------------------- 1 | class ExecutionContext: 2 | _timestamp = None 3 | _number = None 4 | _gas_limit = None 5 | _prev_hashes = None 6 | 7 | def __init__( 8 | self, 9 | timestamp, 10 | block_number, 11 | gas_limit): 12 | self._timestamp = timestamp 13 | self._block_number = block_number 14 | self._gas_limit = gas_limit 15 | 16 | 17 | @property 18 | def timestamp(self): 19 | return self._timestamp 20 | 21 | @property 22 | def block_number(self): 23 | return self._block_number 24 | 25 | @property 26 | def gas_limit(self): 27 | return self._gas_limit 28 | 29 | -------------------------------------------------------------------------------- /old_tests/core/padding-utils/test_padding.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from hvm.utils.padding import ( 4 | pad32, 5 | pad32r 6 | ) 7 | 8 | padding_byte = b"\x00" 9 | 10 | 11 | @pytest.mark.parametrize( 12 | "value, expected", 13 | ( 14 | (b"", padding_byte * 32), 15 | (b"\x01", (padding_byte * 31) + b"\x01") 16 | ) 17 | ) 18 | def test_pad_32(value, expected): 19 | assert pad32(value) == expected 20 | 21 | 22 | @pytest.mark.parametrize( 23 | "value, expected", 24 | ( 25 | (b"", padding_byte * 32), 26 | (b"\x01", b"\x01" + (padding_byte * 31)) 27 | ) 28 | ) 29 | def test_pad_32r(value, expected): 30 | assert pad32r(value) == expected 31 | -------------------------------------------------------------------------------- /old_tests/helios/core/chain-management/test_light_peer_chain.py: -------------------------------------------------------------------------------- 1 | from helios.sync.light.service import ( 2 | LightPeerChain 3 | ) 4 | from helios.plugins.builtin.light_peer_chain_bridge import ( 5 | EventBusLightPeerChain, 6 | ) 7 | 8 | 9 | # These tests may seem obvious but they safe us from runtime errors where 10 | # changes are made to the `BaseLightPeerChain` that are then forgotton to 11 | # implement on both derived chains. 12 | 13 | def test_can_instantiate_eventbus_light_peer_chain(): 14 | chain = EventBusLightPeerChain(None) 15 | assert chain is not None 16 | 17 | 18 | def test_can_instantiate_light_peer_chain(): 19 | chain = LightPeerChain(None, None) 20 | assert chain is not None 21 | -------------------------------------------------------------------------------- /hvm/tools/rlp.py: -------------------------------------------------------------------------------- 1 | from eth_utils import ( 2 | replace_exceptions, 3 | ValidationError, 4 | ) 5 | 6 | from hvm.utils.rlp import ( 7 | validate_rlp_equal, 8 | ) 9 | 10 | 11 | assert_imported_genesis_header_unchanged = replace_exceptions({ 12 | ValidationError: AssertionError, 13 | })(validate_rlp_equal(obj_a_name='genesis header', obj_b_name='imported header')) 14 | 15 | 16 | assert_mined_block_unchanged = replace_exceptions({ 17 | ValidationError: AssertionError, 18 | })(validate_rlp_equal(obj_a_name='block', obj_b_name='mined block')) 19 | 20 | 21 | assert_headers_eq = replace_exceptions({ 22 | ValidationError: AssertionError, 23 | })(validate_rlp_equal(obj_a_name='expected', obj_b_name='actual')) 24 | -------------------------------------------------------------------------------- /hvm/rlp/logs.py: -------------------------------------------------------------------------------- 1 | import rlp_cython as rlp 2 | from rlp_cython.sedes import ( 3 | CountableList, 4 | binary, 5 | ) 6 | 7 | from .sedes import ( 8 | address, 9 | int32, 10 | ) 11 | 12 | 13 | class Log(rlp.Serializable): 14 | fields = [ 15 | ('address', address), 16 | ('topics', CountableList(int32)), 17 | ('data', binary) 18 | ] 19 | 20 | def __init__(self, address: bytes, topics: bytes, data: bytes) -> None: 21 | super(Log, self).__init__(address, topics, data) 22 | 23 | @property 24 | def bloomables(self): 25 | return ( 26 | self.address, 27 | ) + tuple( 28 | int32.serialize(topic) for topic in self.topics 29 | ) 30 | -------------------------------------------------------------------------------- /hvm/vm/forks/boson/constants.py: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Gas Costs and Refunds 4 | # 5 | REFUND_SELFDESTRUCT = 24000 6 | GAS_CODEDEPOSIT = 200 7 | 8 | 9 | EIP658_TRANSACTION_STATUS_CODE_FAILURE = b'' 10 | EIP658_TRANSACTION_STATUS_CODE_SUCCESS = b'\x01' 11 | 12 | # 13 | # Gas Costs and Refunds 14 | # 15 | GAS_CODEDEPOSIT = 200 16 | 17 | 18 | # https://github.com/ethereum/EIPs/issues/160 19 | GAS_EXP_EIP160 = 10 20 | GAS_EXPBYTE_EIP160 = 50 21 | 22 | 23 | # https://github.com/ethereum/EIPs/issues/170 24 | EIP170_CODE_SIZE_LIMIT = 24577 25 | 26 | # 27 | # Gas Costs and Refunds 28 | # 29 | GAS_SELFDESTRUCT_EIP150 = 5000 30 | GAS_CALL_EIP150 = 700 31 | GAS_EXTCODE_EIP150 = 700 32 | GAS_BALANCE_EIP150 = 400 33 | GAS_SLOAD_EIP150 = 200 34 | 35 | MIN_TIME_BETWEEN_BLOCKS = 10 #seconds -------------------------------------------------------------------------------- /hvm/vm/forks/helios_testnet/constants.py: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Gas Costs and Refunds 4 | # 5 | REFUND_SELFDESTRUCT = 24000 6 | GAS_CODEDEPOSIT = 200 7 | 8 | 9 | EIP658_TRANSACTION_STATUS_CODE_FAILURE = b'' 10 | EIP658_TRANSACTION_STATUS_CODE_SUCCESS = b'\x01' 11 | 12 | # 13 | # Gas Costs and Refunds 14 | # 15 | GAS_CODEDEPOSIT = 200 16 | 17 | 18 | # https://github.com/ethereum/EIPs/issues/160 19 | GAS_EXP_EIP160 = 10 20 | GAS_EXPBYTE_EIP160 = 50 21 | 22 | 23 | # https://github.com/ethereum/EIPs/issues/170 24 | EIP170_CODE_SIZE_LIMIT = 24577 25 | 26 | # 27 | # Gas Costs and Refunds 28 | # 29 | GAS_SELFDESTRUCT_EIP150 = 5000 30 | GAS_CALL_EIP150 = 700 31 | GAS_EXTCODE_EIP150 = 700 32 | GAS_BALANCE_EIP150 = 400 33 | GAS_SLOAD_EIP150 = 200 34 | 35 | 36 | MIN_TIME_BETWEEN_BLOCKS = 0 #seconds -------------------------------------------------------------------------------- /hp2p/tools/factories/keys.py: -------------------------------------------------------------------------------- 1 | import secrets 2 | 3 | import factory 4 | 5 | from eth_utils import ( 6 | int_to_big_endian, 7 | ) 8 | 9 | from eth_keys import keys 10 | 11 | 12 | def _mk_private_key_bytes() -> bytes: 13 | return int_to_big_endian(secrets.randbits(256)).rjust(32, b'\x00') 14 | 15 | 16 | class PrivateKeyFactory(factory.Factory): 17 | class Meta: 18 | model = keys.PrivateKey 19 | 20 | private_key_bytes = factory.LazyFunction(_mk_private_key_bytes) 21 | 22 | 23 | def _mk_public_key_bytes() -> bytes: 24 | return PrivateKeyFactory().public_key.to_bytes() 25 | 26 | 27 | class PublicKeyFactory(factory.Factory): 28 | class Meta: 29 | model = keys.PublicKey 30 | 31 | public_key_bytes = factory.LazyFunction(_mk_public_key_bytes) 32 | -------------------------------------------------------------------------------- /old_tests/core/numeric-utils/test_int_to_bytes32.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from hvm.constants import ( 4 | NULL_BYTE, 5 | UINT_256_MAX, 6 | ) 7 | 8 | from hvm.utils.numeric import ( 9 | int_to_bytes32, 10 | ) 11 | 12 | 13 | @pytest.mark.parametrize( 14 | 'value, expected', 15 | ( 16 | (0, NULL_BYTE * 32), 17 | (1, NULL_BYTE * 31 + b'\x01'), 18 | (UINT_256_MAX, b'\xff' * 32), 19 | ) 20 | ) 21 | def test_int_to_bytes32_valid(value, expected): 22 | assert int_to_bytes32(value) == expected 23 | 24 | 25 | @pytest.mark.parametrize( 26 | 'value', 27 | ( 28 | -1, 29 | UINT_256_MAX + 1, 30 | ) 31 | ) 32 | def test_int_to_bytes32_invalid(value): 33 | with pytest.raises(ValueError): 34 | int_to_bytes32(value) 35 | -------------------------------------------------------------------------------- /helios/README.md: -------------------------------------------------------------------------------- 1 | # Release Process 2 | 3 | 1. Populate `docs/release_notes/helios.rst` 4 | 2. Release `py-evm` 5 | 3. Bump py-evm dependency version in `setup_helios.py` 6 | 4. Manual bump of helios version in `setup_helios.py` 7 | 5. Release `helios` 8 | 6. Tag helios release 9 | 10 | 11 | ## Environment Configuration 12 | 13 | - `HELIOS_MP_CONTEXT` - The context that new processes will be spawned from the python `multiprocessing` library. 14 | - `XDG_HELIOS_ROOT` - Base directory where helios stores data 15 | - `HELIOS_DATA_DIR` - The root directory where the chain data will be stored for the currently running chain. 16 | - `HELIOS_NODEKEY` - The path to a file where the devp2p private key is stored. 17 | - `HELIOS_DATABASE_IPC` - The path to the socket which connects to the database manager. 18 | -------------------------------------------------------------------------------- /hvm/vm/forks/boson/opcodes.py: -------------------------------------------------------------------------------- 1 | import copy 2 | import functools 3 | 4 | from cytoolz import merge 5 | 6 | from hvm.exceptions import ( 7 | WriteProtection, 8 | ) 9 | 10 | def ensure_no_static(opcode_fn): 11 | @functools.wraps(opcode_fn) 12 | def inner(computation): 13 | if computation.msg.is_static: 14 | raise WriteProtection("Cannot modify state while inside of a STATICCALL context") 15 | return opcode_fn(computation) 16 | return inner 17 | 18 | from hvm.vm.forks.helios_testnet.opcodes import HELIOS_TESTNET_OPCODES 19 | 20 | 21 | BOSON_UPDATED_OPCODES = { 22 | 23 | # 24 | # Call 25 | # 26 | 27 | } 28 | 29 | BOSON_OPCODES = merge( 30 | copy.deepcopy(HELIOS_TESTNET_OPCODES), 31 | BOSON_UPDATED_OPCODES, 32 | ) 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /hvm/db/backends/memory.py: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Dict 3 | ) 4 | 5 | from .base import ( 6 | BaseDB, 7 | ) 8 | 9 | 10 | class MemoryDB(BaseDB): 11 | kv_store = None # type: Dict[bytes, bytes] 12 | 13 | def __init__(self, kv_store: Dict[bytes, bytes] = None) -> None: 14 | if kv_store is None: 15 | self.kv_store = {} 16 | else: 17 | self.kv_store = kv_store 18 | 19 | def __getitem__(self, key: bytes) -> bytes: 20 | return self.kv_store[key] 21 | 22 | def __setitem__(self, key: bytes, value: bytes) -> None: 23 | self.kv_store[key] = value 24 | 25 | def _exists(self, key: bytes) -> bool: 26 | return key in self.kv_store 27 | 28 | def __delitem__(self, key: bytes) -> None: 29 | del self.kv_store[key] 30 | -------------------------------------------------------------------------------- /helios/rpc/modules/admin.py: -------------------------------------------------------------------------------- 1 | 2 | from helios.rpc.modules import ( # type: ignore 3 | RPCModule, 4 | ) 5 | from helios.utils.verification import verify_rpc_admin_password 6 | 7 | from hvm.exceptions import ValidationError 8 | class Admin(RPCModule): 9 | 10 | 11 | async def stopRPC(self, password: str): 12 | if not verify_rpc_admin_password(password, self._rpc_context.admin_rpc_password_config_path): 13 | raise ValidationError("Incorrect password.") 14 | 15 | self._rpc_context.halt_rpc.set() 16 | 17 | async def startRPC(self, password: str): 18 | if not verify_rpc_admin_password(password, self._rpc_context.admin_rpc_password_config_path): 19 | raise ValidationError("Incorrect password.") 20 | 21 | self._rpc_context.halt_rpc.clear() 22 | 23 | -------------------------------------------------------------------------------- /hvm/utils/bn128.py: -------------------------------------------------------------------------------- 1 | from py_ecc import ( 2 | optimized_bn128 as bn128, 3 | ) 4 | 5 | from hvm.exceptions import ( 6 | ValidationError, 7 | ) 8 | 9 | from typing import Tuple 10 | 11 | 12 | def validate_point(x: int, y: int) -> Tuple[bn128.FQ, bn128.FQ, bn128.FQ]: 13 | FQ = bn128.FQ 14 | 15 | if x >= bn128.field_modulus: 16 | raise ValidationError("Point x value is greater than field modulus") 17 | elif y >= bn128.field_modulus: 18 | raise ValidationError("Point y value is greater than field modulus") 19 | 20 | if (x, y) != (0, 0): 21 | p1 = (FQ(x), FQ(y), FQ(1)) 22 | if not bn128.is_on_curve(p1, bn128.b): 23 | raise ValidationError("Point is not on the curve") 24 | else: 25 | p1 = (FQ(1), FQ(1), FQ(0)) 26 | 27 | return p1 28 | -------------------------------------------------------------------------------- /helios/rpc/modules/net.py: -------------------------------------------------------------------------------- 1 | from hp2p.events import ( 2 | PeerCountRequest 3 | ) 4 | from helios.rpc.modules import ( 5 | RPCModule, 6 | ) 7 | 8 | 9 | class Net(RPCModule): 10 | async def version(self) -> str: 11 | """ 12 | Returns the current network ID. 13 | """ 14 | return str(self._chain.network_id) 15 | 16 | async def peerCount(self) -> str: 17 | """ 18 | Return the number of peers that are currently connected to the node 19 | """ 20 | response = await self._event_bus.request(PeerCountRequest()) 21 | return hex(response.peer_count) 22 | 23 | async def listening(self) -> bool: 24 | """ 25 | Return `True` if the client is actively listening for network connections 26 | """ 27 | return True 28 | -------------------------------------------------------------------------------- /helios/utils/async_iter.py: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | AsyncIterable, 3 | Set, 4 | ) 5 | 6 | 7 | async def contains_all(async_gen: AsyncIterable[str], keywords: Set[str]) -> bool: 8 | """ 9 | Check wether an ``AsyncIterable[str]`` contains all of the given keywords. The keywords 10 | can be embedded in some larger string. Return ``True`` as soon as all keywords were matched. 11 | If not all keywords were matched by the time that the async iterable is done, return ``False``. 12 | """ 13 | seen_keywords: Set[str] = set() 14 | async for line in async_gen: 15 | for check in keywords - seen_keywords: 16 | if check in line: 17 | seen_keywords.add(check) 18 | if seen_keywords == keywords: 19 | return True 20 | 21 | return False 22 | 23 | 24 | -------------------------------------------------------------------------------- /stubs/eth_keys/backends/native/ecdsa.pyi: -------------------------------------------------------------------------------- 1 | from .jacobian import fast_add, fast_multiply, from_jacobian, inv, jacobian_add, jacobian_multiply 2 | from typing import Any, Callable, Optional, Tuple 3 | 4 | def decode_public_key(public_key_bytes): ... 5 | def encode_raw_public_key(raw_public_key: Tuple[int, int]) -> bytes: ... 6 | def private_key_to_public_key(private_key_bytes: bytes) -> bytes: ... 7 | def deterministic_generate_k(msg_hash: bytes, private_key_bytes: bytes, digest_fn: Callable[, Any]=...) -> int: ... 8 | def ecdsa_raw_sign(msg_hash: bytes, private_key_bytes: bytes) -> Tuple[int, int, int]: ... 9 | def ecdsa_raw_verify(msg_hash: bytes, vrs: Tuple[int, int, int], public_key_bytes: bytes) -> Optional[bool]: ... 10 | def ecdsa_raw_recover(msg_hash: bytes, vrs: Tuple[int, int, int]) -> Optional[bytes]: ... 11 | -------------------------------------------------------------------------------- /helios/__init__.py: -------------------------------------------------------------------------------- 1 | import pkg_resources 2 | import sys 3 | 4 | # TODO: update this to use the `helios` version once extracted from py-evm 5 | __version__: str 6 | try: 7 | __version__ = pkg_resources.get_distribution("helios").version 8 | except pkg_resources.DistributionNotFound: 9 | __version__ = "hls-{0}".format( 10 | pkg_resources.get_distribution("py-helios-node").version, 11 | ) 12 | 13 | # This is to ensure we call setup_trace_logging() before anything else. 14 | import hvm as _eth_module # noqa: F401 15 | 16 | if sys.platform in {'darwin', 'linux'}: 17 | # Set `uvloop` as the default event loop 18 | import asyncio # noqa: E402 19 | import uvloop # noqa: E402 20 | asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) 21 | 22 | from .main import ( # noqa: F401 23 | main, 24 | ) 25 | -------------------------------------------------------------------------------- /hvm/tools/_utils/vyper.py: -------------------------------------------------------------------------------- 1 | import functools 2 | 3 | try: 4 | from vyper.compile_lll import ( 5 | compile_to_assembly, 6 | assembly_to_evm, 7 | ) 8 | from vyper.parser.parser_utils import LLLnode 9 | except ImportError: 10 | vyper_available = False 11 | else: 12 | vyper_available = True 13 | 14 | 15 | def require_vyper(fn): 16 | @functools.wraps(fn) 17 | def inner(*args, **kwargs): 18 | if vyper_available: 19 | return fn(*args, **kwargs) 20 | else: 21 | raise ImportError("The `{0}` function requires the vyper compiler.") 22 | return inner 23 | 24 | 25 | @require_vyper 26 | def compile_vyper_lll(vyper_code): 27 | lll_node = LLLnode.from_list(vyper_code) 28 | assembly = compile_to_assembly(lll_node) 29 | code = assembly_to_evm(assembly) 30 | return code 31 | -------------------------------------------------------------------------------- /hvm/tools/fixtures/_utils.py: -------------------------------------------------------------------------------- 1 | import fnmatch 2 | import functools 3 | import os 4 | 5 | from eth_utils import to_tuple 6 | 7 | 8 | @to_tuple 9 | def recursive_find_files(base_dir, pattern): 10 | for dirpath, _, filenames in os.walk(base_dir): 11 | for filename in filenames: 12 | if fnmatch.fnmatch(filename, pattern): 13 | yield os.path.join(dirpath, filename) 14 | 15 | 16 | def require_pytest(fn): 17 | @functools.wraps(fn) 18 | def inner(*args, **kwargs): 19 | try: 20 | import pytest # noqa: F401 21 | except ImportError: 22 | raise ImportError( 23 | 'pytest is required to use the fixture_tests. Please ensure ' 24 | 'it is installed.' 25 | ) 26 | else: 27 | return fn(*args, **kwargs) 28 | return inner 29 | -------------------------------------------------------------------------------- /hvm/vm/forks/boson/state.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from typing import Type # noqa: F401 3 | 4 | from hvm.db.account import ( 5 | AccountDB, 6 | ) 7 | from hvm.vm.forks.helios_testnet.state import HeliosTestnetTransactionExecutor, HeliosTestnetState 8 | 9 | 10 | from .computation import BosonComputation 11 | 12 | from .transaction_context import ( 13 | BosonTransactionContext) 14 | 15 | 16 | class BosonTransactionExecutor(HeliosTestnetTransactionExecutor): 17 | pass 18 | 19 | 20 | class BosonState(HeliosTestnetState): 21 | computation_class: Type[BosonComputation] = BosonComputation 22 | transaction_executor: Type[BosonTransactionExecutor] = BosonTransactionExecutor 23 | account_db_class: Type[AccountDB] = AccountDB 24 | transaction_context_class: Type[BosonTransactionContext] = BosonTransactionContext 25 | 26 | -------------------------------------------------------------------------------- /old_tests/helios/core/filesystem-utils/test_is_under_path.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from helios.utils.filesystem import ( 4 | is_under_path, 5 | ) 6 | 7 | 8 | @pytest.mark.parametrize( 9 | 'base_path,path,expected', 10 | ( 11 | # Same Path 12 | ('foo', 'foo', False), 13 | ('foo', 'foo/bar/..', False), 14 | # up a directory (or two) 15 | ('foo', '..', False), 16 | ('foo', 'foo/bar/../../', False), 17 | # relative and abs 18 | ('foo', '/foo/bar', False), 19 | ('foo', '/foo', False), 20 | # actually nested 21 | ('foo', 'foo/bar.sol', True), 22 | ('foo', 'foo/bar', True), 23 | ('foo', 'foo/bar/../../foo/baz', True), 24 | ), 25 | ) 26 | def test_is_under_path(base_path, path, expected): 27 | actual = is_under_path(base_path, path) 28 | assert actual is expected 29 | -------------------------------------------------------------------------------- /old_tests/helios/core/cli/test_trinity_repl.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from helios.plugins.builtin.attach.console import console 4 | from pathlib import Path 5 | from helios.utils.log_messages import ( 6 | create_missing_ipc_error_message, 7 | ) 8 | 9 | 10 | def test_console(caplog, jsonrpc_ipc_pipe_path): 11 | # if ipc_path is not found, raise an exception with a useful message 12 | with pytest.raises(FileNotFoundError): 13 | console(Path(jsonrpc_ipc_pipe_path)) 14 | assert create_missing_ipc_error_message(jsonrpc_ipc_pipe_path) in caplog.text 15 | 16 | 17 | def test_python_console(caplog, jsonrpc_ipc_pipe_path): 18 | # if ipc_path is not found, raise an exception with a useful message 19 | with pytest.raises(FileNotFoundError): 20 | console(Path(jsonrpc_ipc_pipe_path), use_ipython=False) 21 | assert create_missing_ipc_error_message(jsonrpc_ipc_pipe_path) in caplog.text 22 | -------------------------------------------------------------------------------- /old_tests/dev/mp.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import functools 3 | import multiprocessing 4 | import os 5 | from typing import Callable, Any 6 | 7 | 8 | MP_CONTEXT = os.environ.get('HELIOS_MP_CONTEXT', 'spawn') 9 | 10 | 11 | # sets the type of process that multiprocessing will create. 12 | ctx = multiprocessing.get_context(MP_CONTEXT) 13 | 14 | 15 | def async_method(method_name: str) -> Callable[..., Any]: 16 | async def method(self, *args, **kwargs): 17 | loop = asyncio.get_event_loop() 18 | 19 | return await loop.run_in_executor( 20 | None, 21 | functools.partial(self._callmethod, kwds=kwargs), 22 | method_name, 23 | args, 24 | ) 25 | return method 26 | 27 | 28 | def sync_method(method_name: str) -> Callable[..., Any]: 29 | def method(self, *args, **kwargs): 30 | return self._callmethod(method_name, args, kwargs) 31 | return method 32 | -------------------------------------------------------------------------------- /hvm/vm/logic/block.py: -------------------------------------------------------------------------------- 1 | from hvm import constants 2 | from hvm.exceptions import DepreciatedVMFunctionality 3 | 4 | 5 | def blockhash(computation): 6 | # block_number = computation.stack_pop(type_hint=constants.UINT256) 7 | # 8 | # block_hash = computation.state.get_ancestor_hash(block_number) 9 | # 10 | # computation.stack_push(block_hash) 11 | raise DepreciatedVMFunctionality("blockhash has been removed.") 12 | 13 | 14 | def coinbase(computation): 15 | computation.stack_push(computation.state.coinbase) 16 | 17 | 18 | def timestamp(computation): 19 | computation.stack_push(computation.state.timestamp) 20 | 21 | 22 | def number(computation): 23 | computation.stack_push(computation.state.block_number) 24 | 25 | 26 | def difficulty(computation): 27 | computation.stack_push(computation.state.difficulty) 28 | 29 | 30 | def gaslimit(computation): 31 | computation.stack_push(computation.state.gas_limit) 32 | -------------------------------------------------------------------------------- /old_tests/core/env-utils/test_get.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from hvm.utils.env import ( 4 | get, 5 | ) 6 | 7 | 8 | @pytest.mark.parametrize( 9 | 'type,expected', 10 | ( 11 | ('int', 42), 12 | (int, 42), 13 | 14 | ('bool', False), 15 | (bool, True), 16 | 17 | ('string', 'ozymandias'), 18 | (str, 'hannibal'), 19 | 20 | ('float', 42.0), 21 | (float, 42.0), 22 | ) 23 | ) 24 | def test_get_mapping(type, expected): 25 | actual = get('ENV_VARIABLE', default=expected, type=type) 26 | assert actual == expected 27 | 28 | 29 | @pytest.mark.parametrize( 30 | 'type,default,expected', 31 | ( 32 | ('list', '1,2,3', ['1', '2', '3']), 33 | (list, '3,2,1', ['3', '2', '1']), 34 | ) 35 | ) 36 | def test_get_mapping_for_lists(type, default, expected): 37 | actual = get('ENV_VARIABLE', default=default, type=type) 38 | assert actual == expected 39 | -------------------------------------------------------------------------------- /old_tests/core/consensus/test_pow_mining.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from hvm.chains.base import MiningChain 4 | from hvm.chains.mainnet import MAINNET_VMS 5 | from hvm.consensus.pow import check_pow 6 | from hvm.tools.mining import POWMiningMixin 7 | from hvm.tools.builder.chain import ( 8 | genesis, 9 | ) 10 | 11 | 12 | @pytest.mark.parametrize( 13 | 'base_vm_class', 14 | MAINNET_VMS, 15 | ) 16 | def test_mining_tools_proof_of_work_mining(base_vm_class): 17 | vm_class = type(base_vm_class.__name__, (POWMiningMixin, base_vm_class), {}) 18 | 19 | class ChainClass(MiningChain): 20 | vm_configuration = ( 21 | (0, vm_class), 22 | ) 23 | 24 | chain = genesis(ChainClass) 25 | 26 | block = chain.mine_block() 27 | check_pow( 28 | block.number, 29 | block.header.mining_hash, 30 | block.header.mix_hash, 31 | block.header.nonce, 32 | block.header.difficulty, 33 | ) 34 | -------------------------------------------------------------------------------- /old_tests/helios/core/chain-management/test_initialize_database.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | # TODO: use a custom chain class only for testing. 4 | from hvm.db.backends.level import LevelDB 5 | from hvm.db.chain import ChainDB 6 | 7 | from helios.chains import ( 8 | initialize_data_dir, 9 | initialize_database, 10 | is_database_initialized, 11 | ) 12 | from helios.config import ( 13 | ChainConfig, 14 | ) 15 | 16 | 17 | @pytest.fixture 18 | def chain_config(): 19 | _chain_config = ChainConfig(network_id=1, max_peers=1) 20 | initialize_data_dir(_chain_config) 21 | return _chain_config 22 | 23 | 24 | @pytest.fixture 25 | def chaindb(chain_config): 26 | return ChainDB(LevelDB(db_path=chain_config.database_dir)) 27 | 28 | 29 | def test_initialize_database(chain_config, chaindb): 30 | assert not is_database_initialized(chaindb) 31 | initialize_database(chain_config, chaindb) 32 | assert is_database_initialized(chaindb) 33 | -------------------------------------------------------------------------------- /hvm/db/cache.py: -------------------------------------------------------------------------------- 1 | from lru import LRU 2 | 3 | from hvm.db.backends.base import BaseDB 4 | 5 | 6 | class CacheDB(BaseDB): 7 | """ 8 | Set and get decoded RLP objects, where the underlying db stores 9 | encoded objects. 10 | """ 11 | def __init__(self, db, cache_size=2048): 12 | self._db = db 13 | self._cache_size = cache_size 14 | self.reset_cache() 15 | 16 | def reset_cache(self): 17 | self._cached_values = LRU(self._cache_size) 18 | 19 | def __getitem__(self, key): 20 | if key not in self._cached_values: 21 | self._cached_values[key] = self._db[key] 22 | return self._cached_values[key] 23 | 24 | def __setitem__(self, key, value): 25 | self._cached_values[key] = value 26 | self._db[key] = value 27 | 28 | def __delitem__(self, key): 29 | if key in self._cached_values: 30 | del self._cached_values[key] 31 | del self._db[key] 32 | -------------------------------------------------------------------------------- /helios/utils/version.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | import pkg_resources 4 | 5 | from helios import __version__ 6 | 7 | 8 | def construct_helios_client_identifier() -> str: 9 | """ 10 | Constructs the client identifier string 11 | 12 | e.g. 'Helios/v1.2.3/darwin-amd64/python3.6.5' 13 | """ 14 | return "Helios/{0}/{platform}/{imp.name}{v.major}.{v.minor}.{v.micro}".format( 15 | __version__, 16 | platform=sys.platform, 17 | v=sys.version_info, 18 | # mypy Doesn't recognize the `sys` module as having an `implementation` attribute. 19 | imp=sys.implementation, # type: ignore 20 | ) 21 | 22 | 23 | def is_prerelease() -> bool: 24 | try: 25 | distro = pkg_resources.get_distribution("helios") 26 | # mypy thinks that parsed_version is a tuple. Ignored... 27 | return distro.parsed_version.is_prerelease # type: ignore 28 | except pkg_resources.DistributionNotFound: 29 | return True 30 | -------------------------------------------------------------------------------- /stubs/eth_keys/main.pyi: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Any, 3 | Optional, 4 | Type, 5 | Union 6 | ) 7 | 8 | from .datatypes import ( 9 | LazyBackend, 10 | ) 11 | 12 | import datatypes 13 | 14 | 15 | class KeyAPI(LazyBackend): 16 | PublicKey: Type[datatypes.PublicKey] = ... 17 | PrivateKey: Type[datatypes.PrivateKey] = ... 18 | Signature: Type[datatypes.Signature] = ... 19 | def ecdsa_sign(self, message_hash: bytes, private_key: Union[datatypes.PrivateKey, bytes]) -> Optional[datatypes.Signature]: ... 20 | def ecdsa_verify(self, message_hash: bytes, signature: Union[datatypes.Signature, bytes], public_key: Union[datatypes.PublicKey, bytes]) -> Optional[bool]: ... 21 | def ecdsa_recover(self, message_hash: bytes, signature: Union[datatypes.Signature, bytes]) -> Optional[datatypes.PublicKey]: ... 22 | def private_key_to_public_key(self, private_key: datatypes.PrivateKey) -> datatypes.PublicKey: ... 23 | 24 | lazy_key_api: KeyAPI 25 | -------------------------------------------------------------------------------- /old_tests/dev/test/leveldb/LOG: -------------------------------------------------------------------------------- 1 | 2019/04/17-20:24:55.980016 7f269f48f440 Recovering log #38 2 | 2019/04/17-20:24:55.980265 7f269f48f440 Level-0 table #40: started 3 | 2019/04/17-20:24:55.983682 7f269f48f440 Level-0 table #40: 3426 bytes OK 4 | 2019/04/17-20:24:55.986378 7f269f48f440 Delete type=0 #38 5 | 2019/04/17-20:24:55.986475 7f269f48f440 Delete type=3 #36 6 | 2019/04/17-20:24:55.986578 7f2697d69700 Compacting 4@0 + 1@1 files 7 | 2019/04/17-20:24:55.989353 7f2697d69700 Generated table #42@0: 201 keys, 3459 bytes 8 | 2019/04/17-20:24:55.989418 7f2697d69700 Compacted 4@0 + 1@1 files => 3459 bytes 9 | 2019/04/17-20:24:55.991243 7f2697d69700 compacted to: files[ 0 1 0 0 0 0 0 ] 10 | 2019/04/17-20:24:55.991439 7f2697d69700 Delete type=2 #29 11 | 2019/04/17-20:24:55.991561 7f2697d69700 Delete type=2 #31 12 | 2019/04/17-20:24:55.991650 7f2697d69700 Delete type=2 #34 13 | 2019/04/17-20:24:55.991735 7f2697d69700 Delete type=2 #37 14 | 2019/04/17-20:24:55.991819 7f2697d69700 Delete type=2 #40 15 | -------------------------------------------------------------------------------- /hvm/vm/logic/duplication.py: -------------------------------------------------------------------------------- 1 | import functools 2 | 3 | 4 | def dup_XX(computation, position): 5 | """ 6 | Stack item duplication. 7 | """ 8 | computation.stack_dup(position) 9 | 10 | 11 | dup1 = functools.partial(dup_XX, position=1) 12 | dup2 = functools.partial(dup_XX, position=2) 13 | dup3 = functools.partial(dup_XX, position=3) 14 | dup4 = functools.partial(dup_XX, position=4) 15 | dup5 = functools.partial(dup_XX, position=5) 16 | dup6 = functools.partial(dup_XX, position=6) 17 | dup7 = functools.partial(dup_XX, position=7) 18 | dup8 = functools.partial(dup_XX, position=8) 19 | dup9 = functools.partial(dup_XX, position=9) 20 | dup10 = functools.partial(dup_XX, position=10) 21 | dup11 = functools.partial(dup_XX, position=11) 22 | dup12 = functools.partial(dup_XX, position=12) 23 | dup13 = functools.partial(dup_XX, position=13) 24 | dup14 = functools.partial(dup_XX, position=14) 25 | dup15 = functools.partial(dup_XX, position=15) 26 | dup16 = functools.partial(dup_XX, position=16) 27 | -------------------------------------------------------------------------------- /helios/plugins/builtin/peer_blacklist/events.py: -------------------------------------------------------------------------------- 1 | from typing import Type 2 | 3 | from lahja import ( 4 | BaseEvent, 5 | BaseRequestResponseEvent, 6 | ) 7 | 8 | 9 | class IsPeerOnBlacklistResponse(BaseEvent): 10 | 11 | def __init__(self, is_peer_on_blacklist: bool) -> None: 12 | self.is_peer_on_blacklist = is_peer_on_blacklist 13 | 14 | class IsPeerOnBlacklistRequest(BaseRequestResponseEvent[IsPeerOnBlacklistResponse]): 15 | 16 | def __init__(self, node_pubkey: bytes) -> None: 17 | self.node_pubkey = node_pubkey 18 | 19 | @staticmethod 20 | def expected_response_type() -> Type[IsPeerOnBlacklistResponse]: 21 | return IsPeerOnBlacklistResponse 22 | 23 | class AddPeerToBlacklistRequest(BaseEvent): 24 | 25 | def __init__(self, node_pubkey: bytes) -> None: 26 | self.node_pubkey = node_pubkey 27 | 28 | class RemovePeerFromBlacklistRequest(BaseEvent): 29 | 30 | def __init__(self, node_pubkey: bytes) -> None: 31 | self.node_pubkey = node_pubkey -------------------------------------------------------------------------------- /hvm/vm/logic/swap.py: -------------------------------------------------------------------------------- 1 | import functools 2 | 3 | 4 | def swap_XX(computation, position): 5 | """ 6 | Stack item swapping 7 | """ 8 | computation.stack_swap(position) 9 | 10 | 11 | swap1 = functools.partial(swap_XX, position=1) 12 | swap2 = functools.partial(swap_XX, position=2) 13 | swap3 = functools.partial(swap_XX, position=3) 14 | swap4 = functools.partial(swap_XX, position=4) 15 | swap5 = functools.partial(swap_XX, position=5) 16 | swap6 = functools.partial(swap_XX, position=6) 17 | swap7 = functools.partial(swap_XX, position=7) 18 | swap8 = functools.partial(swap_XX, position=8) 19 | swap9 = functools.partial(swap_XX, position=9) 20 | swap10 = functools.partial(swap_XX, position=10) 21 | swap11 = functools.partial(swap_XX, position=11) 22 | swap12 = functools.partial(swap_XX, position=12) 23 | swap13 = functools.partial(swap_XX, position=13) 24 | swap14 = functools.partial(swap_XX, position=14) 25 | swap15 = functools.partial(swap_XX, position=15) 26 | swap16 = functools.partial(swap_XX, position=16) 27 | -------------------------------------------------------------------------------- /helios/utils/mp.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import functools 3 | import multiprocessing 4 | import os 5 | from typing import ( 6 | Any, 7 | Awaitable, 8 | Callable 9 | ) 10 | 11 | 12 | MP_CONTEXT = os.environ.get('HELIOS_MP_CONTEXT', 'spawn') 13 | 14 | 15 | # sets the type of process that multiprocessing will create. 16 | ctx = multiprocessing.get_context(MP_CONTEXT) 17 | 18 | 19 | def async_method(method_name: str) -> Callable[..., Any]: 20 | async def method(self: Any, *args: Any, **kwargs: Any) -> Awaitable[Any]: 21 | loop = asyncio.get_event_loop() 22 | 23 | return await loop.run_in_executor( 24 | None, 25 | functools.partial(self._callmethod, kwds=kwargs), 26 | method_name, 27 | args, 28 | ) 29 | return method 30 | 31 | 32 | def sync_method(method_name: str) -> Callable[..., Any]: 33 | def method(self: Any, *args: Any, **kwargs: Any) -> Any: 34 | return self._callmethod(method_name, args, kwargs) 35 | return method 36 | -------------------------------------------------------------------------------- /old_tests/p2p/conftest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | 4 | """ 5 | # Uncomment the following lines to globally change the logging level for all 6 | # `hp2p` namespaced loggers. Useful for debugging failing tests in async code 7 | # when the only output you get is a timeout or something else which doens't 8 | # indicate where things failed. 9 | import pytest 10 | 11 | @pytest.fixture(autouse=True, scope="session") 12 | def p2p_logger(): 13 | import logging 14 | import sys 15 | 16 | logger = logging.getLogger('hp2p') 17 | 18 | handler = logging.StreamHandler(sys.stdout) 19 | 20 | # level = TRACE_LEVEL_NUM 21 | level = logging.DEBUG 22 | level = logging.INFO 23 | 24 | logger.setLevel(level) 25 | handler.setLevel(level) 26 | 27 | logger.addHandler(handler) 28 | 29 | return logger 30 | """ 31 | 32 | 33 | @pytest.fixture(autouse=True) 34 | def _network_sim(router): 35 | network = router.get_network(name='simulated') 36 | with network.patch_asyncio(): 37 | yield network 38 | -------------------------------------------------------------------------------- /hp2p/tools/factories/kademlia.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | 3 | import factory 4 | 5 | from hp2p.kademlia import Node, Address 6 | 7 | from .keys import PublicKeyFactory 8 | from .socket import get_open_port 9 | 10 | 11 | class AddressFactory(factory.Factory): 12 | class Meta: 13 | model = Address 14 | 15 | ip = factory.Sequence(lambda n: f'10.{(n // 65536) % 256}.{(n // 256) % 256}.{n % 256}') 16 | udp_port = factory.LazyFunction(get_open_port) 17 | tcp_port = 0 18 | 19 | @classmethod 20 | def localhost(cls, *args: Any, **kwargs: Any): 21 | return cls(*args, ip='127.0.0.1', **kwargs) 22 | 23 | 24 | class NodeFactory(factory.Factory): 25 | class Meta: 26 | model = Node 27 | 28 | pubkey = factory.LazyFunction(PublicKeyFactory) 29 | address = factory.SubFactory(AddressFactory) 30 | 31 | @classmethod 32 | def with_nodeid(cls, nodeid: int, *args: Any, **kwargs: Any): 33 | node = cls(*args, **kwargs) 34 | node.id = nodeid 35 | return node 36 | -------------------------------------------------------------------------------- /hvm/vm/forks/helios_testnet/headers.py: -------------------------------------------------------------------------------- 1 | from hvm.constants import ( 2 | GENESIS_GAS_LIMIT 3 | ) 4 | from hvm.validation import ( 5 | validate_header_params_for_configuration, 6 | ) 7 | from hvm.utils.headers import ( 8 | compute_gas_limit, 9 | ) 10 | 11 | from hvm.rlp.headers import BlockHeader 12 | 13 | 14 | def create_helios_testnet_header_from_parent(parent_header, **header_params): 15 | if 'gas_limit' not in header_params: 16 | # header_params['gas_limit'] = compute_gas_limit( 17 | # parent_header, 18 | # gas_limit_floor=GENESIS_GAS_LIMIT, 19 | # ) 20 | header_params['gas_limit'] = compute_gas_limit() 21 | 22 | header = BlockHeader.from_parent(parent=parent_header, **header_params) 23 | 24 | return header 25 | 26 | 27 | def configure_helios_testnet_header(vm, **header_params): 28 | validate_header_params_for_configuration(header_params) 29 | 30 | with vm.block.header.build_changeset(**header_params) as changeset: 31 | header = changeset.commit() 32 | 33 | return header 34 | -------------------------------------------------------------------------------- /old_tests/core/vm/test_vm_state.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from hvm.db.backends.memory import MemoryDB 4 | from hvm.exceptions import StateRootNotFound 5 | from hvm.vm.forks.frontier.state import FrontierState 6 | 7 | 8 | @pytest.fixture 9 | def state(chain_without_block_validation): 10 | return chain_without_block_validation.get_vm().state 11 | 12 | 13 | def test_block_properties(chain_without_block_validation): 14 | chain = chain_without_block_validation 15 | vm = chain.get_vm() 16 | block, _, _ = chain.import_block(vm.mine_block()) 17 | 18 | assert vm.state.coinbase == block.header.coinbase 19 | assert vm.state.timestamp == block.header.timestamp 20 | assert vm.state.block_number == block.header.block_number 21 | assert vm.state.difficulty == block.header.difficulty 22 | assert vm.state.gas_limit == block.header.gas_limit 23 | 24 | 25 | def test_missing_state_root(): 26 | context = None 27 | state = FrontierState(MemoryDB(), context, b'\x0f' * 32) 28 | with pytest.raises(StateRootNotFound): 29 | state.apply_transaction(None) 30 | -------------------------------------------------------------------------------- /hvm/vm/forks/byzantium/transactions.py: -------------------------------------------------------------------------------- 1 | from hvm.vm.forks.spurious_dragon.transactions import ( 2 | SpuriousDragonTransaction, 3 | SpuriousDragonUnsignedTransaction, 4 | ) 5 | 6 | from hvm.utils.transactions import ( 7 | create_transaction_signature, 8 | ) 9 | 10 | 11 | class ByzantiumTransaction(SpuriousDragonTransaction): 12 | @classmethod 13 | def create_unsigned_transaction(cls, nonce, gas_price, gas, to, value, data): 14 | return ByzantiumUnsignedTransaction(nonce, gas_price, gas, to, value, data) 15 | 16 | 17 | class ByzantiumUnsignedTransaction(SpuriousDragonUnsignedTransaction): 18 | def as_signed_transaction(self, private_key, chain_id=None): 19 | v, r, s = create_transaction_signature(self, private_key, chain_id=chain_id) 20 | return ByzantiumTransaction( 21 | nonce=self.nonce, 22 | gas_price=self.gas_price, 23 | gas=self.gas, 24 | to=self.to, 25 | value=self.value, 26 | data=self.data, 27 | v=v, 28 | r=r, 29 | s=s, 30 | ) 31 | -------------------------------------------------------------------------------- /helios/utils/chain_proxy.py: -------------------------------------------------------------------------------- 1 | from multiprocessing.managers import ( 2 | BaseManager, 3 | ) 4 | import pathlib 5 | 6 | from helios.chains import ( 7 | ChainProxy, 8 | ) 9 | from helios.db.chain import ChainDBProxy 10 | from helios.db.chain_head import ChainHeadDBProxy 11 | from helios.db.base import DBProxy 12 | from helios.db.consensus import ConsensusDBProxy 13 | 14 | 15 | def create_chain_manager(ipc_path: pathlib.Path) -> BaseManager: 16 | """ 17 | We're still using 'str' here on param ipc_path because an issue with 18 | multi-processing not being able to interpret 'Path' objects correctly 19 | """ 20 | class ChainManager(BaseManager): 21 | pass 22 | 23 | # Typeshed definitions for multiprocessing.managers is incomplete, so ignore them for now: 24 | # https://github.com/python/typeshed/blob/85a788dbcaa5e9e9a62e55f15d44530cd28ba830/stdlib/3/multiprocessing/managers.pyi#L3 25 | 26 | ChainManager.register('get_chain', proxytype=ChainProxy) # type: ignore 27 | 28 | manager = ChainManager(address=str(ipc_path)) # type: ignore 29 | return manager 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | 3 | # C extensions 4 | *.so 5 | 6 | # Packages 7 | *.egg 8 | *.egg-info 9 | dist 10 | build 11 | eggs 12 | parts 13 | var 14 | sdist 15 | develop-eggs 16 | .installed.cfg 17 | lib 18 | lib64 19 | 20 | # Installer logs 21 | pip-log.txt 22 | 23 | # Unit test / coverage reports 24 | .coverage 25 | .tox 26 | nosetests.xml 27 | 28 | # Translations 29 | *.mo 30 | 31 | # Mr Developer 32 | .mr.developer.cfg 33 | .project 34 | .pydevproject 35 | 36 | # Complexity 37 | output/*.html 38 | output/*/index.html 39 | 40 | # Sphinx 41 | docs/_build 42 | docs/modules.rst 43 | 44 | # pytest 45 | .cache/ 46 | .pytest_cache/ 47 | 48 | # fixtures 49 | fixtures/** 50 | 51 | # profiling 52 | prof/** 53 | 54 | # hypothesis 55 | .hypothesis/ 56 | 57 | # mypy 58 | .mypy_cache/ 59 | *.swp 60 | docs/evm.*rst 61 | venv* 62 | .eggs/ 63 | 64 | # vscode 65 | .vscode/** 66 | 67 | # monkeytype 68 | monkeytype.sqlite3 69 | 70 | # pyenv 71 | .python-version 72 | 73 | # idea 74 | .idea 75 | 76 | # keystore files 77 | helios/keystore/* 78 | !helios/keystore/.gitkeep 79 | 80 | helios/helios_config.py 81 | 82 | -------------------------------------------------------------------------------- /helios/utils/db.py: -------------------------------------------------------------------------------- 1 | from typing import Dict 2 | 3 | 4 | class MemoryDB: 5 | kv_store: Dict[bytes, bytes] = None 6 | 7 | def __init__(self, kv_store: Dict[bytes, bytes]=None) -> None: 8 | if kv_store is None: 9 | self.kv_store = {} 10 | else: 11 | self.kv_store = kv_store 12 | 13 | def get(self, key: bytes) -> bytes: 14 | return self.kv_store[key] 15 | 16 | def set(self, key: bytes, value: bytes) -> None: 17 | self.kv_store[key] = value 18 | 19 | def exists(self, key: bytes) -> bool: 20 | return key in self.kv_store 21 | 22 | def delete(self, key: bytes) -> None: 23 | del self.kv_store[key] 24 | 25 | # 26 | # Dictionary API 27 | # 28 | def __getitem__(self, key: bytes) -> bytes: 29 | return self.get(key) 30 | 31 | def __setitem__(self, key: bytes, value: bytes) -> None: 32 | return self.set(key, value) 33 | 34 | def __delitem__(self, key: bytes) -> None: 35 | return self.delete(key) 36 | 37 | def __contains__(self, key: bytes) -> bool: 38 | return self.exists(key) 39 | -------------------------------------------------------------------------------- /hvm/vm/forks/byzantium/computation.py: -------------------------------------------------------------------------------- 1 | from cytoolz import ( 2 | merge, 3 | ) 4 | 5 | from hvm import precompiles 6 | from hvm.utils.address import ( 7 | force_bytes_to_address, 8 | ) 9 | from hvm.vm.forks.frontier.computation import FRONTIER_PRECOMPILES 10 | from hvm.vm.forks.spurious_dragon.computation import SpuriousDragonComputation 11 | 12 | from .opcodes import BYZANTIUM_OPCODES 13 | 14 | BYZANTIUM_PRECOMPILES = merge( 15 | FRONTIER_PRECOMPILES, 16 | { 17 | force_bytes_to_address(b'\x05'): precompiles.modexp, 18 | force_bytes_to_address(b'\x06'): precompiles.ecadd, 19 | force_bytes_to_address(b'\x07'): precompiles.ecmul, 20 | force_bytes_to_address(b'\x08'): precompiles.ecpairing, 21 | }, 22 | ) 23 | 24 | 25 | class ByzantiumComputation(SpuriousDragonComputation): 26 | """ 27 | A class for all execution computations in the ``Byzantium`` fork. 28 | Inherits from :class:`~hvm.vm.forks.spurious_dragon.computation.SpuriousDragonComputation` 29 | """ 30 | # Override 31 | opcodes = BYZANTIUM_OPCODES 32 | _precompiles = BYZANTIUM_PRECOMPILES 33 | -------------------------------------------------------------------------------- /hvm/utils/db.py: -------------------------------------------------------------------------------- 1 | from hvm.rlp.headers import BlockHeader 2 | 3 | from typing import TYPE_CHECKING 4 | 5 | if TYPE_CHECKING: 6 | from hvm.db.chain import BaseChainDB # noqa: F401 7 | 8 | 9 | def get_parent_header(block_header: BlockHeader, db: 'BaseChainDB') -> BlockHeader: 10 | """ 11 | Returns the header for the parent block. 12 | """ 13 | return db.get_block_header_by_hash(block_header.parent_hash) 14 | 15 | 16 | def get_block_header_by_hash(block_hash: BlockHeader, db: 'BaseChainDB') -> BlockHeader: 17 | """ 18 | Returns the header for the parent block. 19 | """ 20 | return db.get_block_header_by_hash(block_hash) 21 | 22 | 23 | def apply_state_dict(account_db, state_dict): 24 | for account, account_data in state_dict.items(): 25 | account_db.set_balance(account, account_data["balance"]) 26 | account_db.set_nonce(account, account_data["nonce"]) 27 | account_db.set_code(account, account_data["code"]) 28 | 29 | for slot, value in account_data["storage"].items(): 30 | account_db.set_storage(account, slot, value) 31 | 32 | return account_db 33 | -------------------------------------------------------------------------------- /helios/protocol/common/normalizers.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod, ABC 2 | from typing import ( 3 | Generic, 4 | TypeVar, 5 | ) 6 | 7 | from hp2p.protocol import PayloadType 8 | 9 | from .types import ( 10 | TResponsePayload, 11 | TResult, 12 | ) 13 | 14 | 15 | class BaseNormalizer(ABC, Generic[TResponsePayload, TResult]): 16 | is_normalization_slow = False 17 | """ 18 | This variable indicates how slow normalization is. If normalization requires 19 | any non-trivial computation, consider it slow. Then, the Manager will run it in 20 | a different process. 21 | """ 22 | 23 | @staticmethod 24 | @abstractmethod 25 | def normalize_result(message: TResponsePayload) -> TResult: 26 | """ 27 | Convert underlying peer message to final result 28 | """ 29 | raise NotImplementedError() 30 | 31 | 32 | TPassthrough = TypeVar('TPassthrough', bound=PayloadType) 33 | 34 | 35 | class NoopNormalizer(BaseNormalizer[TPassthrough, TPassthrough]): 36 | @staticmethod 37 | def normalize_result(message: TPassthrough) -> TPassthrough: 38 | return message 39 | -------------------------------------------------------------------------------- /old_tests/helios/core/chain-management/test_is_database_initialized.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | # TODO: use a custom chain class only for testing. 4 | from hvm.chains.ropsten import ROPSTEN_GENESIS_HEADER 5 | from hvm.db.backends.level import LevelDB 6 | from hvm.db.chain import ChainDB 7 | 8 | from helios.chains import ( 9 | initialize_data_dir, 10 | is_database_initialized, 11 | ) 12 | from helios.config import ( 13 | ChainConfig, 14 | ) 15 | 16 | 17 | @pytest.fixture 18 | def chain_config(): 19 | _chain_config = ChainConfig(network_id=1, max_peers=1) 20 | initialize_data_dir(_chain_config) 21 | return _chain_config 22 | 23 | 24 | @pytest.fixture 25 | def chaindb(chain_config): 26 | return ChainDB(LevelDB(db_path=chain_config.database_dir)) 27 | 28 | 29 | def test_database_dir_not_initialized_without_canonical_head_block(chaindb): 30 | assert not is_database_initialized(chaindb) 31 | 32 | 33 | def test_fully_initialized_database_dir(chaindb): 34 | assert not is_database_initialized(chaindb) 35 | chaindb.persist_header(ROPSTEN_GENESIS_HEADER) 36 | assert is_database_initialized(chaindb) 37 | -------------------------------------------------------------------------------- /helios/utils/headers.py: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Tuple, 3 | ) 4 | 5 | from hvm.constants import UINT_256_MAX 6 | 7 | from helios.constants import MAXIMUM_OBJECT_MEMORY_BYTES 8 | from helios.exceptions import OversizeObject 9 | 10 | 11 | def sequence_builder(start_number: int, 12 | max_length: int, 13 | skip: int, 14 | reverse: bool) -> Tuple[int, ...]: 15 | # Limit the in-memory size of this sequence. 16 | # A tuple of 64-bit ints is about 8 bytes per value 17 | # Ignore the cutoffs at 0 and UINT_256_MAX, because this is just a gut check anyway, 18 | # we should never be approaching this value. 19 | if max_length > MAXIMUM_OBJECT_MEMORY_BYTES // 8: 20 | raise OversizeObject("Sequence is too big to fit in memory: {}".format(max_length)) 21 | 22 | if reverse: 23 | step = -1 * (skip + 1) 24 | else: 25 | step = skip + 1 26 | 27 | cutoff_number = start_number + step * max_length 28 | 29 | whole_range = range(start_number, cutoff_number, step) 30 | 31 | return tuple(number for number in whole_range if 0 <= number <= UINT_256_MAX) 32 | -------------------------------------------------------------------------------- /setup_trinity.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | from setuptools import setup 4 | 5 | 6 | setup( 7 | name='helios', 8 | # *IMPORTANT*: Don't manually change the version here. Use the 'bumpversion' utility. 9 | # NOT CURRENTLY APPLICABLE. VERSION BUMPS MANUAL FOR NOW 10 | version='0.1.0-alpha.2', 11 | description='The Helios Node', 12 | author='Tommy Mckinnon', 13 | author_email='tommy@heliosprotocol.io', 14 | url='https://github.com/Helios-Protocol/py-helios-node', 15 | include_package_data=True, 16 | py_modules=[], 17 | install_requires=[ 18 | 'py-helios-node[helios,hp2p]==0.2.0a18', 19 | ], 20 | license='MIT', 21 | zip_safe=False, 22 | keywords='blockchain hvm helios', 23 | packages=[], 24 | classifiers=[ 25 | 'Development Status :: 2 - Pre-Alpha', 26 | 'Intended Audience :: Developers', 27 | 'License :: OSI Approved :: MIT License', 28 | 'Natural Language :: English', 29 | 'Programming Language :: Python :: 3.6', 30 | ], 31 | # helios 32 | entry_points={ 33 | 'console_scripts': ['helios=helios:main'], 34 | }, 35 | ) 36 | -------------------------------------------------------------------------------- /helios/plugins/builtin/fix_unclean_shutdown/plugin.py: -------------------------------------------------------------------------------- 1 | from argparse import ( 2 | ArgumentParser, 3 | Namespace, 4 | _SubParsersAction, 5 | ) 6 | import time 7 | 8 | from helios.config import ( 9 | ChainConfig, 10 | ) 11 | from helios.extensibility import ( 12 | BaseMainProcessPlugin, 13 | ) 14 | from helios.utils.ipc import ( 15 | kill_process_id_gracefully, 16 | fix_unclean_shutdown) 17 | 18 | 19 | class FixUncleanShutdownPlugin(BaseMainProcessPlugin): 20 | 21 | @property 22 | def name(self) -> str: 23 | return "Fix Unclean Shutdown" 24 | 25 | def configure_parser(self, arg_parser: ArgumentParser, subparser: _SubParsersAction) -> None: 26 | 27 | attach_parser = subparser.add_parser( 28 | 'fix-unclean-shutdown', 29 | help='close any dangling processes from a previous unclean shutdown', 30 | ) 31 | 32 | attach_parser.set_defaults(func=self.fix_unclean_shutdown) 33 | 34 | def fix_unclean_shutdown(self, args: Namespace, chain_config: ChainConfig) -> None: 35 | self.logger.info("Cleaning up unclean shutdown...") 36 | 37 | fix_unclean_shutdown(chain_config, self.logger) -------------------------------------------------------------------------------- /hp2p/tools/paragon/proto.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from hp2p.protocol import ( 4 | Protocol, 5 | ) 6 | 7 | from .commands import ( 8 | BroadcastData, 9 | GetSum, 10 | Sum, 11 | ) 12 | 13 | 14 | class ParagonProtocol(Protocol): 15 | name = 'paragon' 16 | version = 1 17 | _commands = [ 18 | BroadcastData, 19 | GetSum, Sum, 20 | ] 21 | cmd_length = 3 22 | logger = logging.getLogger("hp2p.tools.paragon.proto.ParagonProtocol") 23 | 24 | # 25 | # Broadcast 26 | # 27 | def send_broadcast_data(self, data: bytes) -> None: 28 | cmd = BroadcastData(self.cmd_id_offset) 29 | header, body = cmd.encode({'data': data}) 30 | self.send(header, body) 31 | 32 | # 33 | # Sum 34 | # 35 | def send_get_sum(self, value_a: int, value_b: int) -> None: 36 | cmd = GetSum(self.cmd_id_offset) 37 | header, body = cmd.encode({'a': value_a, 'b': value_b}) 38 | self.send(header, body) 39 | 40 | def send_sum(self, result: int) -> None: 41 | cmd = GetSum(self.cmd_id_offset) 42 | header, body = cmd.encode({'result': result}) 43 | self.send(header, body) 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright 2018 Tommy Mckinnon 4 | 5 | Copyright 2017 Piper Merriam 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /helios/utils/xdg.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from pathlib import Path 4 | 5 | from helios.exceptions import ( 6 | AmbigiousFileSystem 7 | ) 8 | 9 | 10 | def get_home() -> Path: 11 | try: 12 | return Path(os.environ['HOME']) 13 | except KeyError: 14 | raise AmbigiousFileSystem('$HOME environment variable not set') 15 | 16 | 17 | def get_xdg_cache_home() -> Path: 18 | try: 19 | return Path(os.environ['XDG_CACHE_HOME']) 20 | except KeyError: 21 | return get_home() / '.cache' 22 | 23 | 24 | def get_xdg_config_home() -> Path: 25 | try: 26 | return Path(os.environ['XDG_CONFIG_HOME']) 27 | except KeyError: 28 | return get_home() / '.config' 29 | 30 | 31 | def get_xdg_data_home() -> Path: 32 | try: 33 | return Path(os.environ['XDG_DATA_HOME']) 34 | except KeyError: 35 | return get_home() / '.local' / 'share' 36 | 37 | 38 | def get_xdg_helios_root() -> Path: 39 | """ 40 | Returns the base directory under which helios will store all data. 41 | """ 42 | try: 43 | return Path(os.environ['XDG_HELIOS_ROOT']) 44 | except KeyError: 45 | return get_xdg_data_home() / 'helios' 46 | -------------------------------------------------------------------------------- /hp2p/tools/paragon/peer.py: -------------------------------------------------------------------------------- 1 | from hp2p.peer import ( 2 | BasePeer, 3 | BasePeerContext, 4 | BasePeerPool, 5 | BasePeerFactory, 6 | ) 7 | from hp2p.protocol import ( 8 | Command, 9 | _DecodedMsgType, 10 | ) 11 | 12 | from .proto import ParagonProtocol 13 | 14 | 15 | class ParagonPeer(BasePeer): 16 | _supported_sub_protocols = [ParagonProtocol] 17 | sub_proto: ParagonProtocol = None 18 | 19 | async def send_sub_proto_handshake(self) -> None: 20 | pass 21 | 22 | async def process_sub_proto_handshake( 23 | self, cmd: Command, msg: _DecodedMsgType) -> None: 24 | pass 25 | 26 | async def do_sub_proto_handshake(self) -> None: 27 | pass 28 | 29 | 30 | class ParagonContext(BasePeerContext): 31 | # nothing magic here. Simply an example of how the context class can be 32 | # used to store data specific to a certain peer class. 33 | paragon: str = "paragon" 34 | 35 | 36 | class ParagonPeerFactory(BasePeerFactory): 37 | peer_class = ParagonPeer 38 | context: ParagonContext 39 | 40 | 41 | class ParagonPeerPool(BasePeerPool): 42 | peer_factory_class = ParagonPeerFactory 43 | context: ParagonContext 44 | -------------------------------------------------------------------------------- /hvm/vm/forks/homestead/__init__.py: -------------------------------------------------------------------------------- 1 | from typing import Type # noqa: F401 2 | from hvm.rlp.blocks import BaseBlock # noqa: F401 3 | from hvm.vm.state import BaseState # noqa: F401 4 | 5 | #from hvm.chains.mainnet.constants import ( 6 | # DAO_FORK_MAINNET_BLOCK 7 | #) 8 | from hvm.vm.forks.frontier import FrontierVM 9 | 10 | from .blocks import HomesteadBlock 11 | from .headers import ( 12 | create_homestead_header_from_parent, 13 | compute_homestead_difficulty, 14 | configure_homestead_header, 15 | ) 16 | from .state import HomesteadState 17 | 18 | 19 | class MetaHomesteadVM(FrontierVM): 20 | support_dao_fork = True 21 | #dao_fork_block_number = DAO_FORK_MAINNET_BLOCK 22 | 23 | 24 | class HomesteadVM(MetaHomesteadVM): 25 | # fork name 26 | fork = 'homestead' # type: str 27 | 28 | # classes 29 | block_class = HomesteadBlock # type: Type[BaseBlock] 30 | _state_class = HomesteadState # type: Type[BaseState] 31 | 32 | # method overrides 33 | create_header_from_parent = staticmethod(create_homestead_header_from_parent) 34 | compute_difficulty = staticmethod(compute_homestead_difficulty) 35 | configure_header = configure_homestead_header 36 | -------------------------------------------------------------------------------- /helios/rlp_templates/sedes.py: -------------------------------------------------------------------------------- 1 | from rlp_cython import sedes 2 | from hvm.rlp.sedes import address 3 | 4 | class HashOrNumber: 5 | 6 | def serialize(self, obj: int) -> bytes: 7 | if isinstance(obj, int): 8 | return sedes.big_endian_int.serialize(obj) 9 | return sedes.binary.serialize(obj) 10 | 11 | def deserialize(self, serial: bytes) -> int: 12 | if len(serial) == 32: 13 | return sedes.binary.deserialize(serial) 14 | return sedes.big_endian_int.deserialize(serial) 15 | 16 | 17 | 18 | class AddressOrNone: 19 | 20 | def serialize(self, obj): 21 | if obj == None: 22 | return '' 23 | return address.serialize(obj) 24 | 25 | def deserialize(self, serial): 26 | if serial is None or serial == '': 27 | return None 28 | return address.deserialize(serial) 29 | 30 | 31 | class HashOrNone: 32 | 33 | def serialize(self, obj): 34 | if obj == None: 35 | return '' 36 | return sedes.binary.serialize(obj) 37 | 38 | def deserialize(self, serial): 39 | if serial is None or serial == '': 40 | return None 41 | return sedes.binary.deserialize(serial) -------------------------------------------------------------------------------- /docs/rpc/net.rst: -------------------------------------------------------------------------------- 1 | ================================= 2 | net JSON RPC Documentation 3 | ================================= 4 | 5 | 6 | This is the documentation for our main RPC module called net. 7 | At this point, our net module is identical to that of Ethereum. You can find documentation for it here: https://github.com/ethereum/wiki/wiki/JSON-RPC 8 | 9 | 10 | 11 | RPC Functions 12 | ------------- 13 | 14 | All RPC calls must also include parameters jsonrpc and id. jsonrpc is the version of the rpc, which is currently "2.0", and id should be a unique number for each call you make. 15 | 16 | Example: 17 | :: 18 | 19 | {"jsonrpc": "2.0", "method": "net_version", "params": [], "id":1337} 20 | 21 | net_version 22 | ~~~~~~~~~~~ 23 | 24 | Returns the network id of the node. 25 | https://github.com/ethereum/wiki/wiki/JSON-RPC#net_version 26 | 27 | 28 | net_peerCount 29 | ~~~~~~~~~~~~~ 30 | 31 | Returns the number of peers currently connected to this node. 32 | https://github.com/ethereum/wiki/wiki/JSON-RPC#net_peerCount 33 | 34 | 35 | net_listening 36 | ~~~~~~~~~~~~~ 37 | 38 | Returns `True` if the client is actively listening for network connections 39 | https://github.com/ethereum/wiki/wiki/JSON-RPC#net_listening 40 | -------------------------------------------------------------------------------- /helios/protocol/hls/handlers.py: -------------------------------------------------------------------------------- 1 | from helios.protocol.common.handlers import ( 2 | BaseExchangeHandler, 3 | ) 4 | 5 | from .exchanges import ( 6 | # GetBlockBodiesExchange, 7 | # GetBlockHeadersExchange, 8 | # GetNodeDataExchange, 9 | # GetReceiptsExchange, 10 | GetBlocksExchange, 11 | GetNodeStakingScoreExchange, 12 | GetHashFragmentsExchange, GetChainsExchange, GetChainSegmentExchange, GetMinGasParametersExchange) 13 | 14 | 15 | class HLSExchangeHandler(BaseExchangeHandler): 16 | 17 | _exchange_config = { 18 | 'get_blocks': GetBlocksExchange, 19 | 'get_node_staking_score': GetNodeStakingScoreExchange, 20 | 'get_hash_fragments': GetHashFragmentsExchange, 21 | 'get_chains': GetChainsExchange, 22 | 'get_chain_segment': GetChainSegmentExchange, 23 | 'get_min_gas_parameters': GetMinGasParametersExchange, 24 | } 25 | 26 | # These are needed only to please mypy. 27 | get_blocks: GetBlocksExchange 28 | get_node_staking_score: GetNodeStakingScoreExchange 29 | get_hash_fragments: GetHashFragmentsExchange 30 | get_chains: GetChainsExchange 31 | get_chain_segment: GetChainSegmentExchange 32 | get_min_gas_parameters: GetMinGasParametersExchange 33 | -------------------------------------------------------------------------------- /hvm/vm/logic/memory.py: -------------------------------------------------------------------------------- 1 | from hvm import constants 2 | 3 | 4 | def mstore(computation): 5 | start_position = computation.stack_pop(type_hint=constants.UINT256) 6 | value = computation.stack_pop(type_hint=constants.BYTES) 7 | 8 | padded_value = value.rjust(32, b'\x00') 9 | normalized_value = padded_value[-32:] 10 | 11 | computation.extend_memory(start_position, 32) 12 | 13 | computation.memory_write(start_position, 32, normalized_value) 14 | 15 | 16 | def mstore8(computation): 17 | start_position = computation.stack_pop(type_hint=constants.UINT256) 18 | value = computation.stack_pop(type_hint=constants.BYTES) 19 | 20 | padded_value = value.rjust(1, b'\x00') 21 | normalized_value = padded_value[-1:] 22 | 23 | computation.extend_memory(start_position, 1) 24 | 25 | computation.memory_write(start_position, 1, normalized_value) 26 | 27 | 28 | def mload(computation): 29 | start_position = computation.stack_pop(type_hint=constants.UINT256) 30 | 31 | computation.extend_memory(start_position, 32) 32 | 33 | value = computation.memory_read(start_position, 32) 34 | computation.stack_push(value) 35 | 36 | 37 | def msize(computation): 38 | computation.stack_push(len(computation._memory)) 39 | -------------------------------------------------------------------------------- /helios/plugins/builtin/peer_blacklist/plugin.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | 3 | from helios.extensibility import ( 4 | BaseEvent, 5 | BaseAsyncStopPlugin, 6 | ) 7 | from helios.plugins.builtin.peer_blacklist.peer_blacklist import PeerBlacklistHandler 8 | 9 | 10 | class PeerBlacklistPlugin(BaseAsyncStopPlugin): 11 | 12 | handler: PeerBlacklistHandler = None 13 | 14 | @property 15 | def name(self) -> str: 16 | return "PeerBlacklistPlugin" 17 | 18 | def should_start(self) -> bool: 19 | return True 20 | 21 | def start(self) -> None: 22 | self.logger.info('PeerBlacklistPlugin started') 23 | self.handler = PeerBlacklistHandler(self.context.event_bus) 24 | asyncio.ensure_future(self.handler.run()) 25 | 26 | async def stop(self) -> None: 27 | # This isn't really needed for the standard shutdown case as the PeerBlacklistPlugin will 28 | # automatically shutdown whenever the `CancelToken` it was chained with is triggered. 29 | # It may still be useful to stop the LightPeerChain Bridge plugin individually though. 30 | if self.handler.is_operational: 31 | await self.handler.cancel() 32 | self.logger.info("Successfully stopped PeerBlacklistPlugin") 33 | -------------------------------------------------------------------------------- /hvm/rlp/collations.py: -------------------------------------------------------------------------------- 1 | import rlp_cython as rlp 2 | 3 | from hvm.utils.datatypes import ( 4 | Configurable, 5 | ) 6 | from hvm.utils.hexadecimal import ( 7 | encode_hex, 8 | ) 9 | 10 | from .headers import CollationHeader 11 | from .sedes import collation_body 12 | 13 | from eth_typing import ( 14 | Address, 15 | Hash32, 16 | ) 17 | 18 | 19 | class Collation(rlp.Serializable, Configurable): 20 | 21 | fields = [ 22 | ("header", CollationHeader), 23 | ("body", collation_body), 24 | ] 25 | 26 | @property 27 | def hash(self) -> Hash32: 28 | return self.header.hash 29 | 30 | @property 31 | def shard_id(self) -> int: 32 | return self.header.shard_id 33 | 34 | @property 35 | def chunk_root(self) -> Hash32: 36 | return self.header.chunk_root 37 | 38 | @property 39 | def period(self) -> int: 40 | return self.header.period 41 | 42 | @property 43 | def proposer_address(self) -> Address: 44 | return self.header.proposer_address 45 | 46 | def __repr__(self) -> str: 47 | return "".format( 48 | self.shard_id, 49 | self.period, 50 | encode_hex(self.hash)[2:10], 51 | ) 52 | -------------------------------------------------------------------------------- /hvm/db/keymap.py: -------------------------------------------------------------------------------- 1 | from abc import ( 2 | abstractmethod, 3 | ) 4 | 5 | from hvm.db.backends.base import BaseDB 6 | 7 | 8 | class KeyMapDB(BaseDB): 9 | """ 10 | Modify keys when accessing the database, according to the 11 | abstract keymap function set in the subclass. 12 | """ 13 | def __init__(self, db): 14 | self._db = db 15 | 16 | @staticmethod 17 | @abstractmethod 18 | def keymap(key: bytes) -> bytes: 19 | raise NotImplementedError 20 | 21 | def __getitem__(self, key): 22 | mapped_key = self.keymap(key) 23 | return self._db[mapped_key] 24 | 25 | def __setitem__(self, key, val): 26 | mapped_key = self.keymap(key) 27 | self._db[mapped_key] = val 28 | 29 | def __delitem__(self, key): 30 | mapped_key = self.keymap(key) 31 | del self._db[mapped_key] 32 | 33 | def __contains__(self, key): 34 | mapped_key = self.keymap(key) 35 | return mapped_key in self._db 36 | 37 | def __getattr__(self, attr): 38 | return getattr(self._db, attr) 39 | 40 | def __setattr__(self, attr, val): 41 | if attr in ('_db', 'keymap'): 42 | super().__setattr__(attr, val) 43 | else: 44 | setattr(self._db, attr, val) 45 | -------------------------------------------------------------------------------- /hvm/vm/forks/boson/validation.py: -------------------------------------------------------------------------------- 1 | from hvm.rlp.transactions import ( 2 | BaseTransaction, 3 | BaseReceiveTransaction 4 | ) 5 | from typing import Union, Optional # noqa: F401 6 | 7 | from hvm.vm.forks.helios_testnet.validation import validate_helios_testnet_transaction, \ 8 | validate_helios_testnet_transaction_against_header 9 | 10 | 11 | def validate_boson_transaction(account_db, 12 | send_transaction: BaseTransaction, 13 | caller_chain_address:bytes, 14 | receive_transaction: Optional[BaseReceiveTransaction] = None, 15 | refund_receive_transaction: Optional[BaseReceiveTransaction] = None): 16 | 17 | return validate_helios_testnet_transaction(account_db, 18 | send_transaction, 19 | caller_chain_address, 20 | receive_transaction, 21 | refund_receive_transaction) 22 | 23 | 24 | def validate_boson_transaction_against_header(_vm, base_header, send_transaction): 25 | return validate_helios_testnet_transaction_against_header(_vm, base_header, send_transaction) 26 | -------------------------------------------------------------------------------- /helios/utils/blockchain_db_health.py: -------------------------------------------------------------------------------- 1 | from hvm import MainnetChain 2 | from hvm import constants 3 | from hvm.chains.mainnet import ( 4 | MAINNET_GENESIS_PARAMS, 5 | MAINNET_GENESIS_STATE, 6 | GENESIS_PRIVATE_KEY_FOR_TESTNET, 7 | ) 8 | 9 | from hvm.db.backends.level import LevelDB 10 | from hvm.db.journal import JournalDB 11 | 12 | 13 | def fix_blockchain_database_errors(base_db): 14 | ''' 15 | Checks to make sure all chains match what is expected from saved chain head root hash 16 | :param base_db: 17 | :return: 18 | ''' 19 | node_1 = MainnetChain(base_db, GENESIS_PRIVATE_KEY_FOR_TESTNET.public_key.to_canonical_address(), GENESIS_PRIVATE_KEY_FOR_TESTNET) 20 | chain_head_hashes = node_1.chain_head_db.get_head_block_hashes_list() 21 | 22 | for head_hash in chain_head_hashes: 23 | address = node_1.chaindb.get_chain_wallet_address_for_block_hash(head_hash) 24 | # make sure the head block matches the expected head_hash 25 | chain_head_header = node_1.chaindb.get_canonical_head_hash(address) 26 | 27 | if chain_head_header != head_hash: 28 | print('fuck') 29 | exit() 30 | 31 | base_db = JournalDB(LevelDB('/home/tommy/.local/share/helios/instance_0/chain')) 32 | fix_blockchain_database_errors(base_db) -------------------------------------------------------------------------------- /hvm/vm/forks/frontier/validation.py: -------------------------------------------------------------------------------- 1 | from hvm.exceptions import ( 2 | ValidationError, 3 | ) 4 | 5 | 6 | def validate_frontier_transaction(account_db, transaction): 7 | gas_cost = transaction.gas * transaction.gas_price 8 | sender_balance = account_db.get_balance(transaction.sender) 9 | 10 | if sender_balance < gas_cost: 11 | raise ValidationError( 12 | "Sender account balance cannot afford txn gas: `{0}`".format(transaction.sender) 13 | ) 14 | 15 | total_cost = transaction.value + gas_cost 16 | 17 | if sender_balance < total_cost: 18 | raise ValidationError("Sender account balance cannot afford txn") 19 | 20 | if account_db.get_nonce(transaction.sender) != transaction.nonce: 21 | raise ValidationError("Invalid transaction nonce") 22 | 23 | 24 | def validate_frontier_transaction_against_header(_vm, base_header, transaction): 25 | if base_header.gas_used + transaction.gas > base_header.gas_limit: 26 | raise ValidationError( 27 | "Transaction exceeds gas limit: using {}, bringing total to {}, but limit is {}".format( 28 | transaction.gas, 29 | base_header.gas_used + transaction.gas, 30 | base_header.gas_limit, 31 | ) 32 | ) 33 | -------------------------------------------------------------------------------- /helios/protocol/common/types.py: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Dict, 3 | Tuple, 4 | TypeVar, 5 | ) 6 | 7 | from hvm.rlp.receipts import Receipt 8 | from eth_typing import ( 9 | Hash32, 10 | ) 11 | from hp2p.peer import BasePeer 12 | from hp2p.protocol import PayloadType 13 | 14 | from helios.rlp_templates.hls import BlockBody 15 | 16 | TPeer = TypeVar('TPeer', bound=BasePeer) 17 | 18 | # A payload delivered by a responding command 19 | TResponsePayload = TypeVar('TResponsePayload', bound=PayloadType) 20 | 21 | # The returned value at the end of an exchange 22 | TResult = TypeVar('TResult') 23 | 24 | # ( 25 | # (node_hash, node), 26 | # ... 27 | # ) 28 | NodeDataBundles = Tuple[Tuple[Hash32, bytes], ...] 29 | 30 | # (receipts_in_block_a, receipts_in_block_b, ...) 31 | ReceiptsByBlock = Tuple[Tuple[Receipt, ...], ...] 32 | 33 | # ( 34 | # (receipts_in_block_a, (receipts_root_hash, receipts_trie_nodes), 35 | # (receipts_in_block_b, (receipts_root_hash, receipts_trie_nodes), 36 | # ... 37 | # ( 38 | ReceiptsBundles = Tuple[Tuple[Tuple[Receipt, ...], Tuple[Hash32, Dict[Hash32, bytes]]], ...] 39 | 40 | # (BlockBody, (txn_root, txn_trie_data), uncles_hash) 41 | BlockBodyBundles = Tuple[Tuple[ 42 | BlockBody, 43 | Tuple[Hash32, Dict[Hash32, bytes]], 44 | Hash32, 45 | ], ...] 46 | -------------------------------------------------------------------------------- /helios/protocol/les/trackers.py: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Optional, 3 | Tuple, 4 | ) 5 | 6 | from hvm.rlp.headers import BlockHeader 7 | 8 | from helios.protocol.common.trackers import BasePerformanceTracker 9 | from helios.utils.headers import sequence_builder 10 | 11 | from .requests import ( 12 | GetBlockHeadersRequest, 13 | ) 14 | 15 | 16 | BaseGetBlockHeadersTracker = BasePerformanceTracker[ 17 | GetBlockHeadersRequest, 18 | Tuple[BlockHeader, ...], 19 | ] 20 | 21 | 22 | class GetBlockHeadersTracker(BaseGetBlockHeadersTracker): 23 | def _get_request_size(self, request: GetBlockHeadersRequest) -> Optional[int]: 24 | payload = request.command_payload['query'] 25 | if isinstance(payload['block_number_or_hash'], int): 26 | return len(sequence_builder( 27 | start_number=payload['block_number_or_hash'], 28 | max_length=payload['max_headers'], 29 | skip=payload['skip'], 30 | reverse=payload['reverse'], 31 | )) 32 | else: 33 | return None 34 | 35 | def _get_result_size(self, result: Tuple[BlockHeader, ...]) -> int: 36 | return len(result) 37 | 38 | def _get_result_item_count(self, result: Tuple[BlockHeader, ...]) -> int: 39 | return len(result) 40 | -------------------------------------------------------------------------------- /helios/plugins/builtin/attach/plugin.py: -------------------------------------------------------------------------------- 1 | from argparse import ( 2 | ArgumentParser, 3 | Namespace, 4 | _SubParsersAction, 5 | ) 6 | import sys 7 | 8 | from helios.config import ( 9 | ChainConfig, 10 | ) 11 | from helios.extensibility import ( 12 | BaseMainProcessPlugin, 13 | ) 14 | 15 | from helios.plugins.builtin.attach.console import ( 16 | console, 17 | ) 18 | 19 | 20 | class AttachPlugin(BaseMainProcessPlugin): 21 | 22 | def __init__(self, use_ipython: bool = True) -> None: 23 | super().__init__() 24 | self.use_ipython = use_ipython 25 | 26 | @property 27 | def name(self) -> str: 28 | return "Attach" 29 | 30 | def configure_parser(self, arg_parser: ArgumentParser, subparser: _SubParsersAction) -> None: 31 | 32 | attach_parser = subparser.add_parser( 33 | 'attach', 34 | help='open an REPL attached to a currently running chain', 35 | ) 36 | 37 | attach_parser.set_defaults(func=self.run_console) 38 | 39 | def run_console(self, args: Namespace, chain_config: ChainConfig) -> None: 40 | try: 41 | console(chain_config.jsonrpc_ipc_path, use_ipython=self.use_ipython) 42 | except FileNotFoundError as err: 43 | self.logger.error(str(err)) 44 | sys.exit(1) 45 | -------------------------------------------------------------------------------- /hvm/vm/forks/spurious_dragon/opcodes.py: -------------------------------------------------------------------------------- 1 | import copy 2 | 3 | from cytoolz import merge 4 | 5 | from hvm.vm.forks.tangerine_whistle.constants import ( 6 | GAS_SELFDESTRUCT_EIP150, 7 | GAS_CALL_EIP150 8 | ) 9 | from hvm.vm import mnemonics 10 | from hvm.vm import opcode_values 11 | from hvm.vm.forks.tangerine_whistle.opcodes import TANGERINE_WHISTLE_OPCODES 12 | from hvm.vm.logic import ( 13 | arithmetic, 14 | system, 15 | call, 16 | ) 17 | from hvm.vm.opcode import as_opcode 18 | 19 | from .constants import ( 20 | GAS_EXP_EIP160, 21 | GAS_EXPBYTE_EIP160 22 | ) 23 | 24 | 25 | UPDATED_OPCODES = { 26 | opcode_values.EXP: as_opcode( 27 | logic_fn=arithmetic.exp(gas_per_byte=GAS_EXPBYTE_EIP160), 28 | mnemonic=mnemonics.EXP, 29 | gas_cost=GAS_EXP_EIP160, 30 | ), 31 | opcode_values.SELFDESTRUCT: as_opcode( 32 | logic_fn=system.selfdestruct_eip161, 33 | mnemonic=mnemonics.SELFDESTRUCT, 34 | gas_cost=GAS_SELFDESTRUCT_EIP150, 35 | ), 36 | opcode_values.CALL: call.CallEIP161.configure( 37 | __name__='opcode:CALL', 38 | mnemonic=mnemonics.CALL, 39 | gas_cost=GAS_CALL_EIP150, 40 | )(), 41 | } 42 | 43 | 44 | SPURIOUS_DRAGON_OPCODES = merge( 45 | copy.deepcopy(TANGERINE_WHISTLE_OPCODES), 46 | UPDATED_OPCODES, 47 | ) 48 | -------------------------------------------------------------------------------- /helios/protocol/common/context.py: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Tuple, 3 | Type, 4 | TYPE_CHECKING, 5 | List, 6 | ) 7 | 8 | from hvm.vm.base import BaseVM 9 | 10 | from hp2p.peer import BasePeerContext 11 | 12 | from helios.db.base import AsyncBaseDB 13 | from helios.db.chain import AsyncChainDB 14 | from helios.db.chain_head import AsyncChainHeadDB 15 | from helios.db.consensus import AsyncConsensusDB 16 | from helios.chains.coro import AsyncChain 17 | 18 | if TYPE_CHECKING: 19 | from helios.config import ChainConfig 20 | 21 | 22 | class ChainContext(BasePeerContext): 23 | def __init__(self, 24 | base_db: AsyncBaseDB, 25 | chains: List[AsyncChain], 26 | chaindb: AsyncChainDB, 27 | chain_head_db: AsyncChainHeadDB, 28 | consensus_db: AsyncConsensusDB, 29 | chain_config: 'ChainConfig', 30 | network_id: int, 31 | vm_configuration: Tuple[Tuple[int, Type[BaseVM]], ...]) -> None: 32 | self.base_db = base_db 33 | self.chains = chains 34 | self.chaindb = chaindb 35 | self.chain_head_db = chain_head_db 36 | self.consensus_db = consensus_db 37 | self.chain_config = chain_config 38 | self.network_id = network_id 39 | self.vm_configuration = vm_configuration 40 | -------------------------------------------------------------------------------- /hvm/precompiles/ecmul.py: -------------------------------------------------------------------------------- 1 | from py_ecc import ( 2 | optimized_bn128 as bn128, 3 | ) 4 | 5 | from hvm import constants 6 | from hvm.exceptions import ( 7 | ValidationError, 8 | VMError, 9 | ) 10 | from hvm.utils.bn128 import ( 11 | validate_point, 12 | ) 13 | from hvm.utils.numeric import ( 14 | big_endian_to_int, 15 | int_to_big_endian, 16 | ) 17 | from hvm.utils.padding import ( 18 | pad32, 19 | pad32r, 20 | ) 21 | 22 | 23 | def ecmul(computation): 24 | computation.consume_gas(constants.GAS_ECMUL, reason='ECMUL Precompile') 25 | 26 | try: 27 | result = _ecmull(computation.msg.data) 28 | except ValidationError: 29 | raise VMError("Invalid ECMUL parameters") 30 | 31 | result_x, result_y = result 32 | result_bytes = b''.join(( 33 | pad32(int_to_big_endian(result_x.n)), 34 | pad32(int_to_big_endian(result_y.n)), 35 | )) 36 | computation.output = result_bytes 37 | return computation 38 | 39 | 40 | def _ecmull(data): 41 | x_bytes = pad32r(data[:32]) 42 | y_bytes = pad32r(data[32:64]) 43 | m_bytes = pad32r(data[64:96]) 44 | 45 | x = big_endian_to_int(x_bytes) 46 | y = big_endian_to_int(y_bytes) 47 | m = big_endian_to_int(m_bytes) 48 | 49 | p = validate_point(x, y) 50 | 51 | result = bn128.normalize(bn128.multiply(p, m)) 52 | return result 53 | -------------------------------------------------------------------------------- /helios/rpc/modules/main.py: -------------------------------------------------------------------------------- 1 | from helios.chains.coro import ( 2 | AsyncChain 3 | ) 4 | 5 | from lahja import ( 6 | Endpoint 7 | ) 8 | 9 | from typing import Type, TYPE_CHECKING 10 | from eth_typing import Address 11 | from eth_keys.datatypes import PrivateKey 12 | 13 | if TYPE_CHECKING: 14 | from .personal import Personal 15 | from helios.rpc.main import RPCContext 16 | 17 | class RPCModule: 18 | _chain: AsyncChain = None 19 | _chain_class: Type[AsyncChain] = None 20 | _rpc_context: "RPCContext" = None 21 | 22 | 23 | def __init__(self, chain: AsyncChain, event_bus: Endpoint, rpc_context: "RPCContext", chain_class: Type[AsyncChain] = None) -> None: 24 | self._chain = chain 25 | self._chain_class: Type[AsyncChain] = chain_class 26 | self._event_bus = event_bus 27 | self._rpc_context = rpc_context 28 | 29 | def set_chain(self, chain: AsyncChain) -> None: 30 | self._chain = chain 31 | 32 | def get_new_chain(self, chain_address: Address = None, private_key: PrivateKey = None) -> AsyncChain: 33 | if chain_address is None: 34 | return self._chain_class(self._chain.db, wallet_address=self._chain.wallet_address, private_key = private_key) 35 | else: 36 | return self._chain_class(self._chain.db, wallet_address=chain_address, private_key = private_key) 37 | 38 | 39 | -------------------------------------------------------------------------------- /hvm/tools/fixtures/fillers/main.py: -------------------------------------------------------------------------------- 1 | from cytoolz import ( 2 | assoc_in, 3 | merge, 4 | ) 5 | 6 | from hvm.tools.fixtures.helpers import ( 7 | get_test_name, 8 | ) 9 | from hvm.tools._utils.git import get_version_from_git 10 | 11 | from .formatters import ( 12 | filled_state_test_formatter, 13 | filled_vm_test_formatter, 14 | ) 15 | from .state import fill_state_test 16 | from .vm import fill_vm_test 17 | 18 | 19 | FILLED_WITH_TEMPLATE = "py-evm-{version}" 20 | 21 | 22 | # 23 | # Primary test filler 24 | # 25 | def fill_test(filler, info=None, apply_formatter=True, **kwargs): 26 | test_name = get_test_name(filler) 27 | test = filler[test_name] 28 | 29 | if "transaction" in test: 30 | filled = fill_state_test(filler) 31 | formatter = filled_state_test_formatter 32 | elif "exec" in test: 33 | filled = fill_vm_test(filler, **kwargs) 34 | formatter = filled_vm_test_formatter 35 | else: 36 | raise ValueError("Given filler does not appear to be for VM or state test") 37 | 38 | info = merge( 39 | {"filledwith": FILLED_WITH_TEMPLATE.format(version=get_version_from_git())}, 40 | info if info else {} 41 | ) 42 | filled = assoc_in(filled, [test_name, "_info"], info) 43 | 44 | if apply_formatter: 45 | return formatter(filled) 46 | else: 47 | return filled 48 | -------------------------------------------------------------------------------- /hvm/utils/state.py: -------------------------------------------------------------------------------- 1 | from eth_utils import ( 2 | to_tuple, 3 | ) 4 | 5 | 6 | @to_tuple 7 | def diff_account_db(expected_state, account_db): 8 | for account, account_data in sorted(expected_state.items()): 9 | expected_nonce = account_data['nonce'] 10 | expected_code = account_data['code'] 11 | expected_balance = account_data['balance'] 12 | 13 | actual_nonce = account_db.get_nonce(account) 14 | actual_code = account_db.get_code(account) 15 | actual_balance = account_db.get_balance(account) 16 | 17 | if actual_nonce != expected_nonce: 18 | yield (account, 'nonce', actual_nonce, expected_nonce) 19 | if actual_code != expected_code: 20 | yield (account, 'code', actual_code, expected_code) 21 | if actual_balance != expected_balance: 22 | yield (account, 'balance', actual_balance, expected_balance) 23 | 24 | for slot, expected_storage_value in sorted(account_data['storage'].items()): 25 | actual_storage_value = account_db.get_storage(account, slot) 26 | if actual_storage_value != expected_storage_value: 27 | yield ( 28 | account, 29 | 'storage[{0}]'.format(slot), 30 | actual_storage_value, 31 | expected_storage_value, 32 | ) 33 | -------------------------------------------------------------------------------- /helios/rpc/modules/evm.py: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Any 3 | ) 4 | from eth_utils import ( 5 | encode_hex, 6 | ) 7 | 8 | from hvm.chains.base import ( 9 | Chain 10 | ) 11 | from hvm.tools.fixtures import ( 12 | apply_fixture_block_to_chain, 13 | new_chain_from_fixture, 14 | normalize_block, 15 | normalize_blockchain_fixtures, 16 | ) 17 | 18 | from helios.rpc.format import ( 19 | format_params, 20 | ) 21 | from helios.rpc.modules import ( 22 | RPCModule, 23 | ) 24 | 25 | 26 | class EVM(RPCModule): 27 | @format_params(normalize_blockchain_fixtures) 28 | async def resetToGenesisFixture(self, chain_info: Any) -> Chain: 29 | ''' 30 | This method is a special case. It returns a new chain object 31 | which is then replaced inside :class:`~helios.rpc.main.RPCServer` 32 | for all future calls. 33 | ''' 34 | return new_chain_from_fixture(chain_info, type(self._chain)) 35 | 36 | @format_params(normalize_block) 37 | async def applyBlockFixture(self, block_info: Any) -> str: 38 | ''' 39 | This method is a special case. It returns a new chain object 40 | which is then replaced inside :class:`~helios.rpc.main.RPCServer` 41 | for all future calls. 42 | ''' 43 | _, _, rlp_encoded = apply_fixture_block_to_chain(block_info, self._chain) 44 | return encode_hex(rlp_encoded) 45 | -------------------------------------------------------------------------------- /helios/utils/db_proxy.py: -------------------------------------------------------------------------------- 1 | from multiprocessing.managers import ( 2 | BaseManager, 3 | ) 4 | import pathlib 5 | 6 | from helios.chains import ( 7 | ChainProxy, 8 | ) 9 | from helios.db.chain import ChainDBProxy 10 | from helios.db.chain_head import ChainHeadDBProxy 11 | from helios.db.base import DBProxy 12 | from helios.db.consensus import ConsensusDBProxy 13 | 14 | 15 | def create_db_manager(ipc_path: pathlib.Path) -> BaseManager: 16 | """ 17 | We're still using 'str' here on param ipc_path because an issue with 18 | multi-processing not being able to interpret 'Path' objects correctly 19 | """ 20 | class DBManager(BaseManager): 21 | pass 22 | 23 | # Typeshed definitions for multiprocessing.managers is incomplete, so ignore them for now: 24 | # https://github.com/python/typeshed/blob/85a788dbcaa5e9e9a62e55f15d44530cd28ba830/stdlib/3/multiprocessing/managers.pyi#L3 25 | DBManager.register('get_db', proxytype=DBProxy) # type: ignore 26 | DBManager.register('get_chaindb', proxytype=ChainDBProxy) # type: ignore 27 | #DBManager.register('get_chain', proxytype=ChainProxy) # type: ignore 28 | DBManager.register('get_chain_head_db', proxytype=ChainHeadDBProxy) # type: ignore 29 | DBManager.register('get_consensus_db', proxytype=ConsensusDBProxy) # type: ignore 30 | 31 | manager = DBManager(address=str(ipc_path)) # type: ignore 32 | return manager 33 | -------------------------------------------------------------------------------- /helios/utils/verification.py: -------------------------------------------------------------------------------- 1 | import getpass 2 | import hashlib 3 | import os 4 | from helios.constants import SCRYPT_N, SCRYPT_P, SCRYPT_R 5 | import json 6 | 7 | def save_rpc_admin_password(password, file_location): 8 | password_bytes = bytes(password, 'utf-8') 9 | salt_bytes = os.urandom(32) 10 | 11 | password_hash = hashlib.scrypt(password=password_bytes, salt=salt_bytes, n=SCRYPT_N, r=SCRYPT_P, p=SCRYPT_R) 12 | 13 | # the first 32 bytes are salt, the rest is the password hash 14 | 15 | to_save_bytes = salt_bytes + password_hash 16 | 17 | f = open(file_location, 'wb') 18 | f.write(to_save_bytes) 19 | f.close() 20 | 21 | 22 | def verify_rpc_admin_password(password, file_location): 23 | # the first 32 bytes are salt, the rest is the password hash 24 | try: 25 | with open(file_location, 'rb') as f: 26 | salt_bytes = f.read(32) 27 | existing_password_hash = f.read() 28 | 29 | test_password_bytes = bytes(password, 'utf-8') 30 | 31 | test_password_hash = hashlib.scrypt(password=test_password_bytes, salt=salt_bytes, n=SCRYPT_N, r=SCRYPT_P, p=SCRYPT_R) 32 | 33 | return test_password_hash == existing_password_hash 34 | except Exception: 35 | raise Exception("A problem occurred when verifying the password. Ensure that you have set a password by starting the node with the set-admin-rpc-password argument") 36 | 37 | -------------------------------------------------------------------------------- /old_tests/core/env-utils/test_env_float.py: -------------------------------------------------------------------------------- 1 | import os 2 | import pytest 3 | 4 | from hvm.utils.env import ( 5 | env_float, 6 | ) 7 | 8 | 9 | @pytest.mark.parametrize( 10 | 'env_value,expected', 11 | ( 12 | ('1.01', 1.01), 13 | ('123.0', 123.0), 14 | ('-123.99', -123.99), 15 | ) 16 | ) 17 | def test_env_float_not_required_with_no_default(monkeypatch, env_value, expected): 18 | """ 19 | Test that when the environment variable is present that it is parsed to a float. 20 | """ 21 | monkeypatch.setenv('TEST_FLOAT_ENV_VARIABLE', env_value) 22 | 23 | actual = env_float('TEST_FLOAT_ENV_VARIABLE') 24 | assert actual == expected 25 | 26 | 27 | def test_env_float_not_required_and_not_set(): 28 | """ 29 | Test that when the env variable is not set and not required it raises a 30 | ValueError 31 | """ 32 | # sanity check 33 | assert 'TEST_FLOAT_ENV_VARIABLE' not in os.environ 34 | 35 | with pytest.raises(ValueError): 36 | env_float('TEST_FLOAT_ENV_VARIABLE') 37 | 38 | 39 | def test_env_float_when_missing_and_required_is_error(): 40 | """ 41 | Test that when the env variable is not set and is required, it raises an 42 | error. 43 | """ 44 | # sanity check 45 | assert 'TEST_FLOAT_ENV_VARIABLE' not in os.environ 46 | 47 | with pytest.raises(KeyError): 48 | env_float('TEST_FLOAT_ENV_VARIABLE', required=True) 49 | -------------------------------------------------------------------------------- /helios/utils/shutdown.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | from async_generator import ( 3 | asynccontextmanager, 4 | ) 5 | import signal 6 | from typing import ( 7 | AsyncGenerator, 8 | ) 9 | 10 | from lahja import ( 11 | Endpoint, 12 | ) 13 | 14 | from hp2p.service import ( 15 | BaseService, 16 | ) 17 | 18 | 19 | async def exit_with_service_and_endpoint(service_to_exit: BaseService, endpoint: Endpoint) -> None: 20 | async with exit_signal_with_service(service_to_exit): 21 | endpoint.stop() 22 | 23 | 24 | async def exit_with_service(service_to_exit: BaseService) -> None: 25 | async with exit_signal_with_service(service_to_exit): 26 | pass 27 | 28 | 29 | @asynccontextmanager 30 | async def exit_signal_with_service(service_to_exit: BaseService) -> AsyncGenerator[None, None]: 31 | loop = service_to_exit.get_event_loop() 32 | async with exit_signal(loop): 33 | await service_to_exit.cancel() 34 | yield 35 | service_to_exit._executor.shutdown(wait=True) 36 | 37 | 38 | @asynccontextmanager 39 | async def exit_signal(loop: asyncio.AbstractEventLoop) -> AsyncGenerator[None, None]: 40 | sigint_received = asyncio.Event() 41 | for sig in [signal.SIGINT, signal.SIGTERM]: 42 | # TODO also support Windows 43 | loop.add_signal_handler(sig, sigint_received.set) 44 | 45 | await sigint_received.wait() 46 | try: 47 | yield 48 | finally: 49 | loop.stop() 50 | 51 | 52 | -------------------------------------------------------------------------------- /old_tests/core/env-utils/test_env_string.py: -------------------------------------------------------------------------------- 1 | import os 2 | import pytest 3 | 4 | from hvm.utils.env import ( 5 | env_string, 6 | ) 7 | 8 | 9 | def test_env_string_with_basic_usage(monkeypatch): 10 | """ 11 | Test that when the environment variable is present that it is returned as a 12 | string. 13 | """ 14 | monkeypatch.setenv('TEST_BOOLEAN_ENV_VARIABLE', 'test-value') 15 | 16 | actual = env_string('TEST_BOOLEAN_ENV_VARIABLE') 17 | assert actual == 'test-value' 18 | 19 | 20 | def test_env_string_with_default_value(monkeypatch): 21 | """ 22 | Test that when the environment variable is missing and a default is 23 | provided, the default is retured. 24 | """ 25 | assert 'TEST_BOOLEAN_ENV_VARIABLE' not in os.environ 26 | 27 | actual = env_string('TEST_BOOLEAN_ENV_VARIABLE', default='test-value') 28 | assert actual == 'test-value' 29 | 30 | 31 | def test_env_string_with_required(): 32 | """ 33 | Test that when the environment variable is missing and a default is 34 | provided, the default is retured. 35 | """ 36 | assert 'TEST_BOOLEAN_ENV_VARIABLE' not in os.environ 37 | 38 | with pytest.raises(KeyError): 39 | env_string('TEST_BOOLEAN_ENV_VARIABLE', required=True) 40 | 41 | 42 | def test_env_string_with_required_and_default_is_error(): 43 | with pytest.raises(ValueError): 44 | env_string('TEST_BOOLEAN_ENV_VARIABLE', required=True, default='test-value') 45 | -------------------------------------------------------------------------------- /hvm/precompiles/ecadd.py: -------------------------------------------------------------------------------- 1 | from py_ecc import ( 2 | optimized_bn128 as bn128, 3 | ) 4 | 5 | from hvm import constants 6 | from hvm.exceptions import ( 7 | ValidationError, 8 | VMError, 9 | ) 10 | from hvm.utils.bn128 import ( 11 | validate_point, 12 | ) 13 | from hvm.utils.numeric import ( 14 | big_endian_to_int, 15 | int_to_big_endian, 16 | ) 17 | from hvm.utils.padding import ( 18 | pad32, 19 | pad32r, 20 | ) 21 | 22 | 23 | def ecadd(computation): 24 | computation.consume_gas(constants.GAS_ECADD, reason='ECADD Precompile') 25 | 26 | try: 27 | result = _ecadd(computation.msg.data) 28 | except ValidationError: 29 | raise VMError("Invalid ECADD parameters") 30 | 31 | result_x, result_y = result 32 | result_bytes = b''.join(( 33 | pad32(int_to_big_endian(result_x.n)), 34 | pad32(int_to_big_endian(result_y.n)), 35 | )) 36 | computation.output = result_bytes 37 | return computation 38 | 39 | 40 | def _ecadd(data): 41 | x1_bytes = pad32r(data[:32]) 42 | y1_bytes = pad32r(data[32:64]) 43 | x2_bytes = pad32r(data[64:96]) 44 | y2_bytes = pad32r(data[96:128]) 45 | 46 | x1 = big_endian_to_int(x1_bytes) 47 | y1 = big_endian_to_int(y1_bytes) 48 | x2 = big_endian_to_int(x2_bytes) 49 | y2 = big_endian_to_int(y2_bytes) 50 | 51 | p1 = validate_point(x1, y1) 52 | p2 = validate_point(x2, y2) 53 | 54 | result = bn128.normalize(bn128.add(p1, p2)) 55 | return result 56 | -------------------------------------------------------------------------------- /helios/tools/timed_cache.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime, timedelta 2 | import functools 3 | 4 | 5 | def timed_cache(**timedelta_kwargs): 6 | def _wrapper(f): 7 | update_delta = timedelta(**timedelta_kwargs) 8 | next_update = datetime.utcnow() - update_delta 9 | # Apply @lru_cache to f with no cache size limit 10 | f = functools.lru_cache(None)(f) 11 | 12 | @functools.wraps(f) 13 | def _wrapped(*args, **kwargs): 14 | nonlocal next_update 15 | now = datetime.utcnow() 16 | if now >= next_update: 17 | f.cache_clear() 18 | next_update = now + update_delta 19 | return f(*args, **kwargs) 20 | 21 | return _wrapped 22 | 23 | return _wrapper 24 | 25 | def async_timed_cache(**timedelta_kwargs): 26 | async def _wrapper(f): 27 | update_delta = timedelta(**timedelta_kwargs) 28 | next_update = datetime.utcnow() - update_delta 29 | # Apply @lru_cache to f with no cache size limit 30 | f = functools.lru_cache(None)(f) 31 | 32 | @functools.wraps(f) 33 | async def _wrapped(*args, **kwargs): 34 | nonlocal next_update 35 | now = datetime.utcnow() 36 | if now >= next_update: 37 | f.cache_clear() 38 | next_update = now + update_delta 39 | result = await f(*args, **kwargs) 40 | return result 41 | 42 | return _wrapped 43 | 44 | return _wrapper -------------------------------------------------------------------------------- /old_tests/p2p/test_peer_subscriber.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import logging 3 | 4 | import pytest 5 | 6 | from hp2p.peer import PeerSubscriber 7 | from hp2p.protocol import Command 8 | 9 | from hp2p.tools.paragon import GetSum 10 | from hp2p.tools.paragon.helpers import get_directly_linked_peers 11 | 12 | 13 | logger = logging.getLogger('testing.hp2p.PeerSubscriber') 14 | 15 | 16 | class GetSumSubscriber(PeerSubscriber): 17 | logger = logger 18 | msg_queue_maxsize = 10 19 | subscription_msg_types = {GetSum} 20 | 21 | 22 | class AllSubscriber(PeerSubscriber): 23 | logger = logger 24 | msg_queue_maxsize = 10 25 | subscription_msg_types = {Command} 26 | 27 | 28 | @pytest.mark.asyncio 29 | async def test_peer_subscriber_filters_messages(request, event_loop): 30 | peer, remote = await get_directly_linked_peers(request, event_loop) 31 | 32 | get_sum_subscriber = GetSumSubscriber() 33 | all_subscriber = AllSubscriber() 34 | 35 | peer.add_subscriber(get_sum_subscriber) 36 | peer.add_subscriber(all_subscriber) 37 | 38 | remote.sub_proto.send_broadcast_data(b'value-a') 39 | remote.sub_proto.send_broadcast_data(b'value-b') 40 | remote.sub_proto.send_get_sum(7, 8) 41 | remote.sub_proto.send_get_sum(1234, 4321) 42 | remote.sub_proto.send_broadcast_data(b'value-b') 43 | 44 | # yeild to let remote and peer transmit. 45 | await asyncio.sleep(0.02) 46 | 47 | assert get_sum_subscriber.queue_size == 2 48 | assert all_subscriber.queue_size == 5 49 | -------------------------------------------------------------------------------- /hvm/vm/forks/spurious_dragon/state.py: -------------------------------------------------------------------------------- 1 | 2 | from hvm.utils.hexadecimal import ( 3 | encode_hex, 4 | ) 5 | from hvm.vm.forks.homestead.state import ( 6 | HomesteadState, 7 | HomesteadTransactionExecutor, 8 | ) 9 | 10 | from .computation import SpuriousDragonComputation 11 | from .utils import collect_touched_accounts 12 | 13 | 14 | class SpuriousDragonTransactionExecutor(HomesteadTransactionExecutor): 15 | def finalize_computation(self, transaction, computation): 16 | computation = super().finalize_computation(transaction, computation) 17 | 18 | # 19 | # EIP161 state clearing 20 | # 21 | touched_accounts = collect_touched_accounts(computation) 22 | 23 | for account in touched_accounts: 24 | should_delete = ( 25 | self.vm_state.account_db.account_exists(account) and 26 | self.vm_state.account_db.account_is_empty(account) 27 | ) 28 | if should_delete: 29 | self.vm_state.logger.debug( 30 | "CLEARING EMPTY ACCOUNT: %s", 31 | encode_hex(account), 32 | ) 33 | self.vm_state.account_db.delete_account(account) 34 | 35 | return computation 36 | 37 | 38 | class SpuriousDragonState(HomesteadState): 39 | computation_class = SpuriousDragonComputation 40 | computation_class = SpuriousDragonComputation 41 | transaction_executor = SpuriousDragonTransactionExecutor # Type[BaseTransactionExecutor] 42 | -------------------------------------------------------------------------------- /docs/rpc/admin.rst: -------------------------------------------------------------------------------- 1 | ================================= 2 | admin JSON RPC Documentation 3 | ================================= 4 | 5 | 6 | The admin module is used for managing the node. Everything is password protected. To enable it, start the node with the --enable-admin-rpc flag. 7 | 8 | :: 9 | 10 | $ python main.py --enable-admin-rpc flag 11 | 12 | Before you can use the admin module, you must first set a password. You can do this by starting the node with the flag set-admin-rpc-password. 13 | 14 | :: 15 | 16 | $ python main.py set-admin-rpc-password 17 | 18 | 19 | Passwords are hashed using a slow function to prevent brute force attacks. But make sure your password is as secure as possible. 20 | 21 | 22 | RPC Functions 23 | ------------- 24 | All RPC calls must also include parameters jsonrpc and id. jsonrpc is the version of the rpc, which is currently "2.0", and id should be a unique number for each call you make. 25 | 26 | Example: 27 | :: 28 | 29 | {"jsonrpc": "2.0", "method": "hls_ping", "params": [], "id":1337} 30 | 31 | admin_stopRPC 32 | ~~~~~~~~~~~~~ 33 | 34 | Stops the RPC 35 | 36 | **Parameters:** 37 | 38 | 1) The admin rpc password 39 | 40 | **RPC Call:** 41 | 42 | :: 43 | 44 | {"method": "admin_stopRPC", "params": ['my_awesome_password']} 45 | 46 | 47 | admin_startRPC 48 | ~~~~~~~~~~~~~~ 49 | 50 | Starts the RPC 51 | 52 | **Parameters:** 53 | 54 | 1) The admin rpc password 55 | 56 | **RPC Call:** 57 | 58 | :: 59 | 60 | {"method": "admin_startRPC", "params": ['my_awesome_password']} -------------------------------------------------------------------------------- /hp2p/cancellable.py: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Awaitable, 3 | TypeVar, 4 | ) 5 | 6 | from cancel_token import CancelToken 7 | 8 | 9 | class CancellableMixin: 10 | cancel_token: CancelToken = None 11 | 12 | _TReturn = TypeVar('_TReturn') 13 | 14 | async def wait(self, 15 | awaitable: Awaitable[_TReturn], 16 | token: CancelToken = None, 17 | timeout: float = None) -> _TReturn: 18 | """See wait_first()""" 19 | return await self.wait_first(awaitable, token=token, timeout=timeout) 20 | 21 | async def wait_first(self, 22 | *awaitables: Awaitable[_TReturn], 23 | token: CancelToken = None, 24 | timeout: float = None) -> _TReturn: 25 | """ 26 | Wait for the first awaitable to complete, unless we timeout or the token chain is triggered. 27 | 28 | The given token is chained with this service's token, so triggering either will cancel 29 | this. 30 | 31 | Returns the result of the first one to complete. 32 | 33 | Raises TimeoutError if we timeout or OperationCancelled if the token chain is triggered. 34 | 35 | All pending futures are cancelled before returning. 36 | """ 37 | if token is None: 38 | token_chain = self.cancel_token 39 | else: 40 | token_chain = token.chain(self.cancel_token) 41 | return await token_chain.cancellable_wait(*awaitables, timeout=timeout) 42 | -------------------------------------------------------------------------------- /hvm/tools/_utils/mappings.py: -------------------------------------------------------------------------------- 1 | from collections.abc import Mapping 2 | import itertools 3 | 4 | from cytoolz import merge_with 5 | 6 | 7 | def merge_if_dicts(values): 8 | if all(isinstance(item, Mapping) for item in values): 9 | return merge_with(merge_if_dicts, *values) 10 | else: 11 | return values[-1] 12 | 13 | 14 | def deep_merge(*dicts): 15 | return merge_with(merge_if_dicts, *dicts) 16 | 17 | 18 | def is_cleanly_mergable(*dicts): 19 | """Check that nothing will be overwritten when dictionaries are merged using `deep_merge`. 20 | 21 | Examples: 22 | 23 | >>> is_cleanly_mergable({"a": 1}, {"b": 2}, {"c": 3}) 24 | True 25 | >>> is_cleanly_mergable({"a": 1}, {"b": 2}, {"a": 0, c": 3}) 26 | False 27 | >>> is_cleanly_mergable({"a": 1, "b": {"ba": 2}}, {"c": 3, {"b": {"bb": 4}}) 28 | True 29 | >>> is_cleanly_mergable({"a": 1, "b": {"ba": 2}}, {"b": {"ba": 4}}) 30 | False 31 | 32 | """ 33 | if len(dicts) <= 1: 34 | return True 35 | elif len(dicts) == 2: 36 | if not all(isinstance(d, Mapping) for d in dicts): 37 | return False 38 | else: 39 | shared_keys = set(dicts[0].keys()) & set(dicts[1].keys()) 40 | return all(is_cleanly_mergable(dicts[0][key], dicts[1][key]) for key in shared_keys) 41 | else: 42 | dict_combinations = itertools.combinations(dicts, 2) 43 | return all(is_cleanly_mergable(*combination) for combination in dict_combinations) 44 | -------------------------------------------------------------------------------- /helios/plugins/builtin/rpc_http_proxy_through_ipc_socket/plugin.py: -------------------------------------------------------------------------------- 1 | from argparse import ( 2 | ArgumentParser, 3 | _SubParsersAction, 4 | ) 5 | 6 | from helios.extensibility import ( 7 | BaseIsolatedPlugin, 8 | ) 9 | 10 | from helios.plugins.builtin.rpc_http_proxy_through_ipc_socket.http_proxy_server import Proxy as rpc_http_proxy 11 | ### 12 | # This one is not used anymore because it is synchronous. There is a new asynchronous one in the json_rpc folder 13 | # This one connects through IPC as well. So it wont be stopped by admin_stopRPC. 14 | ### 15 | class RpcHTTPProxyPlugin(BaseIsolatedPlugin): 16 | 17 | @property 18 | def name(self) -> str: 19 | return "RPC HTTP Proxy" 20 | 21 | def should_start(self) -> bool: 22 | return (self.context.args.enable_rpc_http_proxy) and self.context.chain_config.is_main_instance 23 | 24 | def configure_parser(self, arg_parser: ArgumentParser, subparser: _SubParsersAction) -> None: 25 | arg_parser.add_argument( 26 | '--enable_rpc_http_proxy-NOT_USED', 27 | action="store_true", 28 | help="Should we enable the RPC http proxy?", 29 | ) 30 | 31 | 32 | def start(self) -> None: 33 | self.logger.info('RPC HTTP proxy started') 34 | self.context.event_bus.connect() 35 | 36 | proxy_url = "http://0.0.0.0:" + str(self.context.chain_config.rpc_port) 37 | rpc_websocket_proxy_service = rpc_http_proxy(proxy_url, self.context.chain_config.jsonrpc_ipc_path) 38 | rpc_websocket_proxy_service.run() 39 | 40 | -------------------------------------------------------------------------------- /old_tests/p2p/test_peer_collect_sub_proto_msgs.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import logging 3 | 4 | import pytest 5 | 6 | from hp2p.tools.paragon import BroadcastData, GetSum 7 | from hp2p.tools.paragon.helpers import ( 8 | get_directly_linked_peers, 9 | ) 10 | 11 | 12 | logger = logging.getLogger('testing.hp2p.PeerSubscriber') 13 | 14 | 15 | @pytest.mark.asyncio 16 | async def test_peer_subscriber_filters_messages(request, event_loop): 17 | peer, remote = await get_directly_linked_peers(request, event_loop) 18 | 19 | with peer.collect_sub_proto_messages() as collector: 20 | assert collector in peer._subscribers 21 | remote.sub_proto.send_broadcast_data(b'broadcast-a') 22 | remote.sub_proto.send_broadcast_data(b'broadcast-b') 23 | remote.sub_proto.send_get_sum(7, 8) 24 | remote.sub_proto.send_broadcast_data(b'broadcast-c') 25 | await asyncio.sleep(0.01) 26 | 27 | assert collector not in peer._subscribers 28 | 29 | # yield to let remote and peer transmit. 30 | 31 | all_messages = collector.get_messages() 32 | assert len(all_messages) == 4 33 | 34 | assert isinstance(all_messages[0][1], BroadcastData) 35 | assert isinstance(all_messages[1][1], BroadcastData) 36 | assert isinstance(all_messages[2][1], GetSum) 37 | assert isinstance(all_messages[3][1], BroadcastData) 38 | 39 | # make sure it isn't still collecting 40 | remote.sub_proto.send_broadcast_data(b'broadcast-d') 41 | 42 | await asyncio.sleep(0.01) 43 | 44 | assert len(collector.get_messages()) == 0 45 | -------------------------------------------------------------------------------- /helios/plugins/builtin/rpc_websocket_proxy_through_ipc_socket/plugin.py: -------------------------------------------------------------------------------- 1 | from argparse import ( 2 | ArgumentParser, 3 | _SubParsersAction, 4 | ) 5 | 6 | from helios.extensibility import ( 7 | BaseIsolatedPlugin, 8 | ) 9 | 10 | from .websocket_proxy_server import Proxy as rpc_websocket_proxy 11 | 12 | ### 13 | # This one is not used anymore because it is synchronous. There is a new asynchronous one in the json_rpc folder 14 | # This one connects through IPC as well. So it wont be stopped by admin_stopRPC. 15 | ### 16 | class RpcWebsocketProxyPlugin(BaseIsolatedPlugin): 17 | 18 | @property 19 | def name(self) -> str: 20 | return "RPC Websocket Proxy" 21 | 22 | def should_start(self) -> bool: 23 | return (not self.context.args.disable_rpc_websocket_proxy) and self.context.chain_config.is_main_instance 24 | 25 | def configure_parser(self, arg_parser: ArgumentParser, subparser: _SubParsersAction) -> None: 26 | arg_parser.add_argument( 27 | '--disable_rpc_websocket_proxy-NOT_USED', 28 | action="store_true", 29 | help="Should we disable the RPC websocket proxy server?", 30 | ) 31 | 32 | 33 | def start(self) -> None: 34 | self.logger.info('RPC Websocket proxy started') 35 | self.context.event_bus.connect() 36 | 37 | proxy_url = "ws://0.0.0.0:" + str(self.context.chain_config.rpc_port) 38 | rpc_websocket_proxy_service = rpc_websocket_proxy(proxy_url, self.context.chain_config.jsonrpc_ipc_path) 39 | rpc_websocket_proxy_service.run() 40 | 41 | 42 | 43 | --------------------------------------------------------------------------------