feat: ✨ Add Moonbeam EVM Precompile Registry (#137)
## 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
---------
Co-authored-by: undercover-cactus <lola@moonsonglabs.com>
2025-09-04 08:25:59 +00:00
|
|
|
// Copyright 2019-2025 The DataHaven Team
|
|
|
|
|
// This file is part of DataHaven.
|
|
|
|
|
|
|
|
|
|
// DataHaven is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
// DataHaven is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with DataHaven. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
2025-10-08 13:48:17 +00:00
|
|
|
use crate::configs::MaxAdditionalFields;
|
2025-10-08 21:16:34 +00:00
|
|
|
use crate::governance::councils::{TechnicalCommitteeInstance, TreasuryCouncilInstance};
|
2025-10-10 22:17:21 +00:00
|
|
|
use crate::governance::custom_origins::Origin;
|
feat: Add ERC20 Balances precompile (#150)
## Summary
- Introduces an ERC20-compatible precompile backed by `pallet_balances`,
including approvals and EIP-2612 permit.
- Wires the precompile into Mainnet, Testnet, and Stagenet at address
`0x0000000000000000000000000000000000000802` (u64: 2050).
- Adds comprehensive unit tests and a mock runtime.
## Motivation
- Allow EVM contracts and tooling to interact with Substrate balances
via a familiar ERC20 interface.
- Support off-chain approvals via EIP-2612 for gasless approvals and
improved UX.
## Key Changes
- New crate: `operator/precompiles/erc20-balances`
- Core logic: `src/lib.rs`
- EIP-2612 helpers and validation: `src/eip2612.rs`
- Tests + mock runtime: `src/tests.rs`, `src/mock.rs`
- Runtime wiring (all networks): add `Erc20BalancesPrecompile` at
`AddressU64<2050>`
- `operator/runtime/{mainnet,stagenet,testnet}/src/precompiles.rs`
- Workspace plumbing: include `pallet-evm-precompile-balances-erc20` in
`operator/Cargo.toml`
## Interface
- ERC20: `totalSupply`, `balanceOf`, `allowance`, `approve`, `transfer`,
`transferFrom`, `name`, `symbol`, `decimals`
- Native-only flows: `deposit()` (fallback/payable) and
`withdraw(uint256)`
- EIP-2612: `permit(owner,spender,value,deadline,v,r,s)`,
`nonces(owner)`, `DOMAIN_SEPARATOR()`
- Events: `Transfer`, `Approval`, `Deposit`, `Withdrawal`
- Storage:
- Approvals via `ApprovesStorage` (double map: owner → spender → amount)
- EIP-2612 nonces via `NoncesStorage` keyed by `H160`
- Instance-aware prefixes to support multiple `pallet_balances`
instances
2025-09-12 08:57:44 +00:00
|
|
|
use pallet_evm_precompile_balances_erc20::{Erc20BalancesPrecompile, Erc20Metadata};
|
feat: ✨ Add Moonbeam Batch precompile (#138)
## 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>
2025-09-05 17:24:09 +00:00
|
|
|
use pallet_evm_precompile_batch::BatchPrecompile;
|
feat: ✨ Add Moonbeam EVM Precompile Registry (#137)
## 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
---------
Co-authored-by: undercover-cactus <lola@moonsonglabs.com>
2025-09-04 08:25:59 +00:00
|
|
|
use pallet_evm_precompile_blake2::Blake2F;
|
|
|
|
|
use pallet_evm_precompile_bn128::{Bn128Add, Bn128Mul, Bn128Pairing};
|
feat: ✨ Add Moonbeam CallPermit precompile (#140)
## 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 https://github.com/datahaven-xyz/datahaven/pull/137
---------
Co-authored-by: Claude <noreply@anthropic.com>
2025-09-07 13:00:37 +00:00
|
|
|
use pallet_evm_precompile_call_permit::CallPermitPrecompile;
|
2025-10-08 21:16:34 +00:00
|
|
|
use pallet_evm_precompile_collective::CollectivePrecompile;
|
2025-10-09 08:30:50 +00:00
|
|
|
use pallet_evm_precompile_conviction_voting::ConvictionVotingPrecompile;
|
2025-09-15 08:43:00 +00:00
|
|
|
use pallet_evm_precompile_file_system::FileSystemPrecompile;
|
2025-10-08 13:48:17 +00:00
|
|
|
use pallet_evm_precompile_identity::IdentityPrecompile;
|
feat: ✨ Add Moonbeam EVM Precompile Registry (#137)
## 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
---------
Co-authored-by: undercover-cactus <lola@moonsonglabs.com>
2025-09-04 08:25:59 +00:00
|
|
|
use pallet_evm_precompile_modexp::Modexp;
|
2025-10-09 11:16:46 +00:00
|
|
|
use pallet_evm_precompile_preimage::PreimagePrecompile;
|
2025-09-12 07:45:26 +00:00
|
|
|
use pallet_evm_precompile_proxy::{OnlyIsProxyAndProxy, ProxyPrecompile};
|
2025-10-10 22:17:21 +00:00
|
|
|
use pallet_evm_precompile_referenda::ReferendaPrecompile;
|
feat: ✨ Add Moonbeam EVM Precompile Registry (#137)
## 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
---------
Co-authored-by: undercover-cactus <lola@moonsonglabs.com>
2025-09-04 08:25:59 +00:00
|
|
|
use pallet_evm_precompile_registry::PrecompileRegistry;
|
|
|
|
|
use pallet_evm_precompile_sha3fips::Sha3FIPS256;
|
|
|
|
|
use pallet_evm_precompile_simple::{ECRecover, ECRecoverPublicKey, Identity, Ripemd160, Sha256};
|
|
|
|
|
use precompile_utils::precompile_set::*;
|
|
|
|
|
|
|
|
|
|
type EthereumPrecompilesChecks = (AcceptDelegateCall, CallableByContract, CallableByPrecompile);
|
|
|
|
|
|
feat: Add ERC20 Balances precompile (#150)
## Summary
- Introduces an ERC20-compatible precompile backed by `pallet_balances`,
including approvals and EIP-2612 permit.
- Wires the precompile into Mainnet, Testnet, and Stagenet at address
`0x0000000000000000000000000000000000000802` (u64: 2050).
- Adds comprehensive unit tests and a mock runtime.
## Motivation
- Allow EVM contracts and tooling to interact with Substrate balances
via a familiar ERC20 interface.
- Support off-chain approvals via EIP-2612 for gasless approvals and
improved UX.
## Key Changes
- New crate: `operator/precompiles/erc20-balances`
- Core logic: `src/lib.rs`
- EIP-2612 helpers and validation: `src/eip2612.rs`
- Tests + mock runtime: `src/tests.rs`, `src/mock.rs`
- Runtime wiring (all networks): add `Erc20BalancesPrecompile` at
`AddressU64<2050>`
- `operator/runtime/{mainnet,stagenet,testnet}/src/precompiles.rs`
- Workspace plumbing: include `pallet-evm-precompile-balances-erc20` in
`operator/Cargo.toml`
## Interface
- ERC20: `totalSupply`, `balanceOf`, `allowance`, `approve`, `transfer`,
`transferFrom`, `name`, `symbol`, `decimals`
- Native-only flows: `deposit()` (fallback/payable) and
`withdraw(uint256)`
- EIP-2612: `permit(owner,spender,value,deadline,v,r,s)`,
`nonces(owner)`, `DOMAIN_SEPARATOR()`
- Events: `Transfer`, `Approval`, `Deposit`, `Withdrawal`
- Storage:
- Approvals via `ApprovesStorage` (double map: owner → spender → amount)
- EIP-2612 nonces via `NoncesStorage` keyed by `H160`
- Instance-aware prefixes to support multiple `pallet_balances`
instances
2025-09-12 08:57:44 +00:00
|
|
|
pub struct NativeErc20Metadata;
|
|
|
|
|
|
|
|
|
|
impl Erc20Metadata for NativeErc20Metadata {
|
|
|
|
|
fn name() -> &'static str {
|
|
|
|
|
"HAVE"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn symbol() -> &'static str {
|
|
|
|
|
"HAVE"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn decimals() -> u8 {
|
|
|
|
|
18
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn is_native_currency() -> bool {
|
|
|
|
|
true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
feat: ✨ Add Moonbeam EVM Precompile Registry (#137)
## 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
---------
Co-authored-by: undercover-cactus <lola@moonsonglabs.com>
2025-09-04 08:25:59 +00:00
|
|
|
/// EVM precompiles available in the DataHaven Mainnet runtime.
|
|
|
|
|
#[precompile_utils::precompile_name_from_address]
|
|
|
|
|
type DataHavenPrecompilesAt<R> = (
|
|
|
|
|
// Ethereum precompiles:
|
|
|
|
|
// We allow DELEGATECALL to stay compliant with Ethereum behavior.
|
|
|
|
|
PrecompileAt<AddressU64<1>, ECRecover, EthereumPrecompilesChecks>,
|
|
|
|
|
PrecompileAt<AddressU64<2>, Sha256, EthereumPrecompilesChecks>,
|
|
|
|
|
PrecompileAt<AddressU64<3>, Ripemd160, EthereumPrecompilesChecks>,
|
|
|
|
|
PrecompileAt<AddressU64<4>, Identity, EthereumPrecompilesChecks>,
|
|
|
|
|
PrecompileAt<AddressU64<5>, Modexp, EthereumPrecompilesChecks>,
|
|
|
|
|
PrecompileAt<AddressU64<6>, Bn128Add, EthereumPrecompilesChecks>,
|
|
|
|
|
PrecompileAt<AddressU64<7>, Bn128Mul, EthereumPrecompilesChecks>,
|
|
|
|
|
PrecompileAt<AddressU64<8>, Bn128Pairing, EthereumPrecompilesChecks>,
|
|
|
|
|
PrecompileAt<AddressU64<9>, Blake2F, EthereumPrecompilesChecks>,
|
|
|
|
|
// Non-DataHaven specific nor Ethereum precompiles :
|
|
|
|
|
PrecompileAt<AddressU64<1024>, Sha3FIPS256, (CallableByContract, CallableByPrecompile)>,
|
|
|
|
|
RemovedPrecompileAt<AddressU64<1025>>,
|
|
|
|
|
PrecompileAt<AddressU64<1026>, ECRecoverPublicKey, (CallableByContract, CallableByPrecompile)>,
|
|
|
|
|
RemovedPrecompileAt<AddressU64<1027>>,
|
|
|
|
|
// DataHaven specific precompiles:
|
feat: Add ERC20 Balances precompile (#150)
## Summary
- Introduces an ERC20-compatible precompile backed by `pallet_balances`,
including approvals and EIP-2612 permit.
- Wires the precompile into Mainnet, Testnet, and Stagenet at address
`0x0000000000000000000000000000000000000802` (u64: 2050).
- Adds comprehensive unit tests and a mock runtime.
## Motivation
- Allow EVM contracts and tooling to interact with Substrate balances
via a familiar ERC20 interface.
- Support off-chain approvals via EIP-2612 for gasless approvals and
improved UX.
## Key Changes
- New crate: `operator/precompiles/erc20-balances`
- Core logic: `src/lib.rs`
- EIP-2612 helpers and validation: `src/eip2612.rs`
- Tests + mock runtime: `src/tests.rs`, `src/mock.rs`
- Runtime wiring (all networks): add `Erc20BalancesPrecompile` at
`AddressU64<2050>`
- `operator/runtime/{mainnet,stagenet,testnet}/src/precompiles.rs`
- Workspace plumbing: include `pallet-evm-precompile-balances-erc20` in
`operator/Cargo.toml`
## Interface
- ERC20: `totalSupply`, `balanceOf`, `allowance`, `approve`, `transfer`,
`transferFrom`, `name`, `symbol`, `decimals`
- Native-only flows: `deposit()` (fallback/payable) and
`withdraw(uint256)`
- EIP-2612: `permit(owner,spender,value,deadline,v,r,s)`,
`nonces(owner)`, `DOMAIN_SEPARATOR()`
- Events: `Transfer`, `Approval`, `Deposit`, `Withdrawal`
- Storage:
- Approvals via `ApprovesStorage` (double map: owner → spender → amount)
- EIP-2612 nonces via `NoncesStorage` keyed by `H160`
- Instance-aware prefixes to support multiple `pallet_balances`
instances
2025-09-12 08:57:44 +00:00
|
|
|
PrecompileAt<
|
|
|
|
|
AddressU64<2050>,
|
|
|
|
|
Erc20BalancesPrecompile<R, NativeErc20Metadata>,
|
|
|
|
|
(CallableByContract, CallableByPrecompile),
|
|
|
|
|
>,
|
feat: ✨ Add Moonbeam Batch precompile (#138)
## 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>
2025-09-05 17:24:09 +00:00
|
|
|
PrecompileAt<
|
|
|
|
|
AddressU64<2056>,
|
|
|
|
|
BatchPrecompile<R>,
|
|
|
|
|
(
|
|
|
|
|
SubcallWithMaxNesting<2>,
|
|
|
|
|
// Batch is the only precompile allowed to call Batch.
|
|
|
|
|
CallableByPrecompile<OnlyFrom<AddressU64<2056>>>,
|
|
|
|
|
),
|
|
|
|
|
>,
|
feat: ✨ Add Moonbeam CallPermit precompile (#140)
## 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 https://github.com/datahaven-xyz/datahaven/pull/137
---------
Co-authored-by: Claude <noreply@anthropic.com>
2025-09-07 13:00:37 +00:00
|
|
|
PrecompileAt<
|
|
|
|
|
AddressU64<2058>,
|
|
|
|
|
CallPermitPrecompile<R>,
|
|
|
|
|
(SubcallWithMaxNesting<0>, CallableByContract),
|
|
|
|
|
>,
|
2025-09-12 07:45:26 +00:00
|
|
|
PrecompileAt<
|
|
|
|
|
AddressU64<2059>,
|
|
|
|
|
ProxyPrecompile<R>,
|
|
|
|
|
(
|
|
|
|
|
CallableByContract<OnlyIsProxyAndProxy<R>>,
|
|
|
|
|
SubcallWithMaxNesting<0>,
|
|
|
|
|
// Batch is the only precompile allowed to call Proxy.
|
|
|
|
|
CallableByPrecompile<OnlyFrom<AddressU64<2056>>>,
|
|
|
|
|
),
|
2025-10-08 21:16:34 +00:00
|
|
|
>,
|
|
|
|
|
PrecompileAt<
|
|
|
|
|
AddressU64<2064>,
|
|
|
|
|
CollectivePrecompile<R, TreasuryCouncilInstance>,
|
|
|
|
|
(CallableByContract, CallableByPrecompile),
|
|
|
|
|
>,
|
2025-10-10 22:17:21 +00:00
|
|
|
PrecompileAt<
|
|
|
|
|
AddressU64<2065>,
|
|
|
|
|
ReferendaPrecompile<R, Origin>,
|
|
|
|
|
(CallableByContract, CallableByPrecompile),
|
|
|
|
|
>,
|
2025-10-09 08:30:50 +00:00
|
|
|
PrecompileAt<
|
|
|
|
|
AddressU64<2066>,
|
|
|
|
|
ConvictionVotingPrecompile<R>,
|
|
|
|
|
(CallableByContract, CallableByPrecompile),
|
|
|
|
|
>,
|
2025-10-09 11:16:46 +00:00
|
|
|
PrecompileAt<
|
|
|
|
|
AddressU64<2067>,
|
|
|
|
|
PreimagePrecompile<R>,
|
|
|
|
|
(CallableByContract, CallableByPrecompile),
|
|
|
|
|
>,
|
2025-10-08 21:16:34 +00:00
|
|
|
PrecompileAt<
|
|
|
|
|
AddressU64<2068>,
|
|
|
|
|
CollectivePrecompile<R, TechnicalCommitteeInstance>,
|
|
|
|
|
(CallableByContract, CallableByPrecompile),
|
2025-09-12 07:45:26 +00:00
|
|
|
>,
|
feat: ✨ Add Moonbeam EVM Precompile Registry (#137)
## 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
---------
Co-authored-by: undercover-cactus <lola@moonsonglabs.com>
2025-09-04 08:25:59 +00:00
|
|
|
PrecompileAt<
|
|
|
|
|
AddressU64<2069>,
|
|
|
|
|
PrecompileRegistry<R>,
|
|
|
|
|
(CallableByContract, CallableByPrecompile),
|
|
|
|
|
>,
|
2025-10-08 13:48:17 +00:00
|
|
|
PrecompileAt<
|
|
|
|
|
AddressU64<2072>,
|
|
|
|
|
IdentityPrecompile<R, MaxAdditionalFields>,
|
|
|
|
|
(CallableByContract, CallableByPrecompile),
|
|
|
|
|
>,
|
2025-09-15 08:43:00 +00:00
|
|
|
PrecompileAt<AddressU64<1028>, FileSystemPrecompile<R>>,
|
feat: ✨ Add Moonbeam EVM Precompile Registry (#137)
## 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
---------
Co-authored-by: undercover-cactus <lola@moonsonglabs.com>
2025-09-04 08:25:59 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/// The PrecompileSet installed in the DataHaven runtime.
|
|
|
|
|
/// We include the nine Istanbul precompiles
|
|
|
|
|
/// (https://github.com/ethereum/go-ethereum/blob/3c46f557/core/vm/contracts.go#L69)
|
|
|
|
|
/// The following distribution has been decided for the precompiles
|
|
|
|
|
/// 0-1023: Ethereum Mainnet Precompiles
|
|
|
|
|
/// 1024-2047 Precompiles that are not in Ethereum Mainnet but are neither DataHaven specific
|
|
|
|
|
/// 2048-4095 DataHaven specific precompiles
|
|
|
|
|
pub type DataHavenPrecompiles<R> = PrecompileSetBuilder<
|
|
|
|
|
R,
|
|
|
|
|
(
|
|
|
|
|
// Skip precompiles if out of range.
|
|
|
|
|
PrecompilesInRangeInclusive<(AddressU64<1>, AddressU64<4095>), DataHavenPrecompilesAt<R>>,
|
|
|
|
|
),
|
|
|
|
|
>;
|