From 1d85cb2c640769c0ca53eebfe79d147cff44aba6 Mon Sep 17 00:00:00 2001 From: Milosz Muszynski Date: Tue, 18 Jun 2024 17:27:40 +0200 Subject: [PATCH] rusk: dependencies correction --- rusk/src/lib/chain/rusk.rs | 9 +++------ rusk/src/lib/free_tx_verifier.rs | 12 ++++++++---- rusk/tests/services/contract_pays.rs | 1 - 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/rusk/src/lib/chain/rusk.rs b/rusk/src/lib/chain/rusk.rs index d1e156c6b0..f430200d00 100644 --- a/rusk/src/lib/chain/rusk.rs +++ b/rusk/src/lib/chain/rusk.rs @@ -115,6 +115,8 @@ impl Rusk { let mut event_hasher = Sha3_256::new(); + let free_tx_verifier = FreeTxVerifier::new(self.db_viewer().as_ref()); + for unspent_tx in txs { if let Some(timeout) = self.generation_timeout { if started.elapsed() > timeout { @@ -130,12 +132,7 @@ impl Rusk { // check free transaction if unspent_tx.inner.nullifiers.len() == 0 { - info!("found free tx"); - let free_tx_verifier = - FreeTxVerifier::new(self.db_viewer().as_ref()); - if let Some(e) = - free_tx_verifier.verify(&unspent_tx.inner).err() - { + if let Some(e) = free_tx_verifier.verify(&unspent_tx).err() { info!( "Skipping {tx_id} due to unverified proof of work: {}", e diff --git a/rusk/src/lib/free_tx_verifier.rs b/rusk/src/lib/free_tx_verifier.rs index 4ca089fd3c..bae73eece3 100644 --- a/rusk/src/lib/free_tx_verifier.rs +++ b/rusk/src/lib/free_tx_verifier.rs @@ -6,8 +6,8 @@ use crate::free_tx_verifier::Error::*; use crate::pow_verifier::PoW; -use dusk_wallet_core::Transaction; use node::database::DBViewer; +use node_data::ledger::Transaction; use std::fmt; use tracing::info; @@ -49,7 +49,7 @@ impl<'a> FreeTxVerifier<'a> { pub fn verify(&self, tx: &Transaction) -> Result<(), Error> { let tip = self.db_viewer.fetch_tip_height()?; info!("top height={}", tip); - let user_height = Self::extract_block_id(&tx.proof)?; + let user_height = Self::extract_block_id(&tx.inner.proof)?; info!("user height={}", user_height); if user_height >= tip { return Err(BlockHeightInvalid); @@ -62,10 +62,14 @@ impl<'a> FreeTxVerifier<'a> { _ => return Err(BlockNotFound), }; info!("block hash={:x?}", block_hash); - let mut bytes = tx.to_hash_input_bytes(); + let mut bytes = tx.inner.to_hash_input_bytes(); bytes.extend(block_hash.as_ref()); info!("about to verify PoW"); - if !PoW::verify(bytes, &tx.proof[BLOCK_HEIGHT_LEN..], POW_DIFFICULTY) { + if !PoW::verify( + bytes, + &tx.inner.proof[BLOCK_HEIGHT_LEN..], + POW_DIFFICULTY, + ) { info!("PoW invalid"); return Err(PoWInvalid); } diff --git a/rusk/tests/services/contract_pays.rs b/rusk/tests/services/contract_pays.rs index 30fb6f4edf..a320df80c4 100644 --- a/rusk/tests/services/contract_pays.rs +++ b/rusk/tests/services/contract_pays.rs @@ -11,7 +11,6 @@ use std::collections::HashMap; use std::path::Path; use std::sync::{Arc, RwLock}; -use dusk_wallet_core::{self as wallet}; use node::database::DBViewer; use rand::prelude::*; use rand::rngs::StdRng;