Skip to content

Commit

Permalink
Add more info in chunk validation error (#13069)
Browse files Browse the repository at this point in the history
Add more information to the error message that's printed when chunk
validation fails. Will make it easier to pinpoint which chunk producer
created the invalid chunk witness.
  • Loading branch information
jancionear authored Mar 7, 2025
1 parent 48fcab9 commit 411ac9b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions chain/client/src/stateless_validation/chunk_validator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use near_epoch_manager::shard_assignment::shard_id_to_uid;
use near_network::types::{NetworkRequests, PeerManagerMessageRequest};
use near_o11y::log_assert;
use near_primitives::sharding::ShardChunkHeader;
use near_primitives::stateless_validation::ChunkProductionKey;
use near_primitives::stateless_validation::chunk_endorsement::ChunkEndorsement;
use near_primitives::stateless_validation::state_witness::{
ChunkStateWitness, ChunkStateWitnessAck, ChunkStateWitnessSize,
Expand Down Expand Up @@ -109,6 +110,14 @@ impl ChunkValidator {
let last_header =
Chain::get_prev_chunk_header(epoch_manager.as_ref(), &prev_block, shard_id)?;

let chunk_production_key = ChunkProductionKey {
shard_id,
epoch_id,
height_created: chunk_header.height_created(),
};
let chunk_producer_name =
epoch_manager.get_chunk_producer_info(&chunk_production_key)?.take_account_id();

if let Ok(prev_chunk_extra) = chain.get_chunk_extra(prev_block_hash, &shard_uid) {
match validate_chunk_with_chunk_extra(
chain.chain_store(),
Expand All @@ -131,6 +140,8 @@ impl ChunkValidator {
tracing::error!(
target: "client",
?err,
?chunk_producer_name,
?chunk_production_key,
"Failed to validate chunk using existing chunk extra",
);
near_chain::stateless_validation::metrics::CHUNK_WITNESS_VALIDATION_FAILED_TOTAL
Expand Down Expand Up @@ -171,6 +182,8 @@ impl ChunkValidator {
tracing::error!(
target: "client",
?err,
?chunk_producer_name,
?chunk_production_key,
"Failed to validate chunk"
);
}
Expand Down

0 comments on commit 411ac9b

Please sign in to comment.