From 811b9c56d9ce2f8f74e752eabaa29c22bec18425 Mon Sep 17 00:00:00 2001 From: James Piechota Date: Thu, 7 Nov 2024 22:53:02 +0000 Subject: [PATCH] fixup! feat: Introduce tool to verify a storage module --- apps/arweave/src/ar_verify_chunks.erl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/arweave/src/ar_verify_chunks.erl b/apps/arweave/src/ar_verify_chunks.erl index 9c264be16..8908fe8d2 100644 --- a/apps/arweave/src/ar_verify_chunks.erl +++ b/apps/arweave/src/ar_verify_chunks.erl @@ -107,7 +107,7 @@ verify_chunks({End, _Start}, _Intervals, #state{cursor = Cursor} = State) when C verify_chunks({IntervalEnd, IntervalStart}, Intervals, State) -> #state{cursor = Cursor, store_id = StoreID} = State, Cursor2 = max(IntervalStart, Cursor), - ChunkData = ar_data_sync:get_chunk_by_byte({chunks_index, StoreID}, Cursor2+1), + ChunkData = ar_data_sync:get_chunk_by_byte({chunks_index, StoreID}, Cursor2), State2 = verify_chunk(ChunkData, Intervals, State#state{ cursor = Cursor2 }), verify_chunks({IntervalEnd, IntervalStart}, Intervals, State2). @@ -119,11 +119,12 @@ verify_chunk({ok, _Key, MetaData}, Intervals, State) -> _TXRelativeOffset, ChunkSize} = MetaData, {ChunkStorageInterval, _DataSyncInterval} = Intervals, - State2 = verify_chunk_storage(AbsoluteOffset, ChunkSize, ChunkStorageInterval, State), + PaddedOffset = ar_data_sync:get_chunk_padded_offset(AbsoluteOffset), + State2 = verify_chunk_storage(PaddedOffset, ChunkSize, ChunkStorageInterval, State), State3 = verify_proof(MetaData, State2), - PaddedOffset = ar_data_sync:get_chunk_padded_offset(AbsoluteOffset), + State3#state{ cursor = PaddedOffset }. verify_proof(MetaData, State) -> @@ -144,14 +145,14 @@ verify_proof(MetaData, State) -> read_data_path_error, AbsoluteOffset, ChunkSize, [{reason, Error}], State) end. -verify_chunk_storage(Offset, _ChunkSize, {End, Start}, State) - when Offset - ?DATA_CHUNK_SIZE >= Start andalso Offset =< End -> +verify_chunk_storage(PaddedOffset, _ChunkSize, {End, Start}, State) + when PaddedOffset - ?DATA_CHUNK_SIZE >= Start andalso PaddedOffset =< End -> State; -verify_chunk_storage(Offset, ChunkSize, _Interval, State) -> +verify_chunk_storage(PaddedOffset, ChunkSize, _Interval, State) -> #state{ packing = Packing } = State, - case ar_data_sync:should_store_in_chunk_storage(Offset, ChunkSize, Packing) of + case ar_data_sync:should_store_in_chunk_storage(PaddedOffset, ChunkSize, Packing) of true -> - invalidate_chunk(chunk_storage_gap, Offset, ChunkSize, State); + invalidate_chunk(chunk_storage_gap, PaddedOffset, ChunkSize, State); false -> State end.