From 0c2bf2a28f4f063758cc77b8aa36d07fdec29b79 Mon Sep 17 00:00:00 2001 From: Rami Khalil Date: Sat, 14 Dec 2024 07:40:43 +0200 Subject: [PATCH 1/7] enable lto in guest builds --- guests/reth-ethereum/Cargo.toml | 13 +++++++++++++ guests/reth-optimism/Cargo.toml | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/guests/reth-ethereum/Cargo.toml b/guests/reth-ethereum/Cargo.toml index 996ed4c4..250cb7fb 100644 --- a/guests/reth-ethereum/Cargo.toml +++ b/guests/reth-ethereum/Cargo.toml @@ -5,6 +5,19 @@ edition = "2021" [workspace] +[profile.dev] +opt-level = 3 + +[profile.dev.build-override] +opt-level = 3 + +[profile.release] +debug = 1 +lto = true + +[profile.release.build-override] +opt-level = 3 + [dependencies.risc0-zkvm] git = "https://github.com/risc0/risc0" rev = "e98cdad96cfecb3d959cb62abf566e5b17a0d649" diff --git a/guests/reth-optimism/Cargo.toml b/guests/reth-optimism/Cargo.toml index 90a67309..80d869b1 100644 --- a/guests/reth-optimism/Cargo.toml +++ b/guests/reth-optimism/Cargo.toml @@ -5,6 +5,19 @@ edition = "2021" [workspace] +[profile.dev] +opt-level = 3 + +[profile.dev.build-override] +opt-level = 3 + +[profile.release] +debug = 1 +lto = true + +[profile.release.build-override] +opt-level = 3 + [dependencies.risc0-zkvm] git = "https://github.com/risc0/risc0" rev = "e98cdad96cfecb3d959cb62abf566e5b17a0d649" From dec32f9d562e688b0536679700661b5a4d78ccfa Mon Sep 17 00:00:00 2001 From: Rami Khalil Date: Sat, 14 Dec 2024 09:27:47 +0200 Subject: [PATCH 2/7] update guest build config --- guests/reth-ethereum/Cargo.toml | 9 ++++++++- guests/reth-optimism/Cargo.toml | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/guests/reth-ethereum/Cargo.toml b/guests/reth-ethereum/Cargo.toml index 250cb7fb..c9712579 100644 --- a/guests/reth-ethereum/Cargo.toml +++ b/guests/reth-ethereum/Cargo.toml @@ -6,16 +6,23 @@ edition = "2021" [workspace] [profile.dev] +codegen-units = 1 +debug = 1 +lto = "fat" opt-level = 3 [profile.dev.build-override] +codegen-units = 1 opt-level = 3 [profile.release] +codegen-units = 1 debug = 1 -lto = true +lto = "fat" +opt-level = 3 [profile.release.build-override] +codegen-units = 1 opt-level = 3 [dependencies.risc0-zkvm] diff --git a/guests/reth-optimism/Cargo.toml b/guests/reth-optimism/Cargo.toml index 80d869b1..db5f1ddb 100644 --- a/guests/reth-optimism/Cargo.toml +++ b/guests/reth-optimism/Cargo.toml @@ -6,16 +6,23 @@ edition = "2021" [workspace] [profile.dev] +codegen-units = 1 +debug = 1 +lto = "fat" opt-level = 3 [profile.dev.build-override] +codegen-units = 1 opt-level = 3 [profile.release] +codegen-units = 1 debug = 1 -lto = true +lto = "fat" +opt-level = 3 [profile.release.build-override] +codegen-units = 1 opt-level = 3 [dependencies.risc0-zkvm] From 9378be3d6a3716c026998fc84fe590f9ea435516 Mon Sep 17 00:00:00 2001 From: Rami Khalil Date: Sun, 15 Dec 2024 08:09:46 +0200 Subject: [PATCH 3/7] refactor core db mod --- crates/core-ethereum/src/lib.rs | 2 +- crates/core-optimism/src/lib.rs | 2 +- crates/core/src/db.rs | 202 ------------------------ crates/core/src/db/changeset.rs | 79 +++++++++ crates/core/src/db/memory.rs | 72 +++++++++ crates/core/src/db/mod.rs | 18 +++ crates/core/src/db/unreachable.rs | 41 +++++ crates/core/src/db/wrapper.rs | 65 ++++++++ crates/core/src/stateless/finalize.rs | 5 +- crates/core/src/stateless/initialize.rs | 2 +- crates/preflight-ethereum/src/lib.rs | 2 +- crates/preflight-optimism/src/lib.rs | 2 +- crates/preflight/src/client.rs | 2 +- crates/preflight/src/db.rs | 4 +- testing/ef-tests/src/driver.rs | 2 +- testing/ef-tests/tests/evm.rs | 3 +- 16 files changed, 289 insertions(+), 214 deletions(-) delete mode 100644 crates/core/src/db.rs create mode 100644 crates/core/src/db/changeset.rs create mode 100644 crates/core/src/db/memory.rs create mode 100644 crates/core/src/db/mod.rs create mode 100644 crates/core/src/db/unreachable.rs create mode 100644 crates/core/src/db/wrapper.rs diff --git a/crates/core-ethereum/src/lib.rs b/crates/core-ethereum/src/lib.rs index ab9a0d9d..24709321 100644 --- a/crates/core-ethereum/src/lib.rs +++ b/crates/core-ethereum/src/lib.rs @@ -33,7 +33,7 @@ use reth_storage_errors::provider::ProviderError; use std::fmt::Display; use std::mem::take; use std::sync::Arc; -use zeth_core::db::MemoryDB; +use zeth_core::db::memory::MemoryDB; use zeth_core::driver::CoreDriver; use zeth_core::stateless::client::StatelessClient; use zeth_core::stateless::execute::ExecutionStrategy; diff --git a/crates/core-optimism/src/lib.rs b/crates/core-optimism/src/lib.rs index 707d0f40..ca55f97a 100644 --- a/crates/core-optimism/src/lib.rs +++ b/crates/core-optimism/src/lib.rs @@ -34,7 +34,7 @@ use reth_storage_errors::provider::ProviderError; use std::fmt::Display; use std::mem::take; use std::sync::Arc; -use zeth_core::db::MemoryDB; +use zeth_core::db::memory::MemoryDB; use zeth_core::driver::CoreDriver; use zeth_core::stateless::client::StatelessClient; use zeth_core::stateless::execute::ExecutionStrategy; diff --git a/crates/core/src/db.rs b/crates/core/src/db.rs deleted file mode 100644 index 443f4f8c..00000000 --- a/crates/core/src/db.rs +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright 2024 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use crate::rescue::{Recoverable, Wrapper}; -use alloy_primitives::map::{HashMap, HashSet}; -use alloy_primitives::{Address, B256, U256}; -use reth_primitives::revm_primitives::{Account, AccountInfo, Bytecode}; -use reth_primitives::KECCAK_EMPTY; -use reth_revm::db::states::{PlainStorageChangeset, StateChangeset}; -use reth_revm::db::{AccountState, BundleState, CacheDB}; -use reth_revm::{Database, DatabaseCommit, DatabaseRef}; -use reth_storage_errors::db::DatabaseError; - -pub type MemoryDB = CacheDB; - -#[derive(Clone, Copy, Default)] -pub struct UnreachableDB; - -impl DatabaseRef for UnreachableDB { - type Error = DatabaseError; - - fn basic_ref(&self, address: Address) -> Result, Self::Error> { - unreachable!("basic_ref {address}") - } - - fn code_by_hash_ref(&self, code_hash: B256) -> Result { - unreachable!("code_by_hash_ref {code_hash}") - } - - fn storage_ref(&self, address: Address, index: U256) -> Result { - unreachable!("storage_ref {address}-{index}") - } - - fn block_hash_ref(&self, number: u64) -> Result { - unreachable!("block_hash_ref {number}") - } -} - -impl Recoverable for MemoryDB { - fn rescue(&mut self) -> Option { - Some(core::mem::take(self)) - } -} - -impl Database for Wrapper { - type Error = ::Error; - - fn basic(&mut self, address: Address) -> Result, Self::Error> { - self.inner.basic(address) - } - - fn code_by_hash(&mut self, code_hash: B256) -> Result { - self.inner.code_by_hash(code_hash) - } - - fn storage(&mut self, address: Address, index: U256) -> Result { - self.inner.storage(address, index) - } - - fn block_hash(&mut self, number: u64) -> Result { - self.inner.block_hash(number) - } -} - -impl DatabaseRef for Wrapper { - type Error = ::Error; - - fn basic_ref(&self, address: Address) -> Result, Self::Error> { - self.inner.basic_ref(address) - } - - fn code_by_hash_ref(&self, code_hash: B256) -> Result { - self.inner.code_by_hash_ref(code_hash) - } - - fn storage_ref(&self, address: Address, index: U256) -> Result { - self.inner.storage_ref(address, index) - } - - fn block_hash_ref(&self, number: u64) -> Result { - self.inner.block_hash_ref(number) - } -} - -impl DatabaseCommit for Wrapper { - fn commit(&mut self, changes: HashMap) { - self.inner.commit(changes) - } -} - -pub fn apply_changeset( - db: &mut CacheDB, - state_changeset: StateChangeset, -) -> anyhow::Result<()> { - // Update accounts in state trie - let mut was_destroyed = HashSet::new(); - for (address, account_info) in state_changeset.accounts { - let db_account = db.accounts.get_mut(&address).unwrap(); - let Some(info) = account_info else { - db_account.storage.clear(); - db_account.account_state = AccountState::NotExisting; - db_account.info = AccountInfo::default(); - was_destroyed.insert(address); - continue; - }; - if info.code_hash != db_account.info.code_hash { - db_account.info = info; - } else { - db_account.info.balance = info.balance; - db_account.info.nonce = info.nonce; - } - } - // Update account storages - for PlainStorageChangeset { - address, - wipe_storage, - storage, - } in state_changeset.storage - { - if was_destroyed.contains(&address) { - continue; - } - let db_account = db.accounts.get_mut(&address).unwrap(); - if wipe_storage { - db_account.storage.clear(); - db_account.account_state = AccountState::StorageCleared; - } - for (key, val) in storage { - db_account.storage.insert(key, val); - } - } - Ok(()) -} - -/// This function is a modified version of [`BundleState::into_plane_state`] from the revm crate: -/// https://github.com/bluealloy/revm/blob/4f093996c6059aad4db02b7eb03dca13e13be8a1/crates/revm/src/db/states/bundle_state.rs#L587 -/// It retains account code for reuse instead of the default revm behavior to drop it. -pub fn into_plain_state(bundle: BundleState) -> StateChangeset { - // pessimistically pre-allocate assuming _all_ accounts changed. - let state_len = bundle.state.len(); - let mut accounts = Vec::with_capacity(state_len); - let mut storage = Vec::with_capacity(state_len); - - for (address, account) in bundle.state { - // append account info if it is changed. - let was_destroyed = account.was_destroyed(); - if account.is_info_changed() { - accounts.push((address, account.info)); - } - - // append storage changes - - // NOTE: Assumption is that revert is going to remove whole plain storage from - // database so we can check if plain state was wiped or not. - let mut account_storage_changed = Vec::with_capacity(account.storage.len()); - - for (key, slot) in account.storage { - // If storage was destroyed that means that storage was wiped. - // In that case we need to check if present storage value is different then ZERO. - let destroyed_and_not_zero = was_destroyed && !slot.present_value.is_zero(); - - // If account is not destroyed check if original values was changed, - // so we can update it. - let not_destroyed_and_changed = !was_destroyed && slot.is_changed(); - - if destroyed_and_not_zero || not_destroyed_and_changed { - account_storage_changed.push((key, slot.present_value)); - } - } - - if !account_storage_changed.is_empty() || was_destroyed { - // append storage changes to account. - storage.push(PlainStorageChangeset { - address, - wipe_storage: was_destroyed, - storage: account_storage_changed, - }); - } - } - let contracts = bundle - .contracts - .into_iter() - // remove empty bytecodes - .filter(|(b, _)| *b != KECCAK_EMPTY) - .collect::>(); - StateChangeset { - accounts, - storage, - contracts, - } -} diff --git a/crates/core/src/db/changeset.rs b/crates/core/src/db/changeset.rs new file mode 100644 index 00000000..5e91574f --- /dev/null +++ b/crates/core/src/db/changeset.rs @@ -0,0 +1,79 @@ +// Copyright 2024 RISC Zero, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use reth_revm::db::states::{PlainStorageChangeset, StateChangeset}; +use reth_revm::db::BundleState; +use reth_primitives::KECCAK_EMPTY; + +pub trait ApplyChangeset { + fn apply_changeset(&mut self, changeset: StateChangeset) -> anyhow::Result<()>; +} + +/// This function is a modified version of [`BundleState::into_plane_state`] from the revm crate: +/// https://github.com/bluealloy/revm/blob/4f093996c6059aad4db02b7eb03dca13e13be8a1/crates/revm/src/db/states/bundle_state.rs#L587 +/// It retains account code for reuse instead of the default revm behavior to drop it. +pub fn into_plain_state(bundle: BundleState) -> StateChangeset { + // pessimistically pre-allocate assuming _all_ accounts changed. + let state_len = bundle.state.len(); + let mut accounts = Vec::with_capacity(state_len); + let mut storage = Vec::with_capacity(state_len); + + for (address, account) in bundle.state { + // append account info if it is changed. + let was_destroyed = account.was_destroyed(); + if account.is_info_changed() { + accounts.push((address, account.info)); + } + + // append storage changes + + // NOTE: Assumption is that revert is going to remove whole plain storage from + // database so we can check if plain state was wiped or not. + let mut account_storage_changed = Vec::with_capacity(account.storage.len()); + + for (key, slot) in account.storage { + // If storage was destroyed that means that storage was wiped. + // In that case we need to check if present storage value is different then ZERO. + let destroyed_and_not_zero = was_destroyed && !slot.present_value.is_zero(); + + // If account is not destroyed check if original values was changed, + // so we can update it. + let not_destroyed_and_changed = !was_destroyed && slot.is_changed(); + + if destroyed_and_not_zero || not_destroyed_and_changed { + account_storage_changed.push((key, slot.present_value)); + } + } + + if !account_storage_changed.is_empty() || was_destroyed { + // append storage changes to account. + storage.push(PlainStorageChangeset { + address, + wipe_storage: was_destroyed, + storage: account_storage_changed, + }); + } + } + let contracts = bundle + .contracts + .into_iter() + // remove empty bytecodes + .filter(|(b, _)| *b != KECCAK_EMPTY) + .collect::>(); + StateChangeset { + accounts, + storage, + contracts, + } +} \ No newline at end of file diff --git a/crates/core/src/db/memory.rs b/crates/core/src/db/memory.rs new file mode 100644 index 00000000..a59c2538 --- /dev/null +++ b/crates/core/src/db/memory.rs @@ -0,0 +1,72 @@ +// Copyright 2024 RISC Zero, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::db::unreachable::UnreachableDB; +use crate::db::changeset::ApplyChangeset; +use crate::rescue::Recoverable; +use alloy_primitives::map::HashSet; +use reth_primitives::revm_primitives::AccountInfo; +use reth_revm::db::states::{PlainStorageChangeset, StateChangeset}; +use reth_revm::db::{AccountState, CacheDB}; + +pub type MemoryDB = CacheDB; + +impl Recoverable for CacheDB { + fn rescue(&mut self) -> Option { + Some(core::mem::take(self)) + } +} + +impl ApplyChangeset for CacheDB { + fn apply_changeset(&mut self, changeset: StateChangeset) -> anyhow::Result<()> { + // Update accounts in state trie + let mut was_destroyed = HashSet::new(); + for (address, account_info) in changeset.accounts { + let db_account = self.accounts.get_mut(&address).unwrap(); + let Some(info) = account_info else { + db_account.storage.clear(); + db_account.account_state = AccountState::NotExisting; + db_account.info = AccountInfo::default(); + was_destroyed.insert(address); + continue; + }; + if info.code_hash != db_account.info.code_hash { + db_account.info = info; + } else { + db_account.info.balance = info.balance; + db_account.info.nonce = info.nonce; + } + } + // Update account storages + for PlainStorageChangeset { + address, + wipe_storage, + storage, + } in changeset.storage + { + if was_destroyed.contains(&address) { + continue; + } + let db_account = self.accounts.get_mut(&address).unwrap(); + if wipe_storage { + db_account.storage.clear(); + db_account.account_state = AccountState::StorageCleared; + } + for (key, val) in storage { + db_account.storage.insert(key, val); + } + } + Ok(()) + } +} diff --git a/crates/core/src/db/mod.rs b/crates/core/src/db/mod.rs new file mode 100644 index 00000000..cc5e346d --- /dev/null +++ b/crates/core/src/db/mod.rs @@ -0,0 +1,18 @@ +// Copyright 2024 RISC Zero, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +pub mod memory; +pub mod unreachable; +pub mod wrapper; +pub mod changeset; diff --git a/crates/core/src/db/unreachable.rs b/crates/core/src/db/unreachable.rs new file mode 100644 index 00000000..0a79aac9 --- /dev/null +++ b/crates/core/src/db/unreachable.rs @@ -0,0 +1,41 @@ +// Copyright 2024 RISC Zero, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use alloy_primitives::{Address, B256, U256}; +use reth_primitives::revm_primitives::db::DatabaseRef; +use reth_primitives::revm_primitives::{AccountInfo, Bytecode}; +use reth_storage_errors::db::DatabaseError; + +#[derive(Clone, Copy, Default)] +pub struct UnreachableDB; + +impl DatabaseRef for UnreachableDB { + type Error = DatabaseError; + + fn basic_ref(&self, address: Address) -> Result, Self::Error> { + unreachable!("basic_ref {address}") + } + + fn code_by_hash_ref(&self, code_hash: B256) -> Result { + unreachable!("code_by_hash_ref {code_hash}") + } + + fn storage_ref(&self, address: Address, index: U256) -> Result { + unreachable!("storage_ref {address}-{index}") + } + + fn block_hash_ref(&self, number: u64) -> Result { + unreachable!("block_hash_ref {number}") + } +} diff --git a/crates/core/src/db/wrapper.rs b/crates/core/src/db/wrapper.rs new file mode 100644 index 00000000..5b904e75 --- /dev/null +++ b/crates/core/src/db/wrapper.rs @@ -0,0 +1,65 @@ +// Copyright 2024 RISC Zero, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::rescue::{Recoverable, Wrapper}; +use alloy_primitives::map::HashMap; +use alloy_primitives::{Address, B256, U256}; +use reth_primitives::revm_primitives::db::{Database, DatabaseCommit, DatabaseRef}; +use reth_primitives::revm_primitives::{Account, AccountInfo, Bytecode}; + +impl Database for Wrapper { + type Error = ::Error; + + fn basic(&mut self, address: Address) -> Result, Self::Error> { + self.inner.basic(address) + } + + fn code_by_hash(&mut self, code_hash: B256) -> Result { + self.inner.code_by_hash(code_hash) + } + + fn storage(&mut self, address: Address, index: U256) -> Result { + self.inner.storage(address, index) + } + + fn block_hash(&mut self, number: u64) -> Result { + self.inner.block_hash(number) + } +} + +impl DatabaseRef for Wrapper { + type Error = ::Error; + + fn basic_ref(&self, address: Address) -> Result, Self::Error> { + self.inner.basic_ref(address) + } + + fn code_by_hash_ref(&self, code_hash: B256) -> Result { + self.inner.code_by_hash_ref(code_hash) + } + + fn storage_ref(&self, address: Address, index: U256) -> Result { + self.inner.storage_ref(address, index) + } + + fn block_hash_ref(&self, number: u64) -> Result { + self.inner.block_hash_ref(number) + } +} + +impl DatabaseCommit for Wrapper { + fn commit(&mut self, changes: HashMap) { + self.inner.commit(changes) + } +} diff --git a/crates/core/src/stateless/finalize.rs b/crates/core/src/stateless/finalize.rs index 7d222931..1eb00f5f 100644 --- a/crates/core/src/stateless/finalize.rs +++ b/crates/core/src/stateless/finalize.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::db::{apply_changeset, into_plain_state, MemoryDB}; +use crate::db::memory::MemoryDB; use crate::driver::CoreDriver; use crate::keccak::keccak; use crate::mpt::MptNode; @@ -23,6 +23,7 @@ use alloy_primitives::{Address, U256}; use anyhow::Context; use reth_revm::db::states::StateChangeset; use reth_revm::db::BundleState; +use crate::db::changeset::{into_plain_state, ApplyChangeset}; pub trait FinalizationStrategy { fn finalize_state( @@ -139,7 +140,7 @@ impl FinalizationStrategy for RethFinaliza // Update the database if let Some(db) = db { - apply_changeset(db, state_changeset)?; + db.apply_changeset(state_changeset)?; db.block_hashes.insert( U256::from(Driver::block_number(header)), diff --git a/crates/core/src/stateless/initialize.rs b/crates/core/src/stateless/initialize.rs index 6051323b..1caad992 100644 --- a/crates/core/src/stateless/initialize.rs +++ b/crates/core/src/stateless/initialize.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::db::MemoryDB; +use crate::db::memory::MemoryDB; use crate::driver::CoreDriver; use crate::keccak::keccak; use crate::mpt::MptNode; diff --git a/crates/preflight-ethereum/src/lib.rs b/crates/preflight-ethereum/src/lib.rs index c82a3f52..2928c884 100644 --- a/crates/preflight-ethereum/src/lib.rs +++ b/crates/preflight-ethereum/src/lib.rs @@ -21,7 +21,7 @@ use reth_chainspec::ChainSpec; use reth_primitives::{Block, BlockBody, Header, Log, Receipt, TransactionSigned, Withdrawals}; use std::iter::zip; use std::sync::Arc; -use zeth_core::db::MemoryDB; +use zeth_core::db::memory::MemoryDB; use zeth_core::driver::CoreDriver; use zeth_core::stateless::data::StatelessClientData; use zeth_core_ethereum::RethStatelessClient; diff --git a/crates/preflight-optimism/src/lib.rs b/crates/preflight-optimism/src/lib.rs index 9fe59962..5d18392d 100644 --- a/crates/preflight-optimism/src/lib.rs +++ b/crates/preflight-optimism/src/lib.rs @@ -22,7 +22,7 @@ use reth_optimism_chainspec::OpChainSpec; use reth_primitives::{Block, BlockBody, Header, Receipt, TransactionSigned, TxType, Withdrawals}; use std::iter::zip; use std::sync::Arc; -use zeth_core::db::MemoryDB; +use zeth_core::db::memory::MemoryDB; use zeth_core::driver::CoreDriver; use zeth_core::stateless::data::StatelessClientData; use zeth_core_optimism::{ diff --git a/crates/preflight/src/client.rs b/crates/preflight/src/client.rs index afa9a76e..1433280b 100644 --- a/crates/preflight/src/client.rs +++ b/crates/preflight/src/client.rs @@ -27,7 +27,7 @@ use std::cell::RefCell; use std::iter::zip; use std::path::PathBuf; use std::rc::Rc; -use zeth_core::db::into_plain_state; +use zeth_core::db::changeset::into_plain_state; use zeth_core::driver::CoreDriver; use zeth_core::mpt::{ parse_proof, resolve_nodes_in_place, shorten_node_path, MptNode, MptNodeReference, diff --git a/crates/preflight/src/db.rs b/crates/preflight/src/db.rs index 6712fe34..51d859b3 100644 --- a/crates/preflight/src/db.rs +++ b/crates/preflight/src/db.rs @@ -29,7 +29,7 @@ use reth_revm::{Database, DatabaseCommit, DatabaseRef}; use std::cell::{Ref, RefCell}; use std::marker::PhantomData; use std::ops::DerefMut; -use zeth_core::db::apply_changeset; +use zeth_core::db::changeset::ApplyChangeset; use zeth_core::driver::CoreDriver; use zeth_core::rescue::{Recoverable, Rescued}; @@ -142,7 +142,7 @@ impl> PreflightDB { } pub fn apply_changeset(&mut self, state_changeset: StateChangeset) -> anyhow::Result<()> { - apply_changeset(&mut self.inner, state_changeset) + self.inner.apply_changeset(state_changeset) } pub fn sanity_check(&mut self, state_changeset: StateChangeset) -> anyhow::Result<()> { diff --git a/testing/ef-tests/src/driver.rs b/testing/ef-tests/src/driver.rs index 7c451887..3731ec75 100644 --- a/testing/ef-tests/src/driver.rs +++ b/testing/ef-tests/src/driver.rs @@ -9,8 +9,8 @@ use reth_chainspec::{ NamedChain, }; use std::{fmt::Display, sync::Arc}; +use zeth_core::db::memory::MemoryDB; use zeth_core::{ - db::MemoryDB, driver::CoreDriver, stateless::{ client::StatelessClient, data::StatelessClientData, execute::ExecutionStrategy, diff --git a/testing/ef-tests/tests/evm.rs b/testing/ef-tests/tests/evm.rs index ff61f21f..0b6c2710 100644 --- a/testing/ef-tests/tests/evm.rs +++ b/testing/ef-tests/tests/evm.rs @@ -17,7 +17,8 @@ use alloy::{network::Ethereum, primitives::BlockHash}; use rstest::rstest; use std::{cell::RefCell, path::PathBuf, rc::Rc}; -use zeth_core::{db::MemoryDB, stateless::client::StatelessClient}; +use zeth_core::db::memory::MemoryDB; +use zeth_core::stateless::client::StatelessClient; use zeth_preflight::{client::PreflightClient, provider::Provider, BlockBuilder, Witness}; use zeth_preflight_ethereum::{RethBlockBuilder, RethPreflightDriver}; use zeth_testeth::{read_eth_execution_tests, TestCoreDriver, TestProvider}; From fdce13c9903959ed20705ecb65a3ffe10d2955ae Mon Sep 17 00:00:00 2001 From: Rami Khalil Date: Sun, 15 Dec 2024 08:57:21 +0200 Subject: [PATCH 4/7] refactor: replace db drop with flag --- crates/core/src/db/memory.rs | 9 ++++- crates/core/src/db/mod.rs | 2 +- .../core/src/db/{changeset.rs => update.rs} | 8 ++-- crates/core/src/stateless/client.rs | 8 ++-- crates/core/src/stateless/engine.rs | 2 + crates/core/src/stateless/finalize.rs | 40 ++++++++++++------- crates/preflight/src/client.rs | 2 +- crates/preflight/src/db.rs | 2 +- 8 files changed, 45 insertions(+), 28 deletions(-) rename crates/core/src/db/{changeset.rs => update.rs} (95%) diff --git a/crates/core/src/db/memory.rs b/crates/core/src/db/memory.rs index a59c2538..3982293c 100644 --- a/crates/core/src/db/memory.rs +++ b/crates/core/src/db/memory.rs @@ -13,9 +13,10 @@ // limitations under the License. use crate::db::unreachable::UnreachableDB; -use crate::db::changeset::ApplyChangeset; +use crate::db::update::Update; use crate::rescue::Recoverable; use alloy_primitives::map::HashSet; +use alloy_primitives::{B256, U256}; use reth_primitives::revm_primitives::AccountInfo; use reth_revm::db::states::{PlainStorageChangeset, StateChangeset}; use reth_revm::db::{AccountState, CacheDB}; @@ -28,7 +29,7 @@ impl Recoverable for CacheDB { } } -impl ApplyChangeset for CacheDB { +impl Update for CacheDB { fn apply_changeset(&mut self, changeset: StateChangeset) -> anyhow::Result<()> { // Update accounts in state trie let mut was_destroyed = HashSet::new(); @@ -69,4 +70,8 @@ impl ApplyChangeset for CacheDB { } Ok(()) } + fn insert_block_hash(&mut self, block_number: U256, block_hash: B256) -> anyhow::Result<()> { + self.block_hashes.insert(block_number, block_hash); + Ok(()) + } } diff --git a/crates/core/src/db/mod.rs b/crates/core/src/db/mod.rs index cc5e346d..7fec1bf1 100644 --- a/crates/core/src/db/mod.rs +++ b/crates/core/src/db/mod.rs @@ -14,5 +14,5 @@ pub mod memory; pub mod unreachable; +pub mod update; pub mod wrapper; -pub mod changeset; diff --git a/crates/core/src/db/changeset.rs b/crates/core/src/db/update.rs similarity index 95% rename from crates/core/src/db/changeset.rs rename to crates/core/src/db/update.rs index 5e91574f..08b3a611 100644 --- a/crates/core/src/db/changeset.rs +++ b/crates/core/src/db/update.rs @@ -12,12 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +use alloy_primitives::{B256, U256}; +use reth_primitives::KECCAK_EMPTY; use reth_revm::db::states::{PlainStorageChangeset, StateChangeset}; use reth_revm::db::BundleState; -use reth_primitives::KECCAK_EMPTY; -pub trait ApplyChangeset { +pub trait Update { fn apply_changeset(&mut self, changeset: StateChangeset) -> anyhow::Result<()>; + fn insert_block_hash(&mut self, block_number: U256, block_hash: B256) -> anyhow::Result<()>; } /// This function is a modified version of [`BundleState::into_plane_state`] from the revm crate: @@ -76,4 +78,4 @@ pub fn into_plain_state(bundle: BundleState) -> StateChangeset { storage, contracts, } -} \ No newline at end of file +} diff --git a/crates/core/src/stateless/client.rs b/crates/core/src/stateless/client.rs index fb03d81a..f6c8ec64 100644 --- a/crates/core/src/stateless/client.rs +++ b/crates/core/src/stateless/client.rs @@ -60,11 +60,9 @@ where while !engine.data.blocks.is_empty() { engine.validate_header::()?; let bundle_state = engine.execute_transactions::()?; - // Skip the database update if we're finalizing the last block - if engine.data.blocks.len() == 1 { - engine.db.take(); - } - engine.finalize_state::(bundle_state)?; + // Finalize the state updates + engine + .finalize_state::(bundle_state, engine.data.blocks.len() > 1)?; } // Return the engine for inspection Ok(engine) diff --git a/crates/core/src/stateless/engine.rs b/crates/core/src/stateless/engine.rs index 88268e70..878d00df 100644 --- a/crates/core/src/stateless/engine.rs +++ b/crates/core/src/stateless/engine.rs @@ -147,6 +147,7 @@ impl StatelessClientEngine>( &mut self, bundle_state: BundleState, + with_further_updates: bool, ) -> anyhow::Result<()> { // Unpack input let StatelessClientEngine { @@ -171,6 +172,7 @@ impl StatelessClientEngine { fn finalize_state( @@ -33,25 +32,34 @@ pub trait FinalizationStrategy { parent_header: &mut Driver::Header, db: Option<&mut Database>, bundle_state: BundleState, + with_further_updates: bool, ) -> anyhow::Result<()>; } pub struct RethFinalizationStrategy; -impl FinalizationStrategy for RethFinalizationStrategy { +impl FinalizationStrategy + for RethFinalizationStrategy +{ fn finalize_state( block: &mut Driver::Block, state_trie: &mut MptNode, storage_tries: &mut HashMap, parent_header: &mut Driver::Header, - db: Option<&mut MemoryDB>, + db: Option<&mut Database>, bundle_state: BundleState, + with_further_updates: bool, ) -> anyhow::Result<()> { // Apply state updates - assert_eq!(state_trie.hash(), Driver::state_root(parent_header)); - + if state_trie.hash() != Driver::state_root(parent_header) { + bail!( + "Invalid state root (expected {:?}, got {:?})", + Driver::state_root(parent_header), + state_trie.hash() + ); + } + // Convert the state update bundle let state_changeset = into_plain_state(bundle_state); - // Update the trie data let StateChangeset { accounts, storage, .. @@ -138,14 +146,16 @@ impl FinalizationStrategy for RethFinaliza let header = Driver::block_header(block); assert_eq!(Driver::state_root(header), state_trie.hash()); - // Update the database - if let Some(db) = db { - db.apply_changeset(state_changeset)?; + // Update the database if available + if with_further_updates { + if let Some(db) = db { + db.apply_changeset(state_changeset)?; - db.block_hashes.insert( - U256::from(Driver::block_number(header)), - Driver::header_hash(header), - ); + db.insert_block_hash( + U256::from(Driver::block_number(header)), + Driver::header_hash(header), + )?; + } } Ok(()) diff --git a/crates/preflight/src/client.rs b/crates/preflight/src/client.rs index 1433280b..2a5b1318 100644 --- a/crates/preflight/src/client.rs +++ b/crates/preflight/src/client.rs @@ -27,7 +27,7 @@ use std::cell::RefCell; use std::iter::zip; use std::path::PathBuf; use std::rc::Rc; -use zeth_core::db::changeset::into_plain_state; +use zeth_core::db::update::into_plain_state; use zeth_core::driver::CoreDriver; use zeth_core::mpt::{ parse_proof, resolve_nodes_in_place, shorten_node_path, MptNode, MptNodeReference, diff --git a/crates/preflight/src/db.rs b/crates/preflight/src/db.rs index 51d859b3..56e18e68 100644 --- a/crates/preflight/src/db.rs +++ b/crates/preflight/src/db.rs @@ -29,7 +29,7 @@ use reth_revm::{Database, DatabaseCommit, DatabaseRef}; use std::cell::{Ref, RefCell}; use std::marker::PhantomData; use std::ops::DerefMut; -use zeth_core::db::changeset::ApplyChangeset; +use zeth_core::db::update::Update; use zeth_core::driver::CoreDriver; use zeth_core::rescue::{Recoverable, Rescued}; From 106b213549ab836154612397d6be2990d6849d15 Mon Sep 17 00:00:00 2001 From: Rami Khalil Date: Sun, 15 Dec 2024 10:09:49 +0200 Subject: [PATCH 5/7] direct trie db strategy --- crates/core-ethereum/src/lib.rs | 18 +++-- crates/core-optimism/src/lib.rs | 18 +++-- crates/core/src/db/mod.rs | 1 + crates/core/src/db/trie.rs | 93 +++++++++++++++++++++++++ crates/core/src/stateless/finalize.rs | 56 +++++++++++++-- crates/core/src/stateless/initialize.rs | 71 ++++++++++++++++++- guests/reth-ethereum/src/main.rs | 20 +++--- guests/reth-optimism/src/main.rs | 20 +++--- testing/ef-tests/src/driver.rs | 6 +- 9 files changed, 269 insertions(+), 34 deletions(-) create mode 100644 crates/core/src/db/trie.rs diff --git a/crates/core-ethereum/src/lib.rs b/crates/core-ethereum/src/lib.rs index 24709321..e5ed95e6 100644 --- a/crates/core-ethereum/src/lib.rs +++ b/crates/core-ethereum/src/lib.rs @@ -34,20 +34,30 @@ use std::fmt::Display; use std::mem::take; use std::sync::Arc; use zeth_core::db::memory::MemoryDB; +use zeth_core::db::trie::TrieDB; use zeth_core::driver::CoreDriver; use zeth_core::stateless::client::StatelessClient; use zeth_core::stateless::execute::ExecutionStrategy; -use zeth_core::stateless::finalize::RethFinalizationStrategy; -use zeth_core::stateless::initialize::MemoryDbStrategy; +use zeth_core::stateless::finalize::{MemoryDbFinalizationStrategy, TrieDbFinalizationStrategy}; +use zeth_core::stateless::initialize::{ + MemoryDbInitializationStrategy, TrieDbInitializationStrategy, +}; use zeth_core::stateless::validate::ValidationStrategy; pub struct RethStatelessClient; impl StatelessClient for RethStatelessClient { - type Initialization = MemoryDbStrategy; + type Initialization = MemoryDbInitializationStrategy; + type Validation = RethValidationStrategy; + type Execution = RethExecutionStrategy; + type Finalization = MemoryDbFinalizationStrategy; +} + +impl StatelessClient for RethStatelessClient { + type Initialization = TrieDbInitializationStrategy; type Validation = RethValidationStrategy; type Execution = RethExecutionStrategy; - type Finalization = RethFinalizationStrategy; + type Finalization = TrieDbFinalizationStrategy; } pub struct RethValidationStrategy; diff --git a/crates/core-optimism/src/lib.rs b/crates/core-optimism/src/lib.rs index ca55f97a..2322dc05 100644 --- a/crates/core-optimism/src/lib.rs +++ b/crates/core-optimism/src/lib.rs @@ -35,20 +35,30 @@ use std::fmt::Display; use std::mem::take; use std::sync::Arc; use zeth_core::db::memory::MemoryDB; +use zeth_core::db::trie::TrieDB; use zeth_core::driver::CoreDriver; use zeth_core::stateless::client::StatelessClient; use zeth_core::stateless::execute::ExecutionStrategy; -use zeth_core::stateless::finalize::RethFinalizationStrategy; -use zeth_core::stateless::initialize::MemoryDbStrategy; +use zeth_core::stateless::finalize::{MemoryDbFinalizationStrategy, TrieDbFinalizationStrategy}; +use zeth_core::stateless::initialize::{ + MemoryDbInitializationStrategy, TrieDbInitializationStrategy, +}; use zeth_core::stateless::validate::ValidationStrategy; pub struct OpRethStatelessClient; impl StatelessClient for OpRethStatelessClient { - type Initialization = MemoryDbStrategy; + type Initialization = MemoryDbInitializationStrategy; + type Validation = OpRethValidationStrategy; + type Execution = OpRethExecutionStrategy; + type Finalization = MemoryDbFinalizationStrategy; +} + +impl StatelessClient for OpRethStatelessClient { + type Initialization = TrieDbInitializationStrategy; type Validation = OpRethValidationStrategy; type Execution = OpRethExecutionStrategy; - type Finalization = RethFinalizationStrategy; + type Finalization = TrieDbFinalizationStrategy; } pub struct OpRethValidationStrategy; diff --git a/crates/core/src/db/mod.rs b/crates/core/src/db/mod.rs index 7fec1bf1..ed9cb1cc 100644 --- a/crates/core/src/db/mod.rs +++ b/crates/core/src/db/mod.rs @@ -13,6 +13,7 @@ // limitations under the License. pub mod memory; +pub mod trie; pub mod unreachable; pub mod update; pub mod wrapper; diff --git a/crates/core/src/db/trie.rs b/crates/core/src/db/trie.rs new file mode 100644 index 00000000..7398b0c0 --- /dev/null +++ b/crates/core/src/db/trie.rs @@ -0,0 +1,93 @@ +// Copyright 2024 RISC Zero, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::keccak::keccak; +use crate::mpt::MptNode; +use crate::rescue::Recoverable; +use crate::stateless::data::StorageEntry; +use alloy_consensus::Account; +use alloy_primitives::map::HashMap; +use alloy_primitives::{Address, B256, U256}; +use reth_primitives::revm_primitives::db::Database; +use reth_primitives::revm_primitives::{AccountInfo, Bytecode}; +use reth_revm::DatabaseRef; +use reth_storage_errors::provider::ProviderError; + +#[derive(Default)] +pub struct TrieDB { + pub accounts: MptNode, + pub storage: HashMap, + pub contracts: HashMap, + pub block_hashes: HashMap, +} + +impl Recoverable for TrieDB { + fn rescue(&mut self) -> Option { + Some(core::mem::take(self)) + } +} + +impl DatabaseRef for TrieDB { + type Error = ProviderError; + + fn basic_ref(&self, address: Address) -> Result, Self::Error> { + Ok(self + .accounts + .get_rlp::(&keccak(address)) + .unwrap() + .map(|acc| AccountInfo { + balance: acc.balance, + nonce: acc.nonce, + code_hash: acc.code_hash, + code: None, + })) + } + + fn code_by_hash_ref(&self, code_hash: B256) -> Result { + Ok(self.contracts.get(&code_hash).unwrap().clone()) + } + + fn storage_ref(&self, address: Address, index: U256) -> Result { + let entry = self.storage.get(&address).unwrap(); + Ok(entry + .storage_trie + .get_rlp(&keccak(index.to_be_bytes::<32>())) + .unwrap() + .unwrap_or_default()) + } + + fn block_hash_ref(&self, number: u64) -> Result { + Ok(*self.block_hashes.get(&number).unwrap()) + } +} + +impl Database for TrieDB { + type Error = ProviderError; + + fn basic(&mut self, address: Address) -> Result, Self::Error> { + self.basic_ref(address) + } + + fn code_by_hash(&mut self, code_hash: B256) -> Result { + self.code_by_hash_ref(code_hash) + } + + fn storage(&mut self, address: Address, index: U256) -> Result { + self.storage_ref(address, index) + } + + fn block_hash(&mut self, number: u64) -> Result { + self.block_hash_ref(number) + } +} diff --git a/crates/core/src/stateless/finalize.rs b/crates/core/src/stateless/finalize.rs index 19dbc5f0..1310b529 100644 --- a/crates/core/src/stateless/finalize.rs +++ b/crates/core/src/stateless/finalize.rs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +use crate::db::memory::MemoryDB; +use crate::db::trie::TrieDB; use crate::db::update::{into_plain_state, Update}; use crate::driver::CoreDriver; use crate::keccak::keccak; @@ -36,17 +38,60 @@ pub trait FinalizationStrategy { ) -> anyhow::Result<()>; } -pub struct RethFinalizationStrategy; +pub struct TrieDbFinalizationStrategy; -impl FinalizationStrategy - for RethFinalizationStrategy -{ +impl FinalizationStrategy for TrieDbFinalizationStrategy { + fn finalize_state( + block: &mut Driver::Block, + _state_trie: &mut MptNode, + _storage_tries: &mut HashMap, + parent_header: &mut Driver::Header, + db: Option<&mut TrieDB>, + bundle_state: BundleState, + with_further_updates: bool, + ) -> anyhow::Result<()> { + let TrieDB { + accounts: state_trie, + storage: storage_tries, + block_hashes, + .. + } = db.expect("Missing TrieDB instance"); + + // Update the trie data + >::finalize_state( + block, + state_trie, + storage_tries, + parent_header, + None, + bundle_state, + false, + )?; + + // Get the header + let header = Driver::block_header(block); + + // Give back the tries + if !with_further_updates { + core::mem::swap(state_trie, _state_trie); + core::mem::swap(storage_tries, _storage_tries); + } else { + block_hashes.insert(Driver::block_number(header), Driver::header_hash(header)); + } + + Ok(()) + } +} + +pub struct MemoryDbFinalizationStrategy; + +impl FinalizationStrategy for MemoryDbFinalizationStrategy { fn finalize_state( block: &mut Driver::Block, state_trie: &mut MptNode, storage_tries: &mut HashMap, parent_header: &mut Driver::Header, - db: Option<&mut Database>, + db: Option<&mut MemoryDB>, bundle_state: BundleState, with_further_updates: bool, ) -> anyhow::Result<()> { @@ -58,6 +103,7 @@ impl FinalizationStrategy { ) -> anyhow::Result; } -pub struct MemoryDbStrategy; +pub struct TrieDbInitializationStrategy; -impl InitializationStrategy for MemoryDbStrategy { +impl InitializationStrategy for TrieDbInitializationStrategy { + fn initialize_database( + state_trie: &mut MptNode, + storage_tries: &mut HashMap, + contracts: &mut Vec, + parent_header: &mut Driver::Header, + ancestor_headers: &mut Vec, + ) -> anyhow::Result { + // Verify starting state trie root + if Driver::state_root(parent_header) != state_trie.hash() { + bail!( + "Invalid initial state trie: expected {}, got {}", + Driver::state_root(parent_header), + state_trie.hash() + ); + } + + // hash all the contract code + let contracts = take(contracts) + .into_iter() + .map(|bytes| (keccak(&bytes).into(), Bytecode::new_raw(bytes))) + .collect(); + + // prepare block hash history + let mut block_hashes: HashMap = + HashMap::with_capacity_and_hasher(ancestor_headers.len() + 1, Default::default()); + block_hashes.insert( + Driver::block_number(parent_header), + Driver::header_hash(parent_header), + ); + let mut prev = &*parent_header; + for current in ancestor_headers.iter() { + let current_hash = Driver::header_hash(current); + if Driver::parent_hash(prev) != current_hash { + bail!( + "Invalid chain: {} is not the parent of {}", + Driver::block_number(current), + Driver::block_number(prev) + ); + } + if Driver::block_number(parent_header) < Driver::block_number(current) + || Driver::block_number(parent_header) - Driver::block_number(current) >= 256 + { + bail!( + "Invalid chain: {} is not one of the {} most recent blocks", + Driver::block_number(current), + 256, + ); + } + block_hashes.insert(Driver::block_number(current), current_hash); + prev = current; + } + + Ok(TrieDB { + accounts: take(state_trie), + storage: take(storage_tries), + contracts, + block_hashes, + }) + } +} + +pub struct MemoryDbInitializationStrategy; + +impl InitializationStrategy + for MemoryDbInitializationStrategy +{ fn initialize_database( state_trie: &mut MptNode, storage_tries: &mut HashMap, diff --git a/guests/reth-ethereum/src/main.rs b/guests/reth-ethereum/src/main.rs index fc9fcc8c..a4be958d 100644 --- a/guests/reth-ethereum/src/main.rs +++ b/guests/reth-ethereum/src/main.rs @@ -14,8 +14,9 @@ // use c_kzg::KzgSettings; use risc0_zkvm::guest::env; +use zeth_core::db::trie::TrieDB; use zeth_core::stateless::client::StatelessClient; -use zeth_core_ethereum::RethStatelessClient; +use zeth_core_ethereum::{RethCoreDriver, RethStatelessClient}; // todo: use this instead of the alloy KzgEnv to save cycles // lazy_static::lazy_static! { // /// KZG Ceremony data @@ -36,11 +37,12 @@ fn main() { let stateless_client_data_rkyv = env::read_frame(); let stateless_client_data_pot = env::read_frame(); env::log("Deserializing input data"); - let stateless_client_data = RethStatelessClient::data_from_parts( - &stateless_client_data_rkyv, - &stateless_client_data_pot, - ) - .expect("Failed to load client data from stdin"); + let stateless_client_data = + >::data_from_parts( + &stateless_client_data_rkyv, + &stateless_client_data_pot, + ) + .expect("Failed to load client data from stdin"); let validation_depth = stateless_client_data.blocks.len() as u64; assert!( stateless_client_data.chain.is_ethereum(), @@ -49,8 +51,10 @@ fn main() { let chain_id = stateless_client_data.chain as u64; // Build the block env::log("Validating blocks"); - let engine = - RethStatelessClient::validate(stateless_client_data).expect("block validation failed"); + let engine = >::validate( + stateless_client_data, + ) + .expect("block validation failed"); // Build the journal (todo: make this a strategy) let block_hash = engine.data.parent_header.hash_slow(); let total_difficulty = engine.data.total_difficulty; diff --git a/guests/reth-optimism/src/main.rs b/guests/reth-optimism/src/main.rs index 8fc85f87..7a376bc5 100644 --- a/guests/reth-optimism/src/main.rs +++ b/guests/reth-optimism/src/main.rs @@ -14,8 +14,9 @@ // use c_kzg::KzgSettings; use risc0_zkvm::guest::env; +use zeth_core::db::trie::TrieDB; use zeth_core::stateless::client::StatelessClient; -use zeth_core_optimism::OpRethStatelessClient; +use zeth_core_optimism::{OpRethCoreDriver, OpRethStatelessClient}; // todo: use this instead of the alloy KzgEnv to save cycles // lazy_static::lazy_static! { // /// KZG Ceremony data @@ -36,11 +37,12 @@ fn main() { let stateless_client_data_rkyv = env::read_frame(); let stateless_client_data_pot = env::read_frame(); env::log("Deserializing input data"); - let stateless_client_data = OpRethStatelessClient::data_from_parts( - &stateless_client_data_rkyv, - &stateless_client_data_pot, - ) - .expect("Failed to load client data from stdin"); + let stateless_client_data = + >::data_from_parts( + &stateless_client_data_rkyv, + &stateless_client_data_pot, + ) + .expect("Failed to load client data from stdin"); let validation_depth = stateless_client_data.blocks.len() as u64; assert!( stateless_client_data.chain.is_optimism(), @@ -49,8 +51,10 @@ fn main() { let chain_id = stateless_client_data.chain as u64; // Build the block env::log("Validating blocks"); - let engine = - OpRethStatelessClient::validate(stateless_client_data).expect("block validation failed"); + let engine = >::validate( + stateless_client_data, + ) + .expect("block validation failed"); // Build the journal (todo: make this a strategy) let block_hash = engine.data.parent_header.hash_slow(); let total_difficulty = engine.data.total_difficulty; diff --git a/testing/ef-tests/src/driver.rs b/testing/ef-tests/src/driver.rs index 3731ec75..0c9dca6d 100644 --- a/testing/ef-tests/src/driver.rs +++ b/testing/ef-tests/src/driver.rs @@ -14,7 +14,7 @@ use zeth_core::{ driver::CoreDriver, stateless::{ client::StatelessClient, data::StatelessClientData, execute::ExecutionStrategy, - finalize::RethFinalizationStrategy, initialize::MemoryDbStrategy, + finalize::MemoryDbFinalizationStrategy, initialize::MemoryDbInitializationStrategy, validate::ValidationStrategy, }, }; @@ -129,10 +129,10 @@ impl PreflightClient for RethPref } impl StatelessClient for RethStatelessClient { - type Initialization = MemoryDbStrategy; + type Initialization = MemoryDbInitializationStrategy; type Validation = RethValidationStrategy; type Execution = RethExecutionStrategy; - type Finalization = RethFinalizationStrategy; + type Finalization = MemoryDbFinalizationStrategy; } impl ValidationStrategy From 9484028d2671f99054f704106a8f8fc27c63c35f Mon Sep 17 00:00:00 2001 From: Richard Howard Date: Mon, 16 Dec 2024 18:10:00 -0800 Subject: [PATCH 6/7] rev up r0 and add bonsai feature (#132) Co-authored-by: root --- Cargo.lock | 1 + Cargo.toml | 1 + guests/reth-ethereum/Cargo.lock | 20 ++++++++++---------- guests/reth-ethereum/Cargo.toml | 6 +++--- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c49305b..22f655d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4808,6 +4808,7 @@ dependencies = [ "addr2line 0.22.0", "anyhow", "bincode", + "bonsai-sdk", "borsh", "bytemuck", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 283c21f9..35ed7b63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ features = ["unstable"] git = "https://github.com/risc0/risc0" rev = "e98cdad96cfecb3d959cb62abf566e5b17a0d649" default-features = false +features = ["bonsai"] # External [workspace.dependencies] diff --git a/guests/reth-ethereum/Cargo.lock b/guests/reth-ethereum/Cargo.lock index 8a328127..340654cc 100644 --- a/guests/reth-ethereum/Cargo.lock +++ b/guests/reth-ethereum/Cargo.lock @@ -2772,7 +2772,7 @@ dependencies = [ [[package]] name = "risc0-binfmt" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "borsh", @@ -2786,7 +2786,7 @@ dependencies = [ [[package]] name = "risc0-circuit-keccak" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "bytemuck", @@ -2801,7 +2801,7 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "bytemuck", @@ -2815,7 +2815,7 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "metal", @@ -2830,7 +2830,7 @@ dependencies = [ [[package]] name = "risc0-core" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "bytemuck", "rand_core", @@ -2839,7 +2839,7 @@ dependencies = [ [[package]] name = "risc0-groth16" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "ark-bn254", @@ -2859,7 +2859,7 @@ dependencies = [ [[package]] name = "risc0-zkp" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "blake2", @@ -2882,7 +2882,7 @@ dependencies = [ [[package]] name = "risc0-zkvm" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "borsh", @@ -2908,7 +2908,7 @@ dependencies = [ [[package]] name = "risc0-zkvm-platform" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "bytemuck", "getrandom", @@ -3513,7 +3513,7 @@ dependencies = [ [[package]] name = "tiny-keccak" version = "2.0.2" -source = "git+https://github.com/risc0/tiny-keccak?rev=b93afa7dc803d2db6ddae7df15e9db5a79212ba0#b93afa7dc803d2db6ddae7df15e9db5a79212ba0" +source = "git+https://github.com/risc0/tiny-keccak?rev=37645712de2d24f56410f3ba0bfc71175df51cc8#37645712de2d24f56410f3ba0bfc71175df51cc8" dependencies = [ "crunchy", "risc0-zkvm", diff --git a/guests/reth-ethereum/Cargo.toml b/guests/reth-ethereum/Cargo.toml index c9712579..c2f5af4f 100644 --- a/guests/reth-ethereum/Cargo.toml +++ b/guests/reth-ethereum/Cargo.toml @@ -27,13 +27,13 @@ opt-level = 3 [dependencies.risc0-zkvm] git = "https://github.com/risc0/risc0" -rev = "e98cdad96cfecb3d959cb62abf566e5b17a0d649" +rev = "f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" default-features = false features = ["std", "unstable"] [dependencies.risc0-zkvm-platform] git = "https://github.com/risc0/risc0" -rev = "e98cdad96cfecb3d959cb62abf566e5b17a0d649" +rev = "f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" features = ["sys-getenv"] [dependencies.zeth-core] @@ -58,4 +58,4 @@ c-kzg = { git = "https://github.com/risc0/c-kzg-4844.git", branch = "p1.0.3" } crypto-bigint = { git = "https://github.com/risc0/RustCrypto-crypto-bigint", tag = "v0.5.5-risczero.0" } k256 = { git = "https://github.com/risc0/RustCrypto-elliptic-curves", tag = "k256/v0.13.3-risczero.1" } sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.6-risczero.0" } -tiny-keccak = { git = "https://github.com/risc0/tiny-keccak", rev = "b93afa7dc803d2db6ddae7df15e9db5a79212ba0" } +tiny-keccak = { git = "https://github.com/risc0/tiny-keccak", rev = "37645712de2d24f56410f3ba0bfc71175df51cc8" } From 2f2571700a5b293fbcfab23b24fbfc587d0c5145 Mon Sep 17 00:00:00 2001 From: Rami Khalil Date: Tue, 17 Dec 2024 20:02:12 +0200 Subject: [PATCH 7/7] patch all crate definitions --- Cargo.lock | 32 ++++++++++++++++---------------- Cargo.toml | 6 +++--- guests/reth-optimism/Cargo.lock | 20 ++++++++++---------- guests/reth-optimism/Cargo.toml | 6 +++--- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 22f655d6..6ff8f49e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1206,7 +1206,7 @@ dependencies = [ [[package]] name = "bonsai-sdk" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "duplicate", "maybe-async", @@ -4564,7 +4564,7 @@ dependencies = [ [[package]] name = "risc0-binfmt" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "borsh", @@ -4578,7 +4578,7 @@ dependencies = [ [[package]] name = "risc0-build" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "cargo_metadata", @@ -4596,7 +4596,7 @@ dependencies = [ [[package]] name = "risc0-build-kernel" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "cc", "directories", @@ -4610,7 +4610,7 @@ dependencies = [ [[package]] name = "risc0-circuit-keccak" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "bytemuck", @@ -4630,7 +4630,7 @@ dependencies = [ [[package]] name = "risc0-circuit-keccak-sys" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "cc", "cust", @@ -4645,7 +4645,7 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "bytemuck", @@ -4670,7 +4670,7 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion-sys" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "glob", "risc0-build-kernel", @@ -4682,7 +4682,7 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "auto_ops", @@ -4715,7 +4715,7 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im-sys" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "glob", "risc0-build-kernel", @@ -4727,7 +4727,7 @@ dependencies = [ [[package]] name = "risc0-core" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "bytemuck", "nvtx", @@ -4738,7 +4738,7 @@ dependencies = [ [[package]] name = "risc0-groth16" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "ark-bn254", @@ -4762,7 +4762,7 @@ dependencies = [ [[package]] name = "risc0-sys" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "cust", @@ -4773,7 +4773,7 @@ dependencies = [ [[package]] name = "risc0-zkp" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "blake2", @@ -4803,7 +4803,7 @@ dependencies = [ [[package]] name = "risc0-zkvm" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "addr2line 0.22.0", "anyhow", @@ -4846,7 +4846,7 @@ dependencies = [ [[package]] name = "risc0-zkvm-platform" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "bytemuck", "getrandom", diff --git a/Cargo.toml b/Cargo.toml index 35ed7b63..22d49193 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,17 +19,17 @@ opt-level = 3 # RISC Zero [workspace.dependencies.bonsai-sdk] git = "https://github.com/risc0/risc0" -rev = "e98cdad96cfecb3d959cb62abf566e5b17a0d649" +rev = "f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" features = ["non_blocking"] [workspace.dependencies.risc0-build] git = "https://github.com/risc0/risc0" -rev = "e98cdad96cfecb3d959cb62abf566e5b17a0d649" +rev = "f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" features = ["unstable"] [workspace.dependencies.risc0-zkvm] git = "https://github.com/risc0/risc0" -rev = "e98cdad96cfecb3d959cb62abf566e5b17a0d649" +rev = "f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" default-features = false features = ["bonsai"] diff --git a/guests/reth-optimism/Cargo.lock b/guests/reth-optimism/Cargo.lock index e5f68fd8..ee209a0b 100644 --- a/guests/reth-optimism/Cargo.lock +++ b/guests/reth-optimism/Cargo.lock @@ -2812,7 +2812,7 @@ dependencies = [ [[package]] name = "risc0-binfmt" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "borsh", @@ -2826,7 +2826,7 @@ dependencies = [ [[package]] name = "risc0-circuit-keccak" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "bytemuck", @@ -2841,7 +2841,7 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "bytemuck", @@ -2855,7 +2855,7 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "metal", @@ -2870,7 +2870,7 @@ dependencies = [ [[package]] name = "risc0-core" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "bytemuck", "rand_core", @@ -2879,7 +2879,7 @@ dependencies = [ [[package]] name = "risc0-groth16" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "ark-bn254", @@ -2899,7 +2899,7 @@ dependencies = [ [[package]] name = "risc0-zkp" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "blake2", @@ -2922,7 +2922,7 @@ dependencies = [ [[package]] name = "risc0-zkvm" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "anyhow", "borsh", @@ -2948,7 +2948,7 @@ dependencies = [ [[package]] name = "risc0-zkvm-platform" version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=e98cdad96cfecb3d959cb62abf566e5b17a0d649#e98cdad96cfecb3d959cb62abf566e5b17a0d649" +source = "git+https://github.com/risc0/risc0?rev=f74920596c745a8bb7e8a6f1dfdefb44d03ed06f#f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" dependencies = [ "bytemuck", "getrandom", @@ -3553,7 +3553,7 @@ dependencies = [ [[package]] name = "tiny-keccak" version = "2.0.2" -source = "git+https://github.com/risc0/tiny-keccak?rev=b93afa7dc803d2db6ddae7df15e9db5a79212ba0#b93afa7dc803d2db6ddae7df15e9db5a79212ba0" +source = "git+https://github.com/risc0/tiny-keccak?rev=37645712de2d24f56410f3ba0bfc71175df51cc8#37645712de2d24f56410f3ba0bfc71175df51cc8" dependencies = [ "crunchy", "risc0-zkvm", diff --git a/guests/reth-optimism/Cargo.toml b/guests/reth-optimism/Cargo.toml index db5f1ddb..6a062a81 100644 --- a/guests/reth-optimism/Cargo.toml +++ b/guests/reth-optimism/Cargo.toml @@ -27,13 +27,13 @@ opt-level = 3 [dependencies.risc0-zkvm] git = "https://github.com/risc0/risc0" -rev = "e98cdad96cfecb3d959cb62abf566e5b17a0d649" +rev = "f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" default-features = false features = ["std", "unstable"] [dependencies.risc0-zkvm-platform] git = "https://github.com/risc0/risc0" -rev = "e98cdad96cfecb3d959cb62abf566e5b17a0d649" +rev = "f74920596c745a8bb7e8a6f1dfdefb44d03ed06f" features = ["sys-getenv"] [dependencies.zeth-core] @@ -58,4 +58,4 @@ c-kzg = { git = "https://github.com/risc0/c-kzg-4844.git", branch = "p1.0.3" } crypto-bigint = { git = "https://github.com/risc0/RustCrypto-crypto-bigint", tag = "v0.5.5-risczero.0" } k256 = { git = "https://github.com/risc0/RustCrypto-elliptic-curves", tag = "k256/v0.13.3-risczero.1" } sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.6-risczero.0" } -tiny-keccak = { git = "https://github.com/risc0/tiny-keccak", rev = "b93afa7dc803d2db6ddae7df15e9db5a79212ba0" } +tiny-keccak = { git = "https://github.com/risc0/tiny-keccak", rev = "37645712de2d24f56410f3ba0bfc71175df51cc8" }