diff --git a/rusk/benches/block_ingestion.rs b/rusk/benches/block_ingestion.rs index f872d08e97..8d16bac883 100644 --- a/rusk/benches/block_ingestion.rs +++ b/rusk/benches/block_ingestion.rs @@ -18,7 +18,7 @@ use criterion::{ criterion_group, criterion_main, BenchmarkGroup, BenchmarkId, Criterion, }; use execution_core::{ - transfer::Transaction as PhoenixTransaction, StakePublicKey, StakeSecretKey, + transfer::Transaction as ProtocolTransaction, BlsPublicKey, BlsSecretKey, }; use node_data::ledger::Transaction; use rand::prelude::StdRng; @@ -37,7 +37,7 @@ fn load_txs() -> Vec { for line in BufReader::new(TXS_BYTES).lines() { let line = line.unwrap(); let tx_bytes = hex::decode(line).unwrap(); - let tx = PhoenixTransaction::from_slice(&tx_bytes).unwrap(); + let tx = ProtocolTransaction::from_slice(&tx_bytes).unwrap(); txs.push(Transaction { version: 1, r#type: 0, @@ -46,12 +46,21 @@ fn load_txs() -> Vec { } for tx in txs.iter() { - match rusk::verifier::verify_proof(&tx.inner) { - Ok(true) => Ok(()), - Ok(false) => Err(anyhow::anyhow!("Invalid proof")), - Err(e) => Err(anyhow::anyhow!("Cannot verify the proof: {e}")), + match &tx.inner { + ProtocolTransaction::Phoenix(tx) => { + match rusk::verifier::verify_proof(tx) { + Ok(true) => Ok(()), + Ok(false) => Err(anyhow::anyhow!("Invalid proof")), + Err(e) => { + Err(anyhow::anyhow!("Cannot verify the proof: {e}")) + } + } + .unwrap() + } + ProtocolTransaction::Moonlight(_) => { + panic!("All transactions must be phoenix") + } } - .unwrap() } txs @@ -80,8 +89,8 @@ pub fn accept_benchmark(c: &mut Criterion) { let generator = { let mut rng = StdRng::seed_from_u64(0xbeef); - let sk = StakeSecretKey::random(&mut rng); - StakePublicKey::from(&sk) + let sk = BlsSecretKey::random(&mut rng); + BlsPublicKey::from(&sk) }; const BLOCK_HEIGHT: u64 = 1; diff --git a/rusk/src/lib/chain/rusk.rs b/rusk/src/lib/chain/rusk.rs index 80b680f66f..0ae63b1e9a 100644 --- a/rusk/src/lib/chain/rusk.rs +++ b/rusk/src/lib/chain/rusk.rs @@ -26,8 +26,9 @@ use dusk_consensus::operations::{ use execution_core::bytecode::Bytecode; use execution_core::transfer::ContractDeploy; use execution_core::{ - stake::StakeData, transfer::Transaction as PhoenixTransaction, BlsScalar, - StakePublicKey, + stake::StakeData, + transfer::{AccountData, Transaction as ProtocolTransaction}, + BlsPublicKey, BlsScalar, }; use node_data::ledger::{Slash, SpentTransaction, Transaction}; use rusk_abi::dusk::Dusk; @@ -44,9 +45,9 @@ use crate::http::RuesEvent; use crate::Error::InvalidCreditsCount; use crate::{Error, Result}; -pub static DUSK_KEY: LazyLock = LazyLock::new(|| { +pub static DUSK_KEY: LazyLock = LazyLock::new(|| { let dusk_cpk_bytes = include_bytes!("../../assets/dusk.cpk"); - StakePublicKey::from_slice(dusk_cpk_bytes) + BlsPublicKey::from_slice(dusk_cpk_bytes) .expect("Dusk consensus public key to be valid") }); @@ -129,7 +130,7 @@ impl Rusk { } } let tx_id = hex::encode(unspent_tx.id()); - if unspent_tx.inner.payload().fee.gas_limit > block_gas_left { + if unspent_tx.inner.gas_limit() > block_gas_left { info!("Skipping {tx_id} due gas_limit greater than left: {block_gas_left}"); continue; } @@ -169,7 +170,7 @@ impl Rusk { update_hasher(&mut event_hasher, &receipt.events); block_gas_left -= gas_spent; - let gas_price = unspent_tx.inner.payload().fee.gas_price; + let gas_price = unspent_tx.inner.gas_price(); dusk_spent += gas_spent * gas_price; spent_txs.push(SpentTransaction { inner: unspent_tx, @@ -215,7 +216,7 @@ impl Rusk { &self, block_height: u64, block_gas_limit: u64, - generator: &StakePublicKey, + generator: &BlsPublicKey, txs: &[Transaction], slashing: Vec, voters: Option<&[VoterWithCredits]>, @@ -245,7 +246,7 @@ impl Rusk { &self, block_height: u64, block_gas_limit: u64, - generator: StakePublicKey, + generator: BlsPublicKey, txs: Vec, consistency_check: Option, slashing: Vec, @@ -332,16 +333,21 @@ impl Rusk { pub fn provisioners( &self, base_commit: Option<[u8; 32]>, - ) -> Result> { + ) -> Result> { let (sender, receiver) = mpsc::channel(); self.feeder_query(STAKE_CONTRACT, "stakes", &(), sender, base_commit)?; Ok(receiver.into_iter().map(|bytes| { - rkyv::from_bytes::<(StakePublicKey, StakeData)>(&bytes).expect( + rkyv::from_bytes::<(BlsPublicKey, StakeData)>(&bytes).expect( "The contract should only return (pk, stake_data) tuples", ) })) } + /// Returns an account's information. + pub fn account(&self, pk: &BlsPublicKey) -> Result { + self.query(TRANSFER_CONTRACT, "account", pk) + } + /// Fetches the previous state data for stake changes in the contract. /// /// Communicates with the stake contract to obtain information about the @@ -356,12 +362,12 @@ impl Rusk { /// # Returns /// /// Returns a Result containing an iterator over tuples. Each tuple consists - /// of a `StakePublicKey` and an optional `StakeData`, representing the + /// of a `BlsPublicKey` and an optional `StakeData`, representing the /// state data before the last changes in the stake contract. pub fn last_provisioners_change( &self, base_commit: Option<[u8; 32]>, - ) -> Result)>> { + ) -> Result)>> { let (sender, receiver) = mpsc::channel(); self.feeder_query( STAKE_CONTRACT, @@ -371,16 +377,13 @@ impl Rusk { base_commit, )?; Ok(receiver.into_iter().map(|bytes| { - rkyv::from_bytes::<(StakePublicKey, Option)>(&bytes).expect( + rkyv::from_bytes::<(BlsPublicKey, Option)>(&bytes).expect( "The contract should only return (pk, Option) tuples", ) }).collect()) } - pub fn provisioner( - &self, - pk: &StakePublicKey, - ) -> Result> { + pub fn provisioner(&self, pk: &BlsPublicKey) -> Result> { self.query(STAKE_CONTRACT, "get_stake", pk) } @@ -433,7 +436,7 @@ fn accept( session: Session, block_height: u64, block_gas_limit: u64, - generator: &StakePublicKey, + generator: &BlsPublicKey, txs: &[Transaction], slashing: Vec, voters: Option<&[VoterWithCredits]>, @@ -463,7 +466,7 @@ fn accept( let gas_spent = receipt.gas_spent; - dusk_spent += gas_spent * tx.payload().fee.gas_price; + dusk_spent += gas_spent * tx.gas_price(); block_gas_left = block_gas_left .checked_sub(gas_spent) .ok_or(Error::OutOfGas)?; @@ -588,15 +591,15 @@ fn contract_deploy( /// failed to fit the block. fn execute( session: &mut Session, - tx: &PhoenixTransaction, + tx: &ProtocolTransaction, gas_per_deploy_byte: Option, ) -> Result, ContractError>>, PiecrustError> { // Transaction will be discarded if it is a deployment transaction // with gas limit smaller than deploy charge. - if let Some(deploy) = tx.payload().contract_deploy() { + if let Some(deploy) = tx.deploy() { let deploy_charge = bytecode_charge(&deploy.bytecode, &gas_per_deploy_byte); - if tx.payload().fee.gas_limit < deploy_charge { + if tx.gas_limit() < deploy_charge { return Err(PiecrustError::Panic( "not enough gas to deploy".into(), )); @@ -610,16 +613,16 @@ fn execute( TRANSFER_CONTRACT, "spend_and_execute", tx_stripped.as_ref().unwrap_or(tx), - tx.payload().fee.gas_limit, + tx.gas_limit(), )?; // Deploy if this is a deployment transaction and spend part is successful. - if let Some(deploy) = tx.payload().contract_deploy() { + if let Some(deploy) = tx.deploy() { if receipt.data.is_ok() { contract_deploy( session, deploy, - tx.payload().fee.gas_limit, + tx.gas_limit(), gas_per_deploy_byte, &mut receipt, ); @@ -638,7 +641,7 @@ fn execute( .call::<_, ()>( TRANSFER_CONTRACT, "refund", - &(tx.payload().fee, receipt.gas_spent), + &receipt.gas_spent, u64::MAX, ) .expect("Refunding must succeed"); @@ -660,9 +663,9 @@ fn reward_slash_and_update_root( session: &mut Session, block_height: u64, dusk_spent: Dusk, - generator: &StakePublicKey, + generator: &BlsPublicKey, slashing: Vec, - voters: Option<&[(StakePublicKey, usize)]>, + voters: Option<&[(BlsPublicKey, usize)]>, ) -> Result> { let ( dusk_value, @@ -768,7 +771,7 @@ fn calc_generator_extra_reward( credits.saturating_sub(sum as u64) * reward_per_quota } -fn to_bs58(pk: &StakePublicKey) -> String { +fn to_bs58(pk: &BlsPublicKey) -> String { let mut pk = bs58::encode(&pk.to_bytes()).into_string(); pk.truncate(16); pk diff --git a/rusk/src/lib/chain/vm.rs b/rusk/src/lib/chain/vm.rs index c0d699e4ee..aa15ca1f7f 100644 --- a/rusk/src/lib/chain/vm.rs +++ b/rusk/src/lib/chain/vm.rs @@ -14,7 +14,10 @@ use dusk_consensus::operations::{ }; use dusk_consensus::user::provisioners::Provisioners; use dusk_consensus::user::stake::Stake; -use execution_core::{stake::StakeData, StakePublicKey}; +use execution_core::{ + stake::StakeData, transfer::Transaction as ProtocolTransaction, + BlsPublicKey, +}; use node::vm::VMExecution; use node_data::ledger::{Block, Slash, SpentTransaction, Transaction}; @@ -47,7 +50,7 @@ impl VMExecution for Rusk { ) -> anyhow::Result { info!("Received verify_state_transition request"); let generator = blk.header().generator_bls_pubkey; - let generator = StakePublicKey::from_slice(&generator.0) + let generator = BlsPublicKey::from_slice(&generator.0) .map_err(|e| anyhow::anyhow!("Error in from_slice {e:?}"))?; let slashing = Slash::from_block(blk)?; @@ -73,7 +76,7 @@ impl VMExecution for Rusk { ) -> anyhow::Result<(Vec, VerificationOutput)> { info!("Received accept request"); let generator = blk.header().generator_bls_pubkey; - let generator = StakePublicKey::from_slice(&generator.0) + let generator = BlsPublicKey::from_slice(&generator.0) .map_err(|e| anyhow::anyhow!("Error in from_slice {e:?}"))?; let slashing = Slash::from_block(blk)?; @@ -109,18 +112,64 @@ impl VMExecution for Rusk { fn preverify(&self, tx: &Transaction) -> anyhow::Result<()> { info!("Received preverify request"); let tx = &tx.inner; - let existing_nullifiers = self - .existing_nullifiers(&tx.payload().tx_skeleton.nullifiers) - .map_err(|e| anyhow::anyhow!("Cannot check nullifiers: {e}"))?; - if !existing_nullifiers.is_empty() { - let err = crate::Error::RepeatingNullifiers(existing_nullifiers); - return Err(anyhow::anyhow!("Invalid tx: {err}")); - } - match crate::verifier::verify_proof(tx) { - Ok(true) => Ok(()), - Ok(false) => Err(anyhow::anyhow!("Invalid proof")), - Err(e) => Err(anyhow::anyhow!("Cannot verify the proof: {e}")), + match tx { + ProtocolTransaction::Phoenix(tx) => { + let payload = tx.payload(); + + let existing_nullifiers = self + .existing_nullifiers(&payload.tx_skeleton.nullifiers) + .map_err(|e| { + anyhow::anyhow!("Cannot check nullifiers: {e}") + })?; + + if !existing_nullifiers.is_empty() { + let err = + crate::Error::RepeatingNullifiers(existing_nullifiers); + return Err(anyhow::anyhow!("Invalid tx: {err}")); + } + + match crate::verifier::verify_proof(tx) { + Ok(true) => Ok(()), + Ok(false) => Err(anyhow::anyhow!("Invalid proof")), + Err(e) => { + Err(anyhow::anyhow!("Cannot verify the proof: {e}")) + } + } + } + ProtocolTransaction::Moonlight(tx) => { + let payload = tx.payload(); + + let account_data = + self.account(&payload.from).map_err(|e| { + anyhow::anyhow!("Cannot check account: {e}") + })?; + + let max_value = payload.value + + payload.deposit + + payload.gas_limit * payload.gas_price; + if max_value > account_data.balance { + return Err(anyhow::anyhow!( + "Value spent larger than account holds" + )); + } + + if payload.nonce <= account_data.nonce { + let err = crate::Error::RepeatingNonce( + payload.from.into(), + payload.nonce, + ); + return Err(anyhow::anyhow!("Invalid tx: {err}")); + } + + match crate::verifier::verify_signature(tx) { + Ok(true) => Ok(()), + Ok(false) => Err(anyhow::anyhow!("Invalid signature")), + Err(e) => { + Err(anyhow::anyhow!("Cannot verify the signature: {e}")) + } + } + } } } @@ -140,15 +189,12 @@ impl VMExecution for Rusk { fn get_provisioner( &self, - pk: &StakePublicKey, + pk: &BlsPublicKey, ) -> anyhow::Result> { let stake = self .provisioner(pk) .map_err(|e| anyhow::anyhow!("Cannot get provisioner {e}"))? - .map(|stake| { - let (value, eligibility) = stake.amount.unwrap_or_default(); - Stake::new(value, stake.reward, eligibility, stake.counter) - }); + .map(Self::to_stake); Ok(stake) } @@ -218,7 +264,11 @@ impl Rusk { } fn to_stake(stake: StakeData) -> Stake { - let (value, eligibility) = stake.amount.unwrap_or_default(); - Stake::new(value, stake.reward, eligibility, stake.counter) + let stake_amount = stake.amount.unwrap_or_default(); + + let value = stake_amount.value; + let eligibility = stake_amount.eligibility; + + Stake::new(value, stake.reward, eligibility, stake.nonce) } } diff --git a/rusk/src/lib/error.rs b/rusk/src/lib/error.rs index 1f2c5dadd3..9556e268af 100644 --- a/rusk/src/lib/error.rs +++ b/rusk/src/lib/error.rs @@ -6,8 +6,9 @@ use std::{fmt, io}; +use dusk_bytes::Serializable; use execution_core::BlsScalar; -use execution_core::PhoenixError; +use execution_core::{BlsPublicKey, PhoenixError}; use rusk_abi::dusk::Dusk; #[derive(Debug)] @@ -22,6 +23,8 @@ pub enum Error { OutOfGas, /// Repeated nullifier in transaction verification RepeatingNullifiers(Vec), + /// Repeating a nonce that has already been used + RepeatingNonce(Box, u64), /// Wrong inputs and/or outputs in the transaction verification InvalidCircuitArguments(usize, usize), /// Failed to build a Rusk instance @@ -132,6 +135,11 @@ impl fmt::Display for Error { Error::RepeatingNullifiers(n) => { write!(f, "Nullifiers repeat: {n:?}") } + Error::RepeatingNonce(account, nonce) => { + let encoded_account = + bs58::encode(&account.to_bytes()).into_string(); + write!(f, "Nonce repeat: {encoded_account} {nonce}") + } Error::InvalidCircuitArguments(inputs_len, outputs_len) => { write!(f,"Expected: 0 < (inputs: {inputs_len}) < 5, 0 ≤ (outputs: {outputs_len}) < 3") } diff --git a/rusk/src/lib/http/chain/graphql.rs b/rusk/src/lib/http/chain/graphql.rs index c7e2612b0c..600ff0a0f2 100644 --- a/rusk/src/lib/http/chain/graphql.rs +++ b/rusk/src/lib/http/chain/graphql.rs @@ -82,9 +82,7 @@ impl Query { let tx_contract = t.0.inner .inner - .payload() - .contract_call() - .as_ref() + .call() .map(|c| c.contract) .unwrap_or( rusk_abi::TRANSFER_CONTRACT.to_bytes(), diff --git a/rusk/src/lib/http/chain/graphql/data.rs b/rusk/src/lib/http/chain/graphql/data.rs index 6e9f5df13e..64d8d5ee2e 100644 --- a/rusk/src/lib/http/chain/graphql/data.rs +++ b/rusk/src/lib/http/chain/graphql/data.rs @@ -249,26 +249,33 @@ impl Transaction<'_> { let tx = &self.0.inner; let mut map = Map::new(); - map.insert( - "root".into(), - json!(hex::encode(tx.payload().tx_skeleton.root.to_bytes())), - ); + + if let Some(root) = tx.root() { + map.insert("root".into(), json!(hex::encode(root.to_bytes()))); + } + + if let Some(from) = tx.from() { + map.insert("from".into(), json!(hex::encode(from.to_bytes()))); + } + if let Some(to) = tx.to() { + map.insert("to".into(), json!(hex::encode(to.to_bytes()))); + } + if let Some(value) = tx.value() { + map.insert("value".into(), json!(hex::encode(value.to_bytes()))); + } + let nullifiers: Vec<_> = tx - .payload() - .tx_skeleton - .nullifiers + .nullifiers() .iter() .map(|n| hex::encode(n.to_bytes())) .collect(); - map.insert("nullifier".into(), json!(nullifiers)); + map.insert("nullifiers".into(), json!(nullifiers)); map.insert( "deposit".into(), - json!(hex::encode(tx.payload().tx_skeleton.deposit.to_bytes())), + json!(hex::encode(tx.deposit().to_bytes())), ); let notes: Vec<_> = tx - .payload() - .tx_skeleton - .outputs + .outputs() .iter() .map(|n| { let mut map = Map::new(); @@ -303,20 +310,23 @@ impl Transaction<'_> { map.insert("notes".into(), json!(notes)); let mut fee = Map::new(); - fee.insert("gas_limit".into(), json!(tx.payload().fee.gas_limit)); - fee.insert("gas_price".into(), json!(tx.payload().fee.gas_price)); - fee.insert( - "stealth_address".into(), - json!(bs58::encode(tx.payload().fee.stealth_address.to_bytes()) - .into_string()), - ); - fee.insert( - "sender".into(), - json!(hex::encode(tx.payload().fee.sender.to_bytes())), - ); + + fee.insert("gas_limit".into(), json!(tx.gas_limit())); + fee.insert("gas_price".into(), json!(tx.gas_price())); + + if let Some(stealth_address) = tx.stealth_address() { + fee.insert( + "stealth_address".into(), + json!(bs58::encode(stealth_address.to_bytes()).into_string()), + ); + } + if let Some(sender) = tx.sender() { + fee.insert("sender".into(), json!(hex::encode(sender.to_bytes()))); + } + map.insert("fee".into(), json!(fee)); - if let Some(c) = &tx.payload().contract_call() { + if let Some(c) = tx.call() { let mut call = Map::new(); call.insert("contract".into(), json!(hex::encode(c.contract))); call.insert("fn_name".into(), json!(&c.fn_name)); @@ -332,24 +342,19 @@ impl Transaction<'_> { } pub async fn gas_limit(&self) -> u64 { - self.0.inner.payload().fee.gas_limit + self.0.inner.gas_limit() } pub async fn gas_price(&self) -> u64 { - self.0.inner.payload().fee.gas_price + self.0.inner.gas_price() } pub async fn call_data(&self) -> Option { - self.0 - .inner - .payload() - .contract_call() - .as_ref() - .map(|call| CallData { - contract: hex::encode(call.contract), - fn_name: call.fn_name.clone(), - fn_args: hex::encode(&call.fn_args), - }) + self.0.inner.call().map(|call| CallData { + contract: hex::encode(call.contract), + fn_name: call.fn_name.clone(), + fn_args: hex::encode(&call.fn_args), + }) } } diff --git a/rusk/src/lib/http/rusk.rs b/rusk/src/lib/http/rusk.rs index 6911431e5b..591b27b91f 100644 --- a/rusk/src/lib/http/rusk.rs +++ b/rusk/src/lib/http/rusk.rs @@ -98,10 +98,11 @@ impl Rusk { .expect("Cannot query state for provisioners") .map(|(key, stake)| { let key = bs58::encode(key.to_bytes()).into_string(); - let (amount, eligibility) = stake.amount.unwrap_or_default(); + let amount = stake.amount.unwrap_or_default(); + Provisioner { - amount, - eligibility, + amount: amount.value, + eligibility: amount.eligibility, key, reward: stake.reward, } diff --git a/rusk/src/lib/verifier.rs b/rusk/src/lib/verifier.rs index 743f44ffda..3e884c52e9 100644 --- a/rusk/src/lib/verifier.rs +++ b/rusk/src/lib/verifier.rs @@ -9,7 +9,7 @@ use crate::error::Error; use crate::Result; -use execution_core::transfer::Transaction; +use execution_core::transfer::{MoonlightTransaction, PhoenixTransaction}; use rusk_profile::Circuit as CircuitProfile; use std::sync::LazyLock; @@ -26,7 +26,8 @@ pub static VD_EXEC_3_2: LazyLock> = pub static VD_EXEC_4_2: LazyLock> = LazyLock::new(|| fetch_verifier("ExecuteCircuitFourTwo")); -pub fn verify_proof(tx: &Transaction) -> Result { +/// Verifies the proof of the incoming transaction. +pub fn verify_proof(tx: &PhoenixTransaction) -> Result { let pi: Vec = tx.public_inputs().iter().map(|pi| pi.into()).collect(); @@ -43,11 +44,22 @@ pub fn verify_proof(tx: &Transaction) -> Result { } }; - // Maybe we want to handle internal serialization error too, currently - // they map to `false`. + // Maybe we want to handle internal serialization error too, + // currently they map to `false`. Ok(rusk_abi::verify_proof(vd.to_vec(), tx.proof().to_vec(), pi)) } +/// Verifies the signature of the incoming transaction. +pub fn verify_signature(tx: &MoonlightTransaction) -> Result { + let payload = tx.payload(); + let signature = tx.signature(); + + let digest = payload.to_hash_input_bytes(); + let is_valid = rusk_abi::verify_bls(digest, payload.from, *signature); + + Ok(is_valid) +} + fn fetch_verifier(circuit_name: &str) -> Vec { let circuit_profile = CircuitProfile::from_name(circuit_name) .unwrap_or_else(|_| { diff --git a/rusk/tests/common/keys.rs b/rusk/tests/common/keys.rs index f96871a8e1..73c92e9756 100644 --- a/rusk/tests/common/keys.rs +++ b/rusk/tests/common/keys.rs @@ -10,12 +10,12 @@ use rand::prelude::*; use rand::rngs::StdRng; use tracing::info; -use execution_core::StakeSecretKey; +use execution_core::BlsSecretKey; #[allow(dead_code)] -pub static STAKE_SK: LazyLock = LazyLock::new(|| { - info!("Generating StakeSecretKey"); +pub static STAKE_SK: LazyLock = LazyLock::new(|| { + info!("Generating BlsSecretKey"); let mut rng = StdRng::seed_from_u64(0xdead); - StakeSecretKey::random(&mut rng) + BlsSecretKey::random(&mut rng) }); diff --git a/rusk/tests/common/state.rs b/rusk/tests/common/state.rs index 6349b16744..edeab3affe 100644 --- a/rusk/tests/common/state.rs +++ b/rusk/tests/common/state.rs @@ -14,7 +14,7 @@ use rusk_recovery_tools::state::{self, Snapshot}; use dusk_consensus::operations::CallParams; use execution_core::{ - transfer::Transaction as PhoenixTransaction, StakePublicKey, + transfer::Transaction as PhoenixTransaction, BlsPublicKey, }; use node_data::{ bls::PublicKeyBytes, @@ -71,7 +71,7 @@ pub fn generator_procedure( txs: &[PhoenixTransaction], block_height: u64, block_gas_limit: u64, - missed_generators: Vec, + missed_generators: Vec, expected: Option, ) -> anyhow::Result> { let expected = expected.unwrap_or(ExecuteResult { @@ -84,7 +84,7 @@ pub fn generator_procedure( rusk.preverify(tx)?; } - let generator = StakePublicKey::from(LazyLock::force(&STAKE_SK)); + let generator = BlsPublicKey::from(LazyLock::force(&STAKE_SK)); let generator_pubkey = node_data::bls::PublicKey::new(generator); let generator_pubkey_bytes = *generator_pubkey.bytes(); let round = block_height; diff --git a/rusk/tests/common/wallet.rs b/rusk/tests/common/wallet.rs index 0daed7d5ad..f723067a65 100644 --- a/rusk/tests/common/wallet.rs +++ b/rusk/tests/common/wallet.rs @@ -12,15 +12,18 @@ use crate::common::block::Block as BlockAwait; use dusk_bytes::{DeserializableSlice, Serializable}; use dusk_plonk::prelude::Proof; -use execution_core::transfer::{ - Transaction as PhoenixTransaction, TRANSFER_TREE_DEPTH, +use execution_core::{ + stake::StakeData, + transfer::{ + AccountData, Transaction as PhoenixTransaction, TRANSFER_TREE_DEPTH, + }, + BlsPublicKey, BlsScalar, Note, ViewKey, }; -use execution_core::{BlsPublicKey, BlsScalar, Note, ViewKey}; use futures::StreamExt; use poseidon_merkle::Opening as PoseidonOpening; use rusk::{Error, Result, Rusk}; use rusk_prover::{LocalProver, Prover}; -use test_wallet::{self as wallet, StakeInfo, Store, UnprovenTransaction}; +use test_wallet::{self as wallet, Store, UnprovenTransaction}; use tracing::info; #[derive(Debug, Clone)] @@ -106,18 +109,18 @@ impl wallet::StateClient for TestStateClient { .ok_or(Error::OpeningPositionNotFound(*note.pos())) } - fn fetch_stake(&self, pk: &BlsPublicKey) -> Result { - let stake = self - .rusk - .provisioner(pk)? - .map(|stake| StakeInfo { - amount: stake.amount, - counter: stake.counter, - reward: stake.reward, - }) - .unwrap_or_default(); + fn fetch_stake(&self, pk: &BlsPublicKey) -> Result { + let stake = self.rusk.provisioner(pk)?.unwrap_or(StakeData::EMPTY); Ok(stake) } + + fn fetch_account( + &self, + pk: &BlsPublicKey, + ) -> Result { + let account = self.rusk.account(pk)?; + Ok(account) + } } #[derive(Default)] @@ -146,7 +149,7 @@ impl wallet::ProverClient for TestProverClient { //Propagate is not required yet - Ok(tx) + Ok(tx.into()) } } diff --git a/rusk/tests/config/bench.toml b/rusk/tests/config/bench.toml index d79800a3e4..7d219f1617 100644 --- a/rusk/tests/config/bench.toml +++ b/rusk/tests/config/bench.toml @@ -2,502 +2,502 @@ owners = [] allowlist = [] -[[balance]] +[[phoenix_balance]] address = "ivmscertKgRyX8wNMJJsQcSVEyPsfSMUQXSAgeAPQXsndqFq9Pmknzhm61QvcEEdxPaGgxDS4RHpb6KKccrnSKN" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3MoVQ6VfGNu8fJ5GeHPRDVUfxcsDEmGXpWhvKhXY7F2dKCp7QWRw8RqPcbuJGdRqeTtxpuiwETnGAJLnhT4Kq4e8" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "4RyaodGmN8MyUDmpRrtRxJJhrVW2HsY2ycRUnRUXR97JCN1GHraQT9Ygb8yYo7oKzyZg2EXXCGkHBwoeNb96BKtQ" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "4csmXrPE5bbw6jhrrZ6gtfEbGRJQkYWmaDLxRiAprvFH8ZULZXr5vwGoRohPEzwUQZUZJtgtQzJtiaD1tbX6E2Ef" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5ocii5SbQFu8L3oZUz8nxXN97aS2WbiofzsJZGFWnRiW2HHc58m55SJXtu5KXNgJEwawA9axmDpseaen5HmoFZVA" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "62U4U6DqbbL86qtvzsp1Nv7fwF8VBKY8TgQCMjgbvZgppB35DB7gHrDoSv3xfpoxGMeksTwyftXZYeyBHRquEYxo" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "2bu73CmZbbavWojBMtmP811JkNTv4uqpU55Xw5ieVCvXsB28WWUq9h2VFvU2jTJJA4eZaWb5vE7HUWgjBhpaCQuo" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3FCKVvuAFsMQKk4y1sbfyRp4Mhct6YcJXF5TUijZK825txyFpTv5cw8KgcpPjRHLs5wUy7QBUdLZ3kjCC9EMyNbR" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5ZNtdcXXEMPMV4gR8WpeqoZyd15xMfsAGMd7LCwnpLW6rHkq1JAehYHsCn4Qkhrv2qYdZfn9iaP4LucZBJwS9mEt" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3Yz6yWWbnF2tXeCnMyhFvX6c8f6HEr49hy4WNus3pM3KmkBppbUggwMduhUpnmAzrqUHpZpFKMjwYrj4SPokp92T" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "gyC9TpyFDivjKMaQ1mWGvK1R46ajuKVqh99Ck9SfrujFNSV2RU6PiqNvGf8mYhxFyvkHbrRTzU4vQpMbdaMCpZF" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "rXQqPhrsCFwbtUGNFsvM9wR14183nGL8BCTU2mN2Z3xUr8UZMeNGfCC1RkxxvaVs8ubfa3Dhxo2WdUxhFE2JsZo" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3Caf5EmCGrfpB4vsjT7Musw9PCwyBbjNTZZqyczA6g4gUmTJUnbnCrzETjmKaC3cXzEywHfFyXb64fKrWK5DNBwu" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "21qrgR6XXoE5Jv97MEa6w11nQuzo3trkKcLwrtGMdkdPRyVbyTPNzRet32rX3taZeLjXvidprw2iW1b183381hFJ" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "2vW324Kn9QxQdYngn6Wu5QJZ3AuMCHBSVEw1nUaRtxvmbS4efRVJho5ChoVLjYJwxA6hxJbvkhgwAFdEqyxdgjik" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3jaU8Atz1tgcFHA6SPuforum8dm5jbADJxoqmekw77mRv96aj2gh36mP4jESbLZRVfh9Zpce921SbDKrHCrgr96X" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "2L4A9ufMmhCwc4VcC1guL5vW5B3CzjyhBuBAneU2GpedNMPXTDALY4vFATgxwZuxSW7zCUgjcuRvQaiYPfUUqiK" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "33McXDGhwLbvF9fxSfEzR7dQZeapRD3hUdnscL4t7XD5TKS5SGgJBKExJ7LFAxrVpsHoxnxBLoTqJwj4JfLMKkkn" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5KQhdTnMAwDDFs23t2NWvSKfBZuf3Q4zm4R687CurZKWVXPuwkmX7ipt63wahDRxcqRreeaJ2YYtJ6updHjj2ttq" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5oK9gF3gxUmpUyQNLMfCg71a7E8X8Rx3Xr7J7k6LupsBK44XraFe48osC3sJG2XCYgTqaxCUZA4MGUN97XEmszPp" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "4XwE8LmHJaKN1W1DycyFKQHHn8qapekjHaK5vReqdPDKzGpimns2xM9CsxutKY4E9ewZQvc9vRJTkeWp4LQWcG1F" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "rgUY7fCjwaGHD9f8UyAXJ4yJgNHgDnmyC7EWU7SDDuGo3KJPasZtMJheLbNXNGVygAmZL2fEpzJkAMhL4cJLwP3" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5LPjsubaXqAhrRoLF3s7XjZUmtTe38xFffVvar8YYATsMy6SVBfYssnTjBs8pQd5xh6krGzSmrppSmzC17GX4UZ" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "crGaYYkbCWAXEoVmtjzJXhYWifE68TkAxvZjNEUqA2AkWJiENcFbaSR5HetE3mHrKEkgJAxEgjAPT34UDKBhJni" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "2hZ6E58B3xgVK6AoVLbyqoYLGKYzDNUJMLBao9nhhypyxt7axM9UwRWVZ7QdV4W6mkXWCeAfMGTG9aXyvyTqXTH2" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "g3uJ37m5SfGXazaTG1XHBZRSShCoEJtbyGsCR519JithwsfEqbcvNDK5YeyVK4nVL17PVZvoHD7xevk7X7JvRU7" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "4FSc4RRBBcbsu6wmLLJocciKADFW7NfbRi29aJ4fnJeocRzqiSbGzBztb1gjB5JMRuZtqvWWViM4oreYdTzW4zue" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5RaiJk4Mi1SNbEQFDQqibKZVpKxLt9CE9F5GaAAyLyDjLS8kQtK9nNTGdaHcJCVZFkBrAnRec1YKaC2kmUCzQcc6" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "4JvQ3RV68fskV9ZiXRjVqDb3vyjyiwjwjywYYuKbY66v2dekU7NdbwR8ZwjecHVHRaKNNzkAvT4UzVNAwPPBVHMS" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3SxDqNZw8dMZzB8tCRSFYjxFcAEmbJ5VFws8JnN1E4PNbiETKjTBbe3iKPN3EneJDpSYvemJvz9Ehp419YkJSDJx" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5nfU5c9Te7wVsukb1aWyq5ZNTqqjfnAaa4QYPwcvEcsf8LKri9DgiChvcJjNSvttjr5LcENb2TBvHVBjPcqjcQMh" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "4b6mMQwDJCw433Cw9JQ3dPBu8gPXHCr1zoVe4GGpUHMFQgyQUmrCGjE4vKr9GX3ScTr62v7bSqV9FoSRhAi19cKn" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "63T1U8hdY474uvrMV7AyCjH8iu73ecaupDuXipmuoXgAs2BaR5Wc5JznuMGCYJSSzhXfCwCZGctSfqLqRBBUuTBf" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5PKa8ivDGwxUQNt3tzGqYNfBH5nv6nVKCWpM8Xz5ux8N3jfrSfiCjqxam1wNWXHqEKhW5wDPh3yp2tqGh9PeiC5S" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3BFT4dya32fQFN1QsPagUPUVDKXFCXkhHbuzMEvMyz6J9m5CpQV7mDoFurUD47NbxqfNQxU7J5GaMZe2PzfREfCm" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "Zh61npxEFUczgipGC9sQViGhqj2hah1rozGyGUWNxsg5ADTMJKaKyKcmQbnPJFfiBf5VJcPsgerUhNfwJKEDNRZ" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5HH3tZLopGgABacuzkTv8bf5qCaZdX73zqbPwHmaAk4uarnoU2c3NXpjCn9MKBNYt3GWyGVnTSVSFBQW5K7JJJnx" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "n6LvprxWRjsdaiJ15gCz9nejyouqK9CXcuEZc5YPQnChWpnR3jvaeeo23WBVj13hNH3nzv665KJR52B7wA37HrY" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "BWHLdy5XVZ3ZbAFFj41BPHGeErWdLX9Ajw91AEo9GcuhkePgtCBPg48nxLoBTaCEjhgnFePeX8qLtiL1jHKecHD" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "2tctTRyYsJcoxNaVCRn22JJxPZEPKMPY9nT5XuBkMr3MQ3rKgGXrtfno9eiascgF6SjE2k1dCzmNq28gazhRrse7" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "23n2mMNLaRQ4Y8YX9m9nViLPXG1pWsFSAkVwf4WKnAG37TuaJEAaLWwWUcwo8LY77RRhY5scGKL8cGizxpCq2kqB" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "qeGvAQN6MPn41uCKpLNzaw7Mqw1VEYUJfW5Mf5BaEwS6fk5WEtYYkswYoR9EKapruRVLApW7ko3EnjC6XEWSTcZ" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "234krJcAkmM6V33CJiBMVwZdWNWMNT3PpsfnZT8L99yPDtL9Gk3n3SaN71rDsQs9wGCHfKAJZMVxrJvHtojsJzWt" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3dGxB78sVYj8YUUvGD8s4KXVEu5Cc94sepDbqCio9MjGaqfPMhz6muR71WEWuL9xEcV3VrcmKXUHU883BGbDfqDg" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5MzRRvf7CSrBpYJoKnoe2U3qpj3iceiJZwtp3cipxWtqdkakCyA9YffygufiT6tcD5oHrJNrmqU4DJKjNa7p5G3Z" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5yBkU7qNUDUMXqZbUbXPCYYKTtMeHMekuznx9XXWuioAs4QfzMXzwnXP8t7BVd7iMJmDazo86GFqMpj33um1KNG6" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "2nhKKA3rrQEu6FTpQ3SJwJuwBUYQY9Whbg1QqUwhBAURcs3UsfbjUuFVTZdNcCvvLFz8Z783F3jnjSY2hJJTvaFy" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "31RZmSH8y7WaKG8CZBoatKm2CuWtKkYaspnejRV2rrL6F3JfiaH3oLsnknrD3jzgtaSfDVtgpVRTaa8sHr7X3PSm" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "4yiKrYVff43bPismeqR1K5UaWNnyi5a973VxUCoYCe8xogs74eocgqxHYfYDD2dmRjyjGzpzQ2q9aXcSDraYNvAP" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3uEGPvqhMwh9u4Dg3nbqtGAHGALrh5GX5ctvLS1Tj5srNNY92e9n5qpwkgCpqJ3kgXgugzRLx1JrPxxaKRXWDhXy" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "2xvry7WtUQbsaPnFVmvdTVSE9o8ZFtD2WquT2m8zM6MUWx3MgioRxrG7VPJ5BWeWJy6zMdyjRXB47xUPSALrnEvk" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "2oNqbjtjhVX183xemr1WcWMUJQ5Xr2gL5xzB5oYZ99mEwvfBDLgHLL2LEEFEj5XkYMh3h9aPcf2cubqv5bzciNj3" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "bXjqRN8wvBotSfLQc2Y3TVhMnAT1qSxjKtCVyTDSYzyHbtmZYMxvSrWn3Lik7oo1wZseArNaTpuucRfKtUC9DF8" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5VBquJ24Yu8UjcVWVHhNeHE7NKTYZdvKjSkWDs8xcbm2yKVsXATyjoYd9AEWggatB8Pv6bB5Zoq51UyzLFFhCQjn" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "22Pa9YQuFF21yEb3NvXzvbxAtu6c6MAAgUNnMS9VFQKBJpsDSwGhvDXrX8y26yMQosctZk1c6BZh6N1tAfTez3Ch" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "4HNpF1jhNPQqZaFtSh97b479LaaaHBcikLhJj574Q2ip5mCppTmogY3UnqPcqFcRQjgzxuWob1kXq7qKknoqteXJ" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "627uNFuZ1QaUFF1J7wQLMbhbztnkTQXjsbTSbornSCN3w9XMbBU39sRYDm3zncYCYNeC2NHGSgC831S2S2Rqk5Hf" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "63awhjyALPuzV8UyzMehs27ZMQrr6emjzQ3zFQkdby5TSB9ZkBrhGnkCTyHm4dcxJRPCt32ct7bK4PfLq7wWLJVB" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3u6prTnXA7jPGcX5XPWTbqQ44RcrV5iUMf478Qv5A4MuA7xmj8V2j8PCKfuw3GLz5K12DGQVYV9qi9bxwoJVDLwC" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3oUrVJnfS4TTsBdRH2QF5AcrV6ZMPT34nMHaBiHBcF7RQTrKSqFS2cXtFAPktGpg9CGT6FNr8kuucd8kHWhGsQx6" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "2ZzNYciQ2Gfpg54nE2NMxvBAKLboLSq34AWKnbPhDCVkM1nE8jt77uBZ927srFWWhNcDjVw3W2AGYvRuWwV4jm51" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "2gsz4G3toLvip7C8iYycMKdoTrV4cqF4Cd2xTmaLUhCQeSVT58tyL1fdvoXVvxW9YmeAKnUdJiUp7azVGchQ8DuH" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5MNy3k5uTV97PUTPE4gjKUaNxBXaU4c6AQFszqDTWZ4Zf6ahU63sfiy7D65fBsuu4BzKTd318Ne9bz67Z1hkVBsR" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "4a71cEiJikTfv8nEXNxN9QdUjFT63fgRVELfcXED5tJGKJsuEQwjwPS9NQQqRzzTKL4jhs3ioyADKa18LyTxMRqE" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5a1VCq32gUcR79SN92qahj6yinnSwoyxhmDngSLdmUkZQmcKBjHsAh2eAiGoRm4cXx61tDqg5GSATD7UofnCgRi8" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "2vUYbcLkvJkMT7SZrm49VoUVSYbGXDdLLZLPmrCjnMa8gcEtrqD7LG6EbBsWZ2iBm84EU5xi5boDjX8rnr2TTrZn" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3EJAuaLwokvMHgmZuMsH6tcbvPpfySJ7pM1PsprkyY9GfemyyYojRa9zmBFQXwPGsB1K3EnQFAR11b1c7ZsubLyS" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5nh6gTYEfDA4ZzHzoqxKWrcv7VBJ8mjdrkmFnGNaAVyEJ8FYqRUx5WhX9V39Rp4sS8CmrWhkiLh11yQzy51p7HUg" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "zaBifCyywS6qV3dGznJ95c5g4D2hoxbWUpRbDUXGYkdkBXuikFSSC1ECZCBVeq7YhFdgmtgnvCgWxnynZkRMWwB" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5j1wxMC6aGgCFSz1QV9tisiT82utubk4h9M8oEYkXawM6vEqRXpLkFcfuhKN1kZKDvW8wBRhoo7YisPmEvVGKu2m" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "24Eq4p9WhSgvDUwxwjCuqevZsUQzqbjCkijBiecpWVbdUUBqb6cUKCt2JXnEAfSPJzQjJBme7Fi3pMEaUL49PHM9" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3zuKL9AwoHTiUW4nr5J48P1zVhBMMbeX8isMjqgtha9gTF1famJ3DvfhbegaWWNDwhwKtpEZvew3JDnxqDCP5zAi" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5y2aGb8swMupCTZH5TUH2hqkNc7eWrkbFKyfgpEJgNwQqty8QBDjpv7gLmPWHHc3v6vWYQSQ4TPFfpPyFuDmPhCt" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5qHigydKMau4QJFVLjPeYewuKy4EittbDC4LcDrXN2dMhkhmGDJrnkCKwJGRbeC777KetFGWURdrSCrrTDWveWUc" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "33xo4QiwpX1W4VyPQ5yCv77KCpnn5W4aSLbTztAUoVf9rWe5sknUwp8bCfLLt56r934QwZCrcBv7TEwexTpo2EVH" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5CCB1n5RXirddtD2iqiKv5jMCPD4w6ZhDapga4iA6pvHNDN3u3ShL1R2xGmfBUpfitMdZnRV5MVt2a8M4cH2uFnU" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "4vrhLD7TjZM9FYg9rtrX6cKJAR5s6iDwVVAvsnmNrJCstudDAPf8vPzuAZvJxPmqQ4iB5kVC6bZ2kP9A5CgsvLU4" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "rcCfNFYoAPGLsn4dsPPAW6i7hzFbKzT3bUij4mjrFLTWBQyWVeoH9Mxp9whsF9g3dv4LQieeSjx31jWnEa4vJZt" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "2Mh1M1HQpe1b9RgWthrTHVDN9vda8qW46DSyeykeyG8iabDfi5MWbaRCWF6diD14qj9qad7NmNQnSb2GKroKoGEp" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "f8f9kWc6jxpq7xTtQwUoBX6mn3nqymFyBaCGfa2p3bNmEs6jPdWnNRMDcSamgo4KoS2Q9GsRPGTvbn2CHajMdgf" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "54oXBmmS6egddTmSCJrVnAKfiVEUGDJSHdQDApoNYzrvzR1U92ESC6HxDo7c8xBCBpu5DCdmetNaZtFCRVKXXZJV" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "cjkA1SAGWDTeQH43LqQaQMpe3chjvGuQjChbCCupm4iJGbFxgyPz3D4BjK3bGEJ2TwNiudQYZv9eGYYX5pEBn8k" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "2TsAGP21XZ53KLHkwzcwK2xyhEcoTzPpkBpTCfiU6RKdAGDhrBnFXKA8xmFFVzAzjj5LWvxPC2MP3BU2znCLC5dC" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "2NZkWZ8hT4iHcC8LFCh4NU29AP1PuFUYMWG7oX8QV1WQYFcSzV1KjpxfotMPDj14o3dQPTLCV1vqLQLKcNVHTyiJ" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "21cDt3yMP1vVNRRT89fnYW6j2zZ2c17FVxakiWFe4UFjUoJsayembAFVjbYHhAHB29pywq7A2o4EH88GDafwo7h9" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "4uR2TNHpyJ4qrF7C9GRAh5CfsgfjntpW5XzcnVWDNkbU84NLmHWAZhQcdrUcpKSvziKvNWfK4nsmq4ras7v4kJ4c" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "cjkSvAJyWarWfi3y4Fv5XkugjGcnYkTryW8MoQVBKwRmYiG2xgQqwt3QTvoPFpDEz1ceWjBoSaHWADvj7w28UTK" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "cyp6EUdy3mrC7rBvhUZKYDwzh9TNgg1hADhSe2v7a7Ha5BZ2JxiHHwCTFf5LmwLUW39fNA3BcFU8Xe5zYnMpkex" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "NcXCQ4XkizooMW6mwiRNVndTQbdHL6vPMNYjVjR1B2qfxQD39eFpqrmscKBWqij1wntTi9HUJdvhaNzK3wx7pwq" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "hxkYm7ZdX8xxaCBnB2jenmTA7MKm2apRHkgU5AX4BhCj3q8g3zwzZhf2ct5h6DtQmWmfA4ZESxbTy9rs58BjL3F" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3V4qRoMUTv8v8LDgsLuikn1vBDrJ6kh8gSDf4eJG5FMkHMSbR1tNkAbDkGYiDRuqa6BqK6ppnyEkYXW7Q34zjo51" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "nWPkucpSv8bEQbQCnJ5qy3fRHJ42LmaoqAF1kA4HguGFcnKzG5X4pruFMAGKPndFDmWySuX1zmu1ZoEs9C8NWFC" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "2mqZDnRXLfd4oPQfGdpd2AssDYX1vUoCGzxQPp4q5WLW6rmaQCfRn39KzFYZkYDfDSF6hCrFZqCraZpUUL8sCtYy" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "fNK4RqzLb7s4xPcxJCixFcNbjPFU7iSwCJM4wcaFnB4UpBMEeKLx3SEQZDd4Lyag2QfwvZMootWfhau5VPpPfGF" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3ZnVAe3swEHF5VGJSJHWzdD3jMqGceepMiQ8B694S1FBRnyQteMfoh2xsnQWNWxsfvyQE5exxXSCxSZscZHgkcEP" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "5WKMm5hvk6fSQinVq1z61coN1G2Y2fbuzKsmj9tJvfjcjLYPdnXJyZ6hCKxUQf3pYfMRB4SaWwtB7xi68JaM3Fge" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3mYXQujZrvbkcPErxHaFZQHYKEw7zX4kMtDkcTkhqKF5seZBnSNeSDvPYaBQrUucW9smq2VkBE7D7QsfTmgz1eYZ" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "uwUqqWhfRoWdsc4qbRtbSQuYEmcTigHKXfnM136u2whZMq9w9yeiJyxD9Kx5QiF5yEcKf7o5d6jwj5G52y5ihey" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3VeQA7eTZHakSBLrAAL6E7CSfNCjdMbm84CccV765VTrcNaurh1GWC2zSKhnqtQ6fMy9eTLcWBMdV6iD4kbwzEd4" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "2yXq2JgJ1FWZADRTkNubns5skENYEjEX2XA27yqviDWFU2kSSEA8P4ZTkLXtYvGiyUsjkL7rDrMcN6EQXWn9ZZyq" seed = 57005 notes = [10_000_000_000] diff --git a/rusk/tests/config/contract_deployment.toml b/rusk/tests/config/contract_deployment.toml index a6502ad7ac..1d61cec0e9 100644 --- a/rusk/tests/config/contract_deployment.toml +++ b/rusk/tests/config/contract_deployment.toml @@ -1,4 +1,4 @@ -[[balance]] +[[phoenix_balance]] address = "ivmscertKgRyX8wNMJJsQcSVEyPsfSMUQXSAgeAPQXsndqFq9Pmknzhm61QvcEEdxPaGgxDS4RHpb6KKccrnSKN" seed = 57005 notes = [10_000_000_000] diff --git a/rusk/tests/config/gas-behavior.toml b/rusk/tests/config/gas-behavior.toml index 984acdf5b4..2674bfa893 100644 --- a/rusk/tests/config/gas-behavior.toml +++ b/rusk/tests/config/gas-behavior.toml @@ -1,9 +1,9 @@ -[[balance]] +[[phoenix_balance]] address = "ivmscertKgRyX8wNMJJsQcSVEyPsfSMUQXSAgeAPQXsndqFq9Pmknzhm61QvcEEdxPaGgxDS4RHpb6KKccrnSKN" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3MoVQ6VfGNu8fJ5GeHPRDVUfxcsDEmGXpWhvKhXY7F2dKCp7QWRw8RqPcbuJGdRqeTtxpuiwETnGAJLnhT4Kq4e8" seed = 57005 notes = [10_000_000_000] diff --git a/rusk/tests/config/multi_transfer.toml b/rusk/tests/config/multi_transfer.toml index 5ab88e2533..f3905c128f 100644 --- a/rusk/tests/config/multi_transfer.toml +++ b/rusk/tests/config/multi_transfer.toml @@ -1,14 +1,14 @@ -[[balance]] +[[phoenix_balance]] address = "ivmscertKgRyX8wNMJJsQcSVEyPsfSMUQXSAgeAPQXsndqFq9Pmknzhm61QvcEEdxPaGgxDS4RHpb6KKccrnSKN" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3MoVQ6VfGNu8fJ5GeHPRDVUfxcsDEmGXpWhvKhXY7F2dKCp7QWRw8RqPcbuJGdRqeTtxpuiwETnGAJLnhT4Kq4e8" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "4RyaodGmN8MyUDmpRrtRxJJhrVW2HsY2ycRUnRUXR97JCN1GHraQT9Ygb8yYo7oKzyZg2EXXCGkHBwoeNb96BKtQ" seed = 57005 notes = [10_000_000_000] diff --git a/rusk/tests/config/rusk-state.toml b/rusk/tests/config/rusk-state.toml index 46ea313173..dedee2cebc 100644 --- a/rusk/tests/config/rusk-state.toml +++ b/rusk/tests/config/rusk-state.toml @@ -1,3 +1,3 @@ -[[balance]] +[[phoenix_balance]] address = "29ENJqLtHJRSZdghZxiGuzQTe3F4t1bv35zM7mEMS142e5QdxkknokMALrBEFUnyav9NfeXLNvfjx4sfTtJN9WCB" notes = [10_000_000_000] diff --git a/rusk/tests/config/slash.toml b/rusk/tests/config/slash.toml index b55927269c..a25023954f 100644 --- a/rusk/tests/config/slash.toml +++ b/rusk/tests/config/slash.toml @@ -1,4 +1,4 @@ -[[balance]] +[[phoenix_balance]] address = "ivmscertKgRyX8wNMJJsQcSVEyPsfSMUQXSAgeAPQXsndqFq9Pmknzhm61QvcEEdxPaGgxDS4RHpb6KKccrnSKN" seed = 57005 notes = [ diff --git a/rusk/tests/config/stake.toml b/rusk/tests/config/stake.toml index 91771b1607..9aca8ee612 100644 --- a/rusk/tests/config/stake.toml +++ b/rusk/tests/config/stake.toml @@ -1,4 +1,4 @@ -[[balance]] +[[phoenix_balance]] address = "ivmscertKgRyX8wNMJJsQcSVEyPsfSMUQXSAgeAPQXsndqFq9Pmknzhm61QvcEEdxPaGgxDS4RHpb6KKccrnSKN" seed = 57005 notes = [ diff --git a/rusk/tests/config/transfer.toml b/rusk/tests/config/transfer.toml index 42d2e378c8..8bbbc89344 100644 --- a/rusk/tests/config/transfer.toml +++ b/rusk/tests/config/transfer.toml @@ -1,4 +1,4 @@ -[[balance]] +[[phoenix_balance]] address = "ivmscertKgRyX8wNMJJsQcSVEyPsfSMUQXSAgeAPQXsndqFq9Pmknzhm61QvcEEdxPaGgxDS4RHpb6KKccrnSKN" seed = 57005 notes = [ @@ -13,3 +13,7 @@ notes = [ 10_000_000_000, 10_000_000_000, ] + +[[moonlight_account]] +address = "qe1FbZxf6YaCAeFNSvL1G82cBhG4Q4gBf4vKYo527Vws3b23jdbBuzKSFsdUHnZeBgsTnyNJLkApEpRyJw87sdzR9g9iESJrG5ZgpCs9jq88m6d4qMY5txGpaXskRQmkzE3" +balance = 10_000_000_000 diff --git a/rusk/tests/config/unspendable.toml b/rusk/tests/config/unspendable.toml index 5ab88e2533..f3905c128f 100644 --- a/rusk/tests/config/unspendable.toml +++ b/rusk/tests/config/unspendable.toml @@ -1,14 +1,14 @@ -[[balance]] +[[phoenix_balance]] address = "ivmscertKgRyX8wNMJJsQcSVEyPsfSMUQXSAgeAPQXsndqFq9Pmknzhm61QvcEEdxPaGgxDS4RHpb6KKccrnSKN" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "3MoVQ6VfGNu8fJ5GeHPRDVUfxcsDEmGXpWhvKhXY7F2dKCp7QWRw8RqPcbuJGdRqeTtxpuiwETnGAJLnhT4Kq4e8" seed = 57005 notes = [10_000_000_000] -[[balance]] +[[phoenix_balance]] address = "4RyaodGmN8MyUDmpRrtRxJJhrVW2HsY2ycRUnRUXR97JCN1GHraQT9Ygb8yYo7oKzyZg2EXXCGkHBwoeNb96BKtQ" seed = 57005 notes = [10_000_000_000] diff --git a/rusk/tests/rusk-state.rs b/rusk/tests/rusk-state.rs index c5745cc5ce..9c2ca83884 100644 --- a/rusk/tests/rusk-state.rs +++ b/rusk/tests/rusk-state.rs @@ -204,7 +204,7 @@ async fn generate_phoenix_txs() -> Result<(), Box> { let task = tokio::task::spawn_blocking(move || { wallet - .transfer( + .phoenix_transfer( &mut rng, sender_index, &receiver, diff --git a/rusk/tests/services/contract_deployment.rs b/rusk/tests/services/contract_deployment.rs index 6f2bd20ae0..e0d3c8db3f 100644 --- a/rusk/tests/services/contract_deployment.rs +++ b/rusk/tests/services/contract_deployment.rs @@ -113,7 +113,7 @@ fn make_and_execute_transaction_deploy( let hash = bytecode_hash(bytecode.as_ref()).to_bytes(); let tx = wallet - .execute( + .phoenix_execute( &mut rng, ContractExec::Deploy(ContractDeploy { bytecode: Bytecode { diff --git a/rusk/tests/services/gas_behavior.rs b/rusk/tests/services/gas_behavior.rs index 6cecb1a971..0d01ddc8a8 100644 --- a/rusk/tests/services/gas_behavior.rs +++ b/rusk/tests/services/gas_behavior.rs @@ -73,7 +73,7 @@ fn make_transactions( fn_args: Vec::new(), }; let tx_0 = wallet - .execute( + .phoenix_execute( &mut rng, ContractExec::Call(contract_call.clone()), SENDER_INDEX_0, @@ -87,9 +87,9 @@ fn make_transactions( // contract, querying for the root of the tree. This will be tested for // gas cost. let tx_1 = wallet - .execute( + .phoenix_execute( &mut rng, - ContractExec::Call(contract_call), + contract_call, SENDER_INDEX_1, GAS_LIMIT_1, 1, diff --git a/rusk/tests/services/multi_transfer.rs b/rusk/tests/services/multi_transfer.rs index cc0c722bd1..4619bcf650 100644 --- a/rusk/tests/services/multi_transfer.rs +++ b/rusk/tests/services/multi_transfer.rs @@ -88,7 +88,7 @@ fn wallet_transfer( for i in 0..3 { let tx = wallet - .transfer(&mut rng, i, &receiver, amount, GAS_LIMIT, 1) + .phoenix_transfer(&mut rng, i, &receiver, amount, GAS_LIMIT, 1) .expect("Failed to transfer"); txs.push(tx); } @@ -122,15 +122,17 @@ fn wallet_transfer( .get_balance(0) .expect("Failed to get the balance") .value; - let fee_0 = txs[0].payload().fee; - let fee_0 = fee_0.gas_limit * fee_0.gas_price; + let gas_limit_0 = txs[0].gas_limit(); + let gas_price_0 = txs[0].gas_price(); + let fee_0 = gas_limit_0 * gas_price_0; let final_balance_1 = wallet .get_balance(1) .expect("Failed to get the balance") .value; - let fee_1 = txs[1].payload().fee; - let fee_1 = fee_1.gas_limit * fee_1.gas_price; + let gas_limit_1 = txs[1].gas_limit(); + let gas_price_1 = txs[1].gas_price(); + let fee_1 = gas_limit_1 * gas_price_1; assert!( initial_balance_0 - amount - fee_0 <= final_balance_0, diff --git a/rusk/tests/services/stake.rs b/rusk/tests/services/stake.rs index 09a4e5fb0f..03acf61c50 100644 --- a/rusk/tests/services/stake.rs +++ b/rusk/tests/services/stake.rs @@ -8,8 +8,7 @@ use std::path::Path; use std::sync::{Arc, RwLock}; use execution_core::{ - transfer::{ContractCall, ContractExec}, - StakePublicKey, + stake::StakeAmount, transfer::ContractCall, BlsPublicKey, }; use rand::prelude::*; use rand::rngs::StdRng; @@ -72,7 +71,7 @@ fn wallet_stake( ); let tx = wallet - .stake(&mut rng, 0, 2, value, GAS_LIMIT, 1) + .phoenix_stake(&mut rng, 0, 2, value, GAS_LIMIT, 1) .expect("Failed to create a stake transaction"); let executed_txs = generator_procedure( rusk, @@ -92,7 +91,7 @@ fn wallet_stake( } let stake = wallet.get_stake(2).expect("stake to be found"); - let stake_value = stake.amount.expect("stake should have an amount").0; + let stake_value = stake.amount.expect("stake should have an amount").value; assert_eq!(stake_value, value); @@ -103,7 +102,7 @@ fn wallet_stake( .expect("stake amount to be found"); let tx = wallet - .unstake(&mut rng, 0, 0, GAS_LIMIT, 1) + .phoenix_unstake(&mut rng, 0, 0, GAS_LIMIT, 1) .expect("Failed to unstake"); let spent_txs = generator_procedure( rusk, @@ -121,7 +120,7 @@ fn wallet_stake( assert_eq!(stake.amount, None); let tx = wallet - .withdraw(&mut rng, 0, 1, GAS_LIMIT, 1) + .phoenix_withdraw(&mut rng, 0, 1, GAS_LIMIT, 1) .expect("failed to withdraw reward"); generator_procedure( rusk, @@ -189,8 +188,8 @@ fn wallet_reward( ) { let mut rng = StdRng::seed_from_u64(0xdead); - let stake_sk = wallet.store().retrieve_stake_sk(2).unwrap(); - let stake_pk = StakePublicKey::from(&stake_sk); + let stake_sk = wallet.store().fetch_account_secret_key(2).unwrap(); + let stake_pk = BlsPublicKey::from(&stake_sk); let reward_calldata = (stake_pk, 6u32); let stake = wallet.get_stake(2).expect("stake to be found"); @@ -203,14 +202,7 @@ fn wallet_reward( ) .expect("calldata should serialize"); let tx = wallet - .execute( - &mut rng, - ContractExec::Call(contract_call), - 0, - GAS_LIMIT, - 1, - 0, - ) + .phoenix_execute(&mut rng, contract_call, 0, GAS_LIMIT, 1, 0) .expect("Failed to create a reward transaction"); let executed_txs = generator_procedure( rusk, @@ -296,10 +288,16 @@ pub async fn slash() -> Result<()> { let contract_balance = rusk .contract_balance(STAKE_CONTRACT) .expect("balance to exists"); - let to_slash = wallet.stake_public_key(0).unwrap(); + let to_slash = wallet.account_public_key(0).unwrap(); let stake = wallet.get_stake(0).unwrap(); assert_eq!(stake.reward, dusk(3.0)); - assert_eq!(stake.amount, Some((dusk(20.0), 0))); + assert_eq!( + stake.amount, + Some(StakeAmount { + value: dusk(20.0), + eligibility: 0 + }) + ); generator_procedure( &rusk, @@ -324,9 +322,15 @@ pub async fn slash() -> Result<()> { let (_, prev) = last_changes.first().expect("Something changed").clone(); let prev = prev.expect("to have something"); assert_eq!(prev.reward, dusk(3.0)); - assert_eq!(prev.amount, Some((dusk(20.0), 0))); + assert_eq!( + prev.amount, + Some(StakeAmount { + value: dusk(20.0), + eligibility: 0 + }) + ); - let (prev_stake, _) = prev.amount.unwrap(); + let prev_stake = prev.amount.unwrap().value; let slashed_amount = prev_stake / 10; let after_slash = wallet.get_stake(0).unwrap(); @@ -334,9 +338,18 @@ pub async fn slash() -> Result<()> { assert_eq!(after_slash.reward, prev.reward + slashed_amount); assert_eq!( after_slash.amount, - Some((prev_stake - slashed_amount, 4320)) + Some(StakeAmount { + value: prev_stake - slashed_amount, + eligibility: 4320 + }) + ); + assert_eq!( + after_slash.amount, + Some(StakeAmount { + value: dusk(18.0), + eligibility: 4320 + }) ); - assert_eq!(after_slash.amount, Some((dusk(18.0), 4320))); let new_balance = rusk.contract_balance(STAKE_CONTRACT).unwrap(); assert_eq!(new_balance, contract_balance - slashed_amount); let contract_balance = new_balance; @@ -355,9 +368,15 @@ pub async fn slash() -> Result<()> { let (_, prev) = last_changes.first().expect("Something changed").clone(); let prev = prev.expect("to have something"); assert_eq!(prev.reward, dusk(5.0)); - assert_eq!(prev.amount, Some((dusk(18.0), 4320))); + assert_eq!( + prev.amount, + Some(StakeAmount { + value: dusk(18.0), + eligibility: 4320 + }) + ); - let (prev_stake, _) = prev.amount.unwrap(); + let prev_stake = prev.amount.unwrap().value; // 20% slash let slashed_amount = prev_stake / 10 * 2; @@ -366,9 +385,18 @@ pub async fn slash() -> Result<()> { assert_eq!(after_slash.reward, prev.reward + slashed_amount); assert_eq!( after_slash.amount, - Some((prev_stake - slashed_amount, 6480)) + Some(StakeAmount { + value: prev_stake - slashed_amount, + eligibility: 6480 + }) + ); + assert_eq!( + after_slash.amount, + Some(StakeAmount { + value: dusk(14.4), + eligibility: 6480 + }) ); - assert_eq!(after_slash.amount, Some((dusk(14.4), 6480))); let new_balance = rusk.contract_balance(STAKE_CONTRACT).unwrap(); assert_eq!(new_balance, contract_balance - slashed_amount); @@ -388,14 +416,26 @@ pub async fn slash() -> Result<()> { let (_, prev) = last_changes.first().expect("Something changed").clone(); let prev = prev.expect("to have something"); assert_eq!(prev.reward, dusk(8.6)); - assert_eq!(prev.amount, Some((dusk(14.4), 6480))); + assert_eq!( + prev.amount, + Some(StakeAmount { + value: dusk(14.4), + eligibility: 6480 + }) + ); - let (prev_stake, _) = prev.amount.unwrap(); + let prev_stake = prev.amount.unwrap().value; // 30% slash let slashed_amount = prev_stake / 10 * 3; let after_slash = wallet.get_stake(0).unwrap(); assert_eq!(after_slash.reward, dusk(12.92)); - assert_eq!(after_slash.amount, Some((dusk(10.08), 17280))); + assert_eq!( + after_slash.amount, + Some(StakeAmount { + value: dusk(10.08), + eligibility: 17280 + }) + ); let new_balance = rusk.contract_balance(STAKE_CONTRACT).unwrap(); assert_eq!(new_balance, contract_balance - slashed_amount); @@ -404,7 +444,7 @@ pub async fn slash() -> Result<()> { &[], 9001, BLOCK_GAS_LIMIT, - vec![wallet.stake_public_key(1).unwrap()], + vec![wallet.account_public_key(1).unwrap()], None, ) .expect_err("Slashing a public key that never staked must fail"); @@ -414,7 +454,13 @@ pub async fn slash() -> Result<()> { let (_, prev) = last_changes.first().expect("Something changed").clone(); let prev = prev.expect("to have something"); assert_eq!(prev.reward, dusk(8.6)); - assert_eq!(prev.amount, Some((dusk(14.4), 6480))); + assert_eq!( + prev.amount, + Some(StakeAmount { + value: dusk(14.4), + eligibility: 6480 + }) + ); generator_procedure(&rusk, &[], 9001, BLOCK_GAS_LIMIT, vec![], None) .expect("To work properly"); diff --git a/rusk/tests/services/transfer.rs b/rusk/tests/services/transfer.rs index fd03041cf8..51e1095ff0 100644 --- a/rusk/tests/services/transfer.rs +++ b/rusk/tests/services/transfer.rs @@ -71,7 +71,7 @@ fn wallet_transfer( // Execute a transfer let tx = wallet - .transfer(&mut rng, 0, &receiver_pk, amount, 1_000_000_000, 2) + .phoenix_transfer(&mut rng, 0, &receiver_pk, amount, 1_000_000_000, 2) .expect("Failed to transfer"); info!("Tx: {}", hex::encode(tx.to_var_bytes())); @@ -117,8 +117,7 @@ fn wallet_transfer( .get_balance(0) .expect("Failed to get the balance") .value; - let fee = tx.inner.inner.payload().fee; - let fee = gas_spent * fee.gas_price; + let fee = gas_spent * tx.inner.inner.gas_price(); assert_eq!( sender_initial_balance - amount - fee, diff --git a/rusk/tests/services/unspendable.rs b/rusk/tests/services/unspendable.rs index 2b4ddddd9e..af2c2d0c5b 100644 --- a/rusk/tests/services/unspendable.rs +++ b/rusk/tests/services/unspendable.rs @@ -85,7 +85,7 @@ fn make_transactions( fn_args: Vec::new(), }; let tx_0 = wallet - .execute( + .phoenix_execute( &mut rng, ContractExec::Call(contract_call.clone()), SENDER_INDEX_0, @@ -99,7 +99,7 @@ fn make_transactions( // contract, but with no enough gas to spend. Transaction should be // discarded let tx_1 = wallet - .execute( + .phoenix_execute( &mut rng, ContractExec::Call(contract_call.clone()), SENDER_INDEX_1, @@ -113,9 +113,9 @@ fn make_transactions( // transfer contract, querying for the root of the tree. This will be // tested for gas cost. let tx_2 = wallet - .execute( + .phoenix_execute( &mut rng, - ContractExec::Call(contract_call), + contract_call, SENDER_INDEX_2, GAS_LIMIT_2, 1,