diff --git a/apps/arweave/src/ar_chunk_storage.erl b/apps/arweave/src/ar_chunk_storage.erl index 2a91afc42..70bf711bb 100644 --- a/apps/arweave/src/ar_chunk_storage.erl +++ b/apps/arweave/src/ar_chunk_storage.erl @@ -288,7 +288,9 @@ get_chunk_storage_path(DataDir, StoreID) -> filename:join([get_storage_module_path(DataDir, StoreID), ?CHUNK_DIR]). %% @doc Return the start and end offset of the bucket containing the given offset. -%% A chunk bucket a 0-based, 256-KiB wide, 256-KiB aligned range that fully contains a chunk. +%% A chunk bucket is a 0-based, 256-KiB wide, 256-KiB aligned range that +%% ar_chunk_storage uses to index chunks. The bucket start does NOT necessarily +%% match the chunk's start offset. -spec get_chunk_bucket_start(Offset :: non_neg_integer()) -> non_neg_integer(). get_chunk_bucket_start(Offset) -> PaddedEndOffset = ar_block:get_chunk_padded_offset(Offset), diff --git a/apps/arweave/src/ar_entropy_storage.erl b/apps/arweave/src/ar_entropy_storage.erl index 0577a579d..4beeef9b8 100644 --- a/apps/arweave/src/ar_entropy_storage.erl +++ b/apps/arweave/src/ar_entropy_storage.erl @@ -310,14 +310,14 @@ record_entropy(ChunkEntropy, BucketEndOffset, StoreID, RewardAddr) -> Chunk = case IsUnpackedChunkRecorded of true -> - case ar_chunk_storage:get(Byte, Byte, StoreID) of + StartOffset = EndOffset - ?DATA_CHUNK_SIZE, + case ar_chunk_storage:get(Byte, StartOffset, StoreID) of not_found -> {error, not_found}; {error, _} = Error -> Error; {_, UnpackedChunk} -> - ar_sync_record:delete( - EndOffset, EndOffset - ?DATA_CHUNK_SIZE, ar_data_sync, StoreID), + ar_sync_record:delete(EndOffset, StartOffset, ar_data_sync, StoreID), ar_packing_server:encipher_replica_2_9_chunk(UnpackedChunk, ChunkEntropy) end; false ->