From c8b4c55da3f6bdd5705c679869a6c1aed66ab384 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Sat, 7 Sep 2024 20:33:00 +0000
Subject: [PATCH] WEB3-111: Update revm requirement from 13.0 to 14.0 (#210)

Updates the requirements on revm to permit the latest version.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Wolfgang Welz <welzwo@gmail.com>
---
 Cargo.toml                                    | 12 +++++-----
 examples/erc20-counter/Cargo.toml             |  6 ++---
 .../erc20-counter/methods/guest/Cargo.toml    |  7 ++----
 examples/erc20/Cargo.toml                     |  4 ++--
 examples/erc20/host/Cargo.toml                |  2 +-
 examples/erc20/methods/guest/Cargo.toml       |  7 ++----
 examples/token-stats/Cargo.toml               |  5 ++--
 examples/token-stats/methods/guest/Cargo.toml |  5 +---
 steel/src/beacon.rs                           |  6 ++---
 steel/src/block.rs                            |  9 +++-----
 steel/src/host/db/alloy.rs                    |  7 +++---
 steel/src/host/db/proof.rs                    | 11 +++++----
 steel/src/host/mod.rs                         | 23 +++++++++----------
 13 files changed, 47 insertions(+), 57 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index ffbd2d52..38d4373b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,15 +22,15 @@ risc0-zkp = { git = "https://github.com/risc0/risc0", branch = "main", default-f
 risc0-zkvm = { git = "https://github.com/risc0/risc0", branch = "main", default-features = false }
 
 # Alloy guest dependencies
-alloy-consensus = { version = "0.2.1" }
-alloy-primitives = { version = "0.7" }
+alloy-consensus = { version = "0.3" }
+alloy-primitives = { version = "0.8" }
 alloy-rlp = { version = "0.3.8" }
 alloy-rlp-derive = { version = "0.3.8" }
-alloy-sol-types = { version = "0.7" }
+alloy-sol-types = { version = "0.8" }
 
 # Alloy host dependencies
-alloy = { version = "0.2.1" }
-alloy-trie = { version = "0.4.0" }
+alloy = { version = "0.3" }
+alloy-trie = { version = "0.5" }
 
 # Beacon chain support
 beacon-api-client = { git = "https://github.com/ralexstokes/ethereum-consensus.git", rev = "cf3c404043230559660810bc0c9d6d5a8498d819" }
@@ -42,7 +42,7 @@ clap = { version = "4.5", features = ["derive", "env"] }
 log = "0.4"
 nybbles = { version = "0.2.1" }
 once_cell = "1.19"
-revm = { version = "13.0", default-features = false, features = ["std"] }
+revm = { version = "14.0", default-features = false, features = ["std"] }
 serde = "1.0"
 serde_json = "1.0"
 sha2 = { version = "0.10" }
diff --git a/examples/erc20-counter/Cargo.toml b/examples/erc20-counter/Cargo.toml
index e1e37659..175d32e8 100644
--- a/examples/erc20-counter/Cargo.toml
+++ b/examples/erc20-counter/Cargo.toml
@@ -18,9 +18,9 @@ risc0-build = { git = "https://github.com/risc0/risc0", branch = "main", feature
 risc0-zkvm = { git = "https://github.com/risc0/risc0", branch = "main", default-features = false }
 risc0-zkp = { git = "https://github.com/risc0/risc0", branch = "main", default-features = false }
 
-alloy = { version = "0.2.1", features = ["full"] }
-alloy-primitives = { version = "0.7", features = ["rlp", "serde", "std"] }
-alloy-sol-types = { version = "0.7" }
+alloy = { version = "0.3", features = ["full"] }
+alloy-primitives = { version = "0.8", features = ["rlp", "serde", "std"] }
+alloy-sol-types = { version = "0.8" }
 anyhow = { version = "1.0.75" }
 bincode = { version = "1.3" }
 bytemuck = { version = "1.14" }
diff --git a/examples/erc20-counter/methods/guest/Cargo.toml b/examples/erc20-counter/methods/guest/Cargo.toml
index 395db206..4934e26e 100644
--- a/examples/erc20-counter/methods/guest/Cargo.toml
+++ b/examples/erc20-counter/methods/guest/Cargo.toml
@@ -10,11 +10,8 @@ path = "src/bin/balance_of.rs"
 [workspace]
 
 [dependencies]
-
-# Force the `compile-time-rng` feature, to prevent `getrandom` from being used.
-ahash = { version = "0.8", default-features = false, features = ["compile-time-rng"] }
-alloy-primitives = { version = "0.7" }
-alloy-sol-types = { version = "0.7" }
+alloy-primitives = { version = "0.8" }
+alloy-sol-types = { version = "0.8" }
 risc0-steel = { path = "../../../../steel" }
 risc0-zkvm = { git = "https://github.com/risc0/risc0", branch = "main", default-features = false, features = ["std"] }
 
diff --git a/examples/erc20/Cargo.toml b/examples/erc20/Cargo.toml
index 4d7a1a1f..9001d7db 100644
--- a/examples/erc20/Cargo.toml
+++ b/examples/erc20/Cargo.toml
@@ -11,8 +11,8 @@ risc0-build = { git = "https://github.com/risc0/risc0", branch = "main" }
 risc0-zkvm = { git = "https://github.com/risc0/risc0", branch = "main", default-features = false }
 risc0-zkp = { git = "https://github.com/risc0/risc0", branch = "main", default-features = false }
 
-alloy-primitives = { version = "0.7" }
-alloy-sol-types = { version = "0.7" }
+alloy-primitives = { version = "0.8" }
+alloy-sol-types = { version = "0.8" }
 anyhow = "1.0"
 clap = { version = "4.5", features = ["derive", "env"] }
 erc20-methods = { path = "methods" }
diff --git a/examples/erc20/host/Cargo.toml b/examples/erc20/host/Cargo.toml
index 0f714f2e..3f207370 100644
--- a/examples/erc20/host/Cargo.toml
+++ b/examples/erc20/host/Cargo.toml
@@ -9,7 +9,7 @@ alloy-sol-types = { workspace = true }
 anyhow = { workspace = true }
 clap = { workspace = true }
 erc20-methods = { workspace = true }
-risc0-steel = { path = "../../../steel", features = ["host"] }
+risc0-steel = { workspace = true, features = ["host"] }
 risc0-zkvm = { workspace = true, features = ["client"] }
 tokio = { workspace = true }
 tracing-subscriber = { workspace = true }
diff --git a/examples/erc20/methods/guest/Cargo.toml b/examples/erc20/methods/guest/Cargo.toml
index 0054e9e6..a08d430f 100644
--- a/examples/erc20/methods/guest/Cargo.toml
+++ b/examples/erc20/methods/guest/Cargo.toml
@@ -6,11 +6,8 @@ edition = "2021"
 [workspace]
 
 [dependencies]
-
-# Force the `compile-time-rng` feature, to prevent `getrandom` from being used.
-ahash = { version = "0.8", default-features = false, features = ["compile-time-rng"] }
-alloy-primitives = { version = "0.7" }
-alloy-sol-types = { version = "0.7" }
+alloy-primitives = { version = "0.8" }
+alloy-sol-types = { version = "0.8" }
 risc0-steel = { path = "../../../../steel" }
 risc0-zkvm = { git = "https://github.com/risc0/risc0", branch = "main", default-features = false, features = ["std"] }
 
diff --git a/examples/token-stats/Cargo.toml b/examples/token-stats/Cargo.toml
index 465c48e5..1b5af6c7 100644
--- a/examples/token-stats/Cargo.toml
+++ b/examples/token-stats/Cargo.toml
@@ -11,16 +11,15 @@ risc0-build = { git = "https://github.com/risc0/risc0", branch = "main" }
 risc0-zkvm = { git = "https://github.com/risc0/risc0", branch = "main", default-features = false }
 risc0-zkp = { git = "https://github.com/risc0/risc0", branch = "main", default-features = false }
 
-alloy-primitives = { version = "0.7", features = ["serde", "rlp", "std"] }
+alloy-primitives = { version = "0.8", features = ["serde", "rlp", "std"] }
 alloy-rlp = { version = "0.3", default-features = false }
 alloy-rlp-derive = { version = "0.3", default-features = false }
-alloy-sol-types = { version = "0.7" }
+alloy-sol-types = { version = "0.8" }
 anyhow = "1.0"
 clap = { version = "4.4", features = ["derive", "env"] }
 log = "0.4"
 methods = { path = "methods" }
 once_cell = "1.19"
-revm = { version = "9.0", default-features = false, features = ["std"] }
 rlp = "0.5.2"
 serde = "1.0"
 thiserror = "1.0"
diff --git a/examples/token-stats/methods/guest/Cargo.toml b/examples/token-stats/methods/guest/Cargo.toml
index b6de88fa..6f46ca82 100644
--- a/examples/token-stats/methods/guest/Cargo.toml
+++ b/examples/token-stats/methods/guest/Cargo.toml
@@ -6,14 +6,11 @@ edition = "2021"
 [workspace]
 
 [dependencies]
-alloy-sol-types = { version = "0.7" }
+alloy-sol-types = { version = "0.8" }
 core = { path = "../../core" }
 risc0-steel = { path = "../../../../steel" }
 risc0-zkvm = { git = "https://github.com/risc0/risc0", branch = "main", default-features = false, features = ["std"] }
 
-# Force the `compile-time-rng` feature, to prevent `getrandom` from being used.
-ahash = { version = "0.8", default-features = false, features = ["compile-time-rng"] }
-
 [patch.crates-io]
 # use optimized risc0 circuit
 crypto-bigint = { git = "https://github.com/risc0/RustCrypto-crypto-bigint", tag = "v0.5.5-risczero.0" }
diff --git a/steel/src/beacon.rs b/steel/src/beacon.rs
index e7c0eb8a..1cb6580a 100644
--- a/steel/src/beacon.rs
+++ b/steel/src/beacon.rs
@@ -119,7 +119,7 @@ mod host {
 
             // first get the header of the parent and then the actual block header
             let parent_beacon_header = client
-                .get_beacon_header(BlockId::Root(parent_beacon_block_root))
+                .get_beacon_header(BlockId::Root(parent_beacon_block_root.0.into()))
                 .await
                 .with_context(|| {
                     format!("failed to get block header {}", parent_beacon_block_root)
@@ -155,7 +155,7 @@ mod host {
                 .try_into()
                 .context("proof derived from API is invalid")?;
             ensure!(
-                proof.process(block_hash) == beacon_root,
+                proof.process(block_hash).0 == beacon_root.0,
                 "proof derived from API does not verify",
             );
 
@@ -215,7 +215,7 @@ mod host {
             ensure!(proof.branch.len() == depth as usize, "index is invalid");
 
             Ok(MerkleProof {
-                path: proof.branch,
+                path: proof.branch.iter().map(|n| n.0.into()).collect(),
                 index: index.try_into().context("index too large")?,
             })
         }
diff --git a/steel/src/block.rs b/steel/src/block.rs
index fe7ad956..a3dfe64e 100644
--- a/steel/src/block.rs
+++ b/steel/src/block.rs
@@ -79,10 +79,7 @@ pub mod host {
         },
         EvmBlockHeader,
     };
-    use alloy::{
-        network::Network, providers::Provider, rpc::types::Header as RpcHeader,
-        transports::Transport,
-    };
+    use alloy::{network::Network, providers::Provider, transports::Transport};
     use anyhow::{anyhow, ensure};
     use log::debug;
 
@@ -95,8 +92,8 @@ pub mod host {
             T: Transport + Clone,
             N: Network,
             P: Provider<T, N>,
-            H: EvmBlockHeader + TryFrom<RpcHeader>,
-            <H as TryFrom<RpcHeader>>::Error: Display,
+            H: EvmBlockHeader + TryFrom<<N as Network>::HeaderResponse>,
+            <H as TryFrom<<N as Network>::HeaderResponse>>::Error: Display,
         {
             let mut db = env.db.unwrap();
             assert_eq!(
diff --git a/steel/src/host/db/alloy.rs b/steel/src/host/db/alloy.rs
index fcd3cbc1..124d068e 100644
--- a/steel/src/host/db/alloy.rs
+++ b/steel/src/host/db/alloy.rs
@@ -16,7 +16,7 @@ use std::{collections::HashMap, future::IntoFuture, marker::PhantomData};
 
 use super::provider::{ProviderConfig, ProviderDb};
 use alloy::{
-    network::Network,
+    network::{BlockResponse, HeaderResponse, Network},
     providers::Provider,
     transports::{Transport, TransportError},
 };
@@ -146,7 +146,8 @@ impl<T: Transport + Clone, N: Network, P: Provider<T, N>> Database for AlloyDb<T
         let block = self
             .handle
             .block_on(self.provider.get_block_by_number(number.into(), false))?;
-        let header = block.unwrap().header;
-        Ok(header.hash.unwrap())
+        // TODO: return proper error
+        let block = block.unwrap();
+        Ok(block.header().hash())
     }
 }
diff --git a/steel/src/host/db/proof.rs b/steel/src/host/db/proof.rs
index 31304fcd..241c7f18 100644
--- a/steel/src/host/db/proof.rs
+++ b/steel/src/host/db/proof.rs
@@ -18,9 +18,9 @@ use super::{provider::ProviderDb, AlloyDb};
 use crate::MerkleTrie;
 use alloy::{
     eips::eip2930::{AccessList, AccessListItem},
-    network::Network,
+    network::{BlockResponse, Network},
     providers::Provider,
-    rpc::types::{EIP1186AccountProofResponse, Header},
+    rpc::types::EIP1186AccountProofResponse,
     transports::Transport,
 };
 use alloy_primitives::{Address, BlockNumber, Bytes, StorageKey, StorageValue, B256, U256};
@@ -115,7 +115,10 @@ impl<T: Transport + Clone, N: Network, P: Provider<T, N>> ProofDb<AlloyDb<T, N,
     }
 
     /// Returns the proof (hash chain) of all `blockhash` calls recorded by the [Database].
-    pub async fn ancestor_proof(&self, block_number: BlockNumber) -> Result<Vec<Header>> {
+    pub async fn ancestor_proof(
+        &self,
+        block_number: BlockNumber,
+    ) -> Result<Vec<<N as Network>::HeaderResponse>> {
         let mut ancestors = Vec::new();
         if let Some(&block_hash_min_number) = self.block_hash_numbers.iter().min() {
             assert!(block_hash_min_number <= block_number);
@@ -127,7 +130,7 @@ impl<T: Transport + Clone, N: Network, P: Provider<T, N>> ProofDb<AlloyDb<T, N,
                     .await
                     .context("eth_getBlockByNumber failed")?
                     .with_context(|| format!("block {} not found", number))?;
-                ancestors.push(rpc_block.header);
+                ancestors.push(rpc_block.header().clone());
             }
         }
 
diff --git a/steel/src/host/mod.rs b/steel/src/host/mod.rs
index 1be8554c..f1454779 100644
--- a/steel/src/host/mod.rs
+++ b/steel/src/host/mod.rs
@@ -22,9 +22,8 @@ use crate::{
     EvmBlockHeader, EvmEnv, EvmInput,
 };
 use alloy::{
-    network::{Ethereum, Network},
+    network::{BlockResponse, Ethereum, Network},
     providers::{Provider, ProviderBuilder, ReqwestProvider, RootProvider},
-    rpc::types::Header as RpcHeader,
     transports::{
         http::{Client, Http},
         Transport,
@@ -59,8 +58,8 @@ where
     T: Transport + Clone,
     N: Network,
     P: Provider<T, N>,
-    H: EvmBlockHeader + TryFrom<RpcHeader>,
-    <H as TryFrom<RpcHeader>>::Error: Display,
+    H: EvmBlockHeader + TryFrom<<N as Network>::HeaderResponse>,
+    <H as TryFrom<<N as Network>::HeaderResponse>>::Error: Display,
 {
     /// Creates a new provable [EvmEnv] from an alloy [Provider].
     #[deprecated(since = "0.12.0", note = "use `EvmEnv::builder().provider()` instead")]
@@ -78,8 +77,8 @@ where
     T: Transport + Clone,
     N: Network,
     P: Provider<T, N>,
-    H: EvmBlockHeader + TryFrom<RpcHeader>,
-    <H as TryFrom<RpcHeader>>::Error: Display,
+    H: EvmBlockHeader + TryFrom<<N as Network>::HeaderResponse>,
+    <H as TryFrom<<N as Network>::HeaderResponse>>::Error: Display,
 {
     /// Converts the environment into a [EvmInput] committing to a block hash.
     pub async fn into_input(self) -> Result<EvmInput<H>> {
@@ -138,8 +137,8 @@ impl<H: EvmBlockHeader> EvmEnvBuilder<NoProvider, H> {
         T: Transport + Clone,
         N: Network,
         P: Provider<T, N>,
-        H: EvmBlockHeader + TryFrom<RpcHeader>,
-        <H as TryFrom<RpcHeader>>::Error: Display,
+        H: EvmBlockHeader + TryFrom<<N as Network>::HeaderResponse>,
+        <H as TryFrom<<N as Network>::HeaderResponse>>::Error: Display,
     {
         EvmEnvBuilder {
             provider,
@@ -177,8 +176,8 @@ impl<P, H> EvmEnvBuilder<P, H> {
         T: Transport + Clone,
         N: Network,
         P: Provider<T, N>,
-        H: EvmBlockHeader + TryFrom<RpcHeader>,
-        <H as TryFrom<RpcHeader>>::Error: Display,
+        H: EvmBlockHeader + TryFrom<<N as Network>::HeaderResponse>,
+        <H as TryFrom<<N as Network>::HeaderResponse>>::Error: Display,
     {
         let rpc_block = self
             .provider
@@ -186,8 +185,8 @@ impl<P, H> EvmEnvBuilder<P, H> {
             .await
             .context("eth_getBlockByNumber failed")?
             .with_context(|| format!("block {} not found", self.block))?;
-        let header: H = rpc_block
-            .header
+        let header = rpc_block.header().clone();
+        let header: H = header
             .try_into()
             .map_err(|err| anyhow!("header invalid: {}", err))?;
         let sealed_header = header.seal_slow();