Skip to content
This repository was archived by the owner on Mar 5, 2024. It is now read-only.

Commit 81d8c90

Browse files
committed
reject poc requests txns if chainvar set
1 parent 5b74177 commit 81d8c90

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

include/blockchain_vars.hrl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@
173173
%% from POC targets :: boolean()
174174
-define(poc_activity_filter_enabled, poc_activity_filter_enabled).
175175

176+
%% If set to true, all incoming poc request txns will be rejected : boolean
177+
-define(poc_reject_requests, poc_reject_requests).
178+
176179
%% Number of blocks to wait before a hotspot can be eligible to participate in a poc
177180
%% challenge. This would avoid new hotspots getting challenged before they sync to an
178181
%% acceptable height.

src/transactions/v1/blockchain_txn_poc_request_v1.erl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ is_valid(Txn, Chain) ->
154154
BaseTxn = Txn#blockchain_txn_poc_request_v1_pb{signature = <<>>},
155155
EncodedTxn = blockchain_txn_poc_request_v1_pb:encode_msg(BaseTxn),
156156

157+
%% if this var is enabled reject request txns
158+
case blockchain:config(?poc_reject_requests, Ledger) of
159+
{ok, true} -> throw({error, poc_requests_not_accepted});
160+
_ -> ok
161+
end,
157162
case blockchain_txn:validate_fields([{{secret_hash, ?MODULE:secret_hash(Txn)}, {binary, 32}},
158163
{{onion_key_hash, ?MODULE:secret_hash(Txn)}, {binary, 32}},
159164
{{block_hash, ?MODULE:secret_hash(Txn)}, {binary, 32}}]) of
@@ -274,7 +279,6 @@ maybe_log_duration(Type, Start) ->
274279
_ -> ok
275280
end.
276281

277-
278282
%% ------------------------------------------------------------------
279283
%% EUNIT Tests
280284
%% ------------------------------------------------------------------

src/transactions/v1/blockchain_txn_vars_v1.erl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,12 @@ validate_var(?poc_proposal_gc_window_check, Value) ->
10361036
false -> ok;
10371037
_ -> throw({error, {poc_proposal_gc_window_check, Value}})
10381038
end;
1039-
1039+
validate_var(?poc_reject_requests, Value) ->
1040+
case Value of
1041+
true -> ok;
1042+
false -> ok;
1043+
_ -> throw({error, {poc_reject_requests, Value}})
1044+
end;
10401045
validate_var(?poc_challenge_sync_interval, Value) ->
10411046
validate_int(Value, "poc_challenge_sync_interval", 10, 1440, false);
10421047
validate_var(?poc_path_limit, undefined) ->

0 commit comments

Comments
 (0)