Skip to content
Draft
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
7 changes: 7 additions & 0 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion bin/florestad/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ fn main() {
let _rt = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.worker_threads(4)
.max_blocking_threads(2)
.thread_keep_alive(Duration::from_secs(60))
.thread_name("florestad")
.build()
Expand Down
10 changes: 7 additions & 3 deletions crates/floresta-chain/benches/chain_state_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ use floresta_chain::FlatChainStore;
use floresta_chain::FlatChainStoreConfig;
use rustreexo::accumulator::proof::Proof;

/// Reads the first 151 blocks (or 150 blocks on top of genesis) from blocks.txt, which are regtest
/// Reads the first 151 blocks (or 150 blocks on top of genesis) from `regtest_blocks.txt`
fn read_blocks_txt() -> Vec<Block> {
let blocks: Vec<_> = include_str!("../testdata/blocks.txt")
let blocks: Vec<_> = include_str!("../testdata/regtest_blocks.txt")
.lines()
.take(151)
.map(|b| deserialize(&hex::decode(b).unwrap()).unwrap())
.collect();

assert_eq!(blocks.len(), 151, "Expected 151 blocks in blocks.txt");
assert_eq!(
blocks.len(),
151,
"Expected 151 blocks in regtest_blocks.txt"
);
blocks
}

Expand Down
1 change: 1 addition & 0 deletions crates/floresta-chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub(crate) use floresta_common::prelude;
pub use pruned_utreexo::chain_state::*;
pub use pruned_utreexo::chainparams::*;
pub use pruned_utreexo::chainstore::*;
pub use pruned_utreexo::consensus::swift_sync_agg;
pub use pruned_utreexo::error::*;
#[cfg(feature = "flat-chainstore")]
pub use pruned_utreexo::flat_chain_store::*;
Expand Down
24 changes: 15 additions & 9 deletions crates/floresta-chain/src/pruned_utreexo/chain_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,23 +1172,29 @@ impl<PersistedState: ChainStore> UpdatableChainstate for ChainState<PersistedSta
acc: Stump,
assumed_hash: BlockHash,
) -> Result<bool, BlockchainError> {
let mut curr_header = self.get_disk_block_header(&assumed_hash)?;
let assumed_header = self.get_disk_block_header(&assumed_hash)?;

while let Ok(header) = self.get_disk_block_header(&curr_header.block_hash()) {
let mut header = assumed_header;
let mut hash = assumed_hash;
loop {
if self.is_genesis(&header) {
break;
}

let height = header.try_height()?;
self.update_header(&DiskBlockHeader::FullyValid(*header, height))?;
curr_header = self.get_ancestor(&header)?;
}
self.update_header_and_index(
&DiskBlockHeader::FullyValid(*header, height),
hash,
height,
)?;

self.update_view(curr_header.try_height()?, &curr_header, acc.clone())?;
// Move to the previous block
header = self.get_ancestor(&header)?;
hash = header.block_hash();
}

let mut guard = write_lock!(self);
guard.best_block.validation_index = assumed_hash;
guard.acc = acc;
// Update the tip and accumulator data with our assumed tip
self.update_view(assumed_header.try_height()?, &assumed_header, acc)?;

Ok(true)
}
Expand Down
Loading
Loading