Skip to content

Commit

Permalink
rusk: Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
moCello committed Apr 26, 2024
1 parent 738cbba commit 9828d1c
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 84 deletions.
17 changes: 8 additions & 9 deletions rusk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,18 @@ rkyv = { version = "0.7", default-features = false, features = ["size_32"] }
bytecheck = { version = "0.6", default-features = false }
dirs = "4"

dusk-schnorr = "0.14"
dusk-poseidon = "0.31"
poseidon-merkle = { version = "0.3", features = ["rkyv-impl", "size_32"] }
jubjub-schnorr = "0.2"
dusk-poseidon = "0.33"
poseidon-merkle = { version = "0.5", features = ["rkyv-impl", "size_32"] }
sha3 = "0.10"
dusk-plonk = "0.16"
dusk-bls12_381 = "0.12"
dusk-bls12_381-sign = "0.5"
dusk-jubjub = "0.13"
dusk-pki = "0.13"
dusk-plonk = "0.19"
dusk-bls12_381 = "0.13"
bls12_381-bls = "0.2"
dusk-jubjub = "0.14"
dusk-bytes = "0.1"
kadcast = "0.6.0-rc"
dusk-wallet-core = "0.24.0-plonk.0.16-rc.2"
phoenix-core = { version = "0.21", default-features = false, features = ["rkyv-impl", "alloc"] }
phoenix-core = { version = "0.26", default-features = false, features = ["rkyv-impl", "alloc"] }
tungstenite = "0.20"
hyper-tungstenite = "0.11"
hyper = { version = "0.14", features = ["server", "stream", "http1", "http2"] }
Expand Down
5 changes: 2 additions & 3 deletions rusk/src/lib/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ use tokio::spawn;
use tracing::{error, info};

use dusk_bls12_381::BlsScalar;
use dusk_bls12_381_sign::PublicKey as BlsPublicKey;
use dusk_pki::{PublicKey, ViewKey};
use bls12_381_bls::PublicKey as BlsPublicKey;
use parking_lot::RwLockWriteGuard;
use phoenix_core::transaction::{StakeData, TreeLeaf, TRANSFER_TREE_DEPTH};
use phoenix_core::{Message, Note};
use phoenix_core::{PublicKey, ViewKey, Message, Note};
use poseidon_merkle::Opening as PoseidonOpening;
use rusk_abi::{ContractId, STAKE_CONTRACT, TRANSFER_CONTRACT, VM};

Expand Down
9 changes: 4 additions & 5 deletions rusk/tests/common/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@ use std::io::Write;
use std::sync::{Arc, RwLock};

use crate::common::block::Block as BlockAwait;
use bls12_381_bls::PublicKey as BlsPublicKey;
use dusk_bls12_381::BlsScalar;
use dusk_bls12_381_sign::PublicKey;
use dusk_bytes::{DeserializableSlice, Serializable};
use dusk_jubjub::{JubJubAffine, JubJubScalar};
use dusk_pki::ViewKey;
use dusk_plonk::proof_system::Proof;
use dusk_schnorr::Signature;
use dusk_wallet_core::{
self as wallet, StakeInfo, Store, Transaction as PhoenixTransaction,
UnprovenTransaction,
};
use futures::StreamExt;
use jubjub_schnorr::Signature;
use phoenix_core::transaction::TRANSFER_TREE_DEPTH;
use phoenix_core::{Crossover, Fee, Note};
use phoenix_core::{Crossover, Fee, Note, ViewKey};
use poseidon_merkle::Opening as PoseidonOpening;
use rusk::{Error, Result, Rusk};
use rusk_prover::prover::{A, STCT_INPUT_LEN, WFCT_INPUT_LEN};
Expand Down Expand Up @@ -113,7 +112,7 @@ impl wallet::StateClient for TestStateClient {
.ok_or(Error::OpeningPositionNotFound(*note.pos()))
}

