Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Longarithm committed Oct 11, 2024
1 parent 3abff05 commit d00943d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 4 additions & 2 deletions chain/chain/src/stateless_validation/chunk_endorsement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ pub fn validate_chunk_endorsements_in_block(
let epoch_id = epoch_manager.get_epoch_id_from_prev_block(block.header().prev_hash())?;
let shard_layout = epoch_manager.get_shard_layout(&epoch_id)?;
for (chunk_header, signatures) in block.chunks().iter().zip(block.chunk_endorsements()) {
let shard_id = chunk_header.shard_id();
let shard_index = shard_layout.get_shard_index(shard_id);
// For old chunks, we optimize the block by not including the chunk endorsements.
if chunk_header.height_included() != block.header().height() {
if !signatures.is_empty() {
Expand All @@ -60,8 +58,12 @@ pub fn validate_chunk_endorsements_in_block(
}
continue;
}

// Validation for chunks in each shard
// The signatures from chunk validators for each shard must match the ordered_chunk_validators
let shard_id = chunk_header.shard_id();
let shard_index = shard_layout.get_shard_index(shard_id);

let chunk_validator_assignments = epoch_manager.get_chunk_validator_assignments(
&epoch_id,
shard_id,
Expand Down
11 changes: 7 additions & 4 deletions integration-tests/src/test_loop/tests/resharding_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ fn test_resharding_v3() {
let mut shards_split_map: BTreeMap<ShardId, Vec<ShardId>> =
shard_ids.iter().map(|shard_id| (*shard_id, vec![*shard_id])).collect();
// TODO(#11881): keep this way until non-contiguous shard ids are supported.
// let new_shards = vec![max_shard_id + 1, max_shard_id + 2];
let new_shards = vec![max_shard_id, max_shard_id + 1];
let new_shards = vec![max_shard_id + 1, max_shard_id + 2];
// let new_shards = vec![max_shard_id, max_shard_id + 1];
shard_ids.extend(new_shards.clone());
shards_split_map.insert(last_shard_id, new_shards);
boundary_accounts.push(AccountId::try_from("account6".to_string()).unwrap());
Expand Down Expand Up @@ -120,7 +120,7 @@ fn test_resharding_v3() {
.collect_vec()
);

for shard_id in shard_ids.clone() {
for shard_id in 0..4 {
let shard_uid = ShardUId { version: 3, shard_id: shard_id as u32 };
let Ok(chunk_extra) =
client.chain.get_chunk_extra(&tip.prev_block_hash, &shard_uid)
Expand Down Expand Up @@ -155,7 +155,10 @@ fn test_resharding_v3() {
}
// Check that all chunks are included.
let block_header = client.chain.get_block_header(&tip.last_block_hash).unwrap();
assert!(block_header.chunk_mask().iter().all(|chunk_bit| *chunk_bit));
if !block_header.chunk_mask().iter().all(|chunk_bit| *chunk_bit) {
println!("chunk mask: {:?}", block_header.chunk_mask());
assert!(false);
}

// Return true if we passed an epoch with increased number of shards.
let epoch_height =
Expand Down

0 comments on commit d00943d

Please sign in to comment.