Skip to content

EIP-7997 - #2499

Open
Baltoli wants to merge 1 commit into
mainfrom
bruce/eip-7997
Open

EIP-7997#2499
Baltoli wants to merge 1 commit into
mainfrom
bruce/eip-7997

Conversation

@Baltoli

@Baltoli Baltoli commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

No description provided.

return;
}

if (MONAD_UNLIKELY(!state.account_exists(FACTORY_ADDRESS))) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] The deployment guard should be !state.account_has_code_or_nonce(FACTORY_ADDRESS), not !state.account_exists(FACTORY_ADDRESS). account_exists returns true for any touched account (including one that only holds a balance), so if a user sends value to 0x4e59b44847b379578588920cA78FbF26c0B4956C before the MONAD_NEXT/Amsterdam activation, this check skips the factory deployment entirely and the fork silently ships without EIP-7997 code at the predeploy address. The base commit ("Add and use code-or-nonce primitive") introduced account_has_code_or_nonce specifically for this idiom — block_hash_history.cpp:57-58 uses it, and State::create_contract already preserves any existing balance per YP §7.

Suggested change
if (MONAD_UNLIKELY(!state.account_exists(FACTORY_ADDRESS))) {
if (MONAD_UNLIKELY(!state.account_has_code_or_nonce(FACTORY_ADDRESS))) {

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#include <category/core/config.hpp>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Missing #pragma once. CLAUDE.md's style section requires #pragma once on all headers, and the sibling block_hash_history.hpp:16 follows it. Without a guard, any TU that transitively includes this header more than once compiles slower and is one added definition away from an ODR breakage.

Suggested change
#include <category/core/config.hpp>
#pragma once
#include <category/core/config.hpp>

// along with this program. If not, see <http://www.gnu.org/licenses/>.

#include <category/core/config.hpp>
#include <category/execution/ethereum/state3/state.hpp>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Prefer forward-declaring State here — the sibling block_hash_history.hpp:27 uses class State; instead of pulling in the full state3/state.hpp transitive graph, which keeps compile time down and cuts unnecessary rebuild churn when state.hpp changes.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the EIP-7997 factory deployment. Runtime bytecode matches Arachnid's proxy verbatim and the trait wiring for MONAD_NEXTMONAD_ETH_AMSTERDAM looks right, but the deployment guard uses the wrong existence predicate:

  • [P1] deterministic_factory_contract.cpp:46 — uses !state.account_exists(...); must use !state.account_has_code_or_nonce(...) so a pre-fork balance transfer to 0x4e59...956C doesn't silently skip the deploy at activation. This is exactly the pattern the base commit ("Add and use code-or-nonce primitive") set up, and block_hash_history.cpp:57-58 already uses it.
  • [P2] deterministic_factory_contract.hpp:16 — missing #pragma once (CLAUDE.md style rule).
  • [P3] deterministic_factory_contract.hpp:17 — forward-declare State instead of pulling in the full state3/state.hpp, matching block_hash_history.hpp:27.

No unit test alongside the new source (compare block_hash_history_test.cpp). Consider a matching test that verifies the deploy is a no-op on second entry and — with the fix above — that it still deploys when the address holds a pre-existing balance.

Verdict: NEEDS CHANGES

🤖 Generated with Claude Code

@Baltoli Baltoli changed the title Deploy deterministic factory EIP-7997 Aug 20, 2026
Base automatically changed from bruce/code-or-nonce to main August 20, 2026 14:02
Copilot AI lite review requested due to automatic review settings August 26, 2026 08:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds initial plumbing for EIP-7997 by introducing a new trait feature flag and deploying the deterministic factory system contract during block header execution.

Changes:

  • Extend Traits with eip_7997_active() and implement activation in both EvmTraits and MonadTraits.
  • Deploy the deterministic factory contract (EIP-7997) during execute_block_header.
  • Wire the new implementation into the execution library build.

Verdict: NEEDS CHANGES

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
category/vm/evm/traits.hpp Adds eip_7997_active() to the Traits concept and both trait families.
category/execution/ethereum/execute_block_header.cpp Calls deterministic factory deployment as part of block-header execution.
category/execution/ethereum/deterministic_factory_contract.hpp Declares the deployment helper for the EIP-7997 system contract.
category/execution/ethereum/deterministic_factory_contract.cpp Implements deterministic factory deployment logic and instantiates across traits.
category/execution/CMakeLists.txt Adds the new deterministic factory sources to the execution library.

🤖 Generated with Claude Code

Suppressed comments (1)

category/execution/ethereum/deterministic_factory_contract.cpp:46

  • Using account_exists() here can skip deployment if the address was previously “created” by a balance transfer (balance-only account), leaving the system contract without code/nonce. The existing system-contract deploy path (deploy_block_hash_history_contract) uses account_has_code_or_nonce() for this reason.
    if (MONAD_UNLIKELY(!state.account_exists(FACTORY_ADDRESS))) {

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +16 to +18
#include <category/core/config.hpp>
#include <category/execution/ethereum/state3/state.hpp>
#include <category/vm/evm/traits.hpp>
Comment on lines +16 to +21
#include <category/core/address.hpp>
#include <category/core/byte_string.hpp>
#include <category/core/bytes.hpp>
#include <category/core/hex.hpp>
#include <category/execution/ethereum/deterministic_factory_contract.hpp>
#include <category/vm/evm/explicit_traits.hpp>
Comment on lines +38 to +50
// EIP-7997
template <Traits traits>
void deploy_deterministic_factory_contract(State &state)
{
if constexpr (!traits::eip_7997_active()) {
return;
}

if (MONAD_UNLIKELY(!state.account_exists(FACTORY_ADDRESS))) {
state.create_contract(FACTORY_ADDRESS);
state.set_code(FACTORY_ADDRESS, FACTORY_CODE);
state.set_nonce(FACTORY_ADDRESS, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants