Skip to content

Commit

Permalink
fix: fix a repack_in_place regression I'd introduced earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesPiechota committed Jan 9, 2025
1 parent 1c4a6d7 commit e5889b5
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 120 deletions.
15 changes: 14 additions & 1 deletion apps/arweave/e2e/ar_e2e.erl
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,17 @@ start_source_node(Node, unpacked, _WalletFixture) ->
storage_modules = StorageModules,
auto_join = true
}, true),

ar_e2e:assert_partition_size(Node, 0, unpacked, ?PARTITION_SIZE),
ar_e2e:assert_partition_size(Node, 1, unpacked, ?PARTITION_SIZE),

ar_e2e:assert_syncs_range(Node, ?PARTITION_SIZE, 2*?PARTITION_SIZE),
ar_e2e:assert_chunks(Node, unpacked, Chunks),
ar_test_node:stop(TempNode),
{Blocks, undefined, Chunks};
start_source_node(Node, PackingType, WalletFixture) ->
?LOG_INFO("Starting source node ~p with packing type ~p and wallet fixture ~p",
[Node, PackingType, WalletFixture]),
{Wallet, StorageModules} = source_node_storage_modules(Node, PackingType, WalletFixture),
RewardAddr = ar_wallet:to_address(Wallet),
[B0] = ar_weave:init([{RewardAddr, ?AR(200), <<>>}], 0, ?PARTITION_SIZE),
Expand Down Expand Up @@ -127,11 +133,18 @@ start_source_node(Node, PackingType, WalletFixture) ->
{B3, ?PARTITION_SIZE + (8*?DATA_CHUNK_SIZE), ?DATA_CHUNK_SIZE}
],

?LOG_INFO("Source node ~p started.", [Node]),

SourcePacking = ar_e2e:packing_type_to_packing(PackingType, RewardAddr),
ar_e2e:assert_syncs_range(Node, ?PARTITION_SIZE, 2*?PARTITION_SIZE),

ar_e2e:assert_partition_size(Node, 0, SourcePacking, ?PARTITION_SIZE),
ar_e2e:assert_partition_size(Node, 1, SourcePacking, ?PARTITION_SIZE),

ar_e2e:assert_syncs_range(Node, ?PARTITION_SIZE, 2*?PARTITION_SIZE),
ar_e2e:assert_chunks(Node, SourcePacking, Chunks),

?LOG_INFO("Source node ~p assertions passed.", [Node]),

{[B0, B1, B2, B3, B4, B5], RewardAddr, Chunks}.

max_chunk_offset(Chunks) ->
Expand Down
20 changes: 11 additions & 9 deletions apps/arweave/e2e/ar_repack_in_place_mine_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
%% --------------------------------------------------------------------------------------------
repack_in_place_mine_test_() ->
[
% {timeout, 300, {with, {unpacked, spora_2_6}, [fun test_repack_in_place_mine/1]}},
% {timeout, 300, {with, {unpacked, composite_1}, [fun test_repack_in_place_mine/1]}},
% {timeout, 300, {with, {unpacked, composite_2}, [fun test_repack_in_place_mine/1]}},
% XXX {timeout, 300, {with, {unpacked, spora_2_6}, [fun test_repack_in_place_mine/1]}},
% XXX {timeout, 300, {with, {unpacked, composite_1}, [fun test_repack_in_place_mine/1]}},
% XXX {timeout, 300, {with, {unpacked, composite_2}, [fun test_repack_in_place_mine/1]}},
{timeout, 300, {with, {spora_2_6, spora_2_6}, [fun test_repack_in_place_mine/1]}},
{timeout, 300, {with, {spora_2_6, composite_1}, [fun test_repack_in_place_mine/1]}},
{timeout, 300, {with, {spora_2_6, composite_2}, [fun test_repack_in_place_mine/1]}},
% {timeout, 300, {with, {spora_2_6, unpacked}, [fun test_repack_in_place_mine/1]}},
% % XXX {timeout, 300, {with, {spora_2_6, unpacked}, [fun test_repack_in_place_mine/1]}},
{timeout, 300, {with, {composite_1, spora_2_6}, [fun test_repack_in_place_mine/1]}},
{timeout, 300, {with, {composite_1, composite_1}, [fun test_repack_in_place_mine/1]}},
{timeout, 300, {with, {composite_1, composite_2}, [fun test_repack_in_place_mine/1]}},
% {timeout, 300, {with, {composite_1, unpacked}, [fun test_repack_in_place_mine/1]}},
% % XXX {timeout, 300, {with, {composite_1, unpacked}, [fun test_repack_in_place_mine/1]}},
{timeout, 300, {with, {composite_2, spora_2_6}, [fun test_repack_in_place_mine/1]}},
{timeout, 300, {with, {composite_2, composite_1}, [fun test_repack_in_place_mine/1]}},
{timeout, 300, {with, {composite_2, composite_2}, [fun test_repack_in_place_mine/1]}}
% {timeout, 300, {with, {composite_2, unpacked}, [fun test_repack_in_place_mine/1]}}
% % XXX {timeout, 300, {with, {composite_2, unpacked}, [fun test_repack_in_place_mine/1]}}
].

%% --------------------------------------------------------------------------------------------
Expand All @@ -39,17 +39,18 @@ test_repack_in_place_mine({FromPackingType, ToPackingType}) ->
[B0 | _] = Blocks,
start_validator_node(ValidatorNode, RepackerNode, B0),

{WalletB, FinalStorageModules} = ar_e2e:source_node_storage_modules(
{WalletB, SourceStorageModules} = ar_e2e:source_node_storage_modules(
RepackerNode, ToPackingType, wallet_b),
AddrB = case WalletB of
undefined -> undefined;
_ -> ar_wallet:to_address(WalletB)
end,
FinalStorageModules = lists:sublist(SourceStorageModules, 2),
ToPacking = ar_e2e:packing_type_to_packing(ToPackingType, AddrB),
{ok, Config} = ar_test_node:get_config(RepackerNode),

RepackInPlaceStorageModules = [
{Module, ToPacking} || Module <- Config#config.storage_modules ],
RepackInPlaceStorageModules = lists:sublist([
{Module, ToPacking} || Module <- Config#config.storage_modules ], 2),

ar_test_node:update_config(RepackerNode, Config#config{
storage_modules = [],
Expand All @@ -58,6 +59,7 @@ test_repack_in_place_mine({FromPackingType, ToPackingType}) ->
}),
ar_test_node:restart(RepackerNode),

ar_e2e:assert_partition_size(RepackerNode, 0, ToPacking, ?PARTITION_SIZE),
ar_e2e:assert_partition_size(RepackerNode, 1, ToPacking, ?PARTITION_SIZE),

ar_test_node:stop(RepackerNode),
Expand Down
92 changes: 46 additions & 46 deletions apps/arweave/e2e/ar_sync_pack_mine_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ instantiator(GenesisData, SinkPackingType, TestFun) ->
%% Test Registration
%% --------------------------------------------------------------------------------------------

replica_2_9_block_sync_test_() ->
{setup, fun () -> setup_source_node(replica_2_9) end,
fun (GenesisData) ->
[
instantiator(GenesisData, replica_2_9, fun test_syncing_blocked/1),
instantiator(GenesisData, spora_2_6, fun test_syncing_blocked/1),
instantiator(GenesisData, composite_1, fun test_syncing_blocked/1),
instantiator(GenesisData, composite_2, fun test_syncing_blocked/1),
instantiator(GenesisData, unpacked, fun test_syncing_blocked/1)
]
end}.
% replica_2_9_block_sync_test_() ->
% {setup, fun () -> setup_source_node(replica_2_9) end,
% fun (GenesisData) ->
% [
% instantiator(GenesisData, replica_2_9, fun test_syncing_blocked/1),
% instantiator(GenesisData, spora_2_6, fun test_syncing_blocked/1),
% instantiator(GenesisData, composite_1, fun test_syncing_blocked/1),
% instantiator(GenesisData, composite_2, fun test_syncing_blocked/1),
% instantiator(GenesisData, unpacked, fun test_syncing_blocked/1)
% ]
% end}.

spora_2_6_sync_pack_mine_test_() ->
{setup, fun () -> setup_source_node(spora_2_6) end,
Expand All @@ -47,41 +47,41 @@ spora_2_6_sync_pack_mine_test_() ->
]
end}.

composite_1_sync_pack_mine_test_() ->
{setup, fun () -> setup_source_node(composite_1) end,
fun (GenesisData) ->
[
instantiator(GenesisData, replica_2_9, fun test_sync_pack_mine/1),
instantiator(GenesisData, spora_2_6, fun test_sync_pack_mine/1),
instantiator(GenesisData, composite_1, fun test_sync_pack_mine/1),
instantiator(GenesisData, composite_2, fun test_sync_pack_mine/1),
instantiator(GenesisData, unpacked, fun test_sync_pack_mine/1)
]
end}.

composite_2_sync_pack_mine_test_() ->
{setup, fun () -> setup_source_node(composite_2) end,
fun (GenesisData) ->
[
instantiator(GenesisData, replica_2_9, fun test_sync_pack_mine/1),
instantiator(GenesisData, spora_2_6, fun test_sync_pack_mine/1),
instantiator(GenesisData, composite_1, fun test_sync_pack_mine/1),
instantiator(GenesisData, composite_2, fun test_sync_pack_mine/1),
instantiator(GenesisData, unpacked, fun test_sync_pack_mine/1)
]
end}.

unpacked_sync_pack_mine_test_() ->
{setup, fun () -> setup_source_node(unpacked) end,
fun (GenesisData) ->
[
instantiator(GenesisData, replica_2_9, fun test_sync_pack_mine/1),
instantiator(GenesisData, spora_2_6, fun test_sync_pack_mine/1),
instantiator(GenesisData, composite_1, fun test_sync_pack_mine/1),
instantiator(GenesisData, composite_2, fun test_sync_pack_mine/1),
instantiator(GenesisData, unpacked, fun test_sync_pack_mine/1)
]
end}.
% composite_1_sync_pack_mine_test_() ->
% {setup, fun () -> setup_source_node(composite_1) end,
% fun (GenesisData) ->
% [
% instantiator(GenesisData, replica_2_9, fun test_sync_pack_mine/1),
% instantiator(GenesisData, spora_2_6, fun test_sync_pack_mine/1),
% instantiator(GenesisData, composite_1, fun test_sync_pack_mine/1),
% instantiator(GenesisData, composite_2, fun test_sync_pack_mine/1),
% instantiator(GenesisData, unpacked, fun test_sync_pack_mine/1)
% ]
% end}.

% composite_2_sync_pack_mine_test_() ->
% {setup, fun () -> setup_source_node(composite_2) end,
% fun (GenesisData) ->
% [
% instantiator(GenesisData, replica_2_9, fun test_sync_pack_mine/1),
% instantiator(GenesisData, spora_2_6, fun test_sync_pack_mine/1),
% instantiator(GenesisData, composite_1, fun test_sync_pack_mine/1),
% instantiator(GenesisData, composite_2, fun test_sync_pack_mine/1),
% instantiator(GenesisData, unpacked, fun test_sync_pack_mine/1)
% ]
% end}.

% unpacked_sync_pack_mine_test_() ->
% {setup, fun () -> setup_source_node(unpacked) end,
% fun (GenesisData) ->
% [
% instantiator(GenesisData, replica_2_9, fun test_sync_pack_mine/1),
% instantiator(GenesisData, spora_2_6, fun test_sync_pack_mine/1),
% instantiator(GenesisData, composite_1, fun test_sync_pack_mine/1),
% instantiator(GenesisData, composite_2, fun test_sync_pack_mine/1),
% instantiator(GenesisData, unpacked, fun test_sync_pack_mine/1)
% ]
% end}.

%% --------------------------------------------------------------------------------------------
%% test_sync_pack_mine
Expand Down
Loading

0 comments on commit e5889b5

Please sign in to comment.