fn fetch_stake(&self, pk: &PublicKey) -> Result<StakeInfo, Self::Error> {
fn fetch_stake(&self, pk: &BlsPublicKey) -> Result<StakeInfo, Self::Error> {
let stake = self
.rusk
.provisioner(pk)?
Expand Down
23 changes: 11 additions & 12 deletions rusk/tests/rusk-state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ use dusk_bls12_381::BlsScalar;
use std::path::Path;
use std::sync::{mpsc, Arc, RwLock};

use dusk_pki::SecretSpendKey;
use dusk_wallet_core::{self as wallet};
use ff::Field;
use parking_lot::RwLockWriteGuard;
use phoenix_core::transaction::TreeLeaf;
use phoenix_core::Note;
use phoenix_core::{SecretKey, Note};
use rand::prelude::*;
use rand::rngs::StdRng;
use rusk::chain::{Rusk, RuskTip};
Expand Down Expand Up @@ -60,10 +59,10 @@ where
info!("Generating a note");
let mut rng = StdRng::seed_from_u64(0xdead);

let ssk = SecretSpendKey::random(&mut rng);
let psk = ssk.public_spend_key();
let sk = SecretKey::random(&mut rng);
let pk = PublicKey::from(sk);

let note = Note::transparent(&mut rng, &psk, INITIAL_BALANCE);
let note = Note::transparent(&mut rng, &pk, INITIAL_BALANCE);

rusk.with_tip(|mut tip, vm| {
let current_commit = tip.current;
Expand Down Expand Up @@ -172,12 +171,12 @@ async fn generate_bench_txs() -> Result<(), Box<dyn std::error::Error>> {
TestProverClient::default(),
);

// Generates some public spend keys for the wallet
// Generates some public keys for the wallet
// for i in 0..100 {
// let psk = wallet.public_spend_key(i).unwrap();
// let psk_bytes = psk.to_bytes();
// let psk_string = bs58::encode(psk_bytes).into_string();
// println!("{psk_string}");
// let pk = wallet.public_key(i).unwrap();
// let pk_bytes = pk.to_bytes();
// let pk_string = bs58::encode(pk_bytes).into_string();
// println!("{pk_string}");
// }

const N_ADDRESSES: usize = 100;
Expand All @@ -195,8 +194,8 @@ async fn generate_bench_txs() -> Result<(), Box<dyn std::error::Error>> {
let mut rng = StdRng::seed_from_u64(0xdead);

let receiver_index = (sender_index + 1) % N_ADDRESSES as u64;
let receiver = wallet.public_spend_key(receiver_index).unwrap();
let refund = wallet.public_spend_key(sender_index).unwrap();
let receiver = wallet.public_key(receiver_index).unwrap();
let refund = wallet.public_key(sender_index).unwrap();

let ref_id = BlsScalar::random(&mut rng);

Expand Down
8 changes: 4 additions & 4 deletions rusk/tests/services/gas_behavior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ fn make_transactions(
) {
// We will refund the transaction to ourselves.
let refund_0 = wallet
.public_spend_key(SENDER_INDEX_0)
.expect("Getting a public spend key should succeed");
.public_key(SENDER_INDEX_0)
.expect("Getting a public key should succeed");

let initial_balance_0 = wallet
.get_balance(SENDER_INDEX_0)
Expand All @@ -54,8 +54,8 @@ fn make_transactions(

// We will refund the transaction to ourselves.
let refund_1 = wallet
.public_spend_key(SENDER_INDEX_1)
.expect("Getting a public spend key should succeed");
.public_key(SENDER_INDEX_1)
.expect("Getting a public key should succeed");

let initial_balance_1 = wallet
.get_balance(SENDER_INDEX_1)
Expand Down
36 changes: 18 additions & 18 deletions rusk/tests/services/multi_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::path::Path;
use std::sync::{Arc, LazyLock, RwLock};

use dusk_bls12_381::BlsScalar;
use dusk_pki::SecretSpendKey;
use phoenix_core::SecretKey;
use dusk_wallet_core::{self as wallet, Store};
use ff::Field;
use rand::prelude::*;
Expand Down Expand Up @@ -38,19 +38,19 @@ fn initial_state<P: AsRef<Path>>(dir: P) -> Result<Rusk> {
new_state(dir, &snapshot)
}

static SSK_0: LazyLock<SecretSpendKey> = LazyLock::new(|| {
info!("Generating SecretSpendKey #0");
TestStore.retrieve_ssk(0).expect("Should not fail in test")
static SK_0: LazyLock<SecretKey> = LazyLock::new(|| {
info!("Generating SecretKey #0");
TestStore.retrieve_sk(0).expect("Should not fail in test")
});

static SSK_1: LazyLock<SecretSpendKey> = LazyLock::new(|| {
info!("Generating SecretSpendKey #1");
TestStore.retrieve_ssk(1).expect("Should not fail in test")
static SK_1: LazyLock<SecretKey> = LazyLock::new(|| {
info!("Generating SecretKey #1");
TestStore.retrieve_sk(1).expect("Should not fail in test")
});

static SSK_2: LazyLock<SecretSpendKey> = LazyLock::new(|| {
info!("Generating SecretSpendKey #2");
TestStore.retrieve_ssk(2).expect("Should not fail in test")
static SK_2: LazyLock<SecretKey> = LazyLock::new(|| {
info!("Generating SecretKey #2");
TestStore.retrieve_sk(2).expect("Should not fail in test")
});

/// Executes three different transactions in the same block, expecting only two
Expand All @@ -60,17 +60,17 @@ fn wallet_transfer(
wallet: &wallet::Wallet<TestStore, TestStateClient, TestProverClient>,
amount: u64,
) {
// Sender psk
let psk_0 = SSK_0.public_spend_key();
let psk_1 = SSK_1.public_spend_key();
let psk_2 = SSK_2.public_spend_key();
// Sender pk
let pk_0 = PublicKey::from(SK_0);
let pk_1 = PublicKey::from(SK_1);
let pk_2 = PublicKey::from(SK_2);

let refunds = vec![psk_0, psk_1, psk_2];
let refunds = vec![pk_0, pk_1, pk_2];

// Generate a receiver psk
// Generate a receiver pk
let receiver = wallet
.public_spend_key(3)
.expect("Failed to get public spend key");
.public_key(3)
.expect("Failed to get public key");

let mut rng = StdRng::seed_from_u64(0xdead);
let nonce = BlsScalar::random(&mut rng);
Expand Down
34 changes: 17 additions & 17 deletions rusk/tests/services/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use std::path::Path;
use std::sync::{Arc, LazyLock, RwLock};

use dusk_bls12_381_sign::PublicKey;
use dusk_pki::SecretSpendKey;
use bls12_381_bls::PublicKey as BlsPublicKey;
use phoenix_core::SecretKey;
use dusk_wallet_core::{self as wallet, Store};
use rand::prelude::*;
use rand::rngs::StdRng;
Expand Down Expand Up @@ -44,14 +44,14 @@ fn slash_state<P: AsRef<Path>>(dir: P) -> Result<Rusk> {
new_state(dir, &snapshot)
}

static SSK: LazyLock<SecretSpendKey> = LazyLock::new(|| {
info!("Generating SecretSpendKey");
TestStore.retrieve_ssk(0).expect("Should not fail in test")
static SK: LazyLock<SecretKey> = LazyLock::new(|| {
info!("Generating SecretKey");
TestStore.retrieve_sk(0).expect("Should not fail in test")
});

// static SK: LazyLock<SecretKey> = LazyLock::new(|| {
// static BLS_SK: LazyLock<BLSSecretKey> = LazyLock::new(|| {
// info!("Generating BLS SecretKey");
// TestStore.retrieve_sk(0).expect("Should not fail in test")
// TestStore.retrieve_bls_sk(0).expect("Should not fail in test")
// });

/// Stakes an amount Dusk and produces a block with this single transaction,
Expand All @@ -62,8 +62,8 @@ fn wallet_stake(
wallet: &wallet::Wallet<TestStore, TestStateClient, TestProverClient>,
value: u64,
) {
// Sender psk
let psk = SSK.public_spend_key();
// Sender pk
let pk = PublicKey::from(SK);

let mut rng = StdRng::seed_from_u64(0xdead);

Expand All @@ -83,7 +83,7 @@ fn wallet_stake(
);

let tx = wallet
.stake(&mut rng, 0, 2, &psk, value, GAS_LIMIT, 1)
.stake(&mut rng, 0, 2, &pk, value, GAS_LIMIT, 1)
.expect("Failed to create a stake transaction");
let executed_txs = generator_procedure(
rusk,
Expand Down Expand Up @@ -114,7 +114,7 @@ fn wallet_stake(
.expect("stake amount to be found");

let tx = wallet
.unstake(&mut rng, 0, 0, &psk, GAS_LIMIT, 1)
.unstake(&mut rng, 0, 0, &pk, GAS_LIMIT, 1)
.expect("Failed to unstake");
let spent_txs = generator_procedure(
rusk,
Expand All @@ -132,7 +132,7 @@ fn wallet_stake(
assert_eq!(stake.amount, None);

let tx = wallet
.withdraw(&mut rng, 0, 1, &psk, GAS_LIMIT, 1)
.withdraw(&mut rng, 0, 1, &pk, GAS_LIMIT, 1)
.expect("failed to withdraw reward");
generator_procedure(
rusk,
Expand Down Expand Up @@ -198,13 +198,13 @@ fn wallet_reward(
rusk: &Rusk,
wallet: &wallet::Wallet<TestStore, TestStateClient, TestProverClient>,
) {
// Sender psk
let psk = SSK.public_spend_key();
// Sender pk
let pk = PublicKey::from(SK);

let mut rng = StdRng::seed_from_u64(0xdead);

let bls_key = wallet.store().retrieve_sk(2).unwrap();
let bls_key = PublicKey::from(&bls_key);
let bls_key = wallet.store().retrieve_bls_sk(2).unwrap();
let bls_key = BlsPublicKey::from(&bls_key);
let reward_calldata = (bls_key, 6u32);

let stake = wallet.get_stake(2).expect("stake to be found");
Expand All @@ -217,7 +217,7 @@ fn wallet_reward(
String::from("reward"),
reward_calldata,
0,
&psk,
&pk,
GAS_LIMIT,
1,
)
Expand Down
20 changes: 10 additions & 10 deletions rusk/tests/services/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::path::Path;
use std::sync::{Arc, LazyLock, RwLock};

use dusk_bls12_381::BlsScalar;
use dusk_pki::SecretSpendKey;
use phoenix_core::SecretKey;
use dusk_wallet_core::{self as wallet, Store};
use ff::Field;
use node_data::ledger::SpentTransaction;
Expand All @@ -35,9 +35,9 @@ fn initial_state<P: AsRef<Path>>(dir: P) -> Result<Rusk> {
new_state(dir, &snapshot)
}

static SSK: LazyLock<SecretSpendKey> = LazyLock::new(|| {
info!("Generating SecretSpendKey");
TestStore.retrieve_ssk(0).expect("Should not fail in test")
static SK: LazyLock<SecretKey> = LazyLock::new(|| {
info!("Generating SecretKey");
TestStore.retrieve_sk(0).expect("Should not fail in test")
});

/// Transacts between two accounts on the in the same wallet and produces a
Expand All @@ -49,13 +49,13 @@ fn wallet_transfer(
amount: u64,
block_height: u64,
) {
// Sender psk
let psk = SSK.public_spend_key();
// Sender pk
let pk = PublicKey::from(SK);

// Generate a receiver psk
// Generate a receiver pk
let receiver = wallet
.public_spend_key(1)
.expect("Failed to get public spend key");
.public_key(1)
.expect("Failed to get public key");

let mut rng = StdRng::seed_from_u64(0xdead);
let nonce = BlsScalar::random(&mut rng);
Expand Down Expand Up @@ -88,7 +88,7 @@ fn wallet_transfer(
.transfer(
&mut rng,
0,
&psk,
&pk,
&receiver,
amount,
1_000_000_000,
Expand Down
12 changes: 6 additions & 6 deletions rusk/tests/services/unspendable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ fn make_transactions(
) {
// We will refund the transaction to ourselves.
let refund_0 = wallet
.public_spend_key(SENDER_INDEX_0)
.expect("Getting a public spend key should succeed");
.public_key(SENDER_INDEX_0)
.expect("Getting a public key should succeed");

let initial_balance_0 = wallet
.get_balance(SENDER_INDEX_0)
Expand All @@ -56,8 +56,8 @@ fn make_transactions(

// We will refund the transaction to ourselves.
let refund_1 = wallet
.public_spend_key(SENDER_INDEX_1)
.expect("Getting a public spend key should succeed");
.public_key(SENDER_INDEX_1)
.expect("Getting a public key should succeed");

let initial_balance_1 = wallet
.get_balance(SENDER_INDEX_1)
Expand All @@ -66,8 +66,8 @@ fn make_transactions(

// We will refund the transaction to ourselves.
let refund_2 = wallet
.public_spend_key(SENDER_INDEX_2)
.expect("Getting a public spend key should succeed");
.public_key(SENDER_INDEX_2)
.expect("Getting a public key should succeed");

let initial_balance_2 = wallet
.get_balance(SENDER_INDEX_2)
Expand Down

0 comments on commit 9828d1c

Please sign in to comment.