From 316c866d1decb50a66c5bd5f3754c2b078464c64 Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Krieger <gustavo.m.krieger@gmail.com> Date: Tue, 14 Nov 2023 12:19:20 -0300 Subject: [PATCH] fix(claimer): fix duplicate checker verification --- offchain/authority-claimer/src/checker.rs | 34 +++++++++++++++-------- offchain/authority-claimer/src/lib.rs | 2 +- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/offchain/authority-claimer/src/checker.rs b/offchain/authority-claimer/src/checker.rs index b9cdc6581..da81e710e 100644 --- a/offchain/authority-claimer/src/checker.rs +++ b/offchain/authority-claimer/src/checker.rs @@ -2,10 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 (see LICENSE) use async_trait::async_trait; -use contracts::authority::Authority; +use contracts::history::History; use ethers::{ self, abi::AbiEncode, + contract::ContractError, providers::{Http, HttpRateLimitRetryPolicy, Provider, RetryClient}, types::{H160, U256}, }; @@ -37,16 +38,14 @@ pub trait DuplicateChecker: Debug { #[derive(Debug)] pub struct DefaultDuplicateChecker { - authority: Authority<Provider<RetryClient<Http>>>, + history: History<Provider<RetryClient<Http>>>, } #[derive(Debug, Snafu)] pub enum DuplicateCheckerError { #[snafu(display("invalid provider URL"))] ContractError { - source: ethers::contract::ContractError< - ethers::providers::Provider<RetryClient<Http>>, - >, + source: ContractError<ethers::providers::Provider<RetryClient<Http>>>, }, #[snafu(display("parser error"))] @@ -56,7 +55,7 @@ pub enum DuplicateCheckerError { impl DefaultDuplicateChecker { pub fn new( http_endpoint: String, - authority_address: Address, + history_address: Address, ) -> Result<Self, DuplicateCheckerError> { let http = Http::new(Url::parse(&http_endpoint).context(ParseSnafu)?); @@ -69,12 +68,10 @@ impl DefaultDuplicateChecker { let provider = Arc::new(Provider::new(retry_client)); - let authority = Authority::new( - H160(authority_address.inner().to_owned()), - provider, - ); + let history = + History::new(H160(history_address.inner().to_owned()), provider); - Ok(Self { authority }) + Ok(Self { history }) } } @@ -90,8 +87,21 @@ impl DuplicateChecker for DefaultDuplicateChecker { let proof_context = U256([rollups_claim.epoch_index, 0, 0, 0]).encode().into(); + let claims = self + .history + .new_claim_to_history_filter() + .query() + .await + .context(ContractSnafu)?; + + info!(">>>>>>>>> CLAIMS {:?}", claims); + + // for claim in claims { + // info!(">>>>>>>>> {:?}", claim.claim); + // } + match self - .authority + .history .get_claim(H160(dapp_address.inner().to_owned()), proof_context) .block(ethers::types::BlockNumber::Latest) .call() diff --git a/offchain/authority-claimer/src/lib.rs b/offchain/authority-claimer/src/lib.rs index c7d521386..91e05e033 100644 --- a/offchain/authority-claimer/src/lib.rs +++ b/offchain/authority-claimer/src/lib.rs @@ -46,7 +46,7 @@ pub async fn run(config: Config) -> Result<(), Box<dyn Error>> { trace!("Creating the duplicate checker"); let duplicate_checker = DefaultDuplicateChecker::new( config.tx_manager_config.provider_http_endpoint.clone(), - config.blockchain_config.authority_address.clone(), + config.blockchain_config.history_address.clone(), )?; // Creating the transaction sender.