Skip to content

refactor: precompile-guard, fees and create-whitelist - #1519

Merged
enthusiastmartin merged 3 commits into
masterfrom
evm-fixes-squashed
Sep 3, 2026
Merged

refactor: precompile-guard, fees and create-whitelist#1519
enthusiastmartin merged 3 commits into
masterfrom
evm-fixes-squashed

Conversation

@mrq1911

@mrq1911 mrq1911 commented Sep 2, 2026

Copy link
Copy Markdown
Member

No description provided.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Crate versions that have been updated:

  • runtime-integration-tests: v1.108.0 -> v1.108.1
  • hydradx-runtime: v440.0.0 -> v441.0.0

Runtime version has been increased.

@mrq1911 mrq1911 changed the title refactor: precompile-guard and create-whitelist refactor: precompile-guard, fees and create-whitelist Sep 2, 2026
@mrq1911
mrq1911 marked this pull request as ready for review September 2, 2026 21:11
Copilot AI lite review requested due to automatic review settings September 2, 2026 21:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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 Ethereum transact creates.
  • Align is_precompile with the precompile execute surface 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.

Comment on lines +3447 to +3456
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
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Quick benchmark at commit 5165420 has been executed successfully.
View results

@enthusiastmartin
enthusiastmartin merged commit ce66e3a into master Sep 3, 2026
10 of 11 checks passed
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.

3 participants