diff --git a/rusk-wallet/src/wallet/transaction.rs b/rusk-wallet/src/wallet/transaction.rs index 590da774a2..37a06d0a0f 100644 --- a/rusk-wallet/src/wallet/transaction.rs +++ b/rusk-wallet/src/wallet/transaction.rs @@ -188,7 +188,6 @@ impl Wallet { } /// Executes a generic contract call, paying gas from a public account. - #[allow(clippy::too_many_arguments)] pub async fn moonlight_execute( &self, sender_idx: u8, diff --git a/rusk/benches/block_ingestion.rs b/rusk/benches/block_ingestion.rs index 21c85deb6d..d2dad5259c 100644 --- a/rusk/benches/block_ingestion.rs +++ b/rusk/benches/block_ingestion.rs @@ -19,7 +19,7 @@ use criterion::{ }; use dusk_core::transfer::Transaction as ProtocolTransaction; use node_data::bls::PublicKey; -use node_data::ledger::Transaction; +use node_data::ledger::{Header, Transaction}; use rand::prelude::StdRng; use rand::seq::SliceRandom; use rand::SeedableRng; @@ -116,7 +116,7 @@ fn bench_accept( const BLOCK_GAS_LIMIT: u64 = 1_000_000_000_000; const BLOCK_HASH: [u8; 32] = [0u8; 32]; - let generator = PublicKey::new(*DUSK_CONSENSUS_KEY).into_inner(); + let generator = *PublicKey::new(*DUSK_CONSENSUS_KEY).bytes(); let txs = Arc::new(txs); let prev_root = rusk.state_root(); @@ -124,6 +124,13 @@ fn bench_accept( for n_txs in N_TXS { let rusk = rusk.clone(); let txs = txs.clone(); + let header = Header { + height: BLOCK_HEIGHT, + gas_limit: BLOCK_GAS_LIMIT, + hash: BLOCK_HASH, + generator_bls_pubkey: generator, + ..Default::default() + }; group.bench_with_input( BenchmarkId::new(name, format!("{} TXs", n_txs)), @@ -134,11 +141,8 @@ fn bench_accept( rusk.accept_transactions( prev_root, - BLOCK_HEIGHT, - BLOCK_GAS_LIMIT, - BLOCK_HASH, - generator, - txs, + &header, + &txs, None, vec![], &[], diff --git a/rusk/src/lib/node/rusk.rs b/rusk/src/lib/node/rusk.rs index 3e06f8d4fa..712cfa4f38 100644 --- a/rusk/src/lib/node/rusk.rs +++ b/rusk/src/lib/node/rusk.rs @@ -9,7 +9,7 @@ use std::sync::{mpsc, Arc}; use std::time::Instant; use std::{fs, io}; -use dusk_bytes::Serializable; +use dusk_bytes::{DeserializableSlice, Serializable}; use dusk_consensus::config::{ ratification_extra, ratification_quorum, validation_extra, validation_quorum, MAX_NUMBER_OF_TRANSACTIONS, @@ -31,7 +31,7 @@ use dusk_vm::{ #[cfg(feature = "archive")] use node::archive::Archive; use node_data::events::contract::ContractTxEvent; -use node_data::ledger::{Hash, Slash, SpentTransaction, Transaction}; +use node_data::ledger::{Header, Slash, SpentTransaction, Transaction}; use parking_lot::RwLock; use rusk_profile::to_rusk_state_id_path; use tokio::sync::broadcast; @@ -238,26 +238,22 @@ impl Rusk { } /// Verify the given transactions are ok. - #[allow(clippy::too_many_arguments)] pub fn verify_transactions( &self, prev_commit: [u8; 32], - block_height: u64, - block_hash: Hash, - block_gas_limit: u64, + header: &Header, generator: &BlsPublicKey, txs: &[Transaction], slashing: Vec, voters: &[Voter], ) -> Result<(Vec, VerificationOutput)> { + let block_height = header.height; let session = self.new_block_session(block_height, prev_commit)?; let execution_config = self.vm_config.to_execution_config(block_height); accept( session, - block_height, - block_hash, - block_gas_limit, + header, generator, txs, slashing, @@ -278,15 +274,11 @@ impl Rusk { /// - VerificationOutput - The verification output. /// - Vec - All contract events that were emitted from the /// given transactions. - #[allow(clippy::too_many_arguments)] pub fn accept_transactions( &self, prev_commit: [u8; 32], - block_height: u64, - block_gas_limit: u64, - block_hash: Hash, - generator: BlsPublicKey, - txs: Vec, + header: &Header, + txs: &[Transaction], consistency_check: Option, slashing: Vec, voters: &[Voter], @@ -295,17 +287,20 @@ impl Rusk { VerificationOutput, Vec, )> { + let generator = header.generator_bls_pubkey.inner(); + let generator = BlsPublicKey::from_slice(generator).map_err(|e| { + Error::Other(anyhow::anyhow!("Error in from_slice {e:?}").into()) + })?; + let block_height = header.height; let session = self.new_block_session(block_height, prev_commit)?; let execution_config = self.vm_config.to_execution_config(block_height); let (spent_txs, verification_output, session, events) = accept( session, - block_height, - block_hash, - block_gas_limit, + header, &generator, - &txs[..], + txs, slashing, voters, &execution_config, @@ -534,12 +529,9 @@ impl Rusk { } } -#[allow(clippy::too_many_arguments)] fn accept( session: Session, - block_height: u64, - block_hash: Hash, - block_gas_limit: u64, + header: &Header, generator: &BlsPublicKey, txs: &[Transaction], slashing: Vec, @@ -553,7 +545,8 @@ fn accept( )> { let mut session = session; - let mut block_gas_left = block_gas_limit; + let mut block_gas_left = header.gas_limit; + let block_height = header.height; let mut spent_txs = Vec::with_capacity(txs.len()); let mut dusk_spent = 0; @@ -606,13 +599,11 @@ fn accept( event_bloom.add_events(&coinbase_events); - let coinbase_events: Vec<_> = coinbase_events - .into_iter() - .map(|event| ContractTxEvent { + let coinbase_events = + coinbase_events.into_iter().map(|event| ContractTxEvent { event: event.into(), - origin: block_hash, - }) - .collect(); + origin: header.hash, + }); events.extend(coinbase_events); let state_root = session.root(); diff --git a/rusk/src/lib/node/vm.rs b/rusk/src/lib/node/vm.rs index aa8987b089..31671899f2 100644 --- a/rusk/src/lib/node/vm.rs +++ b/rusk/src/lib/node/vm.rs @@ -53,8 +53,8 @@ impl VMExecution for Rusk { voters: &[Voter], ) -> Result { info!("Received verify_state_transition request"); - let generator = blk.header().generator_bls_pubkey; - let generator = BlsPublicKey::from_slice(&generator.0) + let generator = blk.header().generator_bls_pubkey.inner(); + let generator = BlsPublicKey::from_slice(generator) .map_err(VstError::InvalidGenerator)?; let slashing = @@ -63,9 +63,7 @@ impl VMExecution for Rusk { let (_, verification_output) = self .verify_transactions( prev_commit, - blk.header().height, - blk.header().hash, - blk.header().gas_limit, + blk.header(), &generator, blk.txs(), slashing, @@ -93,24 +91,19 @@ impl VMExecution for Rusk { Vec, )> { debug!("Received accept request"); - let generator = blk.header().generator_bls_pubkey; - let generator = BlsPublicKey::from_slice(&generator.0) - .map_err(|e| anyhow::anyhow!("Error in from_slice {e:?}"))?; let slashing = Slash::from_block(blk)?; + let expected = VerificationOutput { + event_bloom: blk.header().event_bloom, + state_root: blk.header().state_hash, + }; let (txs, verification_output, contract_events) = self .accept_transactions( prev_root, - blk.header().height, - blk.header().gas_limit, - blk.header().hash, - generator, - blk.txs().clone(), - Some(VerificationOutput { - state_root: blk.header().state_hash, - event_bloom: blk.header().event_bloom, - }), + blk.header(), + blk.txs(), + Some(expected), slashing, voters, ) diff --git a/rusk/tests/common/wallet/test_wallet/imp.rs b/rusk/tests/common/wallet/test_wallet/imp.rs index c6a924899f..3989228442 100644 --- a/rusk/tests/common/wallet/test_wallet/imp.rs +++ b/rusk/tests/common/wallet/test_wallet/imp.rs @@ -339,7 +339,6 @@ where } /// Executes a generic contract call, paying gas from a public account. - #[allow(clippy::too_many_arguments)] pub fn moonlight_execute( &self, sender_idx: u8, @@ -382,7 +381,6 @@ where /// Execute a generic contract call or deployment, using Phoenix notes to /// pay for gas. - #[allow(clippy::too_many_arguments)] pub fn phoenix_execute( &self, rng: &mut Rng, @@ -432,7 +430,6 @@ where } /// Transfer Dusk in the form of Phoenix notes from one key to another. - #[allow(clippy::too_many_arguments)] pub fn phoenix_transfer( &self, rng: &mut Rng, @@ -483,7 +480,6 @@ where } /// Stakes an amount of Dusk using Phoenix notes. - #[allow(clippy::too_many_arguments)] pub fn phoenix_stake( &self, rng: &mut Rng, @@ -796,7 +792,6 @@ where } /// Stakes an amount of Dusk using a Moonlight account. - #[allow(clippy::too_many_arguments)] pub fn moonlight_stake( &self, sender_index: u8,