Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesPiechota committed Feb 12, 2024
1 parent 02b4b6d commit 16b7c8f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 34 deletions.
1 change: 0 additions & 1 deletion apps/arweave/src/ar_doctor_bench.erl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ bench_read(Args) ->
ar:console("'~s'~n~n", [?FILE_FORMAT]),

StopTime = erlang:monotonic_time() + erlang:convert_time_unit(Duration, second, native),
File = file:open(?OUTPUT_FILENAME, [write, append]),

Results = ar_util:pmap(
fun(StorageModule) ->
Expand Down
12 changes: 2 additions & 10 deletions apps/arweave/src/ar_mining_hash.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-behaviour(gen_server).

-export([start_link/0, compute_h0/2, compute_h1/2, compute_h2/2,
set_cache_limit/1, garbage_collect/0]).
garbage_collect/0]).

-export([init/1, handle_cast/2, handle_call/3, handle_info/2, terminate/2]).

Expand All @@ -15,9 +15,7 @@

-record(state, {
hashing_threads = queue:new(),
hashing_thread_monitor_refs = #{},
chunks_seen = 0,
chunk_cache_limit = infinity
hashing_thread_monitor_refs = #{}
}).

%%%===================================================================
Expand All @@ -37,9 +35,6 @@ compute_h1(Worker, Candidate) ->
compute_h2(Worker, Candidate) ->
gen_server:cast(?MODULE, {compute, h2, Worker, Candidate}).

set_cache_limit(CacheLimit) ->
gen_server:cast(?MODULE, {set_cache_limit, CacheLimit}).

garbage_collect() ->
gen_server:cast(?MODULE, garbage_collect).

Expand All @@ -61,9 +56,6 @@ handle_call(Request, _From, State) ->
?LOG_WARNING([{event, unhandled_call}, {module, ?MODULE}, {request, Request}]),
{reply, ok, State}.

handle_cast({set_cache_limit, CacheLimit}, State) ->
{noreply, State#state{ chunk_cache_limit = CacheLimit }};

handle_cast({compute, HashType, Worker, Candidate},
#state{ hashing_threads = Threads } = State) ->
{Thread, Threads2} = pick_hashing_thread(Threads),
Expand Down
5 changes: 2 additions & 3 deletions apps/arweave/src/ar_mining_io.erl
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,9 @@ read_range(WhichChunk, Worker, Candidate, RangeStart, StoreID) ->
StartTime = erlang:monotonic_time(),
Size = ?RECALL_RANGE_SIZE,
#mining_candidate{ mining_address = MiningAddress } = Candidate,
UniqueSize = Size, %% + (rand:uniform(100)*?DATA_CHUNK_SIZE),
Intervals = get_packed_intervals(RangeStart, RangeStart + UniqueSize,
Intervals = get_packed_intervals(RangeStart, RangeStart + Size,
MiningAddress, StoreID, ar_intervals:new()),
ChunkOffsets = ar_chunk_storage:get_range(RangeStart, UniqueSize, StoreID),
ChunkOffsets = ar_chunk_storage:get_range(RangeStart, Size, StoreID),
ChunkOffsets2 = filter_by_packing(ChunkOffsets, Intervals, StoreID),
NonceMax = max(0, (Size div ?DATA_CHUNK_SIZE - 1)),
read_range(WhichChunk, Worker, Candidate, RangeStart, 0, NonceMax, ChunkOffsets2),
Expand Down
5 changes: 2 additions & 3 deletions apps/arweave/src/ar_mining_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

-export([start_link/0, start_mining/1, set_difficulty/1, set_merkle_rebase_threshold/1,
compute_h2_for_peer/1, prepare_and_post_solution/1, post_solution/1, read_poa/3,
get_recall_bytes/4, active_sessions/0, encode_sessions/1]).
get_recall_bytes/4, active_sessions/0, encode_sessions/1, add_pool_job/1]).
-export([pause/0]).

-export([init/1, handle_cast/2, handle_call/3, handle_info/2, terminate/2]).
Expand All @@ -23,7 +23,7 @@
workers = #{},
active_sessions = sets:new(),
diff = infinity,
chunk_cache_size_limit = 0,
chunk_cache_limit = 0,
gc_frequency_ms = undefined,
merkle_rebase_threshold = infinity,
is_pool_client = false
Expand Down Expand Up @@ -319,7 +319,6 @@ update_cache_limits(State) ->
end,
State#state.workers
),
ar_mining_hash:set_cache_limit(OverallCacheLimit),

