refactor: precompile-guard, fees and create-whitelist - #1519
Conversation
|
Crate versions that have been updated:
Runtime version has been increased. |
There was a problem hiding this comment.
🟡 Changes recommended
There are correctness/robustness issues in the new test utilities and some new tests don’t follow the repo’s enforced naming convention.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Refactors the EVM runtime integration around (1) precompile DELEGATECALL/CALLCODE guarding, (2) EVM fee withdraw-fuse handling, and (3) top-level contract creation whitelisting, with accompanying integration-test coverage and runtime version bumps.
Changes:
- Gate top-level EVM contract creation via a deployer whitelist (
CreateOriginFilter) and add integration tests for real Ethereumtransactcreates. - Align
is_precompilewith the precompileexecutesurface to ensure the delegatecall guard applies to all custom precompile addresses, and add Solidity probe contracts for end-to-end testing. - Refactor withdraw-fuse toggling in EVM fee logic using an RAII guard and add unit tests for restoration behavior.
File summaries
| File | Description |
|---|---|
| scripts/test-contracts/contracts/DelegateProbe.sol | Adds a contract used by integration tests to probe CALL vs DELEGATECALL paths to precompiles. |
| scripts/test-contracts/contracts/ContractFactory.sol | Adds a simple factory + minimal child contract for CREATE/CREATE2 testing via Ethereum transactions. |
| scripts/test-contracts/artifacts/contracts/DelegateProbe.sol/DelegateProbe.json | Hardhat artifact for DelegateProbe used by test deployment utilities. |
| scripts/test-contracts/artifacts/contracts/ContractFactory.sol/Minimal.json | Hardhat artifact for Minimal. |
| scripts/test-contracts/artifacts/contracts/ContractFactory.sol/ContractFactory.json | Hardhat artifact for ContractFactory. |
| runtime/hydradx/src/lib.rs | Bumps runtime spec_version. |
| runtime/hydradx/src/evm/runner.rs | Populates the EIP-7702 authorization “authority/authorizing address” field when recoverable. |
| runtime/hydradx/src/evm/precompiles/mod.rs | Expands is_precompile to include all custom precompile addresses served by execute (incl. oracle range). |
| runtime/hydradx/src/evm/mod.rs | Introduces EnsureWhitelistedDeployer and wires it into pallet_evm::Config::CreateOriginFilter. |
| runtime/hydradx/src/evm/evm_fee.rs | Adds with_inactive_withdraw_fuse guard and refactors fee withdraw/refund paths to use it; adds unit tests. |
| runtime/hydradx/Cargo.toml | Bumps runtime crate version. |
| integration-tests/src/gigahdx.rs | Ensures the deployer whitelist is satisfied for a helper that deploys an oracle contract. |
| integration-tests/src/evm.rs | Adds real Ethereum-transaction create/call tests, revert-state tests for currency precompile, and delegatecall-guard tests. |
| integration-tests/Cargo.toml | Bumps integration-tests crate version. |
| Cargo.lock | Updates lockfile versions for bumped crates. |
Review details
Suppressed comments (1)
runtime/hydradx/src/evm/evm_fee.rs:467
- Test name does not follow the repository's BDD-style
*_should_*_when_*naming convention from CLAUDE.md.
fn withdraw_fuse_guard_restores_after_error() {
- Files reviewed: 14/15 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| fn last_deployed_log(from: EvmAddress) -> Option<EvmAddress> { | ||
| System::events().iter().rev().find_map(|r| match &r.event { | ||
| hydradx_runtime::RuntimeEvent::EVM(pallet_evm::Event::Log { log }) | ||
| if log.address == from && log.data.len() == 32 => | ||
| { | ||
| Some(EvmAddress::from_slice(&log.data[12..32])) | ||
| } | ||
| _ => None, | ||
| }) | ||
| } |
| } | ||
|
|
||
| #[test] | ||
| fn withdraw_fuse_guard_restores_after_success() { |
| // SPDX-License-Identifier: UNLICENSED | ||
| pragma solidity ^0.8.24; | ||
|
|
||
| // probes whether a precompile can be reached via DELEGATECALL / CALLCODE |
9ac1bec to
5165420
Compare
|
Quick benchmark at commit 5165420 has been executed successfully. |
No description provided.