Skip to content

Commit

Permalink
Merge branch 'development' into comms-peer-manager-signed-peers
Browse files Browse the repository at this point in the history
* development:
  feat(consensus)!: add tari script byte size limit check to validation (tari-project#3640)
  fix: minor improvements to available neighbouring peer search (tari-project#3598)
  feat: bad block list for invalid blocks after sync (tari-project#3637)
  • Loading branch information
sdbondi committed Dec 7, 2021
2 parents 47f2a22 + 53a5174 commit 0b11c19
Show file tree
Hide file tree
Showing 57 changed files with 1,124 additions and 654 deletions.
104 changes: 46 additions & 58 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion applications/tari_base_node/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ async fn build_node_context(
let factories = CryptoFactories::default();
let randomx_factory = RandomXFactory::new(config.max_randomx_vms);
let validators = Validators::new(
BodyOnlyValidator::default(),
BodyOnlyValidator::new(rules.clone()),
HeaderValidator::new(rules.clone()),
OrphanBlockValidator::new(
rules.clone(),
Expand Down
1 change: 1 addition & 0 deletions applications/tari_base_node/src/command_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ impl CommandHandler {
s.push(format!(
"LAST_SEEN = {}",
Utc::now()
.naive_utc()
.signed_duration_since(dt)
.to_std()
.map(format_duration_basic)
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_base_node/src/recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub async fn run_recovery(node_config: &GlobalConfig) -> Result<(), anyhow::Erro
let factories = CryptoFactories::default();
let randomx_factory = RandomXFactory::new(node_config.max_randomx_vms);
let validators = Validators::new(
BodyOnlyValidator::default(),
BodyOnlyValidator::new(rules.clone()),
HeaderValidator::new(rules.clone()),
OrphanBlockValidator::new(
rules.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ pub enum HorizonSyncError {
MerkleMountainRangeError(#[from] MerkleMountainRangeError),
#[error("Connectivity error: {0}")]
ConnectivityError(#[from] ConnectivityError),
#[error("Validation error: {0}")]
ValidationError(#[from] ValidationError),
}

impl From<TryFromIntError> for HorizonSyncError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use crate::{
transaction_kernel::TransactionKernel,
transaction_output::TransactionOutput,
},
validation::helpers,
};
use croaring::Bitmap;
use futures::{stream::FuturesUnordered, StreamExt};
Expand Down Expand Up @@ -374,6 +375,11 @@ impl<'a, B: BlockchainBackend + 'static> HorizonStateSynchronization<'a, B> {

let mut output_mmr = MerkleMountainRange::<HashDigest, _>::new(output_pruned_set);
let mut witness_mmr = MerkleMountainRange::<HashDigest, _>::new(witness_pruned_set);
let mut constants = self
.shared
.consensus_rules
.consensus_constants(current_header.height())
.clone();

while let Some(response) = output_stream.next().await {
let res: SyncUtxosResponse = response?;
Expand Down Expand Up @@ -401,6 +407,7 @@ impl<'a, B: BlockchainBackend + 'static> HorizonStateSynchronization<'a, B> {
);
height_utxo_counter += 1;
let output = TransactionOutput::try_from(output).map_err(HorizonSyncError::ConversionError)?;
helpers::check_tari_script_byte_size(&output.script, constants.get_max_script_byte_size())?;
unpruned_outputs.push(output.clone());

output_mmr.push(output.hash())?;
Expand Down Expand Up @@ -535,6 +542,11 @@ impl<'a, B: BlockchainBackend + 'static> HorizonStateSynchronization<'a, B> {
break;
} else {
current_header = db.fetch_chain_header(current_header.height() + 1).await?;
constants = self
.shared
.consensus_rules
.consensus_constants(current_header.height())
.clone();
debug!(
target: LOG_TARGET,
"Expecting to receive the next UTXO set {}-{} for header #{}",
Expand Down
Loading

0 comments on commit 0b11c19

Please sign in to comment.