def test_chunk_iteration(): chunk_number = COLLATION_SIZE // CHUNK_SIZE test_chunks = [ zpad_left(int_to_big_endian(i), CHUNK_SIZE) for i in range(chunk_number) ] chunks = test_chunks body = b"".join(chunks) for recovered, original in zip_longest(chunk_iterator(body), chunks, fillvalue=None): assert recovered is not None and original is not None assert recovered == original chunks = test_chunks[:-2] body = b"".join(chunks) for recovered, original in zip_longest(chunk_iterator(body), chunks, fillvalue=None): assert recovered is not None and original is not None assert recovered == original body = b"".join(test_chunks)[:-2] with pytest.raises(ValueError): next(chunk_iterator(body))
def modexp(computation): """ https://github.com/ethereum/EIPs/pull/198 """ gas_fee = _compute_modexp_gas_fee(computation.msg.data) computation.gas_meter.consume_gas(gas_fee, reason='MODEXP Precompile') result = _modexp(computation.msg.data) _, _, modulus_length = _extract_lengths(computation.msg.data) result_bytes = zpad_left(int_to_big_endian(result), to_size=modulus_length) computation.output = result_bytes return computation
DATA_LOGGING_CONTRACT_CODE = ( b"\x36\x60\x00\x60\x00\x37\x36\x60\x00\x20\x60\x00\x52\x60\x20\x60\x00\xa0" ) DATA_LOGGING_CONTRACT_ADDRESS = generate_CREATE2_contract_address( b"", DATA_LOGGING_CONTRACT_CODE) HELPER_CONTRACTS = { ACCOUNT_ADDRESS: ACCOUNT_CODE, NOOP_CONTRACT_ADDRESS: NOOP_CONTRACT_CODE, FAILING_CONTRACT_ADDRESS: FAILING_CONTRACT_CODE, GAS_LOGGING_CONTRACT_ADDRESS: GAS_LOGGING_CONTRACT_CODE, DATA_LOGGING_CONTRACT_ADDRESS: DATA_LOGGING_CONTRACT_CODE, } DESTINATION_ADDRESS = b"\xbb" * 20 ECRECOVER_ADDRESS = zpad_left(int_to_big_endian(ECRECOVER_ADDRESS_INT), 20) DEFAULT_BASE_TX_PARAMS = { "chain_id": 1, "shard_id": 1, "to": ACCOUNT_ADDRESS, "gas": 500000, "access_list": [ [ACCOUNT_ADDRESS, b"\x00" * 32], [ECRECOVER_ADDRESS], ], "code": b"", "salt": b"\x00" * 32, } DEFAULT_TX_PARAMS = merge(