From 45b5acbd82907496222d62534ebad477c53857a1 Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Tue, 31 Oct 2023 19:40:57 -0400 Subject: [PATCH 01/10] patched syncing --- .../tree_availability/src/world_tree/abi.rs | 2 + .../src/world_tree/block_scanner.rs | 3 ++ .../tree_availability/src/world_tree/mod.rs | 2 +- .../src/world_tree/tree_data.rs | 2 + .../src/world_tree/tree_updater.rs | 46 ++++++++++++++----- 5 files changed, 43 insertions(+), 12 deletions(-) diff --git a/crates/tree_availability/src/world_tree/abi.rs b/crates/tree_availability/src/world_tree/abi.rs index 90a0be72..e9abcf0a 100644 --- a/crates/tree_availability/src/world_tree/abi.rs +++ b/crates/tree_availability/src/world_tree/abi.rs @@ -6,5 +6,7 @@ abigen!( event TreeChanged(uint256 indexed preRoot, uint8 indexed kind, uint256 indexed postRoot) function registerIdentities(uint256[8] calldata insertionProof, uint256 preRoot, uint32 startIndex, uint256[] calldata identityCommitments, uint256 postRoot) external function deleteIdentities(uint256[8] calldata deletionProof, bytes calldata packedDeletionIndices, uint256 preRoot, uint256 postRoot) external + function deleteIdentities(uint256[8] calldata deletionProof, uint32 batchSize, bytes calldata packedDeletionIndices, uint256 preRoot, uint256 postRoot) external + ]"#; ); diff --git a/crates/tree_availability/src/world_tree/block_scanner.rs b/crates/tree_availability/src/world_tree/block_scanner.rs index 98f414d5..85e7e516 100644 --- a/crates/tree_availability/src/world_tree/block_scanner.rs +++ b/crates/tree_availability/src/world_tree/block_scanner.rs @@ -40,6 +40,9 @@ where return Ok(Vec::new()); } + //TODO: next should maybe sync to chain head or maybe this logic can be outside of the block scanner + //TODO: but we need some way to create futures ordered until we get the chain head? + let from_block = current_block; let to_block = latest_block.min(from_block + self.window_size); diff --git a/crates/tree_availability/src/world_tree/mod.rs b/crates/tree_availability/src/world_tree/mod.rs index c82a2a05..bd2f069f 100644 --- a/crates/tree_availability/src/world_tree/mod.rs +++ b/crates/tree_availability/src/world_tree/mod.rs @@ -63,7 +63,7 @@ impl WorldTree { tree_updater.sync_to_head(&tree_data).await?; // Sleep a little to unblock the executor - tokio::time::sleep(Duration::from_secs(5)).await; + // tokio::time::sleep(Duration::from_secs(5)).await; } }) } diff --git a/crates/tree_availability/src/world_tree/tree_data.rs b/crates/tree_availability/src/world_tree/tree_data.rs index 59313afb..264de33a 100644 --- a/crates/tree_availability/src/world_tree/tree_data.rs +++ b/crates/tree_availability/src/world_tree/tree_data.rs @@ -9,6 +9,7 @@ use crate::server::InclusionProof; pub struct TreeData { pub tree: RwLock>, + pub depth: usize, pub tree_history_size: usize, pub tree_history: RwLock>>, //TODO: make a note that the latest is at the front } @@ -24,6 +25,7 @@ impl TreeData { ) -> Self { Self { tree_history_size, + depth: tree.depth(), tree: RwLock::new(tree.derived()), tree_history: RwLock::new(VecDeque::new()), } diff --git a/crates/tree_availability/src/world_tree/tree_updater.rs b/crates/tree_availability/src/world_tree/tree_updater.rs index 2be8c1df..c4667ad8 100644 --- a/crates/tree_availability/src/world_tree/tree_updater.rs +++ b/crates/tree_availability/src/world_tree/tree_updater.rs @@ -14,10 +14,11 @@ use super::abi::{ use super::block_scanner::BlockScanner; use super::tree_data::TreeData; use crate::error::TreeAvailabilityError; -use crate::world_tree::Hash; +use crate::world_tree::abi::DeleteIdentitiesWithDeletionProofAndBatchSizeAndPackedDeletionIndicesAndPreRootCall; +use crate::world_tree::{abi, Hash}; // TODO: Change to a configurable parameter -const SCANNING_WINDOW_SIZE: u64 = 100; +const SCANNING_WINDOW_SIZE: u64 = 100000; pub struct TreeUpdater { pub address: H160, @@ -91,7 +92,7 @@ impl TreeUpdater { } //TODO: use a better throttle - tokio::time::sleep(Duration::from_secs(1)).await; + // tokio::time::sleep(Duration::from_secs(1)).await; } Ok(()) @@ -102,7 +103,7 @@ impl TreeUpdater { tree_data: &TreeData, transaction: &Transaction, ) -> Result<(), TreeAvailabilityError> { - tracing::info!("Syncing from transaction {}", transaction.hash); + tracing::info!("Syncing from transaction {:?}", transaction.hash); let calldata = &transaction.input; @@ -117,13 +118,12 @@ impl TreeUpdater { let start_index = register_identities_call.start_index; let identities = register_identities_call.identity_commitments; - let identities: Vec<_> = identities - .into_iter() + + let identities: Vec = identities + .into_iter().take_while(|x| *x != U256::zero()) .map(|u256: U256| Hash::from_limbs(u256.0)) .collect(); - tracing::info!(?start_index, ?identities); - tree_data .insert_many_at(start_index as usize, &identities) .await; @@ -133,13 +133,37 @@ impl TreeUpdater { let delete_identities_call = DeleteIdentitiesCall::decode(calldata.as_ref())?; - let indices = unpack_indices( + let indices= unpack_indices( + delete_identities_call.packed_deletion_indices.as_ref(), + ); + + let indices: Vec = indices + .into_iter().take_while(|x| *x != 2_u32.pow(tree_data.depth as u32)) + .map(|x| x as usize) + .collect(); + + tree_data.delete_many(&indices).await; + + } else if function_selector == DeleteIdentitiesWithDeletionProofAndBatchSizeAndPackedDeletionIndicesAndPreRootCall::selector() { + + tracing::info!("Decoding deleteIdentities calldata"); + + // @dev This is a type that is generated by abigen!() since there is a function defined with a conflicting function name but different params + let delete_identities_call = + DeleteIdentitiesWithDeletionProofAndBatchSizeAndPackedDeletionIndicesAndPreRootCall::decode(calldata.as_ref())?; + + let indices= unpack_indices( delete_identities_call.packed_deletion_indices.as_ref(), ); - let indices: Vec<_> = - indices.into_iter().map(|x| x as usize).collect(); + let indices: Vec = indices + .into_iter().take_while(|x| *x != 2_u32.pow(tree_data.depth as u32)) + .map(|x| x as usize) + .collect(); + tree_data.delete_many(&indices).await; + + } else { return Err(TreeAvailabilityError::UnrecognizedFunctionSelector); } From 0476f43ca15483bc0f297ef0c881e796081bb18d Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Tue, 31 Oct 2023 20:09:47 -0400 Subject: [PATCH 02/10] added window size as a param for tree avail service --- bin/tree_availability_service.rs | 8 +++++++- crates/tree_availability/src/lib.rs | 2 ++ crates/tree_availability/src/world_tree/block_scanner.rs | 3 --- crates/tree_availability/src/world_tree/mod.rs | 4 ++++ crates/tree_availability/src/world_tree/tree_updater.rs | 9 ++++----- crates/tree_availability/tests/inclusion_proof.rs | 1 + 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/bin/tree_availability_service.rs b/bin/tree_availability_service.rs index fead5eb6..37c11147 100644 --- a/bin/tree_availability_service.rs +++ b/bin/tree_availability_service.rs @@ -29,6 +29,12 @@ struct Opts { address: H160, #[clap(short, long, help = "Creation block of the World Tree")] creation_block: u64, + #[clap( + short, + long, + help = "Maximum window size when scanning blocks for TreeChanged events" + )] + window_size: Option, #[clap(short, long, help = "Ethereum RPC endpoint")] rpc_endpoint: String, #[clap( @@ -38,7 +44,6 @@ struct Opts { default_value = "8080" )] port: u16, - #[clap(long, help = "Enable datadog backend for instrumentation")] datadog: bool, } @@ -60,6 +65,7 @@ pub async fn main() -> eyre::Result<()> { opts.tree_history_size, opts.address, opts.creation_block, + opts.window_size, middleware, ) .serve(opts.port) diff --git a/crates/tree_availability/src/lib.rs b/crates/tree_availability/src/lib.rs index 41f4c82d..e2555ccf 100644 --- a/crates/tree_availability/src/lib.rs +++ b/crates/tree_availability/src/lib.rs @@ -25,6 +25,7 @@ impl TreeAvailabilityService { tree_history_size: usize, world_tree_address: H160, world_tree_creation_block: u64, + window_size: Option, middleware: Arc, ) -> Self { let tree = PoseidonTree::::new_with_dense_prefix( @@ -38,6 +39,7 @@ impl TreeAvailabilityService { tree_history_size, world_tree_address, world_tree_creation_block, + window_size, middleware, )); diff --git a/crates/tree_availability/src/world_tree/block_scanner.rs b/crates/tree_availability/src/world_tree/block_scanner.rs index 85e7e516..98f414d5 100644 --- a/crates/tree_availability/src/world_tree/block_scanner.rs +++ b/crates/tree_availability/src/world_tree/block_scanner.rs @@ -40,9 +40,6 @@ where return Ok(Vec::new()); } - //TODO: next should maybe sync to chain head or maybe this logic can be outside of the block scanner - //TODO: but we need some way to create futures ordered until we get the chain head? - let from_block = current_block; let to_block = latest_block.min(from_block + self.window_size); diff --git a/crates/tree_availability/src/world_tree/mod.rs b/crates/tree_availability/src/world_tree/mod.rs index bd2f069f..4cc5c4a9 100644 --- a/crates/tree_availability/src/world_tree/mod.rs +++ b/crates/tree_availability/src/world_tree/mod.rs @@ -18,6 +18,8 @@ use self::tree_data::TreeData; use self::tree_updater::TreeUpdater; use crate::error::TreeAvailabilityError; +pub const DEFAULT_WINDOW_SIZE: u64 = 1000000000; + pub type PoseidonTree = LazyMerkleTree; pub type Hash = ::Hash; @@ -36,6 +38,7 @@ impl WorldTree { tree_history_size: usize, address: H160, creation_block: u64, + window_size: Option, middleware: Arc, ) -> Self { Self { @@ -43,6 +46,7 @@ impl WorldTree { tree_updater: Arc::new(TreeUpdater::new( address, creation_block, + window_size.unwrap_or(DEFAULT_WINDOW_SIZE), middleware, )), } diff --git a/crates/tree_availability/src/world_tree/tree_updater.rs b/crates/tree_availability/src/world_tree/tree_updater.rs index c4667ad8..1d61d5cd 100644 --- a/crates/tree_availability/src/world_tree/tree_updater.rs +++ b/crates/tree_availability/src/world_tree/tree_updater.rs @@ -17,9 +17,6 @@ use crate::error::TreeAvailabilityError; use crate::world_tree::abi::DeleteIdentitiesWithDeletionProofAndBatchSizeAndPackedDeletionIndicesAndPreRootCall; use crate::world_tree::{abi, Hash}; -// TODO: Change to a configurable parameter -const SCANNING_WINDOW_SIZE: u64 = 100000; - pub struct TreeUpdater { pub address: H160, pub latest_synced_block: AtomicU64, @@ -29,14 +26,14 @@ pub struct TreeUpdater { } impl TreeUpdater { - pub fn new(address: H160, creation_block: u64, middleware: Arc) -> Self { + pub fn new(address: H160, creation_block: u64, window_size: u64, middleware: Arc) -> Self { Self { address, latest_synced_block: AtomicU64::new(creation_block), synced: AtomicBool::new(false), block_scanner: BlockScanner::new( middleware.clone(), - SCANNING_WINDOW_SIZE, + window_size, creation_block, ), middleware, @@ -50,6 +47,8 @@ impl TreeUpdater { ) -> Result<(), TreeAvailabilityError> { tracing::info!("Syncing tree to chain head"); + + let logs = self .block_scanner .next( diff --git a/crates/tree_availability/tests/inclusion_proof.rs b/crates/tree_availability/tests/inclusion_proof.rs index 50b57f34..8a6ba8e5 100644 --- a/crates/tree_availability/tests/inclusion_proof.rs +++ b/crates/tree_availability/tests/inclusion_proof.rs @@ -60,6 +60,7 @@ async fn test_inclusion_proof() -> eyre::Result<()> { 5, world_tree_address, world_tree_creation_block, + Some(10000), middleware, ); From f8f6f9956a7eb1cb2c5692d9721490b356f4c93c Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Tue, 31 Oct 2023 20:25:55 -0400 Subject: [PATCH 03/10] updated block scanner logic --- bin/tree_availability_service.rs | 1 + .../src/world_tree/block_scanner.rs | 20 +++++++++---------- .../tree_availability/src/world_tree/mod.rs | 5 ++--- .../src/world_tree/tree_updater.rs | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bin/tree_availability_service.rs b/bin/tree_availability_service.rs index 37c11147..6c631f67 100644 --- a/bin/tree_availability_service.rs +++ b/bin/tree_availability_service.rs @@ -73,6 +73,7 @@ pub async fn main() -> eyre::Result<()> { let mut handles = handles.into_iter().collect::>(); while let Some(result) = handles.next().await { + tracing::error!("TreeAvailabilityError: {:?}", result); result??; } diff --git a/crates/tree_availability/src/world_tree/block_scanner.rs b/crates/tree_availability/src/world_tree/block_scanner.rs index 98f414d5..bad4c2d5 100644 --- a/crates/tree_availability/src/world_tree/block_scanner.rs +++ b/crates/tree_availability/src/world_tree/block_scanner.rs @@ -7,7 +7,7 @@ use ethers::types::{ pub struct BlockScanner { middleware: M, - pub current_block: AtomicU64, + pub last_synced_block: AtomicU64, window_size: u64, } @@ -22,7 +22,7 @@ where ) -> Self { Self { middleware, - current_block: AtomicU64::new(current_block), + last_synced_block: AtomicU64::new(current_block), window_size, } } @@ -34,18 +34,18 @@ where ) -> Result, M::Error> { let latest_block = self.middleware.get_block_number().await?.as_u64(); - let current_block = self.current_block.load(Ordering::SeqCst); + let last_synced_block = self.last_synced_block.load(Ordering::SeqCst); - if current_block >= latest_block { + if last_synced_block >= latest_block { return Ok(Vec::new()); } - let from_block = current_block; + let from_block = last_synced_block + 1; let to_block = latest_block.min(from_block + self.window_size); - tracing::info!("Scanning from {} to {}", current_block, latest_block); + tracing::info!("Scanning from {} to {}", from_block, to_block); - let next_current_block = to_block + 1; + let new_synced_block = to_block; let from_block = Some(BlockNumber::Number(from_block.into())); let to_block = Some(BlockNumber::Number(to_block.into())); @@ -62,10 +62,10 @@ where }) .await?; - self.current_block - .store(next_current_block, Ordering::SeqCst); + self.last_synced_block + .store(new_synced_block, Ordering::SeqCst); - tracing::info!("Current block updated to {next_current_block}"); + tracing::info!("Last synced block updated to {new_synced_block}"); Ok(logs) } diff --git a/crates/tree_availability/src/world_tree/mod.rs b/crates/tree_availability/src/world_tree/mod.rs index 4cc5c4a9..d700417b 100644 --- a/crates/tree_availability/src/world_tree/mod.rs +++ b/crates/tree_availability/src/world_tree/mod.rs @@ -18,7 +18,7 @@ use self::tree_data::TreeData; use self::tree_updater::TreeUpdater; use crate::error::TreeAvailabilityError; -pub const DEFAULT_WINDOW_SIZE: u64 = 1000000000; +pub const DEFAULT_WINDOW_SIZE: u64 = 100_000_000; pub type PoseidonTree = LazyMerkleTree; pub type Hash = ::Hash; @@ -66,8 +66,7 @@ impl WorldTree { loop { tree_updater.sync_to_head(&tree_data).await?; - // Sleep a little to unblock the executor - // tokio::time::sleep(Duration::from_secs(5)).await; + tokio::time::sleep(Duration::from_secs(5)).await; } }) } diff --git a/crates/tree_availability/src/world_tree/tree_updater.rs b/crates/tree_availability/src/world_tree/tree_updater.rs index 1d61d5cd..1c0b1efb 100644 --- a/crates/tree_availability/src/world_tree/tree_updater.rs +++ b/crates/tree_availability/src/world_tree/tree_updater.rs @@ -77,7 +77,7 @@ impl TreeUpdater { .transaction_hash .ok_or(TreeAvailabilityError::TransactionHashNotFound)?; - tracing::info!("Getting transaction for {tx_hash}"); + tracing::info!("Getting transaction {tx_hash:?}"); futures.push_back(self.middleware.get_transaction(tx_hash)); } @@ -91,7 +91,7 @@ impl TreeUpdater { } //TODO: use a better throttle - // tokio::time::sleep(Duration::from_secs(1)).await; + tokio::time::sleep(Duration::from_secs(1)).await; } Ok(()) From e3beba344cf3c566897ced475a9e379f1963c134 Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Tue, 31 Oct 2023 20:35:09 -0400 Subject: [PATCH 04/10] added reqwest client feature for otel dd dependency, enabling async reqwest http client --- Cargo.lock | 3 ++- Cargo.toml | 1 - crates/common/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b2da0856..573251fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2403,7 +2403,6 @@ dependencies = [ "ethers", "eyre", "futures", - "reqwest", "serde", "state_bridge", "tokio", @@ -3150,6 +3149,7 @@ dependencies = [ "opentelemetry", "opentelemetry-http", "opentelemetry-semantic-conventions", + "reqwest", "rmp", "thiserror", "url", @@ -3165,6 +3165,7 @@ dependencies = [ "bytes", "http", "opentelemetry_api", + "reqwest", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 3658a5fe..a48c7049 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,6 @@ common = { path = "./crates/common" } ethers = "2.0.10" eyre = "0.6.8" futures = "0.3.28" -reqwest = "0.11.22" serde = "1.0.188" state_bridge = { path = "crates/state_bridge" } tokio = { version = "1.33.0", features = ["full"] } diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index cef99bbb..ca9eb7e9 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -15,7 +15,7 @@ eyre = "0.6.8" serde = "1.0.189" metrics = "0.21.1" opentelemetry = "0.20.0" -opentelemetry-datadog = "0.8.0" +opentelemetry-datadog = {verison = "0.8.0", features = ["reqwest-client"]} tracing = "0.1.40" tracing-opentelemetry = "0.21.0" tracing-subscriber = {version = "0.3.17", features = ["env-filter"]} From f91a1a9e05d35a75f7afd7797964ef72dd9a0e41 Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Tue, 31 Oct 2023 20:36:16 -0400 Subject: [PATCH 05/10] added rt-tokio for dd batch exporter --- Cargo.lock | 13 +++++++++++++ crates/common/Cargo.toml | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 573251fe..bf9be927 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3211,6 +3211,8 @@ dependencies = [ "rand", "regex", "thiserror", + "tokio", + "tokio-stream", ] [[package]] @@ -4924,6 +4926,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-stream" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-tungstenite" version = "0.20.1" diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index ca9eb7e9..b6e55c04 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -14,7 +14,7 @@ ethers = { version = "2.0.10", features = [ eyre = "0.6.8" serde = "1.0.189" metrics = "0.21.1" -opentelemetry = "0.20.0" +opentelemetry = { version = "0.20.0", features = ["rt-tokio"] } opentelemetry-datadog = {verison = "0.8.0", features = ["reqwest-client"]} tracing = "0.1.40" tracing-opentelemetry = "0.21.0" From 71459ad5e3ffeb9af7970944bcca15ace2c02436 Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Tue, 31 Oct 2023 23:22:14 -0400 Subject: [PATCH 06/10] updated service name --- Cargo.toml | 3 +-- bin/tree_availability_service.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a48c7049..65f1bea4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,8 +6,7 @@ edition = "2021" [workspace] members = [ - "crates/common" -, + "crates/common", "crates/sequencer", "crates/state_bridge", "crates/tree_availability"] diff --git a/bin/tree_availability_service.rs b/bin/tree_availability_service.rs index 6c631f67..8a6493fc 100644 --- a/bin/tree_availability_service.rs +++ b/bin/tree_availability_service.rs @@ -53,7 +53,7 @@ pub async fn main() -> eyre::Result<()> { let opts = Opts::parse(); if opts.datadog { - init_datadog_subscriber("tree_availability_service", Level::INFO); + init_datadog_subscriber("tree-availability-service", Level::INFO); } else { init_subscriber(Level::INFO); } From 108ff3a36450cc483b86335b6ba0fe83f1762f32 Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Tue, 31 Oct 2023 23:35:49 -0400 Subject: [PATCH 07/10] fix: typo --- crates/tree_availability/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/tree_availability/src/lib.rs b/crates/tree_availability/src/lib.rs index e2555ccf..03178a7a 100644 --- a/crates/tree_availability/src/lib.rs +++ b/crates/tree_availability/src/lib.rs @@ -53,7 +53,7 @@ impl TreeAvailabilityService { let mut handles = vec![]; // Initialize a new router and spawn the server - tracing::info!("Iniitalizing axum server on port {port}"); + tracing::info!("Initializing axum server on port {port}"); let router = axum::Router::new() .route("/inclusionProof", axum::routing::post(inclusion_proof)) From 768bdbf1727030b24460df4f94025e8d636655da Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Thu, 2 Nov 2023 12:46:40 -0400 Subject: [PATCH 08/10] updated default window size --- bin/tree_availability_service.rs | 5 +++-- crates/tree_availability/src/lib.rs | 2 +- crates/tree_availability/src/world_tree/mod.rs | 6 ++---- crates/tree_availability/tests/inclusion_proof.rs | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/bin/tree_availability_service.rs b/bin/tree_availability_service.rs index 8a6493fc..87c07513 100644 --- a/bin/tree_availability_service.rs +++ b/bin/tree_availability_service.rs @@ -32,9 +32,10 @@ struct Opts { #[clap( short, long, - help = "Maximum window size when scanning blocks for TreeChanged events" + help = "Maximum window size when scanning blocks for TreeChanged events", + default_value = "1000" )] - window_size: Option, + window_size: u64, #[clap(short, long, help = "Ethereum RPC endpoint")] rpc_endpoint: String, #[clap( diff --git a/crates/tree_availability/src/lib.rs b/crates/tree_availability/src/lib.rs index 03178a7a..1c3e7055 100644 --- a/crates/tree_availability/src/lib.rs +++ b/crates/tree_availability/src/lib.rs @@ -25,7 +25,7 @@ impl TreeAvailabilityService { tree_history_size: usize, world_tree_address: H160, world_tree_creation_block: u64, - window_size: Option, + window_size: u64, middleware: Arc, ) -> Self { let tree = PoseidonTree::::new_with_dense_prefix( diff --git a/crates/tree_availability/src/world_tree/mod.rs b/crates/tree_availability/src/world_tree/mod.rs index d700417b..9b75e1de 100644 --- a/crates/tree_availability/src/world_tree/mod.rs +++ b/crates/tree_availability/src/world_tree/mod.rs @@ -18,8 +18,6 @@ use self::tree_data::TreeData; use self::tree_updater::TreeUpdater; use crate::error::TreeAvailabilityError; -pub const DEFAULT_WINDOW_SIZE: u64 = 100_000_000; - pub type PoseidonTree = LazyMerkleTree; pub type Hash = ::Hash; @@ -38,7 +36,7 @@ impl WorldTree { tree_history_size: usize, address: H160, creation_block: u64, - window_size: Option, + window_size: u64, middleware: Arc, ) -> Self { Self { @@ -46,7 +44,7 @@ impl WorldTree { tree_updater: Arc::new(TreeUpdater::new( address, creation_block, - window_size.unwrap_or(DEFAULT_WINDOW_SIZE), + window_size, middleware, )), } diff --git a/crates/tree_availability/tests/inclusion_proof.rs b/crates/tree_availability/tests/inclusion_proof.rs index 8a6ba8e5..9f4dfa92 100644 --- a/crates/tree_availability/tests/inclusion_proof.rs +++ b/crates/tree_availability/tests/inclusion_proof.rs @@ -60,7 +60,7 @@ async fn test_inclusion_proof() -> eyre::Result<()> { 5, world_tree_address, world_tree_creation_block, - Some(10000), + 1000, middleware, ); From c7dbea4918215b86aba1d30113141edc5b72d564 Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Thu, 2 Nov 2023 12:47:56 -0400 Subject: [PATCH 09/10] added todo to remove `deleteIdentities` with batch size from abi --- crates/tree_availability/src/world_tree/abi.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/tree_availability/src/world_tree/abi.rs b/crates/tree_availability/src/world_tree/abi.rs index e9abcf0a..d30890d2 100644 --- a/crates/tree_availability/src/world_tree/abi.rs +++ b/crates/tree_availability/src/world_tree/abi.rs @@ -1,5 +1,6 @@ use ethers::middleware::contract::abigen; +//TODO: Update staging deployment and remove `deleteIdentities` containing a batch size from the abi below abigen!( IWorldIDIdentityManager, r#"[ From 3116960abe5cd2356c7b5e431fda30d3a82ac099 Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Thu, 2 Nov 2023 12:56:00 -0400 Subject: [PATCH 10/10] cargo clippy --- crates/tree_availability/src/world_tree/tree_updater.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/tree_availability/src/world_tree/tree_updater.rs b/crates/tree_availability/src/world_tree/tree_updater.rs index e3fe4709..b3c2fa8c 100644 --- a/crates/tree_availability/src/world_tree/tree_updater.rs +++ b/crates/tree_availability/src/world_tree/tree_updater.rs @@ -1,4 +1,4 @@ -use std::sync::atomic::{AtomicBool, AtomicU64}; +use std::sync::atomic::{AtomicU64}; use std::sync::Arc; use std::time::Duration; @@ -15,7 +15,7 @@ use super::block_scanner::BlockScanner; use super::tree_data::TreeData; use crate::error::TreeAvailabilityError; use crate::world_tree::abi::DeleteIdentitiesWithDeletionProofAndBatchSizeAndPackedDeletionIndicesAndPreRootCall; -use crate::world_tree::{abi, Hash}; +use crate::world_tree::{Hash}; /// Manages the synchronization of the World Tree with it's onchain representation. pub struct TreeUpdater {