Repository: bluealloy/revm (language: rust)

Issue:
EIP-7702: change `chain_id` type to `U256`
## Description

Change `chain_id` type to `U256`. Blocked by https://github.com/alloy-rs/eips/issues/20.


Discussion / hints:

Fix patch:
diff --git a/Cargo.lock b/Cargo.lock
index 69f4e30101..5f4cbac43e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -115,6 +115,18 @@ name = "alloy-eip7702"
 version = "0.4.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "4c986539255fb839d1533c128e190e557e52ff652c9ef62939e233a81dd93f7e"
+dependencies = [
+ "alloy-primitives",
+ "alloy-rlp",
+ "derive_more 1.0.0",
+ "serde",
+]
+
+[[package]]
+name = "alloy-eip7702"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cabf647eb4650c91a9d38cb6f972bb320009e7e9d61765fb688a86f1563b33e8"
 dependencies = [
  "alloy-primitives",
  "alloy-rlp",
@@ -132,7 +144,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8b6755b093afef5925f25079dd5a7c8d096398b804ba60cb5275397b06b31689"
 dependencies = [
  "alloy-eip2930",
- "alloy-eip7702",
+ "alloy-eip7702 0.4.2",
  "alloy-primitives",
  "alloy-rlp",
  "alloy-serde",
@@ -3302,7 +3314,7 @@ name = "revm-primitives"
 version = "14.0.0"
 dependencies = [
  "alloy-eip2930",
- "alloy-eip7702",
+ "alloy-eip7702 0.5.0",
  "alloy-primitives",
  "auto_impl",
  "bitflags 2.6.0",
diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml
index 8be59e52e1..eb69d3e59b 100644
--- a/crates/primitives/Cargo.toml
+++ b/crates/primitives/Cargo.toml
@@ -24,7 +24,7 @@ all = "warn"
 [dependencies]
 # alloy
 alloy-eip2930 = { version = "0.1", default-features = false }
-alloy-eip7702 = { version = "0.4", default-features = false, features = [
+alloy-eip7702 = { version = "0.5", default-features = false, features = [
     "k256",
 ] }
 alloy-primitives = { version = "0.8", default-features = false, features = [
diff --git a/crates/revm/src/evm.rs b/crates/revm/src/evm.rs
index 5d9f7fb627..724c667abb 100644
--- a/crates/revm/src/evm.rs
+++ b/crates/revm/src/evm.rs
@@ -426,7 +426,7 @@ mod tests {
                 tx.authorization_list = Some(
                     vec![RecoveredAuthorization::new_unchecked(
                         Authorization {
-                            chain_id: 1,
+                            chain_id: U256::from(1),
                             address: delegate,
                             nonce: 0,
                         },
diff --git a/crates/revm/src/handler/mainnet/pre_execution.rs b/crates/revm/src/handler/mainnet/pre_execution.rs
index 5309618864..63586d279a 100644
--- a/crates/revm/src/handler/mainnet/pre_execution.rs
+++ b/crates/revm/src/handler/mainnet/pre_execution.rs
@@ -115,8 +115,8 @@ pub fn apply_eip7702_auth_list<SPEC: Spec, EXT, DB: Database>(
     let mut refunded_accounts = 0;
     for authorization in authorization_list.recovered_iter() {
         // 1. Verify the chain id is either 0 or the chain's current ID.
-        let chain_id = authorization.chain_id();
-        if chain_id != 0 && chain_id != context.evm.inner.env.cfg.chain_id {
+        let chain_id = *authorization.chain_id();
+        if !chain_id.is_zero() && chain_id != U256::from(context.evm.inner.env.cfg.chain_id) {
             continue;
         }
 


Test patch: