evm.utils package

Submodules

evm.utils.address module

evm.utils.address.force_bytes_to_address(value)
evm.utils.address.generate_contract_address(address, nonce)

evm.utils.bn128 module

evm.utils.bn128.validate_point(x, y)

evm.utils.chain module

evm.utils.chain.generate_vms_by_range(vm_configuration)

evm.utils.db module

evm.utils.db.make_block_hash_to_score_lookup_key(block_hash)
evm.utils.db.make_block_number_to_hash_lookup_key(block_number)

evm.utils.empty module

class evm.utils.empty.Empty

Bases: object

evm.utils.fixture_tests module

evm.utils.fixture_tests.assert_rlp_equal(left, right)

Helper for asserting two RPL objects are equal, producing a helpful error message with what fields are not equal.

evm.utils.fixture_tests.filter_fixtures

Helper function for filtering test fixtures.

  • fixtures_base_dir should be the base directory that the fixtures were collected from.
  • mark_fn should be a function which either returns None or a pytest.mark object.
  • ignore_fn should be a function which returns True for any fixture
    which should be ignored.
evm.utils.fixture_tests.find_fixture_files(fixtures_base_dir)
evm.utils.fixture_tests.find_fixtures(fixtures_base_dir)

Finds all of the (fixture_path, fixture_key) pairs for a given path under the JSON test fixtures directory.

evm.utils.fixture_tests.generate_fixture_tests

Helper function for use with pytest_generate_tests which will use the pytest caching facilities to reduce the load time for fixture tests.

  • metafunc is the parameter from pytest_generate_tests
  • base_fixture_path is the base path that fixture files will be collected from.
  • filter_fn handles ignoring or marking the various fixtures. See filter_fixtures.
  • preprocess_fn handles any preprocessing that should be done on the raw
    fixtures (such as expanding the statetest fixtures to be multiple tests for each fork.
evm.utils.fixture_tests.get_fixtures_file_hash(all_fixture_paths)

Returns the MD5 hash of the fixture files. Used for cache busting.

evm.utils.fixture_tests.hash_log_entries(log_entries)

Helper function for computing the RLP hash of the logs from transaction execution.

evm.utils.fixture_tests.idfn(fixture_params)

Function for pytest to produce uniform names for fixtures.

evm.utils.fixture_tests.load_fixture(fixture_path, fixture_key, normalize_fn=<cyfunction identity>)

Loads a specific fixture from a fixture file, optionally passing it through a normalization function.

evm.utils.fixture_tests.load_json_fixture

Loads a fixture file, caching the most recent files it loaded.

evm.utils.fixture_tests.normalize_account_state(account_state)
evm.utils.fixture_tests.normalize_block(block)
evm.utils.fixture_tests.normalize_block_header(header)
evm.utils.fixture_tests.normalize_blockchain_fixtures(fixture)
evm.utils.fixture_tests.normalize_callcreates(callcreates)
evm.utils.fixture_tests.normalize_env(env)
evm.utils.fixture_tests.normalize_exec(exec_params)
evm.utils.fixture_tests.normalize_post_state(post_state)
evm.utils.fixture_tests.normalize_signed_transaction(transaction)
evm.utils.fixture_tests.normalize_statetest_fixture
evm.utils.fixture_tests.normalize_to_address
evm.utils.fixture_tests.normalize_transactiontest_fixture(fixture)
evm.utils.fixture_tests.normalize_unsigned_transaction(transaction, indexes)
evm.utils.fixture_tests.normalize_vmtest_fixture(fixture)
evm.utils.fixture_tests.robust_decode_hex(value)
evm.utils.fixture_tests.setup_state_db(desired_state, state_db)
evm.utils.fixture_tests.to_int

Robust to integer conversion, handling hex values, string representations, and special cases like 0x.

evm.utils.fixture_tests.verify_state_db(expected_state, state_db)

evm.utils.headers module

evm.utils.headers.compute_gas_limit(parent_header, gas_limit_floor)

A simple strategy for adjusting the gas limit.

For each block:

  • decrease by 1/1024th of the gas limit from the previous block
  • increase by 50% of the total gas used by the previous block

If the value is less than the given gas_limit_floor:

  • increase the gas limit by 1/1024th of the gas limit from the previous block.

If the value is less than the GAS_LIMIT_MINIMUM:

  • use the GAS_LIMIT_MINIMUM as the new gas limit.
evm.utils.headers.compute_gas_limit_bounds(parent)

Compute the boundaries for the block gas limit based on the parent block.

evm.utils.hexadecimal module

evm.utils.hexadecimal.decode_hex(value)
evm.utils.hexadecimal.encode_hex(value)

evm.utils.keccak module

evm.utils.keccak.keccak(value)

evm.utils.logging module

evm.utils.logging.trace(self, message, *args, **kwargs)

evm.utils.module_loading module

evm.utils.module_loading.import_string(dotted_path)

Source: django.utils.module_loading Import a dotted module path and return the attribute/class designated by the last name in the path. Raise ImportError if the import failed.

evm.utils.module_loading.split_at_longest_importable_path(dotted_path)

evm.utils.numeric module

evm.utils.numeric.big_endian_to_int(value)
evm.utils.numeric.ceilXX(value, ceiling)
evm.utils.numeric.get_highest_bit_index(value)
evm.utils.numeric.int_to_big_endian(value)
evm.utils.numeric.int_to_byte(value)
evm.utils.numeric.is_even(value)
evm.utils.numeric.is_odd(value)
evm.utils.numeric.safe_ord(value)
evm.utils.numeric.signed_to_unsigned(value)
evm.utils.numeric.unsigned_to_signed(value)

evm.utils.padding module

evm.utils.padding.pad32

Should be called to pad value to expected length

evm.utils.padding.pad32r

Should be called to pad value to expected length

evm.utils.padding.pad_left

Should be called to pad value to expected length

evm.utils.padding.pad_right

Should be called to pad value to expected length

evm.utils.padding.zpad_left

Should be called to pad value to expected length

evm.utils.padding.zpad_right

Should be called to pad value to expected length

evm.utils.rlp module

evm.utils.rlp.diff_rlp_object(left, right)
evm.utils.rlp.ensure_imported_block_unchanged
evm.utils.rlp.ensure_rlp_objects_are_equal

evm.utils.state module

evm.utils.state.diff_state_db(expected_state, state_db)

evm.utils.transactions module

evm.utils.transactions.create_transaction_signature(unsigned_txn, private_key, chain_id=None)
evm.utils.transactions.extract_chain_id(v)
evm.utils.transactions.extract_signature_v(v)
evm.utils.transactions.extract_transaction_sender(transaction)
evm.utils.transactions.is_eip_155_signed_transaction(transaction)
evm.utils.transactions.validate_transaction_signature(transaction)

Module contents