Skip to content

Commit

Permalink
Merge branch 'fix/removed_panic_stabilization' of github.com:taikoxyz…
Browse files Browse the repository at this point in the history
…/raiko into fix/removed_panic_stabilization
  • Loading branch information
35359595 committed May 27, 2024
2 parents eeb22e9 + ecb1318 commit 7678116
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
11 changes: 3 additions & 8 deletions host/src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(incomplete_features)]
use raiko_host::{interfaces::error::HostResult, server::serve, ProverState};
use std::{env, path::PathBuf};
use std::path::PathBuf;
use tracing::debug;
use tracing_appender::{
non_blocking::WorkerGuard,
Expand All @@ -10,20 +10,15 @@ use tracing_subscriber::FmtSubscriber;

#[tokio::main]
async fn main() -> HostResult<()> {
// defailt `info` level if nothing else defined
if env::var("RUST_LOG").is_err() {
env::set_var("RUST_LOG", "info")
}
env_logger::init();
let state = ProverState::init()?;
debug!("Start config:\n{:#?}", state.opts.proof_request_opt);
debug!("Args:\n{:#?}", state.opts);

let _guard = subscribe_log(
&state.opts.log_path,
&state.opts.log_level,
state.opts.max_log,
);
debug!("Start config:\n{:#?}", state.opts.proof_request_opt);
debug!("Args:\n{:#?}", state.opts);

serve(state).await?;
Ok(())
Expand Down
13 changes: 9 additions & 4 deletions host/src/provider/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ use alloy_provider::{ProviderBuilder, ReqwestProvider, RootProvider};
use alloy_rpc_client::{ClientBuilder, RpcClient};
use alloy_rpc_types::{Block, BlockId, BlockNumberOrTag, EIP1186AccountProofResponse};
use alloy_transport_http::Http;
use raiko_lib::{clear_line, inplace_print};
use raiko_lib::clear_line;
use reqwest_alloy::Client;
use revm::primitives::{AccountInfo, Bytecode};
use std::collections::HashMap;
use tracing::trace;

use crate::{
interfaces::error::{HostError, HostResult},
Expand Down Expand Up @@ -227,9 +228,13 @@ impl BlockDataProvider for RpcBlockDataProvider {

let batch_limit = 1000;
while !accounts.is_empty() {
inplace_print(&format!(
"fetching storage proof {idx}/{num_storage_proofs}..."
));
if cfg!(debug_assertions) {
raiko_lib::inplace_print(&format!(
"fetching storage proof {idx}/{num_storage_proofs}..."
));
} else {
trace!("Fetching storage proof {idx}/{num_storage_proofs}...");
}

// Create a batch for all storage proofs
let mut batch = self.client.new_batch();
Expand Down
16 changes: 10 additions & 6 deletions lib/src/builder/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use core::{fmt::Debug, mem::take, str::from_utf8};
use std::collections::HashSet;

use alloy_consensus::{constants::BEACON_ROOTS_ADDRESS, TxEnvelope};
use alloy_primitives::{TxKind, U256};
use anyhow::{anyhow, bail, ensure, Context, Error, Result};
use core::{fmt::Debug, mem::take, str::from_utf8};
#[cfg(feature = "std")]
use log::debug;
use raiko_primitives::{
Expand All @@ -32,6 +30,8 @@ use revm::{
},
taiko, Database, DatabaseCommit, Evm, JournaledState,
};
use std::collections::HashSet;
use tracing::trace;
cfg_if::cfg_if! {
if #[cfg(feature = "tracer")] {
use std::{fs::{OpenOptions, File}, io::{BufWriter, Write}, sync::{Arc, Mutex}};
Expand Down Expand Up @@ -82,7 +82,7 @@ impl TxExecStrategy for TkoTxExecStrategy {
let chain_spec = &block_builder.input.chain_spec;
let chain_id = chain_spec.chain_id();
let is_taiko = chain_spec.is_taiko();
debug!("spec_id: {spec_id:?}");
trace!("spec_id: {spec_id:?}");

// generate the transactions from the tx list
// For taiko blocks, insert the anchor tx as the first transaction
Expand Down Expand Up @@ -175,7 +175,11 @@ impl TxExecStrategy for TkoTxExecStrategy {
let mut actual_tx_no = 0usize;
let num_transactions = transactions.len();
for (tx_no, tx) in take(&mut transactions).into_iter().enumerate() {
inplace_print(&format!("\rprocessing tx {tx_no}/{num_transactions}..."));
if cfg!(debug_assertions) {
inplace_print(&format!("\rprocessing tx {tx_no}/{num_transactions}..."));
} else {
trace!("\rprocessing tx {tx_no}/{num_transactions}...");
}

#[cfg(feature = "tracer")]
let trace = set_trace_writer(
Expand Down Expand Up @@ -283,7 +287,7 @@ impl TxExecStrategy for TkoTxExecStrategy {
}
};
#[cfg(feature = "std")]
debug!(" Ok: {result:?}");
trace!(" Ok: {result:?}");

#[cfg(feature = "tracer")]
// Flush the trace writer
Expand Down
4 changes: 2 additions & 2 deletions lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ pub fn print_duration(title: &str, duration: time::Duration) {
}

pub fn inplace_print(title: &str) {
debug!("\r{title}");
#[cfg(feature = "std")]
print!("\r{title}");
#[cfg(all(feature = "std", debug_assertions))]
io::stdout().flush().unwrap();
}

Expand Down

0 comments on commit 7678116

Please sign in to comment.