fix: merge fix

This commit is contained in:
Oleksandr Pravdyvyi 2025-07-23 15:53:00 +03:00
parent 0f82c0ec05
commit 8604a672bd
No known key found for this signature in database
GPG Key ID: 9F8955C63C443871
3 changed files with 22 additions and 36 deletions

View File

@ -299,7 +299,6 @@ mod tests {
} }
fn create_dummy_transaction( fn create_dummy_transaction(
hash: TreeHashType,
// execution_input: Vec<u8>, // execution_input: Vec<u8>,
nullifier_created_hashes: Vec<[u8; 32]>, nullifier_created_hashes: Vec<[u8; 32]>,
utxo_commitments_spent_hashes: Vec<[u8; 32]>, utxo_commitments_spent_hashes: Vec<[u8; 32]>,
@ -419,7 +418,6 @@ mod tests {
.utxo_commitments_store .utxo_commitments_store
.add_tx_multiple(vec![UTXOCommitment { hash: [3u8; 32] }]); .add_tx_multiple(vec![UTXOCommitment { hash: [3u8; 32] }]);
store.pub_tx_store.add_tx(create_dummy_transaction( store.pub_tx_store.add_tx(create_dummy_transaction(
[12; 32],
vec![[9; 32]], vec![[9; 32]],
vec![[7; 32]], vec![[7; 32]],
vec![[8; 32]], vec![[8; 32]],

View File

@ -271,8 +271,7 @@ impl NodeCore {
secret_r, secret_r,
sc_addr, sc_addr,
state_changes, state_changes,
} },
.into(),
result_hash, result_hash,
)) ))
} }
@ -367,8 +366,7 @@ impl NodeCore {
secret_r, secret_r,
sc_addr, sc_addr,
state_changes, state_changes,
} },
.into(),
result_hashes, result_hashes,
)) ))
} }
@ -481,8 +479,7 @@ impl NodeCore {
secret_r, secret_r,
sc_addr, sc_addr,
state_changes, state_changes,
} },
.into(),
utxo_hashes, utxo_hashes,
)) ))
} }
@ -625,8 +622,7 @@ impl NodeCore {
secret_r, secret_r,
sc_addr, sc_addr,
state_changes, state_changes,
} },
.into(),
utxo_hashes_receiver, utxo_hashes_receiver,
utxo_hashes_not_spent, utxo_hashes_not_spent,
)) ))
@ -752,8 +748,7 @@ impl NodeCore {
secret_r, secret_r,
sc_addr, sc_addr,
state_changes, state_changes,
} },
.into(),
utxo_hashes, utxo_hashes,
)) ))
} }
@ -837,8 +832,7 @@ impl NodeCore {
secret_r, secret_r,
sc_addr, sc_addr,
state_changes, state_changes,
} })
.into())
} }
pub async fn send_private_mint_tx( pub async fn send_private_mint_tx(
@ -932,8 +926,7 @@ impl NodeCore {
secret_r, secret_r,
sc_addr, sc_addr,
state_changes, state_changes,
) );
.into();
tx.log(); tx.log();
Ok(self.sequencer_client.send_tx(tx, tx_roots).await?) Ok(self.sequencer_client.send_tx(tx, tx_roots).await?)
@ -1475,8 +1468,7 @@ impl NodeCore {
secret_r, secret_r,
sc_addr, sc_addr,
state_changes, state_changes,
} },
.into(),
utxo_hashes, utxo_hashes,
)) ))
} }

View File

