diff --git a/contracts/transfer/src/state.rs b/contracts/transfer/src/state.rs index 6004f64b76..82b694518b 100644 --- a/contracts/transfer/src/state.rs +++ b/contracts/transfer/src/state.rs @@ -30,8 +30,10 @@ use execution_core::{ ConvertEvent, DepositEvent, MoonlightTransactionEvent, PhoenixTransactionEvent, ReceiveFromContract, Transaction, TransferToAccount, TransferToAccountEvent, TransferToContract, - TransferToContractEvent, WithdrawEvent, PANIC_NONCE_NOT_READY, - TRANSFER_CONTRACT, + TransferToContractEvent, WithdrawEvent, CONVERT_TOPIC, DEPOSIT_TOPIC, + MINT_TOPIC, MOONLIGHT_TOPIC, PANIC_NONCE_NOT_READY, PHOENIX_TOPIC, + TRANSFER_CONTRACT, TRANSFER_TO_ACCOUNT_TOPIC, + TRANSFER_TO_CONTRACT_TOPIC, WITHDRAW_TOPIC, }, BlsScalar, ContractError, ContractId, }; @@ -178,7 +180,7 @@ impl TransferState { self.mint_withdrawal("mint", &mint); - rusk_abi::emit("mint", WithdrawEvent::from(mint)); + rusk_abi::emit(MINT_TOPIC, WithdrawEvent::from(mint)); } /// Withdraw from a contract's balance to a Phoenix note or a Moonlight @@ -212,7 +214,7 @@ impl TransferState { self.mint_withdrawal("withdraw", &withdraw); - rusk_abi::emit("withdraw", WithdrawEvent::from(withdraw)); + rusk_abi::emit(WITHDRAW_TOPIC, WithdrawEvent::from(withdraw)); } /// Takes the deposit addressed to this contract, and immediately withdraws @@ -266,11 +268,11 @@ impl TransferState { // deposit as being taken. Interesting to note is that we don't // need to change the value held by the contract at all, since // it never changes. - self.mint_withdrawal("CONVERT", &convert); + self.mint_withdrawal("convert", &convert); deposit.set_taken(); rusk_abi::emit( - "convert", + CONVERT_TOPIC, ConvertEvent::from_withdraw_and_sender(sender, &convert), ); } @@ -322,7 +324,7 @@ impl TransferState { deposit.set_taken(); rusk_abi::emit( - "deposit", + DEPOSIT_TOPIC, DepositEvent { sender, value: deposit_value, @@ -354,31 +356,31 @@ impl TransferState { /// receiving contract fails, or if the sending contract doesn't have enough /// funds. pub fn transfer_to_contract(&mut self, transfer: TransferToContract) { - let from = rusk_abi::caller() + let sender_contract = rusk_abi::caller() .expect("A transfer to a contract must happen in the context of a transaction"); - if from == TRANSFER_CONTRACT { + if sender_contract == TRANSFER_CONTRACT { panic!("Cannot be called directly by the transfer contract"); } - let from_balance = self + let sender_balance = self .contract_balances - .get_mut(&from) + .get_mut(&sender_contract) .expect("Caller must have a balance"); - if *from_balance < transfer.value { + if *sender_balance < transfer.value { panic!("Caller must have enough balance"); } - *from_balance -= transfer.value; + *sender_balance -= transfer.value; - let to_balance = + let receiver_balance = self.contract_balances.entry(transfer.contract).or_insert(0); - *to_balance += transfer.value; + *receiver_balance += transfer.value; let receive = ReceiveFromContract { - contract: from, + contract: sender_contract, value: transfer.value, data: transfer.data, }; @@ -387,11 +389,11 @@ impl TransferState { .expect("Calling receiver should succeed"); rusk_abi::emit( - "transfer_to_contract", + TRANSFER_TO_CONTRACT_TOPIC, TransferToContractEvent { - sender: from, - value: transfer.value, + sender: sender_contract, receiver: transfer.contract, + value: transfer.value, }, ); } @@ -406,19 +408,19 @@ impl TransferState { /// is called by the transfer contract itself, or if the calling contract /// doesn't have enough funds. pub fn transfer_to_account(&mut self, transfer: TransferToAccount) { - let from = rusk_abi::caller() + let sender_contract = rusk_abi::caller() .expect("A transfer to an account must happen in the context of a transaction"); - if from == TRANSFER_CONTRACT { + if sender_contract == TRANSFER_CONTRACT { panic!("Cannot be called directly by the transfer contract"); } - let from_balance = self + let sender_balance = self .contract_balances - .get_mut(&from) + .get_mut(&sender_contract) .expect("Caller must have a balance"); - if *from_balance < transfer.value { + if *sender_balance < transfer.value { panic!("Caller must have enough balance"); } @@ -427,15 +429,15 @@ impl TransferState { .entry(transfer.account.to_raw_bytes()) .or_insert(EMPTY_ACCOUNT); - *from_balance -= transfer.value; + *sender_balance -= transfer.value; account.balance += transfer.value; rusk_abi::emit( - "transfer_to_account", + TRANSFER_TO_ACCOUNT_TOPIC, TransferToAccountEvent { - sender: from, - value: transfer.value, + sender: sender_contract, receiver: transfer.account, + value: transfer.value, }, ); } @@ -536,16 +538,16 @@ impl TransferState { panic!("The tx must target the correct chain"); } - // check the signature is valid and made by `from` + // check the signature is valid and made by `sender` if !rusk_abi::verify_bls( moonlight_tx.signature_message(), - *moonlight_tx.from_account(), + *moonlight_tx.sender(), *moonlight_tx.signature(), ) { panic!("Invalid signature!"); } - // check `from` has the funds necessary to suppress the total value + // check `sender` has the funds necessary to suppress the total value // available in this transaction, and that the `nonce` is higher than // the currently held number. If these conditions are violated we panic // since the transaction is invalid - either because the account doesn't @@ -559,7 +561,7 @@ impl TransferState { // TODO: this is expensive, maybe we should address the fact that // `AccountPublicKey` doesn't `impl Ord` so we can just use it // directly as a key in the `BTreeMap` - let from_bytes = moonlight_tx.from_account().to_raw_bytes(); + let from_bytes = moonlight_tx.sender().to_raw_bytes(); // the total value carried by a transaction is the sum of the value, the // deposit, and gas_limit * gas_price. @@ -592,9 +594,9 @@ impl TransferState { } // if there is a value carried by the transaction but no key specified - // in the `to` field, we just give the value back to `from`. + // in the `receiver` field, we just give the value back to `sender`. if moonlight_tx.value() > 0 { - let key = match moonlight_tx.to_account() { + let key = match moonlight_tx.receiver() { Some(to) => to.to_raw_bytes(), None => from_bytes, }; @@ -629,7 +631,7 @@ impl TransferState { // in phoenix, a refund note is with the unspent amount to the stealth // address in the `Fee` structure, while in moonlight we simply refund - // the `from` account for what it didn't spend + // the `sender` account for what it didn't spend // // any eventual deposit that failed to be "picked up" is refunded in the // same way - in phoenix the same note is reused, in moonlight the @@ -651,7 +653,7 @@ impl TransferState { } rusk_abi::emit( - "phoenix", + PHOENIX_TOPIC, PhoenixTransactionEvent { nullifiers: tx.nullifiers().to_vec(), notes, @@ -661,7 +663,7 @@ impl TransferState { ); } Transaction::Moonlight(tx) => { - let from_bytes = tx.from_account().to_raw_bytes(); + let from_bytes = tx.sender().to_raw_bytes(); let remaining_gas = tx.gas_limit() - gas_spent; let remaining = remaining_gas * tx.gas_price() @@ -674,10 +676,10 @@ impl TransferState { account.balance += remaining; rusk_abi::emit( - "moonlight", + MOONLIGHT_TOPIC, MoonlightTransactionEvent { - from: *tx.from_account(), - to: tx.to_account().copied(), + sender: *tx.sender(), + receiver: tx.receiver().copied(), value: tx.value(), memo, gas_spent, diff --git a/contracts/transfer/src/transitory.rs b/contracts/transfer/src/transitory.rs index d9404e9c90..259eb83165 100644 --- a/contracts/transfer/src/transitory.rs +++ b/contracts/transfer/src/transitory.rs @@ -92,7 +92,7 @@ pub fn put_transaction(tx: impl Into) { unsafe { let tx = tx.into(); - let sender = tx.from_account().copied(); + let sender = tx.moonlight_sender().copied(); let value = tx.deposit(); let mut deposit = Deposit::None; diff --git a/execution-core/src/transfer.rs b/execution-core/src/transfer.rs index 7b99bb227f..2119b249db 100644 --- a/execution-core/src/transfer.rs +++ b/execution-core/src/transfer.rs @@ -37,6 +37,23 @@ pub const TRANSFER_CONTRACT: ContractId = crate::reserved(0x1); /// Panic of "Nonce not ready to be used yet" pub const PANIC_NONCE_NOT_READY: &str = "Nonce not ready to be used yet"; +/// Topic for the moonlight transaction event. +pub const MOONLIGHT_TOPIC: &str = "moonlight"; +/// Topic for the phoenix transaction event. +pub const PHOENIX_TOPIC: &str = "phoenix"; +/// Topic for the transfer to contract event. +pub const TRANSFER_TO_CONTRACT_TOPIC: &str = "transfer_to_contract"; +/// Topic for the transfer to account event. +pub const TRANSFER_TO_ACCOUNT_TOPIC: &str = "transfer_to_account"; +/// Topic for the withdraw event. +pub const WITHDRAW_TOPIC: &str = "withdraw"; +/// Topic for the deposit event. +pub const DEPOSIT_TOPIC: &str = "deposit"; +/// Topic for the convert event. +pub const CONVERT_TOPIC: &str = "convert"; +/// Topic for the mint event. +pub const MINT_TOPIC: &str = "mint"; + use data::{ContractCall, ContractDeploy, TransactionData}; use moonlight::Transaction as MoonlightTransaction; use phoenix::{ @@ -108,8 +125,8 @@ impl Transaction { /// - the memo, if given, is too large #[allow(clippy::too_many_arguments)] pub fn moonlight( - from_sk: &AccountSecretKey, - to_account: Option, + sender_sk: &AccountSecretKey, + receiver: Option, value: u64, deposit: u64, gas_limit: u64, @@ -119,27 +136,27 @@ impl Transaction { data: Option>, ) -> Result { Ok(Self::Moonlight(MoonlightTransaction::new( - from_sk, to_account, value, deposit, gas_limit, gas_price, nonce, + sender_sk, receiver, value, deposit, gas_limit, gas_price, nonce, chain_id, data, )?)) } /// Return the sender of the account for Moonlight transactions. #[must_use] - pub fn from_account(&self) -> Option<&AccountPublicKey> { + pub fn moonlight_sender(&self) -> Option<&AccountPublicKey> { match self { Self::Phoenix(_) => None, - Self::Moonlight(tx) => Some(tx.from_account()), + Self::Moonlight(tx) => Some(tx.sender()), } } /// Return the receiver of the transaction for Moonlight transactions, if it /// exists. #[must_use] - pub fn to_account(&self) -> Option<&AccountPublicKey> { + pub fn moonlight_receiver(&self) -> Option<&AccountPublicKey> { match self { Self::Phoenix(_) => None, - Self::Moonlight(tx) => tx.to_account(), + Self::Moonlight(tx) => tx.receiver(), } } @@ -191,7 +208,7 @@ impl Transaction { /// Returns the sender data for Phoenix transactions. #[must_use] - pub fn sender(&self) -> Option<&Sender> { + pub fn phoenix_sender(&self) -> Option<&Sender> { match self { Self::Phoenix(tx) => Some(tx.sender()), Self::Moonlight(_) => None, @@ -378,19 +395,19 @@ pub struct TransferToAccount { #[archive_attr(derive(CheckBytes))] pub struct WithdrawEvent { /// The contract withdrawn from. - pub contract: ContractId, - /// The value withdrawn. - pub value: u64, + pub sender: ContractId, /// The receiver of the value. pub receiver: WithdrawReceiver, + /// The value withdrawn. + pub value: u64, } impl From for WithdrawEvent { fn from(w: Withdraw) -> Self { Self { - contract: w.contract, - value: w.value, + sender: w.contract, receiver: w.receiver, + value: w.value, } } } @@ -404,10 +421,10 @@ pub struct ConvertEvent { /// Moonlight to Phoenix it is possible, but the same cannot be done the /// other way round. pub sender: Option, - /// The value converted. - pub value: u64, /// The receiver of the value. pub receiver: WithdrawReceiver, + /// The value converted. + pub value: u64, } impl ConvertEvent { @@ -419,8 +436,8 @@ impl ConvertEvent { ) -> Self { Self { sender, - value: withdraw.value, receiver: withdraw.receiver, + value: withdraw.value, } } } @@ -433,10 +450,10 @@ pub struct DepositEvent { /// depositor is using Moonlight this will be available. If they're using /// Phoenix it will not. pub sender: Option, - /// The value deposited. - pub value: u64, /// The receiver of the value. pub receiver: ContractId, + /// The value deposited. + pub value: u64, } /// Event data emitted on a transfer from a contract to a contract. @@ -445,10 +462,10 @@ pub struct DepositEvent { pub struct TransferToContractEvent { /// The sender of the funds. pub sender: ContractId, - /// The value transferred. - pub value: u64, /// The receiver of the funds. pub receiver: ContractId, + /// The value transferred. + pub value: u64, } /// Event data emitted on a transfer from a contract to a Moonlight account. @@ -457,10 +474,10 @@ pub struct TransferToContractEvent { pub struct TransferToAccountEvent { /// The sender of the funds. pub sender: ContractId, - /// The value transferred. - pub value: u64, /// The receiver of the funds. pub receiver: AccountPublicKey, + /// The value transferred. + pub value: u64, } /// Event data emitted on a phoenix transaction's completion. @@ -482,9 +499,9 @@ pub struct PhoenixTransactionEvent { #[archive_attr(derive(CheckBytes))] pub struct MoonlightTransactionEvent { /// The account that initiated the transaction. - pub from: AccountPublicKey, + pub sender: AccountPublicKey, /// The receiver of the funds if any were transferred. - pub to: Option, + pub receiver: Option, /// Transfer amount pub value: u64, /// The memo included in the transaction. diff --git a/execution-core/src/transfer/moonlight.rs b/execution-core/src/transfer/moonlight.rs index 4668bcc50c..6fa9f85d63 100644 --- a/execution-core/src/transfer/moonlight.rs +++ b/execution-core/src/transfer/moonlight.rs @@ -51,8 +51,8 @@ impl Transaction { /// - the memo, if given, is too large #[allow(clippy::too_many_arguments)] pub fn new( - from_sk: &AccountSecretKey, - to_account: Option, + sender_sk: &AccountSecretKey, + receiver: Option, value: u64, deposit: u64, gas_limit: u64, @@ -65,8 +65,8 @@ impl Transaction { let payload = Payload { chain_id, - from_account: AccountPublicKey::from(from_sk), - to_account, + sender: AccountPublicKey::from(sender_sk), + receiver, value, deposit, gas_limit, @@ -75,7 +75,7 @@ impl Transaction { data, }; - Self::sign_payload(from_sk, payload) + Self::sign_payload(sender_sk, payload) } /// Create a transaction by signing a previously generated payload with a @@ -83,13 +83,13 @@ impl Transaction { /// /// Note that this transaction will be invalid if the secret-key used for /// signing doesn't form a valid key-pair with the public-key of the - /// `from_account`. + /// `sender`. /// /// # Errors /// The creation of a transaction is not possible and will error if: /// - the payload memo, if given, is too large pub fn sign_payload( - from_sk: &AccountSecretKey, + sender_sk: &AccountSecretKey, payload: Payload, ) -> Result { if let Some(TransactionData::Memo(memo)) = payload.data.as_ref() { @@ -99,7 +99,7 @@ impl Transaction { } let digest = payload.signature_message(); - let signature = from_sk.sign(&digest); + let signature = sender_sk.sign(&digest); Ok(Self { payload, signature }) } @@ -112,14 +112,14 @@ impl Transaction { /// Return the sender of the transaction. #[must_use] - pub fn from_account(&self) -> &AccountPublicKey { - &self.payload.from_account + pub fn sender(&self) -> &AccountPublicKey { + &self.payload.sender } /// Return the receiver of the transaction, if it exists. #[must_use] - pub fn to_account(&self) -> Option<&AccountPublicKey> { - self.payload.to_account.as_ref() + pub fn receiver(&self) -> Option<&AccountPublicKey> { + self.payload.receiver.as_ref() } /// Return the value transferred in the transaction. @@ -288,9 +288,9 @@ pub struct Payload { /// ID of the chain for this transaction to execute on. pub chain_id: u8, /// Key of the sender of this transaction. - pub from_account: AccountPublicKey, + pub sender: AccountPublicKey, /// Key of the receiver of the funds. - pub to_account: Option, + pub receiver: Option, /// Value to be transferred. pub value: u64, /// Deposit for a contract. @@ -315,10 +315,10 @@ impl Payload { pub fn to_var_bytes(&self) -> Vec { let mut bytes = Vec::from([self.chain_id]); - bytes.extend(self.from_account.to_bytes()); + bytes.extend(self.sender.to_bytes()); // serialize the recipient - match self.to_account { + match self.receiver { Some(to) => { bytes.push(1); bytes.extend(to.to_bytes()); @@ -364,10 +364,10 @@ impl Payload { let chain_id = u8::from_reader(&mut buf)?; - let from_account = AccountPublicKey::from_reader(&mut buf)?; + let sender = AccountPublicKey::from_reader(&mut buf)?; // deserialize recipient - let to_account = match u8::from_reader(&mut buf)? { + let receiver = match u8::from_reader(&mut buf)? { 0 => None, 1 => Some(AccountPublicKey::from_reader(&mut buf)?), _ => { @@ -407,8 +407,8 @@ impl Payload { Ok(Self { chain_id, - from_account, - to_account, + sender, + receiver, value, deposit, gas_limit, @@ -426,8 +426,8 @@ impl Payload { pub fn signature_message(&self) -> Vec { let mut bytes = Vec::from([self.chain_id]); - bytes.extend(self.from_account.to_bytes()); - if let Some(to) = &self.to_account { + bytes.extend(self.sender.to_bytes()); + if let Some(to) = &self.receiver { bytes.extend(to.to_bytes()); } bytes.extend(self.value.to_bytes()); diff --git a/execution-core/tests/serialization.rs b/execution-core/tests/serialization.rs index fa995417f8..00cc6f8b8f 100644 --- a/execution-core/tests/serialization.rs +++ b/execution-core/tests/serialization.rs @@ -134,9 +134,8 @@ fn new_moonlight_tx( rng: &mut R, data: Option, ) -> Transaction { - let from_sk = AccountSecretKey::random(rng); - let to_account = - Some(AccountPublicKey::from(&AccountSecretKey::random(rng))); + let sender_sk = AccountSecretKey::random(rng); + let receiver = Some(AccountPublicKey::from(&AccountSecretKey::random(rng))); let value: u64 = rng.gen(); let deposit: u64 = rng.gen(); @@ -145,7 +144,7 @@ fn new_moonlight_tx( let nonce: u64 = rng.gen(); Transaction::moonlight( - &from_sk, to_account, value, deposit, gas_limit, gas_price, nonce, + &sender_sk, receiver, value, deposit, gas_limit, gas_price, nonce, CHAIN_ID, data, ) .expect("transaction generation should work") diff --git a/node-data/src/events/transactions.rs b/node-data/src/events/transactions.rs index e713ff0069..a85f7c7b3d 100644 --- a/node-data/src/events/transactions.rs +++ b/node-data/src/events/transactions.rs @@ -84,12 +84,12 @@ impl Serialize for Transaction { ProtocolTransaction::Moonlight(m) => { state.serialize_field("type", "moonlight")?; - let from = m.from_account(); + let from = m.sender(); let from = bs58::encode(from.to_bytes()).into_string(); state.serialize_field("from", &from)?; let to = m - .to_account() + .receiver() .map(|to| bs58::encode(to.to_bytes()).into_string()); state.serialize_field("to", &to)?; @@ -120,7 +120,7 @@ impl Serialize for Transaction { bs58::encode(stealth_address.to_bytes()).into_string(), ); } - if let Some(sender) = tx.sender() { + if let Some(sender) = tx.moonlight_sender() { fee.insert("sender", hex::encode(sender.to_bytes())); } fee diff --git a/node-data/src/ledger/transaction.rs b/node-data/src/ledger/transaction.rs index 8d04b259c2..da2a73041f 100644 --- a/node-data/src/ledger/transaction.rs +++ b/node-data/src/ledger/transaction.rs @@ -92,7 +92,7 @@ impl Transaction { .map(|n| SpendingId::Nullifier(n.to_bytes())) .collect(), ProtocolTransaction::Moonlight(m) => { - vec![SpendingId::AccountNonce(*m.from_account(), m.nonce())] + vec![SpendingId::AccountNonce(*m.sender(), m.nonce())] } } } diff --git a/rusk-wallet/src/wallet.rs b/rusk-wallet/src/wallet.rs index 28cb7be548..d15935fdbe 100644 --- a/rusk-wallet/src/wallet.rs +++ b/rusk-wallet/src/wallet.rs @@ -442,15 +442,15 @@ impl Wallet { #[allow(clippy::too_many_arguments)] pub async fn moonlight_execute( &self, - from_addr: &Address, - to_account: Option, + sender_addr: &Address, + receiver: Option, transfer_value: Dusk, deposit: Dusk, gas: Gas, exec: Option>, ) -> Result { // make sure we own the sender address - if !from_addr.is_owned() { + if !sender_addr.is_owned() { return Err(Error::Unauthorized); } @@ -462,11 +462,11 @@ impl Wallet { let state = self.state()?; let deposit = *deposit; - let from_index = from_addr.index()?; - let mut from_sk = self.bls_secret_key(from_index); - let from_account = self.bls_public_key(from_index); + let sender_index = sender_addr.index()?; + let mut sender_sk = self.bls_secret_key(sender_index); + let sender = self.bls_public_key(sender_index); - let account = state.fetch_account(&from_account).await?; + let account = state.fetch_account(&sender).await?; // technically this check is not necessary, but it's nice to not spam // the network with transactions that are unspendable. @@ -475,8 +475,8 @@ impl Wallet { let chain_id = state.fetch_chain_id().await?; let tx = moonlight( - &from_sk, - to_account, + &sender_sk, + receiver, *transfer_value, deposit, gas.limit, @@ -486,7 +486,7 @@ impl Wallet { exec, )?; - from_sk.zeroize(); + sender_sk.zeroize(); state.prove_and_propagate(tx).await } @@ -638,17 +638,17 @@ impl Wallet { let sender = sender.index()?; - let mut from_sk = self.bls_secret_key(sender); + let mut sender_sk = self.bls_secret_key(sender); let apk = rcvr.apk()?; - let from_pk = self.bls_public_key(sender); + let sender_pk = self.bls_public_key(sender); let amt = *amt; let state = self.state()?; - let nonce = state.fetch_account(&from_pk).await?.nonce + 1; + let nonce = state.fetch_account(&sender_pk).await?.nonce + 1; let chain_id = state.fetch_chain_id().await?; let tx = moonlight( - &from_sk, + &sender_sk, Some(*apk), amt, 0, @@ -659,7 +659,7 @@ impl Wallet { memo, )?; - from_sk.zeroize(); + sender_sk.zeroize(); state.prove_and_propagate(tx).await } diff --git a/rusk/src/lib/node/vm.rs b/rusk/src/lib/node/vm.rs index 6dc6f80f50..7413885d1e 100644 --- a/rusk/src/lib/node/vm.rs +++ b/rusk/src/lib/node/vm.rs @@ -143,10 +143,9 @@ impl VMExecution for Rusk { } } ProtocolTransaction::Moonlight(tx) => { - let account_data = - self.account(tx.from_account()).map_err(|e| { - anyhow::anyhow!("Cannot check account: {e}") - })?; + let account_data = self.account(tx.sender()).map_err(|e| { + anyhow::anyhow!("Cannot check account: {e}") + })?; let max_value = tx.value() + tx.deposit() + tx.gas_limit() * tx.gas_price(); @@ -158,7 +157,7 @@ impl VMExecution for Rusk { if tx.nonce() <= account_data.nonce { let err = crate::Error::RepeatingNonce( - (*tx.from_account()).into(), + (*tx.sender()).into(), tx.nonce(), ); return Err(anyhow::anyhow!("Invalid tx: {err}")); diff --git a/rusk/src/lib/verifier.rs b/rusk/src/lib/verifier.rs index a20a6c28c2..a03329f4f4 100644 --- a/rusk/src/lib/verifier.rs +++ b/rusk/src/lib/verifier.rs @@ -59,7 +59,7 @@ pub fn verify_proof(tx: &PhoenixTransaction) -> Result { pub fn verify_signature(tx: &MoonlightTransaction) -> Result { Ok(rusk_abi::verify_bls( tx.signature_message(), - *tx.from_account(), + *tx.sender(), *tx.signature(), )) } diff --git a/test-wallet/src/imp.rs b/test-wallet/src/imp.rs index 298a8ab0e7..5d2df23180 100644 --- a/test-wallet/src/imp.rs +++ b/test-wallet/src/imp.rs @@ -695,8 +695,8 @@ where /// Transfer Dusk from one account to another using moonlight. pub fn moonlight_transfer( &self, - from_index: u8, - to_account: BlsPublicKey, + sender_index: u8, + receiver_account: BlsPublicKey, value: u64, gas_limit: u64, gas_price: u64, @@ -705,8 +705,8 @@ where let data: Option = None; self.moonlight_transaction( - from_index, - Some(to_account), + sender_index, + Some(receiver_account), value, deposit, gas_limit, @@ -719,8 +719,8 @@ where #[allow(clippy::too_many_arguments)] pub fn moonlight_transaction( &self, - from_index: u8, - to_account: Option, + sender_index: u8, + receiver_account: Option, value: u64, deposit: u64, gas_limit: u64, @@ -728,12 +728,12 @@ where data: Option>, ) -> Result> { let mut seed = self.store.get_seed().map_err(Error::from_store_err)?; - let mut from_sk = derive_bls_sk(&seed, from_index); - let from_account = BlsPublicKey::from(&from_sk); + let mut sender_sk = derive_bls_sk(&seed, sender_index); + let sender_account = BlsPublicKey::from(&sender_sk); let account = self .state - .fetch_account(&from_account) + .fetch_account(&sender_account) .map_err(Error::from_state_err)?; // technically this check is not necessary, but it's nice to not spam @@ -748,12 +748,19 @@ where self.state.fetch_chain_id().map_err(Error::from_state_err)?; let tx = MoonlightTransaction::new( - &from_sk, to_account, value, deposit, gas_limit, gas_price, nonce, - chain_id, data, + &sender_sk, + receiver_account, + value, + deposit, + gas_limit, + gas_price, + nonce, + chain_id, + data, )?; seed.zeroize(); - from_sk.zeroize(); + sender_sk.zeroize(); Ok(tx.into()) }