Skip to content

Commit

Permalink
rusk: dependencies correction
Browse files Browse the repository at this point in the history
  • Loading branch information
miloszm committed Jun 18, 2024
1 parent cc45161 commit 1d85cb2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
9 changes: 3 additions & 6 deletions rusk/src/lib/chain/rusk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
12 changes: 8 additions & 4 deletions rusk/src/lib/free_tx_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion rusk/tests/services/contract_pays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1d85cb2

Please sign in to comment.