Skip to content

Commit 814b8cc

Browse files
committed
Remove initcode transactions
1 parent 64037bb commit 814b8cc

File tree

10 files changed

+2
-93
lines changed

10 files changed

+2
-93
lines changed

lib/evmone/execution_state.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ class ExecutionState
175175

176176
private:
177177
evmc_tx_context m_tx = {};
178-
std::optional<std::unordered_map<evmc::bytes32, bytes_view>> m_initcodes;
179178

180179
public:
181180
/// Pointer to code analysis.

test/state/errors.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ enum ErrorCode : int
2323
GAS_LIMIT_REACHED,
2424
SENDER_NOT_EOA,
2525
INIT_CODE_SIZE_LIMIT_EXCEEDED,
26-
INIT_CODE_EMPTY,
27-
INIT_CODE_COUNT_LIMIT_EXCEEDED,
28-
INIT_CODE_COUNT_ZERO,
2926
CREATE_BLOB_TX,
3027
EMPTY_BLOB_HASHES_LIST,
3128
INVALID_BLOB_HASH_VERSION,
@@ -68,12 +65,6 @@ inline const std::error_category& evmone_category() noexcept
6865
return "sender not an eoa:";
6966
case INIT_CODE_SIZE_LIMIT_EXCEEDED:
7067
return "max initcode size exceeded";
71-
case INIT_CODE_EMPTY:
72-
return "initcode empty";
73-
case INIT_CODE_COUNT_LIMIT_EXCEEDED:
74-
return "max initcode count exceeded";
75-
case INIT_CODE_COUNT_ZERO:
76-
return "initcode list empty";
7768
case CREATE_BLOB_TX:
7869
return "blob transaction must not be a create transaction";
7970
case EMPTY_BLOB_HASHES_LIST:

test/state/host.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,6 @@ evmc_tx_context Host::get_tx_context() const noexcept
449449
intx::be::store<uint256be>(m_block.blob_base_fee),
450450
m_tx.blob_hashes.data(),
451451
m_tx.blob_hashes.size(),
452-
m_tx_initcodes.data(),
453-
m_tx_initcodes.size(),
454452
};
455453
}
456454

test/state/host.hpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,12 @@ class Host : public evmc::Host
4242
const BlockInfo& m_block;
4343
const Transaction& m_tx;
4444
std::vector<Log> m_logs;
45-
std::vector<evmc_tx_initcode> m_tx_initcodes;
4645

4746
public:
4847
Host(evmc_revision rev, evmc::VM& vm, State& state, const BlockInfo& block,
4948
const Transaction& tx) noexcept
5049
: m_rev{rev}, m_vm{vm}, m_state{state}, m_block{block}, m_tx{tx}
51-
{
52-
if (tx.type == Transaction::Type::initcodes)
53-
{
54-
for (const auto& initcode : tx.initcodes)
55-
{
56-
const auto hash = keccak256({initcode.data(), initcode.size()});
57-
m_tx_initcodes.push_back({hash, initcode.data(), initcode.size()});
58-
}
59-
}
60-
}
50+
{}
6151

6252
[[nodiscard]] std::vector<Log>&& take_logs() noexcept { return std::move(m_logs); }
6353

