Skip to content

Commit

Permalink
client compiles with custom evm config
Browse files Browse the repository at this point in the history
  • Loading branch information
zobront committed Dec 6, 2024
1 parent 0579210 commit 6e0dc0a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 327 deletions.
23 changes: 17 additions & 6 deletions bin/client/src/kona.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@

extern crate alloc;

use alloc::string::String;
mod evm_config;
pub use evm_config::KonaEvmConfig;

mod precompiles;
use precompiles::fpvm_handle_register;

use alloc::{sync::Arc, string::String};
use kona_std_fpvm_proc::client_entry;
use kona_preimage::{HintWriter, OracleReader};
use kona_std_fpvm::{FileChannel, FileDescriptor};
use kona_std_fpvm_proc::client_entry;
use crate::{run, fpvm_handle_register};
use reth_optimism_chainspec::OP_MAINNET;

/// The global preimage oracle reader pipe.
static ORACLE_READER_PIPE: FileChannel =
Expand All @@ -22,10 +28,11 @@ static HINT_WRITER_PIPE: FileChannel =
FileChannel::new(FileDescriptor::HintRead, FileDescriptor::HintWrite);

/// The global preimage oracle reader.
pub static ORACLE_READER: OracleReader<FileChannel> = OracleReader::new(ORACLE_READER_PIPE);
static ORACLE_READER: OracleReader<FileChannel> = OracleReader::new(ORACLE_READER_PIPE);

/// The global hint writer.
pub static HINT_WRITER: HintWriter<FileChannel> = HintWriter::new(HINT_WRITER_PIPE);
static HINT_WRITER: HintWriter<FileChannel> = HintWriter::new(HINT_WRITER_PIPE);


#[client_entry(100_000_000)]
fn main() -> Result<(), String> {
Expand All @@ -38,8 +45,12 @@ fn main() -> Result<(), String> {
.expect("Failed to set tracing subscriber");
}

kona_proof::block_on(run(
// // ZTODO: derive this from the rollup config
let evm_config = KonaEvmConfig::new(Arc::new((**OP_MAINNET).clone()));

kona_proof::block_on(kona_client::run(
ORACLE_READER,
HINT_WRITER,
evm_config
))
}
23 changes: 9 additions & 14 deletions bin/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ extern crate alloc;
use alloc::sync::Arc;
use alloy_consensus::{Header, Sealed};
use alloy_primitives::B256;
use op_alloy_consensus::OpTxEnvelope;
use core::fmt::Debug;
use kona_driver::{Driver, DriverError};
use kona_executor::{ExecutorError, TrieDBProvider};
use kona_preimage::{
CommsClient, HintWriterClient, PreimageKey, PreimageKeyType, PreimageOracleClient,
CommsClient, HintWriterClient, PreimageKey, PreimageKeyType,
PreimageOracleClient,
};
use kona_proof::{
errors::OracleProviderError,
Expand All @@ -24,18 +26,10 @@ use kona_proof::{
sync::new_pipeline_cursor,
BootInfo, CachingOracle, HintType,
};
use reth_evm::ConfigureEvm;
use thiserror::Error;
use tracing::{error, info, warn};
use reth_optimism_chainspec::OP_MAINNET;

mod precompiles;
pub use precompiles::fpvm_handle_register;

mod evm_config;
use evm_config::KonaEvmConfig;

mod kona;
pub use kona::{HINT_WRITER, ORACLE_READER};

/// An error that can occur when running the fault proof program.
#[derive(Error, Debug)]
Expand All @@ -53,13 +47,15 @@ pub enum FaultProofProgramError {

/// Executes the fault proof program with the given [PreimageOracleClient] and [HintWriterClient].
#[inline]
pub async fn run<P, H>(
pub async fn run<P, H, C>(
oracle_client: P,
hint_client: H
hint_client: H,
evm_config: C,
) -> Result<(), FaultProofProgramError>
where
P: PreimageOracleClient + Send + Sync + Debug + Clone + 'static,
H: HintWriterClient + Send + Sync + Debug + Clone + 'static,
C: ConfigureEvm<Header=Header, Transaction=OpTxEnvelope> + Debug + Clone + 'static,
{
const ORACLE_LRU_SIZE: usize = 1024;

Expand Down Expand Up @@ -120,8 +116,7 @@ where
l1_provider.clone(),
l2_provider.clone(),
);
// ZTODO: derive this from the rollup config
let evm_config = KonaEvmConfig::new(Arc::new((**OP_MAINNET).clone()));

let executor = KonaExecutor::new(&cfg, l2_provider.clone(), l2_provider, evm_config, None);
let mut driver = Driver::new(cursor, executor, pipeline);

Expand Down
Loading

0 comments on commit 6e0dc0a

Please sign in to comment.