Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: horizon sync #6197

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -651,35 +651,37 @@ impl<'a, B: BlockchainBackend + 'static> HorizonStateSynchronization<'a, B> {

let constants = self.rules.consensus_constants(current_header.height).clone();
let output = TransactionOutput::try_from(output).map_err(HorizonSyncError::ConversionError)?;
debug!(
target: LOG_TARGET,
"UTXO `{}` received from sync peer ({} of {})",
output.hash(),
utxo_counter,
self.num_outputs,
);
helpers::check_tari_script_byte_size(&output.script, constants.max_script_byte_size())?;

batch_verify_range_proofs(&self.prover, &[&output])?;
let smt_key = NodeKey::try_from(output.commitment.as_bytes())?;
let smt_node = ValueHash::try_from(output.smt_hash(current_header.height).as_slice())?;
if let Err(e) = output_smt.insert(smt_key, smt_node) {
error!(
if !output.is_burned() {
debug!(
target: LOG_TARGET,
"Output commitment({}) already in SMT",
output.commitment.to_hex(),
"UTXO `{}` received from sync peer ({} of {})",
output.hash(),
utxo_counter,
self.num_outputs,
);
return Err(e.into());
}
txn.insert_output_via_horizon_sync(
output,
current_header.hash(),
current_header.height,
current_header.timestamp.as_u64(),
);
helpers::check_tari_script_byte_size(&output.script, constants.max_script_byte_size())?;

// We have checked the range proof, and we have checked that the linked to header exists.
txn.commit().await?;
batch_verify_range_proofs(&self.prover, &[&output])?;
let smt_key = NodeKey::try_from(output.commitment.as_bytes())?;
let smt_node = ValueHash::try_from(output.smt_hash(current_header.height).as_slice())?;
if let Err(e) = output_smt.insert(smt_key, smt_node) {
error!(
target: LOG_TARGET,
"Output commitment({}) already in SMT",
output.commitment.to_hex(),
);
return Err(e.into());
}
txn.insert_output_via_horizon_sync(
output,
current_header.hash(),
current_header.height,
current_header.timestamp.as_u64(),
);

// We have checked the range proof, and we have checked that the linked to header exists.
txn.commit().await?;
}
},
Txo::Commitment(commitment_bytes) => {
stxo_counter += 1;
Expand Down
3 changes: 3 additions & 0 deletions base_layer/core/src/base_node/sync/rpc/sync_utxos_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ where B: BlockchainBackend + 'static

let mut outputs = Vec::with_capacity(outputs_with_statuses.len());
for (output, spent) in outputs_with_statuses {
if output.is_burned() {
continue;
}
if !spent {
match proto::types::TransactionOutput::try_from(output.clone()) {
Ok(tx_ouput) => {
Expand Down
Loading