Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test/pack mine tests 2024115 #654

Draft
wants to merge 37 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d0765bf
feat: make the genesis data deterministic
JamesPiechota Nov 15, 2024
42dcb3c
feat: add support for an e2e test mode
JamesPiechota Nov 17, 2024
58acc43
fixup! feat: add support for an e2e test mode
JamesPiechota Nov 17, 2024
a316d37
fixup! feat: add support for an e2e test mode
JamesPiechota Nov 17, 2024
04afded
fixup! feat: add support for an e2e test mode
JamesPiechota Nov 17, 2024
c395413
WIP
JamesPiechota Nov 18, 2024
d36628e
fixup! feat: add support for an e2e test mode
JamesPiechota Nov 18, 2024
210a74f
fixup! feat: add support for an e2e test mode
JamesPiechota Nov 18, 2024
288c182
Basics of the e2e test
JamesPiechota Nov 18, 2024
37cabfe
fixup! Basics of the e2e test
JamesPiechota Nov 19, 2024
7cb353e
first full spora-spora sync test
JamesPiechota Nov 19, 2024
3afa7cf
multiple sync/pack/mine permutations
JamesPiechota Nov 20, 2024
d4bc0b3
Add wallet fixtures
JamesPiechota Nov 20, 2024
39a2abd
Add regression test to e2e test
JamesPiechota Nov 20, 2024
9994e30
Add unpacked->packed sync/pack/mine tests
JamesPiechota Nov 20, 2024
e87e1cb
Rename ar_pack_mine_tests to ar_sync_pack_mine_tests
JamesPiechota Nov 20, 2024
df8db45
refactor: move helpers into ar_e2e
JamesPiechota Nov 21, 2024
1a27688
First pass at repack_mine test
JamesPiechota Nov 21, 2024
c451eeb
repack_mine_tests are complete
JamesPiechota Nov 21, 2024
c09e523
fixup! repack_mine_tests are complete
JamesPiechota Nov 21, 2024
b684c6c
Get repack_mine_tests working
JamesPiechota Nov 21, 2024
8a80fdd
WIP
JamesPiechota Nov 22, 2024
73c0775
WIP
JamesPiechota Nov 24, 2024
f7fc71c
Try runnig with slower VDF on tests - maybe fixes some flakiness
JamesPiechota Nov 29, 2024
bd32945
Revert "Try runnig with slower VDF on tests - maybe fixes some flakin…
JamesPiechota Nov 29, 2024
d965071
Initialize poa caches for initial block cache blocks
vird Oct 26, 2024
4cf042c
Add Packing Difficulty in v2_index_data_size_by_packing (#649)
humaite Nov 28, 2024
61e39e0
feat: update ar_doctor_bench to use ar_mining_io
JamesPiechota Nov 27, 2024
04e98ae
fix: Run one io thread per os device rather than per storage module
JamesPiechota Nov 28, 2024
2262b46
Improve ar_tx_emitter performance
humaite Nov 28, 2024
9f42a13
Fix High Load Average on Transaction Interface
humaite Nov 25, 2024
e664ee6
fix: start_from_latest_state failed due to missing reward_history
JamesPiechota Nov 29, 2024
37720ef
fix: verify tool will advance past `invalid_iterator` error
JamesPiechota Nov 29, 2024
27c7e9a
fix: fix the broken mining report if there are two packings detected`
JamesPiechota Nov 29, 2024
3dd879e
fixup! fix: fix the broken mining report if there are two packings de…
JamesPiechota Nov 29, 2024
e6c1e4c
fixup! fix: fix the broken mining report if there are two packings de…
JamesPiechota Nov 29, 2024
4c7d0a3
WIP
JamesPiechota Dec 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Get repack_mine_tests working
  • Loading branch information
JamesPiechota committed Nov 29, 2024
commit b684c6c796d8ccaac6312219957fb6a4ccaed7a3
1 change: 0 additions & 1 deletion apps/arweave/e2e/ar_e2e.erl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ install_fixture(FilePath, FixtureType, FixtureName) ->

-spec load_wallet_fixture(atom()) -> tuple().
load_wallet_fixture(WalletFixture) ->
?debugFmt("Loading wallet fixture: ~p", [WalletFixture]),
WalletName = atom_to_list(WalletFixture),
FixtureDir = fixture_dir(wallets),
FixturePath = filename:join([FixtureDir, WalletName ++ ".json"]),
Expand Down
84 changes: 84 additions & 0 deletions apps/arweave/e2e/ar_repack_in_place_mine_tests.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
-module(ar_repack_in_place_mine_tests).

-include_lib("arweave/include/ar_config.hrl").
-include_lib("arweave/include/ar_consensus.hrl").
-include_lib("eunit/include/eunit.hrl").

%% --------------------------------------------------------------------------------------------
%% Test Registration
%% --------------------------------------------------------------------------------------------
repack_in_place_mine_test_() ->
[
{timeout, 300, {with, {spora_2_6, spora_2_6}, [fun test_repack_in_place_mine/1]}}
].

%% --------------------------------------------------------------------------------------------
%% test_repack_in_place_mine
%% --------------------------------------------------------------------------------------------
test_repack_in_place_mine({FromPackingType, ToPackingType}) ->
ar_e2e:delayed_print(<<" ~p -> ~p ">>, [FromPackingType, ToPackingType]),
ValidatorNode = peer1,
RepackerNode = peer2,
{Blocks, _AddrA, Chunks} = ar_e2e:start_source_node(
RepackerNode, FromPackingType, wallet_a),

[B0 | _] = Blocks,
start_validator_node(ValidatorNode, RepackerNode, B0),

{WalletB, FinalStorageModules} = ar_e2e:source_node_storage_modules(
RepackerNode, ToPackingType, wallet_b),
AddrB = case WalletB of
undefined -> undefined;
_ -> ar_wallet:to_address(WalletB)
end,
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 ],

ar_test_node:update_config(RepackerNode, Config#config{
storage_modules = [],
repack_in_place_storage_modules = RepackInPlaceStorageModules,
mining_addr = undefined
}),
ar_test_node:restart(RepackerNode),

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

ar_test_node:update_config(RepackerNode, Config#config{
storage_modules = FinalStorageModules,
repack_in_place_storage_modules = [],
mining_addr = AddrB
}),
ar_test_node:restart(RepackerNode),
ar_e2e:assert_chunks(RepackerNode, ToPacking, Chunks),

case ToPackingType of
unpacked ->
ok;
_ ->
CurrentHeight = ar_test_node:remote_call(RepackerNode, ar_node, get_height, []),
ar_test_node:mine(RepackerNode),

RepackerBI = ar_test_node:wait_until_height(RepackerNode, CurrentHeight + 1),
{ok, RepackerBlock} = ar_test_node:http_get_block(element(1, hd(RepackerBI)), RepackerNode),
ar_e2e:assert_block(ToPacking, RepackerBlock),

ValidatorBI = ar_test_node:wait_until_height(ValidatorNode, RepackerBlock#block.height),
{ok, ValidatorBlock} = ar_test_node:http_get_block(element(1, hd(ValidatorBI)), ValidatorNode),
?assertEqual(RepackerBlock, ValidatorBlock)
end.


start_validator_node(ValidatorNode, RepackerNode, B0) ->
{ok, Config} = ar_test_node:get_config(ValidatorNode),
?assertEqual(ar_test_node:peer_name(ValidatorNode),
ar_test_node:start_other_node(ValidatorNode, B0, Config#config{
peers = [ar_test_node:peer_ip(RepackerNode)],
start_from_latest_state = true,
auto_join = true
}, true)
),
ok.

16 changes: 8 additions & 8 deletions apps/arweave/e2e/ar_repack_mine_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ repack_mine_test_() ->
{timeout, 300, {with, {spora_2_6, composite_1}, [fun test_repack_mine/1]}},
{timeout, 300, {with, {spora_2_6, composite_2}, [fun test_repack_mine/1]}},
{timeout, 300, {with, {spora_2_6, unpacked}, [fun test_repack_mine/1]}},
{timeout, 300, {with, {composite_1, spora_2_6}, [fun test_repack_mine/1]}},
{timeout, 300, {with, {composite_1, composite_1}, [fun test_repack_mine/1]}},
{timeout, 300, {with, {composite_1, composite_2}, [fun test_repack_mine/1]}},
{timeout, 300, {with, {composite_1, unpacked}, [fun test_repack_mine/1]}},
{timeout, 300, {with, {composite_2, spora_2_6}, [fun test_repack_mine/1]}},
{timeout, 300, {with, {composite_2, composite_1}, [fun test_repack_mine/1]}},
{timeout, 300, {with, {composite_2, composite_2}, [fun test_repack_mine/1]}},
{timeout, 300, {with, {composite_2, unpacked}, [fun test_repack_mine/1]}}
{timeout, 600, {with, {composite_1, spora_2_6}, [fun test_repack_mine/1]}},
{timeout, 600, {with, {composite_1, composite_1}, [fun test_repack_mine/1]}},
{timeout, 600, {with, {composite_1, composite_2}, [fun test_repack_mine/1]}},
{timeout, 600, {with, {composite_1, unpacked}, [fun test_repack_mine/1]}},
{timeout, 600, {with, {composite_2, spora_2_6}, [fun test_repack_mine/1]}},
{timeout, 600, {with, {composite_2, composite_1}, [fun test_repack_mine/1]}},
{timeout, 600, {with, {composite_2, composite_2}, [fun test_repack_mine/1]}},
{timeout, 600, {with, {composite_2, unpacked}, [fun test_repack_mine/1]}}
].

%% --------------------------------------------------------------------------------------------
Expand Down
4 changes: 1 addition & 3 deletions apps/arweave/include/ar.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,7 @@
%% picked as recall chunks and therefore equally incentivize the storage.
-define(PADDING_NODE_DATA_ROOT, <<>>).

-ifdef(DEBUG).
-define(INITIAL_VDF_DIFFICULTY, 2).
-else.
-ifndef(INITIAL_VDF_DIFFICULTY).
-define(INITIAL_VDF_DIFFICULTY, 600_000).
-endif.

Expand Down
4 changes: 0 additions & 4 deletions apps/arweave/include/ar_consensus.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,9 @@
%% adding the entropy at certain blocks (rather than nonce limiter steps) allows
%% miners to use extra bandwidth (bearing almost no additional costs) to compute
%% nonces on the short forks with different-entropy nonce limiting chains.
-ifdef(DEBUG).
-define(NONCE_LIMITER_RESET_FREQUENCY, 5).
-else.
-ifndef(NONCE_LIMITER_RESET_FREQUENCY).
-define(NONCE_LIMITER_RESET_FREQUENCY, (10 * 120)).
-endif.
-endif.

%% The maximum number of one-step checkpoints the block header may include.
-ifndef(NONCE_LIMITER_MAX_CHECKPOINTS_COUNT).
Expand Down
8 changes: 6 additions & 2 deletions apps/arweave/include/ar_vdf.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@
%% Typical ryzen 5900X iterations for 1 sec
-define(VDF_SHA_1S, 15_000_000).

-ifndef(VDF_DIFFICULTY).
-define(VDF_DIFFICULTY, ?VDF_SHA_1S div ?VDF_CHECKPOINT_COUNT_IN_STEP).
-endif.

-ifdef(DEBUG).
-define(VDF_DIFFICULTY, 2).
% NOTE. VDF_DIFFICULTY_RETARGET should be > 10 because it's > 10 in mainnet
% So VDF difficulty should change slower than difficulty
-define(VDF_DIFFICULTY_RETARGET, 20).
-define(VDF_HISTORY_CUT, 2).
-else.
-define(VDF_DIFFICULTY, ?VDF_SHA_1S div ?VDF_CHECKPOINT_COUNT_IN_STEP).
-ifndef(VDF_DIFFICULTY_RETARGET).
-define(VDF_DIFFICULTY_RETARGET, 720).
-endif.
-ifndef(VDF_HISTORY_CUT).
-define(VDF_HISTORY_CUT, 50).
-endif.
-endif.


5 changes: 4 additions & 1 deletion apps/arweave/src/ar_mining_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,10 @@ prepare_solution(steps, Candidate, Solution) ->
{start_step_number, PrevStepNumber},
{next_step_number, StepNumber},
{next_seed, ar_util:safe_encode(PrevNextSeed)},
{next_vdf_difficulty, PrevNextVDFDifficulty}]),
{next_vdf_difficulty, PrevNextVDFDifficulty},
{h1, ar_util:safe_encode(Candidate#mining_candidate.h1)},
{h2, ar_util:safe_encode(Candidate#mining_candidate.h2)}
]),
error
end;

Expand Down
9 changes: 7 additions & 2 deletions apps/arweave/src/ar_mining_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,11 @@ handle_task({computed_h1, Candidate, _ExtraArgs}, State) ->
State2 = hash_computed(h1, Candidate, State),
case h1_passes_diff_checks(H1, Candidate, State2) of
true ->
?LOG_INFO([{event, found_h1_solution}, {worker, State2#state.name},
{h1, ar_util:encode(H1)}, {difficulty, get_difficulty(State2, Candidate)}]),
?LOG_INFO([{event, found_h1_solution},
{step, Candidate#mining_candidate.step_number},
{worker, State2#state.name},
{h1, ar_util:encode(H1)},
{difficulty, get_difficulty(State2, Candidate)}]),
ar_mining_stats:h1_solution(),
%% Decrement 1 for chunk1:
%% Since we found a solution we won't need chunk2 (and it will be evicted if
Expand Down Expand Up @@ -519,13 +522,15 @@ handle_task({computed_h2, Candidate, _ExtraArgs}, State) ->
true ->
?LOG_INFO([{event, found_h2_solution},
{worker, State#state.name},
{step, Candidate#mining_candidate.step_number},
{h2, ar_util:encode(H2)},
{difficulty, get_difficulty(State2, Candidate)},
{partial_difficulty, get_partial_difficulty(State2, Candidate)}]),
ar_mining_stats:h2_solution();
partial ->
?LOG_INFO([{event, found_h2_partial_solution},
{worker, State2#state.name},
{step, Candidate#mining_candidate.step_number},
{h2, ar_util:encode(H2)},
{partial_difficulty, get_partial_difficulty(State2, Candidate)}])
end,
Expand Down
1 change: 1 addition & 0 deletions apps/arweave/test/ar_test_node.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ test_with_mocked_functions(Functions, TestFun, Timeout) ->

post_and_mine(#{ miner := Node, await_on := AwaitOnNode }, TXs) ->
CurrentHeight = remote_call(Node, ar_node, get_height, []),
?LOG_INFO("post_and_mine height (~p): ~p", [Node, CurrentHeight+1]),
lists:foreach(fun(TX) -> assert_post_tx_to_peer(Node, TX) end, TXs),
mine(Node),
[{H, _, _} | _] = wait_until_height(AwaitOnNode, CurrentHeight + 1),
Expand Down
5 changes: 4 additions & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,10 @@
%% lower multiplier to allow single-block solutions in tests
{d, 'POA1_DIFF_MULTIPLIER', 1},
%% use sha256 instead of randomx to speed up tests
{d, 'STUB_RANDOMX', true}
{d, 'STUB_RANDOMX', true},
{d, 'VDF_DIFFICULTY', 2},
{d, 'INITIAL_VDF_DIFFICULTY', 2},
{d, 'NONCE_LIMITER_RESET_FREQUENCY', 5}
]}
]},
{e2e, [
Expand Down