Skip to content

Commit 73af1f3

Browse files
author
Naohiro Yoshida
committed
more logger specific
1 parent 15a4a92 commit 73af1f3

File tree

7 files changed

+44
-11
lines changed

7 files changed

+44
-11
lines changed

derivation/src/derivation.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
use crate::errors;
21
use crate::errors::Error;
32
use crate::oracle::{MemoryOracleClient, NopeHintWriter};
3+
use crate::{errors, logger};
4+
use alloc::fmt::format;
5+
use alloc::format;
46
use alloc::sync::Arc;
57
use alloy_consensus::Header;
68
use alloy_primitives::{keccak256, Sealed, B256};
@@ -73,6 +75,12 @@ impl Derivation {
7375
rollup_config: rollup_config.clone(),
7476
};
7577
let rollup_config = Arc::new(boot.rollup_config.clone());
78+
79+
logger::info(&format!(
80+
"fetching safe head hash {:?} for L2 derivation",
81+
boot.agreed_l2_output_root
82+
));
83+
7684
let safe_head_hash = fetch_safe_head_hash(&oracle, boot.agreed_l2_output_root).await?;
7785
let oracle_for_preimage = oracle.clone();
7886
let oracle = Arc::new(oracle);
@@ -106,6 +114,7 @@ impl Derivation {
106114
)
107115
.await?;
108116

