Skip to content

Commit

Permalink
WEB3-111: Update revm requirement from 13.0 to 14.0 (#210)
Browse files Browse the repository at this point in the history
Updates the requirements on revm to permit the latest version.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Wolfgang Welz <[email protected]>
  • Loading branch information
dependabot[bot] and Wollac authored Sep 7, 2024
1 parent 178fb88 commit c8b4c55
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 57 deletions.
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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" }
Expand Down
6 changes: 3 additions & 3 deletions examples/erc20-counter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
7 changes: 2 additions & 5 deletions examples/erc20-counter/methods/guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }

Expand Down
4 changes: 2 additions & 2 deletions examples/erc20/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion examples/erc20/host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
7 changes: 2 additions & 5 deletions examples/erc20/methods/guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }

Expand Down
5 changes: 2 additions & 3 deletions examples/token-stats/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 1 addition & 4 deletions examples/token-stats/methods/guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
6 changes: 3 additions & 3 deletions steel/src/beacon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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",
);

Expand Down Expand Up @@ -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")?,
})
}
Expand Down
9 changes: 3 additions & 6 deletions steel/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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!(
Expand Down
7 changes: 4 additions & 3 deletions steel/src/host/db/alloy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
Expand Down Expand Up @@ -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())
}
}
11 changes: 7 additions & 4 deletions steel/src/host/db/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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);
Expand All @@ -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());
}
}

Expand Down
23 changes: 11 additions & 12 deletions steel/src/host/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")]
Expand All @@ -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>> {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -177,17 +176,17 @@ 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
.get_block_by_number(self.block, false)
.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();
Expand Down

0 comments on commit c8b4c55

Please sign in to comment.