Skip to content

Conversation

@pgherveou
Copy link
Contributor

@pgherveou pgherveou commented Jan 29, 2026

Summary

This PR implements EIP-7702 for pallet-revive, enabling Externally Owned Accounts (EOAs) to temporarily delegate their code execution to contract addresses via authorization tuples in transactions.

Key Structural Changes

New AccountType::Delegated Variant

This allows EOAs to:

  • Point to a contract whose code they want to execute
  • Maintain their own independent storage trie

New code_address Field in Execution Frame (exec.rs)

Added code_address: H160 to the Frame struct to track where code/immutable data originates from:

  • Regular contracts: equals the contract's own address
  • Delegated accounts (EIP-7702): the delegation target's address
  • Explicit delegate_call: the callee's address

This unifies immutable data resolution across all execution modes.

EIP-7702 Authorization Processing Module (evm/eip7702.rs)

New module implementing the core EIP-7702 logic:

  • process_authorizations(): Processes authorization list with weight metering
  • validate_authorization(): Validates chain_id, recovers signer, checks nonce, verifies non-contract status
  • apply_delegation(): Sets/clears delegation indicator and increments nonce

Authorization List Support in eth_call Extrinsic (lib.rs)

Extended eth_call with an authorization_list parameter:

  • Processes EIP-7702 authorizations before executing the call
  • Adjusts gas/weight limits by the weight consumed during authorization processing

Delegation-Aware Code Resolution (lib.rs)

Updated Pallet::code() to return the EIP-7702 delegation indicator (0xef0100 || target) for delegated accounts, enabling external tools to detect delegated EOAs.

@pgherveou
Copy link
Contributor Author

/cmd bench --runtime dev --pallet pallet_revive

@pgherveou pgherveou marked this pull request as ready for review February 2, 2026 19:24
- Move TransactionMeter creation inside with_ethereum_context closure
- Handle meter creation errors by returning EthereumCallResult with error
- Process authorizations inside closure with proper error handling
- Fixes OutOfGas errors in test_runtime_set_authorization and related tests

Note: Tests now fail at delegation assertion instead of OutOfGas, indicating
authorization processing may need to happen outside transaction scope.
- Change Call variant to eth_call_with_authorization_list with named field
- Move authorization processing outside with_ethereum_context closure
- Use TransactionMeter with WeightAndDeposit limits for auth processing
- Subtract consumed gas from eth_gas_limit for main call
- Fixes delegation not being applied in runtime tests

All three runtime tests now pass:
- test_runtime_set_authorization
- test_runtime_clear_authorization
- test_runtime_delegation_resolution
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