test/state/state.cpp

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ namespace evmone::state
1616
{
1717
namespace
1818
{
19-
constexpr auto MAX_INITCODE_COUNT = 256;
20-
2119
inline constexpr int64_t num_words(size_t size_in_bytes) noexcept
2220
{
2321
return static_cast<int64_t>((size_in_bytes + 31) / 32);
@@ -44,14 +42,6 @@ int64_t compute_access_list_cost(const AccessList& access_list) noexcept
4442
return cost;
4543
}
4644

47-
int64_t compute_initcode_list_cost(evmc_revision rev, std::span<const bytes> initcodes) noexcept
48-
{
49-
int64_t cost = 0;
50-
for (const auto& initcode : initcodes)
51-
cost += compute_tx_data_cost(rev, initcode);
52-
return cost;
53-
}
54-
5545
int64_t compute_tx_intrinsic_cost(evmc_revision rev, const Transaction& tx) noexcept
5646
{
5747
static constexpr auto call_tx_cost = 21000;
@@ -62,7 +52,7 @@ int64_t compute_tx_intrinsic_cost(evmc_revision rev, const Transaction& tx) noex
6252
is_create && rev >= EVMC_SHANGHAI ? initcode_word_cost * num_words(tx.data.size()) : 0;
6353
const auto tx_cost = is_create && rev >= EVMC_HOMESTEAD ? create_tx_cost : call_tx_cost;
6454
return tx_cost + compute_tx_data_cost(rev, tx.data) + compute_access_list_cost(tx.access_list) +
65-
compute_initcode_list_cost(rev, tx.initcodes) + initcode_cost;
55+
initcode_cost;
6656
}
6757

6858
evmc_message build_message(
@@ -283,28 +273,12 @@ std::variant<int64_t, std::error_code> validate_transaction(const Account& sende
283273
return make_error_code(BLOB_GAS_LIMIT_EXCEEDED);
284274
break;
285275

286-
case Transaction::Type::initcodes:
287-
if (rev < EVMC_OSAKA)
288-
return make_error_code(TX_TYPE_NOT_SUPPORTED);
289-
if (tx.initcodes.size() > MAX_INITCODE_COUNT)
290-
return make_error_code(INIT_CODE_COUNT_LIMIT_EXCEEDED);
291-
if (tx.initcodes.empty())
292-
return make_error_code(INIT_CODE_COUNT_ZERO);
293-
if (std::any_of(tx.initcodes.begin(), tx.initcodes.end(),
294-
[](const bytes& v) { return v.size() > MAX_INITCODE_SIZE; }))
295-
return make_error_code(INIT_CODE_SIZE_LIMIT_EXCEEDED);
296-
if (std::any_of(
297-
tx.initcodes.begin(), tx.initcodes.end(), [](const bytes& v) { return v.empty(); }))
298-
return make_error_code(INIT_CODE_EMPTY);
299-
break;
300-
301276
default:;
302277
}
303278

304279
switch (tx.type)
305280
{
306281
case Transaction::Type::blob:
307-
case Transaction::Type::initcodes:
308282
case Transaction::Type::eip1559:
309283
if (rev < EVMC_LONDON)
310284
return make_error_code(TX_TYPE_NOT_SUPPORTED);
@@ -620,12 +594,6 @@ std::variant<TransactionReceipt, std::error_code> transition(State& state, const
620594
return "SenderNotEOA";
621595
case INIT_CODE_SIZE_LIMIT_EXCEEDED:
622596
return "TR_InitCodeLimitExceeded";
623-
case INIT_CODE_EMPTY:
624-
return "TR_InitCodeEmpty";
625-
case INIT_CODE_COUNT_LIMIT_EXCEEDED:
626-
return "TR_InitCodeCountLimitExceeded";
627-
case INIT_CODE_COUNT_ZERO:
628-
return "TR_InitCodeCountZero";
629597
case CREATE_BLOB_TX:
630598
return "TR_BLOBCREATE";
631599
case EMPTY_BLOB_HASHES_LIST:

test/state/state.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,6 @@ struct Transaction
196196
/// The typed blob transaction (with array of blob hashes).
197197
/// Introduced by EIP-4844 https://eips.ethereum.org/EIPS/eip-4844.
198198
blob = 3,
199-
200-
/// The typed transaction with initcode list.
201-
initcodes = 4,
202199
};
203200

204201
/// Returns amount of blob gas used by this transaction
@@ -224,7 +221,6 @@ struct Transaction
224221
intx::uint256 r;
225222
intx::uint256 s;
226223
uint8_t v = 0;
227-
std::vector<bytes> initcodes;
228224
};
229225

230226
struct Log

test/statetest/statetest_loader.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,6 @@ static void from_json_tx_common(const json::json& j, state::Transaction& o)
331331
for (const auto& hash : *it)
332332
o.blob_hashes.push_back(from_json<bytes32>(hash));
333333
}
334-
else if (const auto it_initcodes = j.find("initcodes"); it_initcodes != j.end())
335-
{
336-
o.type = state::Transaction::Type::initcodes;
337-
for (const auto& initcode : *it_initcodes)
338-
o.initcodes.push_back(from_json<bytes>(initcode));
339-
}
340334
}
341335

342336
template <>

test/unittests/state_transition.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,6 @@ void state_transition::export_state_test(
200200
jtx["maxPriorityFeePerGas"] = hex0x(tx.max_priority_gas_price);
201201
}
202202

203-
if (tx.type == Transaction::Type::initcodes)
204-
{
205-
auto& jinitcodes = jtx["initcodes"] = json::json::array();
206-
for (const auto& initcode : tx.initcodes)
207-
jinitcodes.emplace_back(hex0x(initcode));
208-
}
209-
210203
jtx["data"][0] = hex0x(tx.data);
211204
jtx["gasLimit"][0] = hex0x(tx.gas_limit);
212205
jtx["value"][0] = hex0x(tx.value);

test/unittests/state_transition_eof_create_test.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,20 +1198,3 @@ TEST_F(state_transition, creation_tx_invalid_eof_version)
11981198
expect.status = EVMC_FAILURE;
11991199
expect.gas_used = 53516;
12001200
}
1201-
1202-
TEST_F(state_transition, initcode_transaction_before_prague)
1203-
{
1204-
rev = EVMC_CANCUN;
1205-
1206-
const auto deploy_container = eof_bytecode(bytecode(OP_INVALID));
1207-
1208-
const auto init_code = returncontract(0, 0, 0);
1209-
const bytecode init_container = eof_bytecode(init_code, 2).container(deploy_container);
1210-
1211-
tx.type = Transaction::Type::initcodes;
1212-
tx.initcodes.assign(257, init_container);
1213-
1214-
tx.to = To;
1215-
1216-
expect.tx_error = TX_TYPE_NOT_SUPPORTED;
1217-
}

test/unittests/state_tx_test.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ TEST(state_tx, validate_nonce)
3131
.nonce = 1,
3232
.r = 0,
3333
.s = 0,
34-
.initcodes = {},
3534
};
3635

3736
ASSERT_FALSE(holds_alternative<std::error_code>(
@@ -68,7 +67,6 @@ TEST(state_tx, validate_sender)
6867
.nonce = 0,
6968
.r = 0,
7069
.s = 0,
71-
.initcodes = {},
7270
};
7371

7472
ASSERT_FALSE(holds_alternative<std::error_code>(
@@ -178,7 +176,6 @@ TEST(state_tx, validate_data)
178176
.nonce = 1,
179177
.r = 0,
180178
.s = 0,
181-
.initcodes = {},
182179
};
183180

184181
ASSERT_FALSE(holds_alternative<std::error_code>(

0 commit comments

Comments
 (0)