117+
logger::info(&format!("create evm factory"));
109118
let evm_factory = FpvmOpEvmFactory::new(NopeHintWriter, oracle_for_preimage);
110119
let executor = KonaExecutor::new(
111120
rollup_config.as_ref(),
@@ -118,10 +127,18 @@ impl Derivation {
118127

119128
// Run the derivation pipeline until we are able to produce the output root of the claimed
120129
// L2 block.
130+
logger::info(&format!(
131+
"start advancing to target L2 block {}",
132+
boot.claimed_l2_block_number
133+
));
121134
let (_, output_root) = driver
122135
.advance_to_target(&boot.rollup_config, Some(boot.claimed_l2_block_number))
123136
.await?;
124137

138+
logger::info(&format!(
139+
"end advancing to target L2 block {}",
140+
boot.claimed_l2_block_number
141+
));
125142
////////////////////////////////////////////////////////////////
126143
// EPILOGUE //
127144
////////////////////////////////////////////////////////////////

derivation/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ extern crate alloc;
33

44
pub mod derivation;
55
pub mod errors;
6+
pub mod logger;
67
pub mod oracle;
78
pub mod types;
89

light-client/src/client.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use crate::header::Header;
66
use crate::message::ClientMessage;
77
use crate::misbehaviour::Misbehaviour;
88
use alloc::string::{String, ToString};
9-
use alloc::{format, vec};
109
use alloc::vec::Vec;
10+
use alloc::{format, vec};
1111
use alloy_primitives::keccak256;
1212
use core::time::Duration;
1313
use ethereum_consensus::types::H256;
@@ -21,7 +21,7 @@ use light_client::{
2121
CreateClientResult, Error as LightClientError, HostClientReader, LightClient, MisbehaviourData,
2222
UpdateClientResult, UpdateStateData, VerifyMembershipResult, VerifyNonMembershipResult,
2323
};
24-
use crate::logger;
24+
use optimism_derivation::logger;
2525

2626
pub struct OptimismLightClient<const L1_SYNC_COMMITTEE_SIZE: usize>;
2727

@@ -175,7 +175,11 @@ impl<const L1_SYNC_COMMITTEE_SIZE: usize> OptimismLightClient<L1_SYNC_COMMITTEE_
175175
client_id: ClientId,
176176
header: Header<L1_SYNC_COMMITTEE_SIZE>,
177177
) -> Result<UpdateStateData, Error> {
178-
logger::info(&format!("update_state {} trusted_height={}", client_id.to_string(), header.trusted_height.revision_height()));
178+
logger::info(&format!(
179+
"update_state {} trusted_height={}",
180+
client_id.to_string(),
181+
header.trusted_height.revision_height()
182+
));
179183
let trusted_height = header.trusted_height;
180184
let any_client_state = ctx.client_state(&client_id).map_err(Error::LCPError)?;
181185
let any_consensus_state = ctx

light-client/src/client_state.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use ethereum_light_client_verifier::context::Fraction;
1818
use ethereum_light_client_verifier::execution::ExecutionVerifier;
1919
use kona_genesis::RollupConfig;
2020
use light_client::types::{Any, ClientId, Height, Time};
21+
use optimism_derivation::logger;
2122
use optimism_ibc_proto::google::protobuf::Any as IBCAny;
2223
use optimism_ibc_proto::ibc::lightclients::ethereum::v1::{
2324
Fork as ProtoFork, ForkParameters as ProtoForkParameters, ForkSpec as ProtoForkSpec,
@@ -26,7 +27,6 @@ use optimism_ibc_proto::ibc::lightclients::ethereum::v1::{
2627
use optimism_ibc_proto::ibc::lightclients::optimism::v1::ClientState as RawClientState;
2728
use optimism_ibc_proto::ibc::lightclients::optimism::v1::L1Config as RawL1Config;
2829
use prost::Message;
29-
use crate::logger;
3030

3131
pub const OPTIMISM_CLIENT_STATE_TYPE_URL: &str = "/ibc.lightclients.optimism.v1.ClientState";
3232

@@ -72,7 +72,10 @@ impl ClientState {
7272
trusted_consensus_state: &ConsensusState,
7373
header: Header<L1_SYNC_COMMITTEE_SIZE>,
7474
) -> Result<(ClientState, ConsensusState, Height), Error> {
75-
logger::info(&format!("check_header_and_update_state trusted_height={}", header.trusted_height.revision_height()));
75+
logger::info(&format!(
76+
"check_header_and_update_state trusted_height={}",
77+
header.trusted_height.revision_height()
78+
));
7679
// Since the L1 block hash is used for L2 derivation, the validity of L1 must be verified.
7780
let l1_consensus = header.verify_l1(
7881
&self.l1_config,

light-client/src/header.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ use alloy_primitives::B256;
99
use kona_genesis::RollupConfig;
1010
use light_client::types::{Any, Height};
1111
use optimism_derivation::derivation::Derivation;
12+
use optimism_derivation::logger;
1213
use optimism_derivation::oracle::MemoryOracleClient;
1314
use optimism_derivation::types::Preimages;
1415
use optimism_ibc_proto::google::protobuf::Any as IBCAny;
1516
use optimism_ibc_proto::ibc::lightclients::optimism::v1::Header as RawHeader;
1617
use prost::Message;
17-
use crate::logger;
1818

1919
pub const OPTIMISM_HEADER_TYPE_URL: &str = "/ibc.lightclients.optimism.v1.Header";
2020

@@ -53,7 +53,10 @@ impl<const L1_SYNC_COMMITTEE_SIZE: usize> L1Headers<L1_SYNC_COMMITTEE_SIZE> {
5353

5454
let mut updated_as_next = false;
5555
for (i, l1_header) in self.trusted_to_deterministic.iter().enumerate() {
56-
logger::info(&format!("verify l1 trusted_to_deterministic index={i} number={}", l1_header.execution_update.block_number));
56+
logger::info(&format!(
57+
"verify l1 trusted_to_deterministic index={i} number={}",
58+
l1_header.execution_update.block_number
59+
));
5760
let result = l1_header.verify(now_sec, l1_config, &l1_consensus);
5861
let result = result.map_err(|e| {
5962
Error::L1HeaderTrustedToDeterministicVerifyError(
@@ -70,7 +73,10 @@ impl<const L1_SYNC_COMMITTEE_SIZE: usize> L1Headers<L1_SYNC_COMMITTEE_SIZE> {
7073
// Verify finalized l1 header by last l1 consensus for L2 derivation
7174
let mut l1_consensus_for_verify_only = l1_consensus.clone();
7275
for (i, l1_header) in self.deterministic_to_latest.iter().enumerate() {
73-
logger::info(&format!("verify l1 deterministic_to_latest index={i} number={}", l1_header.execution_update.block_number));
76+
logger::info(&format!(
77+
"verify l1 deterministic_to_latest index={i} number={}",
78+
l1_header.execution_update.block_number
79+
));
7480
let result = l1_header.verify(now_sec, l1_config, &l1_consensus_for_verify_only);
7581
let result = result.map_err(|e| {
7682
Error::L1HeaderDeterministicToLatestVerifyError(
@@ -114,7 +120,10 @@ impl<const L1_SYNC_COMMITTEE_SIZE: usize> Header<L1_SYNC_COMMITTEE_SIZE> {
114120
trusted_output_root: B256,
115121
rollup_config: &RollupConfig,
116122
) -> Result<(alloy_consensus::Header, u64, B256), Error> {
117-
logger::info(&format!("verify l2 derivation={:?}", self.derivation.l2_block_number));
123+
logger::info(&format!(
124+
"verify l2 derivation={:?}",
125+
self.derivation.l2_block_number
126+
));
118127
// Ensure trusted
119128
if self.derivation.agreed_l2_output_root != trusted_output_root {
120129
return Err(Error::UnexpectedTrustedOutputRoot(

light-client/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ mod commitment;
1515
pub mod errors;
1616
pub mod header;
1717
mod l1;
18-
mod logger;
1918
mod message;
2019
mod misbehaviour;
2120
mod misc;

0 commit comments

Comments
 (0)