@ -77,7 +77,6 @@ impl SequencerCore {
tx_roots: [[u8; 32]; 2], tx_roots: [[u8; 32]; 2],
) -> Result<(), TransactionMalformationErrorKind> { ) -> Result<(), TransactionMalformationErrorKind> {
let Transaction { let Transaction {
hash,
tx_kind, tx_kind,
ref execution_input, ref execution_input,
ref execution_output, ref execution_output,
@ -85,11 +84,12 @@ impl SequencerCore {
ref nullifier_created_hashes, ref nullifier_created_hashes,
.. ..
} = tx; } = tx;
let hash = tx.hash();
let mempool_size = self.mempool.len(); let mempool_size = self.mempool.len();
if mempool_size >= self.sequencer_config.max_num_tx_in_block { 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(); let curr_sequencer_roots = self.get_tree_roots();
@ -97,7 +97,7 @@ impl SequencerCore {
if tx_roots != curr_sequencer_roots { if tx_roots != curr_sequencer_roots {
return Err( return Err(
TransactionMalformationErrorKind::ChainStateFurtherThanTransactionState { TransactionMalformationErrorKind::ChainStateFurtherThanTransactionState {
tx: *hash, tx: hash,
}, },
); );
} }
@ -111,7 +111,7 @@ impl SequencerCore {
//Public transactions can not make private operations. //Public transactions can not make private operations.
return Err( return Err(
TransactionMalformationErrorKind::PublicTransactionChangedPrivateData { TransactionMalformationErrorKind::PublicTransactionChangedPrivateData {
tx: *hash, tx: hash,
}, },
); );
} }
@ -123,7 +123,7 @@ impl SequencerCore {
//between public and private state. //between public and private state.
return Err( return Err(
TransactionMalformationErrorKind::PrivateTransactionChangedPublicData { TransactionMalformationErrorKind::PrivateTransactionChangedPublicData {
tx: *hash, tx: hash,
}, },
); );
} }
@ -132,7 +132,7 @@ impl SequencerCore {
}; };
//Tree checks //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| { let nullifier_tree_check = nullifier_created_hashes.iter().any(|nullifier_hash| {
self.store.nullifier_store.contains(&UTXONullifier { self.store.nullifier_store.contains(&UTXONullifier {
utxo_hash: *nullifier_hash, utxo_hash: *nullifier_hash,
@ -149,18 +149,18 @@ impl SequencerCore {
}); });
if tx_tree_check { if tx_tree_check {
return Err(TransactionMalformationErrorKind::TxHashAlreadyPresentInTree { tx: *hash }); return Err(TransactionMalformationErrorKind::TxHashAlreadyPresentInTree { tx: hash });
} }
if nullifier_tree_check { if nullifier_tree_check {
return Err( return Err(
TransactionMalformationErrorKind::NullifierAlreadyPresentInTree { tx: *hash }, TransactionMalformationErrorKind::NullifierAlreadyPresentInTree { tx: hash },
); );
} }
if utxo_commitments_check { if utxo_commitments_check {
return Err( return Err(
TransactionMalformationErrorKind::UTXOCommitmentAlreadyPresentInTree { tx: *hash }, TransactionMalformationErrorKind::UTXOCommitmentAlreadyPresentInTree { tx: hash },
); );
} }
@ -184,8 +184,6 @@ impl SequencerCore {
tx: TransactionMempool, tx: TransactionMempool,
) -> Result<(), TransactionMalformationErrorKind> { ) -> Result<(), TransactionMalformationErrorKind> {
let Transaction { let Transaction {
// ToDo: remove hashing of transactions on node side [Issue #66]
hash: _,
ref utxo_commitments_created_hashes, ref utxo_commitments_created_hashes,
ref nullifier_created_hashes, ref nullifier_created_hashes,
.. ..
@ -298,7 +296,6 @@ mod tests {
} }
fn create_dummy_transaction( fn create_dummy_transaction(
hash: TreeHashType,
nullifier_created_hashes: Vec<[u8; 32]>, nullifier_created_hashes: Vec<[u8; 32]>,
utxo_commitments_spent_hashes: Vec<[u8; 32]>, utxo_commitments_spent_hashes: Vec<[u8; 32]>,
utxo_commitments_created_hashes: Vec<[u8; 32]>, utxo_commitments_created_hashes: Vec<[u8; 32]>,
@ -306,7 +303,6 @@ mod tests {
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
Transaction { Transaction {
hash,
tx_kind: TxKind::Private, tx_kind: TxKind::Private,
execution_input: vec![], execution_input: vec![],
execution_output: vec![], execution_output: vec![],
@ -325,7 +321,7 @@ mod tests {
} }
fn common_setup(sequencer: &mut SequencerCore) { 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 }; let tx_mempool = TransactionMempool { tx };
sequencer.mempool.push_item(tx_mempool); sequencer.mempool.push_item(tx_mempool);
@ -447,7 +443,7 @@ mod tests {
common_setup(&mut sequencer); 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 tx_roots = sequencer.get_tree_roots();
let result = sequencer.transaction_pre_check(&tx, tx_roots); let result = sequencer.transaction_pre_check(&tx, tx_roots);
@ -464,7 +460,7 @@ mod tests {
common_setup(&mut sequencer); 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(); let tx_roots = sequencer.get_tree_roots();
// Fill the mempool // Fill the mempool
@ -486,7 +482,7 @@ mod tests {
common_setup(&mut sequencer); 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_roots = sequencer.get_tree_roots();
let tx_mempool = TransactionMempool { tx }; let tx_mempool = TransactionMempool { tx };
@ -500,7 +496,7 @@ mod tests {
let config = setup_sequencer_config(); let config = setup_sequencer_config();
let mut sequencer = SequencerCore::start_from_config(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 }; let tx_mempool = TransactionMempool { tx };
sequencer.mempool.push_item(tx_mempool); sequencer.mempool.push_item(tx_mempool);