ar:console(
"~nSetting the mining chunk cache size limit to ~B chunks "
Expand Down
4 changes: 2 additions & 2 deletions apps/arweave/src/ar_mining_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

-define(TASK_CHECK_FREQUENCY_MS, 200).
-define(LAG_CHECK_FREQUENCY_MS, 5000).
-define(SAMPLE_PROCESS_INTERVAL, 1000).

%%%===================================================================
%%% Public interface.
Expand Down Expand Up @@ -334,7 +333,8 @@ handle_task({computed_h0, Candidate}, State) ->

handle_task({computed_h1, Candidate}, State) ->
#state{ diff = Diff } = State,
#mining_candidate{ h1 = H1, chunk1 = Chunk1, partial_diff = PartialDiff } = Candidate,
#mining_candidate{ h1 = H1, chunk1 = Chunk1, session_key = SessionKey,
partial_diff = PartialDiff } = Candidate,
case passes_diff_check(H1, Diff, PartialDiff) of
true ->
?LOG_DEBUG([{event, mining_debug_found_h1_solution}, {worker, State#state.name},
Expand Down
2 changes: 1 addition & 1 deletion apps/arweave/src/ar_pool.erl
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ process_partial_solution_poa2_size(Solution, Ref) ->
process_partial_solution_partition_number(Solution, Ref) ->
PartitionNumber = Solution#mining_solution.partition_number,
PartitionUpperBound = Solution#mining_solution.partition_upper_bound,
Max = ?MAX_PARTITION_NUMBER(PartitionUpperBound),
Max = ar_node:get_max_partition_number(PartitionUpperBound),
case PartitionNumber > Max of
false ->
process_partial_solution_nonce(Solution, Ref);
Expand Down
28 changes: 14 additions & 14 deletions apps/arweave/test/ar_mining_server_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ cleanup_one(_) ->
%% ------------------------------------------------------------------------------------------------
%% Test Registration
%% ------------------------------------------------------------------------------------------------
% chunk_cache_size_test_() ->
% {setup, fun setup_all/0, fun cleanup_all/1,
% {foreach, fun setup_one/0, fun cleanup_one/1,
% [
% {timeout, 30, fun test_h2_solution_chunk1_first/0},
% {timeout, 30, fun test_h2_solution_chunk2_first/0},
% {timeout, 30, fun test_h1_solution_h2_synced_chunk1_first/0},
% {timeout, 30, fun test_h1_solution_h2_synced_chunk2_first/0},
% {timeout, 30, fun test_h1_solution_h2_unsynced/0},
% {timeout, 30, fun test_no_solution_then_h2_solution/0},
% {timeout, 30, fun test_no_solution_then_h1_solution_h2_synced/0},
% {timeout, 30, fun test_no_solution_then_h1_solution_h2_unsynced/0}
% ]}
% }.
chunk_cache_size_test_() ->
{setup, fun setup_all/0, fun cleanup_all/1,
{foreach, fun setup_one/0, fun cleanup_one/1,
[
{timeout, 30, fun test_h2_solution_chunk1_first/0},
{timeout, 30, fun test_h2_solution_chunk2_first/0},
{timeout, 30, fun test_h1_solution_h2_synced_chunk1_first/0},
{timeout, 30, fun test_h1_solution_h2_synced_chunk2_first/0},
{timeout, 30, fun test_h1_solution_h2_unsynced/0},
{timeout, 30, fun test_no_solution_then_h2_solution/0},
{timeout, 30, fun test_no_solution_then_h1_solution_h2_synced/0},
{timeout, 30, fun test_no_solution_then_h1_solution_h2_unsynced/0}
]}
}.

%% ------------------------------------------------------------------------------------------------
%% chunk_cache_size_test_
Expand Down

0 comments on commit 16b7c8f

Please sign in to comment.