Skip to content
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
30 changes: 15 additions & 15 deletions network/src/archive/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ pub async fn run(rpc: Arc<RpcClient>, mut rx: Rx, miner: Pubkey, store: Arc<Tape
packing_difficulty
)?;

// TODO: only update the canopy if this segment is the last for this sector
update_merkle_canopy_for_segment(
&store,
&miner,
&job.tape,
job.seg_no,
)?;

Ok(())
})
.await??;
Expand Down Expand Up @@ -95,11 +87,19 @@ pub fn pack_segment(
packed_segment.to_vec()
)?;

// TODO: only update the canopy if this segment is the last for this sector
update_merkle_canopy_for_segment(
&store,
miner_address,
tape_address,
segment_number,
)?;

Ok(())
}

/// Updates the Merkle canopy for the sector containing the specified segment.
pub fn update_merkle_canopy_for_segment(
fn update_merkle_canopy_for_segment(
store: &Arc<TapeStore>,
miner_address: &Pubkey,
tape_address: &Pubkey,
Expand All @@ -116,7 +116,7 @@ pub fn update_merkle_canopy_for_segment(
}

/// Updates the Merkle canopy for the provided sector number.
pub fn update_merkle_canopy_for_sector(
fn update_merkle_canopy_for_sector(
store: &Arc<TapeStore>,
miner_address: &Pubkey,
tape_address: &Pubkey,
Expand Down Expand Up @@ -215,7 +215,7 @@ pub fn get_tape_root(
}

/// Computes packed leaves (stored solution bytes).
pub fn compute_sector_leaves_packed(
fn compute_sector_leaves_packed(
store: &Arc<TapeStore>,
tape_address: &Pubkey,
sector_number: u64,
Expand All @@ -238,7 +238,7 @@ pub fn compute_sector_leaves_packed(
}

/// Computes unpacked leaves (reconstructed 128-byte data from solutions).
pub fn compute_sector_leaves_unpacked(
fn compute_sector_leaves_unpacked(
store: &Arc<TapeStore>,
miner_address: &Pubkey,
tape_address: &Pubkey,
Expand Down Expand Up @@ -270,7 +270,7 @@ pub fn compute_sector_leaves_unpacked(
}

/// Computes the root node for a sector at the specified layer.
pub fn compute_sector_root(
fn compute_sector_root(
leaves: &[Leaf],
empty_hashes: &[Hash],
) -> Result<Hash> {
Expand Down Expand Up @@ -299,7 +299,7 @@ pub fn compute_sector_root(
}

/// Helper to update a specific MerkleCacheKey layer with the new sector root.
pub fn update_sector_canopy_with_key(
fn update_sector_canopy_with_key(
store: &TapeStore,
sector_number: u64,
root: Hash,
Expand All @@ -320,7 +320,7 @@ pub fn update_sector_canopy_with_key(
}

/// Helper to create or init the zero values for a tape
pub fn get_or_create_empty_hashes(
fn get_or_create_empty_hashes(
store: &Arc<TapeStore>,
tape_address: &Pubkey,
) -> Result<Vec<Hash>> {
Expand Down
6 changes: 3 additions & 3 deletions network/src/archive/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ pub async fn sync_from_block(
let mut visited: HashSet<u64> = HashSet::new();
let mut stack: Vec<u64> = Vec::new();

let miner_bytes = miner_address.to_bytes();
let mem = Arc::new(packx::build_memory(&miner_bytes));

// Ensure the tape address is stored if finalized
let (tape, _) = get_tape_account(client, tape_address).await?;
if tape.state == u64::from(TapeState::Finalized) {
Expand Down Expand Up @@ -256,9 +259,6 @@ pub async fn sync_from_block(
.await
.map_err(|e| anyhow!("Failed to get epoch account: {}", e))?.0;

let miner_bytes = miner_address.to_bytes();
let mem = Arc::new(packx::build_memory(&miner_bytes));

for (key, data) in segment_writes {
if key.address != *tape_address {
continue;
Expand Down