From 8604a672bdeadddbe168cbcc8e016293a62ef2f6 Mon Sep 17 00:00:00 2001 From: Oleksandr Pravdyvyi Date: Wed, 23 Jul 2025 15:53:00 +0300 Subject: [PATCH] fix: merge fix --- node_core/src/chain_storage/mod.rs | 2 -- node_core/src/lib.rs | 24 ++++++++-------------- sequencer_core/src/lib.rs | 32 +++++++++++++----------------- 3 files changed, 22 insertions(+), 36 deletions(-) diff --git a/node_core/src/chain_storage/mod.rs b/node_core/src/chain_storage/mod.rs index 3ee0e0b..21d9da0 100644 --- a/node_core/src/chain_storage/mod.rs +++ b/node_core/src/chain_storage/mod.rs @@ -299,7 +299,6 @@ mod tests { } fn create_dummy_transaction( - hash: TreeHashType, // execution_input: Vec, nullifier_created_hashes: Vec<[u8; 32]>, utxo_commitments_spent_hashes: Vec<[u8; 32]>, @@ -419,7 +418,6 @@ mod tests { .utxo_commitments_store .add_tx_multiple(vec![UTXOCommitment { hash: [3u8; 32] }]); store.pub_tx_store.add_tx(create_dummy_transaction( - [12; 32], vec![[9; 32]], vec![[7; 32]], vec![[8; 32]], diff --git a/node_core/src/lib.rs b/node_core/src/lib.rs index b8ea8fe..eab83ba 100644 --- a/node_core/src/lib.rs +++ b/node_core/src/lib.rs @@ -271,8 +271,7 @@ impl NodeCore { secret_r, sc_addr, state_changes, - } - .into(), + }, result_hash, )) } @@ -367,8 +366,7 @@ impl NodeCore { secret_r, sc_addr, state_changes, - } - .into(), + }, result_hashes, )) } @@ -481,8 +479,7 @@ impl NodeCore { secret_r, sc_addr, state_changes, - } - .into(), + }, utxo_hashes, )) } @@ -625,8 +622,7 @@ impl NodeCore { secret_r, sc_addr, state_changes, - } - .into(), + }, utxo_hashes_receiver, utxo_hashes_not_spent, )) @@ -752,8 +748,7 @@ impl NodeCore { secret_r, sc_addr, state_changes, - } - .into(), + }, utxo_hashes, )) } @@ -837,8 +832,7 @@ impl NodeCore { secret_r, sc_addr, state_changes, - } - .into()) + }) } pub async fn send_private_mint_tx( @@ -932,8 +926,7 @@ impl NodeCore { secret_r, sc_addr, state_changes, - ) - .into(); + ); tx.log(); Ok(self.sequencer_client.send_tx(tx, tx_roots).await?) @@ -1475,8 +1468,7 @@ impl NodeCore { secret_r, sc_addr, state_changes, - } - .into(), + }, utxo_hashes, )) } diff --git a/sequencer_core/src/lib.rs b/sequencer_core/src/lib.rs index 1129e31..e5ddef8 100644 --- a/sequencer_core/src/lib.rs +++ b/sequencer_core/src/lib.rs @@ -77,7 +77,6 @@ impl SequencerCore { tx_roots: [[u8; 32]; 2], ) -> Result<(), TransactionMalformationErrorKind> { let Transaction { - hash, tx_kind, ref execution_input, ref execution_output, @@ -85,11 +84,12 @@ impl SequencerCore { ref nullifier_created_hashes, .. } = tx; + let hash = tx.hash(); let mempool_size = self.mempool.len(); if mempool_size >= self.sequencer_config.max_num_tx_in_block { - return Err(TransactionMalformationErrorKind::MempoolFullForRound { tx: *hash }); + return Err(TransactionMalformationErrorKind::MempoolFullForRound { tx: hash }); } let curr_sequencer_roots = self.get_tree_roots(); @@ -97,7 +97,7 @@ impl SequencerCore { if tx_roots != curr_sequencer_roots { return Err( TransactionMalformationErrorKind::ChainStateFurtherThanTransactionState { - tx: *hash, + tx: hash, }, ); } @@ -111,7 +111,7 @@ impl SequencerCore { //Public transactions can not make private operations. return Err( TransactionMalformationErrorKind::PublicTransactionChangedPrivateData { - tx: *hash, + tx: hash, }, ); } @@ -123,7 +123,7 @@ impl SequencerCore { //between public and private state. return Err( TransactionMalformationErrorKind::PrivateTransactionChangedPublicData { - tx: *hash, + tx: hash, }, ); } @@ -132,7 +132,7 @@ impl SequencerCore { }; //Tree checks - let tx_tree_check = self.store.pub_tx_store.get_tx(*hash).is_some(); + let tx_tree_check = self.store.pub_tx_store.get_tx(hash).is_some(); let nullifier_tree_check = nullifier_created_hashes.iter().any(|nullifier_hash| { self.store.nullifier_store.contains(&UTXONullifier { utxo_hash: *nullifier_hash, @@ -149,18 +149,18 @@ impl SequencerCore { }); if tx_tree_check { - return Err(TransactionMalformationErrorKind::TxHashAlreadyPresentInTree { tx: *hash }); + return Err(TransactionMalformationErrorKind::TxHashAlreadyPresentInTree { tx: hash }); } if nullifier_tree_check { return Err( - TransactionMalformationErrorKind::NullifierAlreadyPresentInTree { tx: *hash }, + TransactionMalformationErrorKind::NullifierAlreadyPresentInTree { tx: hash }, ); } if utxo_commitments_check { return Err( - TransactionMalformationErrorKind::UTXOCommitmentAlreadyPresentInTree { tx: *hash }, + TransactionMalformationErrorKind::UTXOCommitmentAlreadyPresentInTree { tx: hash }, ); } @@ -184,8 +184,6 @@ impl SequencerCore { tx: TransactionMempool, ) -> Result<(), TransactionMalformationErrorKind> { let Transaction { - // ToDo: remove hashing of transactions on node side [Issue #66] - hash: _, ref utxo_commitments_created_hashes, ref nullifier_created_hashes, .. @@ -298,7 +296,6 @@ mod tests { } fn create_dummy_transaction( - hash: TreeHashType, nullifier_created_hashes: Vec<[u8; 32]>, utxo_commitments_spent_hashes: Vec<[u8; 32]>, utxo_commitments_created_hashes: Vec<[u8; 32]>, @@ -306,7 +303,6 @@ mod tests { let mut rng = rand::thread_rng(); Transaction { - hash, tx_kind: TxKind::Private, execution_input: vec![], execution_output: vec![], @@ -325,7 +321,7 @@ mod tests { } fn common_setup(sequencer: &mut SequencerCore) { - let tx = create_dummy_transaction([12; 32], vec![[9; 32]], vec![[7; 32]], vec![[8; 32]]); + let tx = create_dummy_transaction(vec![[9; 32]], vec![[7; 32]], vec![[8; 32]]); let tx_mempool = TransactionMempool { tx }; sequencer.mempool.push_item(tx_mempool); @@ -447,7 +443,7 @@ mod tests { common_setup(&mut sequencer); - let tx = create_dummy_transaction([1; 32], vec![[91; 32]], vec![[71; 32]], vec![[81; 32]]); + let tx = create_dummy_transaction(vec![[91; 32]], vec![[71; 32]], vec![[81; 32]]); let tx_roots = sequencer.get_tree_roots(); let result = sequencer.transaction_pre_check(&tx, tx_roots); @@ -464,7 +460,7 @@ mod tests { common_setup(&mut sequencer); - let tx = create_dummy_transaction([2; 32], vec![[92; 32]], vec![[72; 32]], vec![[82; 32]]); + let tx = create_dummy_transaction(vec![[92; 32]], vec![[72; 32]], vec![[82; 32]]); let tx_roots = sequencer.get_tree_roots(); // Fill the mempool @@ -486,7 +482,7 @@ mod tests { common_setup(&mut sequencer); - let tx = create_dummy_transaction([3; 32], vec![[93; 32]], vec![[73; 32]], vec![[83; 32]]); + let tx = create_dummy_transaction(vec![[93; 32]], vec![[73; 32]], vec![[83; 32]]); let tx_roots = sequencer.get_tree_roots(); let tx_mempool = TransactionMempool { tx }; @@ -500,7 +496,7 @@ mod tests { let config = setup_sequencer_config(); let mut sequencer = SequencerCore::start_from_config(config); - let tx = create_dummy_transaction([4; 32], vec![[94; 32]], vec![[7; 32]], vec![[8; 32]]); + let tx = create_dummy_transaction(vec![[94; 32]], vec![[7; 32]], vec![[8; 32]]); let tx_mempool = TransactionMempool { tx }; sequencer.mempool.push_item(tx_mempool);