Skip to content

chore: ensure precompile bytecode is set for account#65

Merged
tac0turtle merged 8 commits into
marko/native_precompilefrom
damian/set-precompile-bytecode
Oct 22, 2025
Merged

chore: ensure precompile bytecode is set for account#65
tac0turtle merged 8 commits into
marko/native_precompilefrom
damian/set-precompile-bytecode

Conversation

@damiannolan

@damiannolan damiannolan commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

Description

Drafting to get a docker build to test.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Refactoring

Related Issues

Fixes #(issue)

Checklist

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Testing

Additional Notes

@claude

claude Bot commented Oct 22, 2025

Copy link
Copy Markdown

Claude finished @damiannolan's task —— View job


PR Review: Code Quality and Best Practices ✅

Reviewing PR: chore: ensure precompile bytecode is set for account

Todo List:

  • Read repository guidelines (CLAUDE.md)
  • Analyze the changed file: crates/ev-precompiles/src/mint.rs
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Assess performance considerations
  • Evaluate security concerns
  • Review test coverage needs
  • Provide comprehensive feedback

Review Summary

This PR makes important improvements to the mint precompile implementation by ensuring proper bytecode is set for precompile accounts. The changes are clean, well-implemented, and follow good practices.

🟢 Positive Aspects

Code Quality:

  • Clean import consolidation (crates/ev-precompiles/src/mint.rs:10) - combining separate revm imports into a single grouped import
  • Proper use of OnceLock for static bytecode initialization (crates/ev-precompiles/src/mint.rs:37-40)
  • Consistent API usage with account.info.set_code() and account.info.set_nonce() (crates/ev-precompiles/src/mint.rs:62-63)

Functionality:

  • Critical Fix: The addition of bytecode to the precompile account prevents state pruning from wiping out storage between blocks
  • Uses appropriate bytecode value (0xFE - invalid opcode) which is a standard pattern for precompiles
  • Maintains account state consistency by setting both code and nonce

Security:

  • No security vulnerabilities introduced
  • Changes are isolated to account initialization logic
  • Maintains existing authorization mechanisms intact

🟡 Areas for Improvement

Documentation:

  • Consider adding a code comment explaining why 0xFE bytecode is used (it's the INVALID opcode, standard for precompiles)
  • The existing comment explains the "why" but could be enhanced

Minor Optimization:

  • The bytecode initialization could potentially be const if using a simpler approach, but the current OnceLock pattern is acceptable and thread-safe

🟢 Technical Assessment

Performance:

  • Minimal performance impact - bytecode is initialized once and cached
  • No additional computational overhead during normal operations

Testing:

  • Existing test suite remains comprehensive and covers all functionality
  • Tests verify account creation behavior which implicitly tests the bytecode setting
  • No additional tests needed as the change is internal account state management

Architecture:

  • Changes align well with the ev-reth architecture described in CLAUDE.md
  • Maintains separation of concerns within the precompile implementation
  • Follows existing patterns in the codebase

✅ Recommendation

APPROVE - This is a solid improvement that:

  1. Fixes a potential state pruning issue
  2. Follows established patterns and best practices
  3. Maintains code quality and security
  4. Has comprehensive test coverage

The import consolidation and API consistency improvements are additional positive aspects that enhance code maintainability.


@tac0turtle tac0turtle merged commit 6e0308d into marko/native_precompile Oct 22, 2025
16 checks passed
@tac0turtle tac0turtle deleted the damian/set-precompile-bytecode branch October 22, 2025 11:21
tac0turtle added a commit that referenced this pull request Oct 22, 2025
* create precompile for native mint

* complete inspector

* changes

* ++

* make headway on precompile

* ++

* conflict

* do the precompile the easy way

* tsts and integration

* add tests

* remove somem tests and add e2e for fee sink

* format json

* add test

* add factory tests

* fix e2e test

* add mint and burn test to new wallet

* add readme

* lint fmt

* rewrite e2e tests

* add allow list

* nonce for precompile addr

* add info

* dont charge gas

* fmt

* chore: ensure precompile bytecode is set for account (#65)

* chore: ensure precompile bytecode is set for account

* chore: use reth primitives import

* chore: use revm bytecode

* chore: add rust-toolchain and fix compiler issues

* chore: lint

* Revert "chore: lint"

This reverts commit 0818277.

* chore: rm rust-toolchain to use existing ci workflow versions

* chore: lint

---------

Co-authored-by: Damian Nolan <damiannolan@gmail.com>
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