Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move TXCREATE and InitcodeTransaction to Osaka #889

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
@@ -434,7 +434,7 @@ jobs:
~/tests/EIPTests/BlockchainTests/
- download_execution_tests:
repo: ipsilon/tests
rev: v13.3
rev: eof-notxcreate
legacy: false
- run:
name: "State tests (EOF)"
4 changes: 2 additions & 2 deletions lib/evmone/instructions_traits.hpp
Original file line number Diff line number Diff line change
@@ -189,10 +189,10 @@ constexpr inline GasCostTable gas_costs = []() noexcept {
table[EVMC_PRAGUE][OP_EXTDELEGATECALL] = warm_storage_read_cost;
table[EVMC_PRAGUE][OP_EXTSTATICCALL] = warm_storage_read_cost;
table[EVMC_PRAGUE][OP_EOFCREATE] = 32000;
table[EVMC_PRAGUE][OP_TXCREATE] = 32000;
table[EVMC_PRAGUE][OP_RETURNCONTRACT] = 0;

table[EVMC_OSAKA] = table[EVMC_PRAGUE];
table[EVMC_OSAKA][OP_TXCREATE] = 32000;

return table;
}();
@@ -414,7 +414,7 @@ constexpr inline std::array<Traits, 256> traits = []() noexcept {
table[OP_CREATE2] = {"CREATE2", 0, false, 4, -3, EVMC_CONSTANTINOPLE};
table[OP_RETURNDATALOAD] = {"RETURNDATALOAD", 0, false, 1, 0, EVMC_PRAGUE};
table[OP_EOFCREATE] = {"EOFCREATE", 1, false, 4, -3, EVMC_PRAGUE};
table[OP_TXCREATE] = {"TXCREATE", 0, false, 5, -4, EVMC_PRAGUE};
table[OP_TXCREATE] = {"TXCREATE", 0, false, 5, -4, EVMC_OSAKA};
table[OP_RETURNCONTRACT] = {"RETURNCONTRACT", 1, true, 2, -2, EVMC_PRAGUE};
table[OP_EXTCALL] = {"EXTCALL", 0, false, 4, -3, EVMC_PRAGUE};
table[OP_EXTDELEGATECALL] = {"EXTDELEGATECALL", 0, false, 3, -2, EVMC_PRAGUE};
2 changes: 1 addition & 1 deletion test/state/state.cpp
Original file line number Diff line number Diff line change
@@ -265,7 +265,7 @@ std::variant<int64_t, std::error_code> validate_transaction(const Account& sende
break;

case Transaction::Type::initcodes:
if (rev < EVMC_PRAGUE)
if (rev < EVMC_OSAKA)
return make_error_code(TX_TYPE_NOT_SUPPORTED);
if (tx.initcodes.size() > max_initcode_count)
return make_error_code(INIT_CODE_COUNT_LIMIT_EXCEEDED);
78 changes: 39 additions & 39 deletions test/unittests/state_transition_eof_create_test.cpp
Original file line number Diff line number Diff line change
@@ -927,7 +927,7 @@ TEST_F(state_transition, eofcreate_call_created_contract)

TEST_F(state_transition, txcreate_empty_auxdata)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_data = "abcdef"_hex;
const auto deploy_container = eof_bytecode(bytecode(OP_INVALID)).data(deploy_data);

@@ -952,7 +952,7 @@ TEST_F(state_transition, txcreate_empty_auxdata)

TEST_F(state_transition, txcreate_extcall_returncontract)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
constexpr auto callee = 0xca11ee_address;
const auto deploy_container = eof_bytecode(bytecode(OP_INVALID));

@@ -985,7 +985,7 @@ TEST_F(state_transition, txcreate_extcall_returncontract)

TEST_F(state_transition, txcreate_auxdata_equal_to_declared)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_data = "abcdef"_hex;
const auto aux_data = "aabbccddeeff"_hex;
const auto deploy_data_size = static_cast<uint16_t>(deploy_data.size() + aux_data.size());
@@ -1019,7 +1019,7 @@ TEST_F(state_transition, txcreate_auxdata_equal_to_declared)

TEST_F(state_transition, txcreate_auxdata_longer_than_declared)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_data = "abcdef"_hex;
const auto aux_data1 = "aabbccdd"_hex;
const auto aux_data2 = "eeff"_hex;
@@ -1055,7 +1055,7 @@ TEST_F(state_transition, txcreate_auxdata_longer_than_declared)

TEST_F(state_transition, txcreate_auxdata_shorter_than_declared)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_data = "abcdef"_hex;
const auto aux_data = "aabbccddeeff"_hex;
const auto deploy_data_size = static_cast<uint16_t>(deploy_data.size() + aux_data.size() + 1);
@@ -1085,7 +1085,7 @@ TEST_F(state_transition, txcreate_auxdata_shorter_than_declared)

TEST_F(state_transition, txcreate_dataloadn_referring_to_auxdata)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_data = bytes(64, 0);
const auto aux_data = bytes(32, 0);
const auto deploy_data_size = static_cast<uint16_t>(deploy_data.size() + aux_data.size());
@@ -1119,7 +1119,7 @@ TEST_F(state_transition, txcreate_dataloadn_referring_to_auxdata)

TEST_F(state_transition, txcreate_revert_empty_returndata)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto init_code = revert(0, 0);
const bytecode init_container = eof_bytecode(init_code, 2);

@@ -1143,7 +1143,7 @@ TEST_F(state_transition, txcreate_revert_empty_returndata)

TEST_F(state_transition, txcreate_revert_non_empty_returndata)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto init_code = mstore8(0, 0xaa) + revert(0, 1);
const bytecode init_container = eof_bytecode(init_code, 2);

@@ -1167,7 +1167,7 @@ TEST_F(state_transition, txcreate_revert_non_empty_returndata)

TEST_F(state_transition, txcreate_initcontainer_aborts)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto init_code = bytecode{Opcode{OP_INVALID}};
const bytecode init_container = eof_bytecode(init_code, 0);

@@ -1190,7 +1190,7 @@ TEST_F(state_transition, txcreate_initcontainer_aborts)

TEST_F(state_transition, txcreate_initcontainer_return)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto init_code = bytecode{0xaa + ret_top()};
const bytecode init_container = eof_bytecode(init_code, 2);

@@ -1213,7 +1213,7 @@ TEST_F(state_transition, txcreate_initcontainer_return)

TEST_F(state_transition, txcreate_initcontainer_stop)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto init_code = bytecode{Opcode{OP_STOP}};
const bytecode init_container = eof_bytecode(init_code, 0);

@@ -1236,7 +1236,7 @@ TEST_F(state_transition, txcreate_initcontainer_stop)

TEST_F(state_transition, txcreate_initcontainer_max_size)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
block.gas_limit = 10'000'000;
tx.gas_limit = block.gas_limit;
pre.get(tx.sender).balance = tx.gas_limit * tx.max_gas_price + tx.value + 1;
@@ -1268,7 +1268,7 @@ TEST_F(state_transition, txcreate_initcontainer_max_size)

TEST_F(state_transition, txcreate_initcontainer_empty)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;

const bytecode empty_init_container{};

@@ -1293,7 +1293,7 @@ TEST_F(state_transition, txcreate_initcontainer_empty)

TEST_F(state_transition, txcreate_no_initcontainer)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;

tx.type = Transaction::Type::initcodes;

@@ -1309,7 +1309,7 @@ TEST_F(state_transition, txcreate_no_initcontainer)

TEST_F(state_transition, txcreate_initcontainer_too_large)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
block.gas_limit = 10'000'000;
tx.gas_limit = block.gas_limit;
pre.get(tx.sender).balance = tx.gas_limit * tx.max_gas_price + tx.value + 1;
@@ -1339,7 +1339,7 @@ TEST_F(state_transition, txcreate_initcontainer_too_large)

TEST_F(state_transition, txcreate_too_many_initcontainers)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
block.gas_limit = 10'000'000;
tx.gas_limit = block.gas_limit;
pre.get(tx.sender).balance = tx.gas_limit * tx.max_gas_price + tx.value + 1;
@@ -1382,7 +1382,7 @@ TEST_F(state_transition, initcode_transaction_before_prague)

TEST_F(state_transition, txcreate_deploy_container_max_size)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
block.gas_limit = 10'000'000;
tx.gas_limit = block.gas_limit;
pre.get(tx.sender).balance = tx.gas_limit * tx.max_gas_price + tx.value + 1;
@@ -1418,7 +1418,7 @@ TEST_F(state_transition, txcreate_deploy_container_max_size)

TEST_F(state_transition, txcreate_deploy_container_too_large)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
block.gas_limit = 10'000'000;
tx.gas_limit = block.gas_limit;
pre.get(tx.sender).balance = tx.gas_limit * tx.max_gas_price + tx.value + 1;
@@ -1452,7 +1452,7 @@ TEST_F(state_transition, txcreate_deploy_container_too_large)

TEST_F(state_transition, txcreate_appended_data_size_larger_than_64K)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
block.gas_limit = 10'000'000;
tx.gas_limit = block.gas_limit;
pre.get(tx.sender).balance = tx.gas_limit * tx.max_gas_price + tx.value + 1;
@@ -1492,7 +1492,7 @@ TEST_F(state_transition, txcreate_appended_data_size_larger_than_64K)

TEST_F(state_transition, txcreate_deploy_container_with_aux_data_too_large)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
block.gas_limit = 10'000'000;
tx.gas_limit = block.gas_limit;
pre.get(tx.sender).balance = tx.gas_limit * tx.max_gas_price + tx.value + 1;
@@ -1526,7 +1526,7 @@ TEST_F(state_transition, txcreate_deploy_container_with_aux_data_too_large)

TEST_F(state_transition, txcreate_nested_txcreate)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_data = "abcdef"_hex;
const auto deploy_container = eof_bytecode(bytecode(OP_INVALID)).data(deploy_data);

@@ -1568,7 +1568,7 @@ TEST_F(state_transition, txcreate_nested_txcreate)

TEST_F(state_transition, txcreate_nested_txcreate_revert)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_data_nested = "ffffff"_hex;
const auto deploy_container_nested =
eof_bytecode(bytecode(OP_INVALID)).data(deploy_data_nested);
@@ -1598,7 +1598,7 @@ TEST_F(state_transition, txcreate_nested_txcreate_revert)

TEST_F(state_transition, txcreate_nested_eofcreate)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_data = "abcdef"_hex;
const auto deploy_container = eof_bytecode(bytecode(OP_INVALID)).data(deploy_data);

@@ -1638,7 +1638,7 @@ TEST_F(state_transition, txcreate_nested_eofcreate)

TEST_F(state_transition, txcreate_called_balance_too_low)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_data = "abcdef"_hex;
const auto deploy_container = eof_bytecode(bytecode(OP_INVALID)).data(deploy_data);

@@ -1670,7 +1670,7 @@ TEST_F(state_transition, txcreate_clears_returndata)
{
static constexpr auto returning_address = 0x3000_address;

rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_container = eof_bytecode(OP_STOP);

const auto init_code = returncontract(0, 0, 0);
@@ -1705,7 +1705,7 @@ TEST_F(state_transition, txcreate_clears_returndata)

TEST_F(state_transition, txcreate_failure_after_txcreate_success)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
block.gas_limit = 10'000'000;
tx.gas_limit = block.gas_limit;
pre.get(tx.sender).balance = tx.gas_limit * tx.max_gas_price + tx.value + 1;
@@ -1740,7 +1740,7 @@ TEST_F(state_transition, txcreate_failure_after_txcreate_success)

TEST_F(state_transition, txcreate_invalid_initcode)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_container = eof_bytecode(bytecode(OP_INVALID));

const auto init_code = returncontract(0, 0, 0);
@@ -1768,7 +1768,7 @@ TEST_F(state_transition, txcreate_invalid_initcode)

TEST_F(state_transition, txcreate_truncated_data_initcode)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_container = eof_bytecode(bytecode(OP_INVALID));

const auto init_code = returncontract(0, 0, 0);
@@ -1796,7 +1796,7 @@ TEST_F(state_transition, txcreate_truncated_data_initcode)

TEST_F(state_transition, txcreate_invalid_deploycode)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_container = eof_bytecode(bytecode(OP_INVALID), 123); // Invalid EOF

const auto init_code = returncontract(0, 0, 0);
@@ -1822,7 +1822,7 @@ TEST_F(state_transition, txcreate_invalid_deploycode)

TEST_F(state_transition, txcreate_missing_initcontainer)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_container = eof_bytecode(bytecode(OP_INVALID));

const auto init_code = returncontract(0, 0, 0);
@@ -1847,7 +1847,7 @@ TEST_F(state_transition, txcreate_missing_initcontainer)

TEST_F(state_transition, txcreate_light_failure_stack)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_container = eof_bytecode(bytecode(OP_INVALID));

const auto init_code = returncontract(0, 0, 0);
@@ -1873,7 +1873,7 @@ TEST_F(state_transition, txcreate_light_failure_stack)

TEST_F(state_transition, txcreate_missing_deploycontainer)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto init_code = returncontract(0, 0, 0);
const bytes init_container = eof_bytecode(init_code, 2);

@@ -1897,7 +1897,7 @@ TEST_F(state_transition, txcreate_missing_deploycontainer)

TEST_F(state_transition, txcreate_deploy_code_with_dataloadn_invalid)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_data = bytes(32, 0);
// DATALOADN{64} - referring to offset out of bounds even after appending aux_data later
const auto deploy_code = bytecode(OP_DATALOADN) + "0040" + ret_top();
@@ -1928,7 +1928,7 @@ TEST_F(state_transition, txcreate_deploy_code_with_dataloadn_invalid)

TEST_F(state_transition, txcreate_call_created_contract)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_data = "abcdef"_hex; // 3 bytes
const auto static_aux_data =
"aabbccdd00000000000000000000000000000000000000000000000000000000"_hex; // 32 bytes
@@ -1987,7 +1987,7 @@ TEST_F(state_transition, txcreate_call_created_contract)

TEST_F(state_transition, create_nested_in_txcreate)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_container = eof_bytecode(OP_STOP);

const auto init_code = bytecode{OP_DATASIZE} + OP_PUSH0 + OP_PUSH0 + OP_DATACOPY +
@@ -2012,7 +2012,7 @@ TEST_F(state_transition, create_nested_in_txcreate)

TEST_F(state_transition, create2_nested_in_txcreate)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
const auto deploy_container = eof_bytecode(OP_INVALID);

const auto init_code = bytecode{OP_DATASIZE} + OP_PUSH0 + OP_PUSH0 + OP_DATACOPY +
@@ -2038,7 +2038,7 @@ TEST_F(state_transition, create2_nested_in_txcreate)

TEST_F(state_transition, txcreate_from_legacy_tx)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
tx.type = Transaction::Type::legacy;

const auto factory_code = sstore(0, txcreate().initcode(keccak256({})).input(0, 0).salt(Salt)) +
@@ -2056,7 +2056,7 @@ TEST_F(state_transition, txcreate_from_legacy_tx)

TEST_F(state_transition, txcreate_from_1559_tx)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
tx.type = Transaction::Type::eip1559;

const auto factory_code = sstore(0, txcreate().initcode(keccak256({})).input(0, 0).salt(Salt)) +
@@ -2074,7 +2074,7 @@ TEST_F(state_transition, txcreate_from_1559_tx)

TEST_F(state_transition, txcreate_from_blob_tx)
{
rev = EVMC_PRAGUE;
rev = EVMC_OSAKA;
tx.type = Transaction::Type::blob;
tx.blob_hashes.push_back(
0x0100000000000000000000000000000000000000000000000000000000000007_bytes32);