From d6988fde1e83c273706e5b05d761cd315803369a Mon Sep 17 00:00:00 2001 From: moana Date: Tue, 3 Sep 2024 12:32:20 +0200 Subject: [PATCH 1/6] execution-core: Re-export and type alias poseidon-merkle types --- execution-core/src/transfer/phoenix.rs | 37 +++++++++++++++----------- execution-core/tests/serialization.rs | 10 +++---- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/execution-core/src/transfer/phoenix.rs b/execution-core/src/transfer/phoenix.rs index eeb92ee00b..354fb25f32 100644 --- a/execution-core/src/transfer/phoenix.rs +++ b/execution-core/src/transfer/phoenix.rs @@ -14,7 +14,6 @@ use bytecheck::CheckBytes; use dusk_bytes::{DeserializableSlice, Error as BytesError, Serializable}; use dusk_poseidon::{Domain, Hash}; use ff::Field; -use poseidon_merkle::Opening; use rand::{CryptoRng, RngCore}; use rkyv::{Archive, Deserialize, Serialize}; @@ -29,20 +28,37 @@ use crate::{ }; // phoenix types +pub use phoenix_circuits::{InputNoteInfo, OutputNoteInfo, TxCircuit}; pub use phoenix_core::{ value_commitment, Error as CoreError, Note, PublicKey, SecretKey, Sender, StealthAddress, TxSkeleton, ViewKey, NOTE_VAL_ENC_SIZE, OUTPUT_NOTES, }; -pub use phoenix_circuits::{InputNoteInfo, OutputNoteInfo, TxCircuit}; +/// The depth of the merkle tree of notes stored in the transfer-contract. +pub const NOTES_TREE_DEPTH: usize = 17; +/// The arity of the merkle tree of notes stored in the transfer-contract. +pub use poseidon_merkle::ARITY as NOTES_TREE_ARITY; +/// The merkle tree of notes stored in the transfer-contract. +pub type NotesTree = poseidon_merkle::Tree<(), NOTES_TREE_DEPTH>; +/// The merkle opening for a note-hash in the merkle tree of notes. +pub type NoteOpening = poseidon_merkle::Opening<(), NOTES_TREE_DEPTH>; +/// the tree item for the merkle-tree of notes stored in the transfer-contract. +pub type NoteTreeItem = poseidon_merkle::Item<()>; + +/// A leaf of the merkle tree of notes stored in the transfer-contract. +#[derive(Debug, Clone, PartialEq, Eq, Archive, Serialize, Deserialize)] +#[archive_attr(derive(CheckBytes))] +pub struct NoteLeaf { + /// The height of the block when the note was inserted in the tree. + pub block_height: u64, + /// The note inserted in the tree. + pub note: Note, +} /// Label used for the ZK transcript initialization. Must be the same for prover /// and verifier. pub const TRANSCRIPT_LABEL: &[u8] = b"dusk-network"; -/// The depth of the transfer tree. -pub const NOTES_TREE_DEPTH: usize = 17; - /// Phoenix transaction. #[derive(Debug, Clone, Archive, Serialize, Deserialize)] #[archive_attr(derive(CheckBytes))] @@ -79,7 +95,7 @@ impl Transaction { sender_sk: &SecretKey, change_pk: &PublicKey, receiver_pk: &PublicKey, - inputs: Vec<(Note, Opening<(), NOTES_TREE_DEPTH>)>, + inputs: Vec<(Note, NoteOpening)>, root: BlsScalar, transfer_value: u64, obfuscated_transaction: bool, @@ -835,15 +851,6 @@ impl Serializable for Fee { }) } } -/// A leaf of the transfer tree. -#[derive(Debug, Clone, PartialEq, Eq, Archive, Serialize, Deserialize)] -#[archive_attr(derive(CheckBytes))] -pub struct TreeLeaf { - /// The height of the block when the note was inserted in the tree. - pub block_height: u64, - /// The note inserted in the tree. - pub note: Note, -} /// This struct mimics the [`TxCircuit`] but is not generic over the amount of /// input-notes. diff --git a/execution-core/tests/serialization.rs b/execution-core/tests/serialization.rs index a60e8d91c9..f4de91bcae 100644 --- a/execution-core/tests/serialization.rs +++ b/execution-core/tests/serialization.rs @@ -13,15 +13,15 @@ use execution_core::{ ContractBytecode, ContractCall, ContractDeploy, ContractExec, }, phoenix::{ - Note, Prove, PublicKey as PhoenixPublicKey, - SecretKey as PhoenixSecretKey, TxCircuitVec, NOTES_TREE_DEPTH, + Note, NoteTreeItem, NotesTree, Prove, + PublicKey as PhoenixPublicKey, SecretKey as PhoenixSecretKey, + TxCircuitVec, }, Transaction, }, BlsScalar, Error, JubJubScalar, }; use ff::Field; -use poseidon_merkle::{Item, Tree}; use rand::rngs::StdRng; use rand::{CryptoRng, Rng, RngCore, SeedableRng}; @@ -86,9 +86,9 @@ fn new_phoenix_tx( input_2.set_pos(2); let notes = vec![input_0, input_1, input_2]; - let mut notes_tree = Tree::<(), NOTES_TREE_DEPTH>::new(); + let mut notes_tree = NotesTree::new(); for note in notes.iter() { - let item = Item { + let item = NoteTreeItem { hash: note.hash(), data: (), }; From c73140ac9a39aef3c3fa61ad78735a807dd4f27e Mon Sep 17 00:00:00 2001 From: moana Date: Tue, 3 Sep 2024 12:33:11 +0200 Subject: [PATCH 2/6] transfer-contract: Use note-tree types from execution-core --- contracts/transfer/Cargo.toml | 1 - contracts/transfer/src/state.rs | 12 ++++------ contracts/transfer/src/tree.rs | 29 +++++++++--------------- contracts/transfer/tests/common/utils.rs | 16 +++++-------- 4 files changed, 21 insertions(+), 37 deletions(-) diff --git a/contracts/transfer/Cargo.toml b/contracts/transfer/Cargo.toml index ec98377d4a..2749ab73cc 100644 --- a/contracts/transfer/Cargo.toml +++ b/contracts/transfer/Cargo.toml @@ -9,7 +9,6 @@ crate-type = ["cdylib", "rlib"] [dependencies] execution-core = { version = "0.1.0", path = "../../execution-core" } dusk-bytes = "0.1" -poseidon-merkle = { version = "0.7", features = ["rkyv-impl"] } rkyv = { version = "0.7", default-features = false, features = ["size_32"] } ringbuffer = "0.15" diff --git a/contracts/transfer/src/state.rs b/contracts/transfer/src/state.rs index 5631019231..f082286a0c 100644 --- a/contracts/transfer/src/state.rs +++ b/contracts/transfer/src/state.rs @@ -13,7 +13,6 @@ use alloc::collections::{BTreeMap, BTreeSet}; use alloc::vec::Vec; use dusk_bytes::Serializable; -use poseidon_merkle::Opening as PoseidonOpening; use ringbuffer::{ConstGenericRingBuffer, RingBuffer}; use execution_core::{ @@ -22,8 +21,8 @@ use execution_core::{ transfer::{ moonlight::{AccountData, Transaction as MoonlightTransaction}, phoenix::{ - Note, Sender, Transaction as PhoenixTransaction, TreeLeaf, - NOTES_TREE_DEPTH, + Note, NoteLeaf, NoteOpening, Sender, + Transaction as PhoenixTransaction, }, withdraw::{ Withdraw, WithdrawReceiver, WithdrawReplayToken, WithdrawSignature, @@ -539,7 +538,7 @@ impl TransferState { /// Note: the method `update_root` needs to be called after the last note is /// pushed. pub fn push_note(&mut self, block_height: u64, note: Note) -> Note { - let tree_leaf = TreeLeaf { block_height, note }; + let tree_leaf = NoteLeaf { block_height, note }; let pos = self.tree.push(tree_leaf.clone()); rusk_abi::emit("TREE_LEAF", (pos, tree_leaf)); self.get_note(pos) @@ -595,10 +594,7 @@ impl TransferState { } /// Get the opening - pub fn opening( - &self, - pos: u64, - ) -> Option> { + pub fn opening(&self, pos: u64) -> Option { self.tree.opening(pos) } diff --git a/contracts/transfer/src/tree.rs b/contracts/transfer/src/tree.rs index 958d51a633..160c560229 100644 --- a/contracts/transfer/src/tree.rs +++ b/contracts/transfer/src/tree.rs @@ -6,42 +6,38 @@ use alloc::vec::Vec; -use poseidon_merkle::{ - Item as PoseidonItem, Opening as PoseidonOpening, Tree as PoseidonTree, -}; - use execution_core::{ - transfer::phoenix::{Note, TreeLeaf, NOTES_TREE_DEPTH}, + transfer::phoenix::{Note, NoteLeaf, NoteOpening, NoteTreeItem, NotesTree}, BlsScalar, }; pub struct Tree { - tree: PoseidonTree<(), NOTES_TREE_DEPTH>, + tree: NotesTree, // Since `dusk-merkle` does not include data blocks with the tree, we do it // here. - leaves: Vec, + leaves: Vec, } impl Tree { pub const fn new() -> Self { Self { - tree: PoseidonTree::new(), + tree: NotesTree::new(), leaves: Vec::new(), } } - pub fn get(&self, pos: u64) -> Option { + pub fn get(&self, pos: u64) -> Option { self.leaves.get(pos as usize).cloned() } - pub fn push(&mut self, mut leaf: TreeLeaf) -> u64 { + pub fn push(&mut self, mut leaf: NoteLeaf) -> u64 { // update the position before computing the hash let pos = self.leaves.len() as u64; leaf.note.set_pos(pos); // compute the item that goes in the leaf of the tree let hash = rusk_abi::poseidon_hash(leaf.note.hash_inputs().to_vec()); - let item = PoseidonItem { hash, data: () }; + let item = NoteTreeItem { hash, data: () }; self.tree.insert(pos, item); self.leaves.push(leaf); @@ -57,7 +53,7 @@ impl Tree { for note in notes { // skip transparent notes with a value of 0 if !note.value(None).is_ok_and(|value| value == 0) { - self.push(TreeLeaf { block_height, note }); + self.push(NoteLeaf { block_height, note }); } } } @@ -68,7 +64,7 @@ impl Tree { /// Return an iterator through the leaves in the tree, starting from a given /// `height`. - pub fn leaves(&self, height: u64) -> impl Iterator { + pub fn leaves(&self, height: u64) -> impl Iterator { // We can do this since we know the leaves are strictly increasing in // block height. If this ever changes - such as in the case of a // sparsely populated tree - we should annotate the tree and use @@ -80,7 +76,7 @@ impl Tree { /// Return an iterator through the leaves in the tree, starting from a given /// `position`. - pub fn leaves_pos(&self, pos: u64) -> impl Iterator { + pub fn leaves_pos(&self, pos: u64) -> impl Iterator { // We can do this since we know the leaves are strictly increasing in // block height. If this ever changes - such as in the case of a // sparsely populated tree - we should annotate the tree and use @@ -92,10 +88,7 @@ impl Tree { self.leaves[pos..].iter() } - pub fn opening( - &self, - pos: u64, - ) -> Option> { + pub fn opening(&self, pos: u64) -> Option { self.tree.opening(pos) } diff --git a/contracts/transfer/tests/common/utils.rs b/contracts/transfer/tests/common/utils.rs index 3d87b35a0c..ca2e0ab3c7 100644 --- a/contracts/transfer/tests/common/utils.rs +++ b/contracts/transfer/tests/common/utils.rs @@ -12,8 +12,8 @@ use execution_core::{ contract_exec::ContractExec, moonlight::AccountData, phoenix::{ - Note, PublicKey, SecretKey, Transaction as PhoenixTransaction, - TreeLeaf, ViewKey, NOTES_TREE_DEPTH, + Note, NoteLeaf, NoteOpening, NoteTreeItem, PublicKey, SecretKey, + Transaction as PhoenixTransaction, ViewKey, }, Transaction, TRANSFER_CONTRACT, }, @@ -22,7 +22,6 @@ use execution_core::{ use rusk_abi::{CallReceipt, PiecrustError, Session}; use rusk_prover::LocalProver; -use poseidon_merkle::Opening as PoseidonOpening; use rand::rngs::StdRng; const GAS_LIMIT: u64 = 0x10_000_000; @@ -30,7 +29,7 @@ const GAS_LIMIT: u64 = 0x10_000_000; pub fn leaves_from_height( session: &mut Session, height: u64, -) -> Result, PiecrustError> { +) -> Result, PiecrustError> { let (feeder, receiver) = mpsc::channel(); session.feeder_call::<_, ()>( @@ -50,7 +49,7 @@ pub fn leaves_from_height( pub fn leaves_from_pos( session: &mut Session, pos: u64, -) -> Result, PiecrustError> { +) -> Result, PiecrustError> { let (feeder, receiver) = mpsc::channel(); session.feeder_call::<_, ()>( @@ -106,7 +105,7 @@ pub fn contract_balance( pub fn opening( session: &mut Session, pos: u64, -) -> Result>, PiecrustError> { +) -> Result, PiecrustError> { session .call(TRANSFER_CONTRACT, "opening", &pos, GAS_LIMIT) .map(|r| r.data) @@ -212,10 +211,7 @@ pub fn create_phoenix_transaction( .expect("An opening should exist for a note in the tree"); // sanity check of the merkle opening - assert!(opening.verify(poseidon_merkle::Item::new( - rusk_abi::poseidon_hash(note.hash_inputs().to_vec()), - () - ))); + assert!(opening.verify(NoteTreeItem::new(note.hash(), ()))); inputs.push((note.clone(), opening)); } From 4bc2cc9443e8abaac218436dee9b732a975aa7bb Mon Sep 17 00:00:00 2001 From: moana Date: Tue, 3 Sep 2024 12:34:01 +0200 Subject: [PATCH 3/6] stake-contract: Use execution-core note tree types --- contracts/stake/Cargo.toml | 1 - contracts/stake/tests/common/utils.rs | 18 +++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/contracts/stake/Cargo.toml b/contracts/stake/Cargo.toml index eefa752f63..d2ce858287 100644 --- a/contracts/stake/Cargo.toml +++ b/contracts/stake/Cargo.toml @@ -23,7 +23,6 @@ rusk-prover = { version = "0.3", path = "../../rusk-prover/" } rkyv = { version = "0.7", default-features = false, features = ["size_32"] } hex = "0.4" rand = "0.8" -poseidon-merkle = { version = "0.7", features = ["rkyv-impl"] } ff = { version = "0.13", default-features = false } criterion = "0.5" diff --git a/contracts/stake/tests/common/utils.rs b/contracts/stake/tests/common/utils.rs index a794bc07e3..fcf8a4fff6 100644 --- a/contracts/stake/tests/common/utils.rs +++ b/contracts/stake/tests/common/utils.rs @@ -6,16 +6,15 @@ use std::sync::mpsc; -use poseidon_merkle::Opening as PoseidonOpening; use rand::rngs::StdRng; use execution_core::{ transfer::{ contract_exec::ContractExec, phoenix::{ - Note, PublicKey as PhoenixPublicKey, SecretKey as PhoenixSecretKey, - Transaction as PhoenixTransaction, TreeLeaf, - ViewKey as PhoenixViewKey, NOTES_TREE_DEPTH, + Note, NoteLeaf, NoteOpening, NoteTreeItem, + PublicKey as PhoenixPublicKey, SecretKey as PhoenixSecretKey, + Transaction as PhoenixTransaction, ViewKey as PhoenixViewKey, }, Transaction, TRANSFER_CONTRACT, }, @@ -29,7 +28,7 @@ const POINT_LIMIT: u64 = 0x100000000; pub fn leaves_from_height( session: &mut Session, height: u64, -) -> Result, PiecrustError> { +) -> Result, PiecrustError> { let (feeder, receiver) = mpsc::channel(); session.feeder_call::<_, ()>( @@ -49,7 +48,7 @@ pub fn leaves_from_height( pub fn leaves_from_pos( session: &mut Session, pos: u64, -) -> Result, PiecrustError> { +) -> Result, PiecrustError> { let (feeder, receiver) = mpsc::channel(); session.feeder_call::<_, ()>( @@ -81,7 +80,7 @@ pub fn root(session: &mut Session) -> Result { pub fn opening( session: &mut Session, pos: u64, -) -> Result>, PiecrustError> { +) -> Result, PiecrustError> { session .call(TRANSFER_CONTRACT, "opening", &pos, POINT_LIMIT) .map(|r| r.data) @@ -177,10 +176,7 @@ pub fn create_transaction( .expect("An opening should exist for a note in the tree"); // sanity check of the merkle opening - assert!(opening.verify(poseidon_merkle::Item::new( - rusk_abi::poseidon_hash(note.hash_inputs().to_vec()), - () - ))); + assert!(opening.verify(NoteTreeItem::new(note.hash(), ()))); inputs.push((note.clone(), opening)); } From 1a97e396e3fb2b43d8a7d3269a50fc123973dc3d Mon Sep 17 00:00:00 2001 From: moana Date: Tue, 3 Sep 2024 12:34:30 +0200 Subject: [PATCH 4/6] wallet-core: Use execution-core note-tree types --- wallet-core/src/transaction.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/wallet-core/src/transaction.rs b/wallet-core/src/transaction.rs index 923f6e7f6c..e38c7e2006 100644 --- a/wallet-core/src/transaction.rs +++ b/wallet-core/src/transaction.rs @@ -11,7 +11,6 @@ use alloc::vec::Vec; use rand::{CryptoRng, RngCore}; use ff::Field; -use poseidon_merkle::Opening; use zeroize::Zeroize; use execution_core::{ @@ -20,9 +19,8 @@ use execution_core::{ transfer::{ contract_exec::{ContractCall, ContractExec}, phoenix::{ - Note, Prove, PublicKey as PhoenixPublicKey, + Note, NoteOpening, Prove, PublicKey as PhoenixPublicKey, SecretKey as PhoenixSecretKey, Transaction as PhoenixTransaction, - NOTES_TREE_DEPTH, }, withdraw::{Withdraw, WithdrawReceiver, WithdrawReplayToken}, Transaction, @@ -54,7 +52,7 @@ pub fn phoenix( sender_sk: &PhoenixSecretKey, change_pk: &PhoenixPublicKey, receiver_pk: &PhoenixPublicKey, - inputs: Vec<(Note, Opening<(), NOTES_TREE_DEPTH>)>, + inputs: Vec<(Note, NoteOpening)>, root: BlsScalar, transfer_value: u64, obfuscated_transaction: bool, @@ -97,7 +95,7 @@ pub fn phoenix_stake( rng: &mut R, phoenix_sender_sk: &PhoenixSecretKey, stake_sk: &BlsSecretKey, - inputs: Vec<(Note, Opening<(), NOTES_TREE_DEPTH>)>, + inputs: Vec<(Note, NoteOpening)>, root: BlsScalar, gas_limit: u64, gas_price: u64, @@ -149,7 +147,7 @@ pub fn phoenix_stake_reward( rng: &mut R, phoenix_sender_sk: &PhoenixSecretKey, stake_sk: &BlsSecretKey, - inputs: Vec<(Note, Opening<(), NOTES_TREE_DEPTH>, BlsScalar)>, + inputs: Vec<(Note, NoteOpening, BlsScalar)>, root: BlsScalar, reward_amount: u64, gas_limit: u64, @@ -215,7 +213,7 @@ pub fn phoenix_unstake( rng: &mut R, phoenix_sender_sk: &PhoenixSecretKey, stake_sk: &BlsSecretKey, - inputs: Vec<(Note, Opening<(), NOTES_TREE_DEPTH>, BlsScalar)>, + inputs: Vec<(Note, NoteOpening, BlsScalar)>, root: BlsScalar, unstake_value: u64, gas_limit: u64, From 93e18e365827f1c42053284f21237a270e9f417c Mon Sep 17 00:00:00 2001 From: moana Date: Tue, 3 Sep 2024 12:35:05 +0200 Subject: [PATCH 5/6] test-wallet: Use execution-core note tree types --- test-wallet/Cargo.toml | 1 - test-wallet/src/imp.rs | 12 ++++-------- test-wallet/src/lib.rs | 17 ++++++----------- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/test-wallet/Cargo.toml b/test-wallet/Cargo.toml index f45395fd24..9bc9688c02 100644 --- a/test-wallet/Cargo.toml +++ b/test-wallet/Cargo.toml @@ -8,7 +8,6 @@ license = "MPL-2.0" [dependencies] rand_core = "^0.6" dusk-bytes = "^0.1" -poseidon-merkle = { version = "0.7", features = ["rkyv-impl"] } rkyv = { version = "0.7", default-features = false } ff = { version = "0.13", default-features = false } zeroize = { version = "1", default-features = false, features = ["derive"] } diff --git a/test-wallet/src/imp.rs b/test-wallet/src/imp.rs index fb0583b7e1..94b57c128f 100644 --- a/test-wallet/src/imp.rs +++ b/test-wallet/src/imp.rs @@ -12,7 +12,6 @@ use alloc::string::FromUtf8Error; use alloc::vec::Vec; use dusk_bytes::Error as BytesError; -use poseidon_merkle::Opening; use rand_core::{CryptoRng, Error as RngError, RngCore}; use rkyv::ser::serializers::{ AllocScratchError, CompositeSerializerError, SharedSerializeMapError, @@ -27,8 +26,8 @@ use execution_core::{ contract_exec::ContractExec, moonlight::{AccountData, Transaction as MoonlightTransaction}, phoenix::{ - Note, PublicKey as PhoenixPublicKey, SecretKey as PhoenixSecretKey, - ViewKey as PhoenixViewKey, NOTES_TREE_DEPTH, + Note, NoteOpening, PublicKey as PhoenixPublicKey, + SecretKey as PhoenixSecretKey, ViewKey as PhoenixViewKey, }, Transaction, }, @@ -301,10 +300,7 @@ where &self, sender_sk: &PhoenixSecretKey, transaction_cost: u64, - ) -> Result< - Vec<(Note, Opening<(), NOTES_TREE_DEPTH>, BlsScalar)>, - Error, - > { + ) -> Result, Error> { let notes_and_nullifiers = self.input_notes_nullifiers(sender_sk, transaction_cost)?; @@ -328,7 +324,7 @@ where &self, sender_sk: &PhoenixSecretKey, transaction_cost: u64, - ) -> Result)>, Error> { + ) -> Result, Error> { let notes_and_nullifiers = self.input_notes_nullifiers(sender_sk, transaction_cost)?; diff --git a/test-wallet/src/lib.rs b/test-wallet/src/lib.rs index 90efc625d0..a5b9aebdcb 100644 --- a/test-wallet/src/lib.rs +++ b/test-wallet/src/lib.rs @@ -15,7 +15,6 @@ extern crate alloc; mod imp; use alloc::vec::Vec; -use poseidon_merkle::Opening as PoseidonOpening; use zeroize::Zeroize; use execution_core::{ @@ -24,16 +23,15 @@ use execution_core::{ transfer::{ moonlight::AccountData, phoenix::{ - Note, PublicKey as PhoenixPublicKey, SecretKey as PhoenixSecretKey, - ViewKey as PhoenixViewKey, NOTES_TREE_DEPTH, + Note, NoteOpening, PublicKey as PhoenixPublicKey, + SecretKey as PhoenixSecretKey, ViewKey as PhoenixViewKey, }, }, BlsScalar, }; -pub use wallet_core::{ - keys::{derive_bls_sk, derive_phoenix_pk, derive_phoenix_sk}, - EnrichedNote, +pub use wallet_core::keys::{ + derive_bls_sk, derive_phoenix_pk, derive_phoenix_sk, }; pub use imp::*; @@ -114,7 +112,7 @@ pub trait StateClient { fn fetch_notes( &self, vk: &PhoenixViewKey, - ) -> Result, Self::Error>; + ) -> Result, Self::Error>; /// Fetch the current root of the state. fn fetch_root(&self) -> Result; @@ -127,10 +125,7 @@ pub trait StateClient { ) -> Result, Self::Error>; /// Queries the node to find the opening for a specific note. - fn fetch_opening( - &self, - note: &Note, - ) -> Result, Self::Error>; + fn fetch_opening(&self, note: &Note) -> Result; /// Queries the node for the stake of a key. If the key has no stake, a /// `Default` stake info should be returned. From e863d9de670f1492ca56c3a92b4fc1c7033f8143 Mon Sep 17 00:00:00 2001 From: moana Date: Tue, 3 Sep 2024 12:35:33 +0200 Subject: [PATCH 6/6] rusk: Use note-tree types from execution-core --- rusk/Cargo.toml | 1 - rusk/src/lib/test_utils.rs | 10 +++------- rusk/tests/common/wallet.rs | 8 ++------ rusk/tests/rusk-state.rs | 6 +++--- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/rusk/Cargo.toml b/rusk/Cargo.toml index 4918e1d2ef..7e6d2375e6 100644 --- a/rusk/Cargo.toml +++ b/rusk/Cargo.toml @@ -41,7 +41,6 @@ dirs = "4" blake3 = "1" blake2b_simd = { version = "1", default-features = false } -poseidon-merkle = { version = "0.7", features = ["rkyv-impl", "size_32"] } sha3 = "0.10" dusk-bytes = "0.1" kadcast = "0.7.0-rc" diff --git a/rusk/src/lib/test_utils.rs b/rusk/src/lib/test_utils.rs index 37e797afa1..bb025b57ba 100644 --- a/rusk/src/lib/test_utils.rs +++ b/rusk/src/lib/test_utils.rs @@ -20,13 +20,12 @@ use execution_core::{ signatures::bls::PublicKey as BlsPublicKey, stake::{StakeData, STAKE_CONTRACT}, transfer::{ - phoenix::{Note, TreeLeaf, ViewKey, NOTES_TREE_DEPTH}, + phoenix::{Note, NoteLeaf, NoteOpening, ViewKey}, TRANSFER_CONTRACT, }, BlsScalar, ContractId, }; use parking_lot::RwLockWriteGuard; -use poseidon_merkle::Opening as PoseidonOpening; use rusk_abi::VM; pub type StoredNote = (Note, u64); @@ -62,10 +61,7 @@ impl Rusk { } /// Returns the opening of the transfer tree at the given position. - pub fn tree_opening( - &self, - pos: u64, - ) -> Result>> { + pub fn tree_opening(&self, pos: u64) -> Result> { self.query(TRANSFER_CONTRACT, "opening", &pos) } @@ -111,7 +107,7 @@ impl Rusk { // expected output let stream = tokio_stream::iter(receiver.into_iter().filter_map(move |bytes| { - let leaf = rkyv::from_bytes::(&bytes) + let leaf = rkyv::from_bytes::(&bytes) .expect("The contract should always return valid leaves"); match &vk { Some(vk) => vk diff --git a/rusk/tests/common/wallet.rs b/rusk/tests/common/wallet.rs index 612792f50c..af5cf34dad 100644 --- a/rusk/tests/common/wallet.rs +++ b/rusk/tests/common/wallet.rs @@ -16,12 +16,11 @@ use execution_core::{ stake::StakeData, transfer::{ moonlight::AccountData, - phoenix::{Note, ViewKey, NOTES_TREE_DEPTH}, + phoenix::{Note, NoteOpening, ViewKey}, }, BlsScalar, }; use futures::StreamExt; -use poseidon_merkle::Opening as PoseidonOpening; use rusk::{Error, Result, Rusk}; use test_wallet::{self as wallet, Store}; use tracing::info; @@ -100,10 +99,7 @@ impl wallet::StateClient for TestStateClient { } /// Queries the node to find the opening for a specific note. - fn fetch_opening( - &self, - note: &Note, - ) -> Result, Self::Error> { + fn fetch_opening(&self, note: &Note) -> Result { self.rusk .tree_opening(*note.pos())? .ok_or(Error::OpeningPositionNotFound(*note.pos())) diff --git a/rusk/tests/rusk-state.rs b/rusk/tests/rusk-state.rs index 4ef736a130..72e6eab0fd 100644 --- a/rusk/tests/rusk-state.rs +++ b/rusk/tests/rusk-state.rs @@ -15,8 +15,8 @@ use std::sync::{mpsc, Arc}; use execution_core::{ transfer::{ phoenix::{ - Note, PublicKey as PhoenixPublicKey, SecretKey as PhoenixSecretKey, - TreeLeaf, + Note, NoteLeaf, PublicKey as PhoenixPublicKey, + SecretKey as PhoenixSecretKey, }, TRANSFER_CONTRACT, }, @@ -47,7 +47,7 @@ fn initial_state>(dir: P) -> Result { new_state(dir, &snapshot, BLOCK_GAS_LIMIT) } -fn leaves_from_height(rusk: &Rusk, height: u64) -> Result> { +fn leaves_from_height(rusk: &Rusk, height: u64) -> Result> { let (sender, receiver) = mpsc::channel(); rusk.leaves_from_height(height, sender)?; Ok(receiver