diff --git a/test/state/host.cpp b/test/state/host.cpp index 495d4f1a54..cefc796511 100644 --- a/test/state/host.cpp +++ b/test/state/host.cpp @@ -201,23 +201,27 @@ std::optional Host::prepare_message(evmc_message msg) noexcept msg.kind == EVMC_EOFCREATE) { auto& sender_acc = m_state.get(msg.sender); - const auto sender_nonce = sender_acc.nonce; // EIP-2681 (already checked for depth 0 during transaction validation). - if (sender_nonce == Account::NonceMax) + if (sender_acc.nonce == Account::NonceMax) return {}; // Light early exception. if (msg.depth != 0) + { m_state.journal_bump_nonce(msg.sender); - ++sender_acc.nonce; // Bump sender nonce. + ++sender_acc.nonce; // Bump sender nonce. + } if (msg.kind == EVMC_CREATE || msg.kind == EVMC_CREATE2 || msg.kind == EVMC_EOFCREATE) { // Compute and set the address of the account being created. assert(msg.recipient == address{}); assert(msg.code_address == address{}); + // Nonce was already incremented, but creation calculation needs non-incremented value + assert(sender_acc.nonce != 0); + const auto creation_sender_nonce = sender_acc.nonce - 1; if (msg.kind == EVMC_CREATE) - msg.recipient = compute_create_address(msg.sender, sender_nonce); + msg.recipient = compute_create_address(msg.sender, creation_sender_nonce); else if (msg.kind == EVMC_CREATE2) { msg.recipient = compute_create2_address( @@ -256,7 +260,7 @@ std::optional Host::prepare_message(evmc_message msg) noexcept EOFValidationError::success) return {}; // Light early exception. - msg.recipient = compute_create_address(msg.sender, sender_nonce); + msg.recipient = compute_create_address(msg.sender, creation_sender_nonce); } // EOFCREATE else diff --git a/test/state/state.cpp b/test/state/state.cpp index 2d7de4a2ba..aa74c4c3f3 100644 --- a/test/state/state.cpp +++ b/test/state/state.cpp @@ -402,6 +402,9 @@ std::variant transition(State& state, const // The account won't be empty because its nonce will be bumped. auto& sender_acc = (sender_ptr != nullptr) ? *sender_ptr : state.insert(tx.sender); + assert(sender_acc.nonce < Account::NonceMax); // Checked in transaction validation + ++sender_acc.nonce; // Bump sender nonce. + const auto execution_gas_limit = get(validation_result); const auto base_fee = (rev >= EVMC_LONDON) ? block.base_fee : 0;