Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WEB3-111: Update revm requirement from 13.0 to 14.0 #210

Merged
merged 4 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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
Loading