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

pool share label #557

Merged
merged 2 commits into from May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/arweave/include/ar_mining.hrl
Expand Up @@ -28,7 +28,8 @@
seed = not_set, %% serialized
session_key = not_set, %% serialized
start_interval_number = not_set, %% serialized
step_number = not_set %% serialized
step_number = not_set, %% serialized
label = <<"not_set">> %% not term, for prevent term table pollution DoS
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"term" here means atom? Like you want to prevent a malicious actor from submitting a lot of different shares with different labels and overflowing the erlang 1,048,576 atom limit?

}).

-record(mining_solution, {
Expand Down
5 changes: 3 additions & 2 deletions apps/arweave/src/ar_coordination.erl
Expand Up @@ -64,7 +64,7 @@ computed_h1(Candidate, DiffPair) ->
h1 = not_set,
h2 = not_set,
nonce = not_set,
poa2 = not_set,
poa2 = not_set,
preimage = not_set
},
gen_server:cast(?MODULE, {computed_h1, ShareableCandidate, H1, Nonce}).
Expand Down Expand Up @@ -330,8 +330,9 @@ send_h1(Candidate, State) ->
none ->
ok;
Peer ->
Candidate2 = Candidate#mining_candidate { label = <<"cm">> },
spawn(fun() ->
ar_http_iface_client:cm_h1_send(Peer, Candidate)
ar_http_iface_client:cm_h1_send(Peer, Candidate2)
end),
case Peer of
{pool, _} ->
Expand Down
10 changes: 7 additions & 3 deletions apps/arweave/src/ar_serialize.erl
Expand Up @@ -1667,7 +1667,8 @@ candidate_to_json_struct(
seed = Seed,
session_key = SessionKey,
start_interval_number = StartIntervalNumber,
step_number = StepNumber
step_number = StepNumber,
label = Label
}) ->
JSON = [
{cm_diff, diff_pair_to_json_list(DiffPair)},
Expand All @@ -1683,7 +1684,8 @@ candidate_to_json_struct(
{session_key, session_key_json_struct(SessionKey)},
{start_interval_number, integer_to_binary(StartIntervalNumber)},
{step_number, integer_to_binary(StepNumber)},
{nonce_limiter_output, ar_util:encode(NonceLimiterOutput)}
{nonce_limiter_output, ar_util:encode(NonceLimiterOutput)},
{label, Label}
],

JSON2 = encode_if_set(JSON, h1, H1, fun ar_util:encode/1),
Expand Down Expand Up @@ -1728,6 +1730,7 @@ json_map_to_candidate(JSON) ->
SessionKey = json_struct_to_session_key(maps:get(<<"session_key">>, JSON)),
StartIntervalNumber = binary_to_integer(maps:get(<<"start_interval_number">>, JSON)),
StepNumber = binary_to_integer(maps:get(<<"step_number">>, JSON)),
Label = maps:get(<<"label">>, JSON, <<"not_set">>),

#mining_candidate{
cm_diff = DiffPair,
Expand All @@ -1748,7 +1751,8 @@ json_map_to_candidate(JSON) ->
seed = Seed,
session_key = SessionKey,
start_interval_number = StartIntervalNumber,
step_number = StepNumber
step_number = StepNumber,
label = Label
}.

json_struct_to_h1_list(JSON) ->
Expand Down