Skip to content

Commit c6d4dce

Browse files
committed
Adding chunk validation
1 parent eeb1783 commit c6d4dce

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

rskj-core/src/main/java/co/rsk/net/SnapshotProcessor.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,10 +792,9 @@ public void processStateChunkResponse(SnapSyncState state, Peer sender, SnapStat
792792
peersInformation.processSyncingError(sender, EventType.INVALID_STATE_CHUNK, "Received empty state chunk from peer: [{}] for block: [{}]", sender.getPeerNodeID(), lastBlock.getHash());
793793
return;
794794
}
795-
// TODO -> Change this to check that the chunk is exactly the expected size (being aware of heiht)
796-
if (keyValues.size() > TrieChunk.MAX_CHUNK_SIZE) {
797-
logger.error("Received state chunk with [{}] items, exceeding maximum allowed size of [{}] for block: [{}]", keyValues.size(), TrieChunk.MAX_CHUNK_SIZE, lastBlock.getHash());
798-
peersInformation.processSyncingError(sender, EventType.INVALID_STATE_CHUNK, "Received state chunk with [{}] items, exceeding maximum allowed size of [{}] for block: [{}]", keyValues.size(), TrieChunk.MAX_CHUNK_SIZE, lastBlock.getHash());
795+
if (keyValues.size() != TrieChunk.MAX_CHUNK_SIZE) {
796+
logger.error("Received state chunk with [{}] items. Chunk size required size [{}] for block: [{}]", keyValues.size(), TrieChunk.MAX_CHUNK_SIZE, lastBlock.getHash());
797+
peersInformation.processSyncingError(sender, EventType.INVALID_STATE_CHUNK, "Received state chunk with [{}] items. Chunk size required size [{}] for block: [{}]", keyValues.size(), TrieChunk.MAX_CHUNK_SIZE, lastBlock.getHash());
799798
return;
800799
}
801800

0 commit comments

Comments
 (0)