From 5ba3eff9611589f84eb97f06fba47091baab790b Mon Sep 17 00:00:00 2001 From: ZanCorDX <126988525+ZanCorDX@users.noreply.github.com> Date: Fri, 13 Dec 2024 11:28:17 -0300 Subject: [PATCH] OrderIntakeConsumer fixes for less warninig. (#281) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📝 Summary - Stop building on reorg - update_onchain_nonces result propagated ## 💡 Motivation and Context Warninig annoy me --- ## ✅ I have completed the following steps: * [x] Run `make lint` * [x] Run `make test` * [ ] Added tests (if applicable) --- crates/rbuilder/src/building/builders/mod.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/rbuilder/src/building/builders/mod.rs b/crates/rbuilder/src/building/builders/mod.rs index c71f53e5..2297a4c2 100644 --- a/crates/rbuilder/src/building/builders/mod.rs +++ b/crates/rbuilder/src/building/builders/mod.rs @@ -19,6 +19,7 @@ use reth::{ revm::cached::CachedReads, }; use reth_db::Database; +use reth_errors::ProviderError; use reth_provider::{DatabaseProviderFactory, StateProviderFactory}; use std::{fmt::Debug, marker::PhantomData, sync::Arc}; use tokio::sync::{broadcast, broadcast::error::TryRecvError}; @@ -144,7 +145,9 @@ where if !self.order_consumer.consume_next_commands()? { return Ok(false); } - self.update_onchain_nonces()?; + if !self.update_onchain_nonces()? { + return Ok(false); + } self.order_consumer .apply_new_commands(&mut self.block_orders); @@ -161,7 +164,11 @@ where SimulatedOrderCommand::Simulation(sim_order) => Some(sim_order), SimulatedOrderCommand::Cancellation(_) => None, }); - let nonce_db_ref = self.nonce_cache.get_ref()?; + let nonce_db_ref = match self.nonce_cache.get_ref() { + Ok(nonce_db_ref) => nonce_db_ref, + Err(ProviderError::BlockHashNotFound(_)) => return Ok(false), // This can happen on reorgs since the block is removed + Err(err) => return Err(err.into()), + }; let mut nonces = Vec::new(); for new_order in new_orders { for nonce in new_order.order.nonces() {