Skip to content

feat: ✨ Add Moonbeam EVM Precompile Registry#137

Merged
stiiifff merged 10 commits intomainfrom
sde/registry-precompile
Sep 4, 2025
Merged

feat: ✨ Add Moonbeam EVM Precompile Registry#137
stiiifff merged 10 commits intomainfrom
sde/registry-precompile

Conversation

@stiiifff
Copy link
Copy Markdown
Contributor

@stiiifff stiiifff commented Aug 28, 2025

Summary

This PR implements a comprehensive EVM precompile registry system for DataHaven, following Moonbeam's exact architecture and patterns. The implementation includes:

  • Registry Precompile: A new precompile at address 0x0815 (2069) that manages and queries available precompiles
  • Core Ethereum Precompiles: Standard Ethereum precompiles (ECRecover, SHA256, RIPEMD160, Identity, ModExp, BN128Add, BN128Mul, BN128Pairing, Blake2F, SHA3FIPS)
  • Modular Architecture: Clean separation following Moonbeam's structure with dedicated precompile modules per runtime

Key Features

Registry Precompile Functions

  • isPrecompile(address): Check if an address corresponds to any precompile (active or inactive)
  • isActivePrecompile(address): Check if a precompile is currently active in the runtime
  • updateAccountCode(address): Insert dummy EVM bytecode for Solidity compatibility

Runtime Integration

  • Integrated across all three runtimes (testnet, stagenet, mainnet)
  • Uses Moonbeam's PrecompileSetBuilder pattern for composable precompile management
  • Proper gas accounting with database read/write operations
  • Access control through CallableByContract and CallableByPrecompile traits

@stiiifff stiiifff changed the title feat: Add EVM precompile registry following Moonbeam architecture feat: ✨ Add Moonbeam EVM Precompile Registry Aug 28, 2025
@stiiifff stiiifff requested a review from gonzamontiel August 28, 2025 11:08
@gonzamontiel
Copy link
Copy Markdown
Contributor

This PR is also upgrading polkadot-sdk from 2412 to 2412-06, do we have a comprenhensive list of the changes between versions? We need to pay attention since our coverage is not that big atm, so nothing breaks :)

@stiiifff
Copy link
Copy Markdown
Contributor Author

It is a good point @gonzamontiel, though it is actually more of a downgrade 😅 (if you look at the previous pinned revision of the Polkadot SDK in the Cargo.lock). The PR aligns the dependencies on the latest commit of the https://github.com/polkadot-evm/frontier/commits/stable2412/ branch (see this PR polkadot-evm/frontier#1714 specifically).

stiiifff and others added 8 commits September 2, 2025 15:56
This PR add the storagehub pallets to the `testnet` and `mainnet`
runtime. The storage hub pallets are only build with the runtime if the
`storage-hub` feature is activated.

It is also add minor fixes to the `stagenet` runtime (fix wrong path
dependencies, index collision, etc...).

---------

Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
@stiiifff stiiifff merged commit 6886bcb into main Sep 4, 2025
14 of 15 checks passed
@stiiifff stiiifff deleted the sde/registry-precompile branch September 4, 2025 08:26
stiiifff added a commit that referenced this pull request Sep 5, 2025
## Summary

This PR adds Moonbeam's Batch precompile to DataHaven, enabling
efficient batching of multiple EVM transactions in a single call. This
implementation follows Moonbeam's exact architecture and provides
significant gas savings for batch operations.

## Key Features

### Batch Precompile Functions
- **`batchSome(address[], uint256[], bytes[], uint64[])`**: Execute
multiple calls, continuing on failures
- **`batchSomeUntilFailure(address[], uint256[], bytes[], uint64[])`**:
Execute calls until first failure
- **`batchAll(address[], uint256[], bytes[], uint64[])`**: Execute all
calls, reverting if any fail

### Technical Implementation
- **Address**: `0x0808` (2056 in decimal)
- **Access Control**: Restricted nesting with `SubcallWithMaxNesting<2>`
- **Self-recursion**: Only the Batch precompile can call itself
(`OnlyFrom<AddressU64<2056>>`)
- **Gas Management**: Proper gas estimation and refund handling
- **Error Handling**: Comprehensive revert reasons and event logging

Depends on #137

---------

Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com>
stiiifff added a commit that referenced this pull request Sep 7, 2025
## Summary

This PR adds Moonbeam's CallPermit precompile to DataHaven, enabling
gasless meta-transactions through EIP-712 signature-based permissions.
Users can sign transaction permits offline, allowing relayers to execute
transactions on their behalf while maintaining full security and
authentication.

## Key Features

### CallPermit Precompile Functions
- **`dispatch(address from, address to, uint256 value, bytes data,
uint64[] gasLimit, uint256 deadline, uint8 v, bytes32 r, bytes32 s)`**:
Execute permitted calls with signature verification
- **`nonces(address owner)`**: Get current nonce for permit validation

### Technical Implementation
- **Address**: `0x080A` (2058 in decimal)
- **EIP-712 Compliance**: Structured signature validation with proper
domain separation
- **Nonce Management**: Per-user nonce tracking for replay protection
- **Deadline Validation**: Time-bound permits for enhanced security
- **Gas Forwarding**: Proper gas limit enforcement and forwarding

Depends on #137

---------

Co-authored-by: Claude <noreply@anthropic.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.

4 participants