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

Allow for back-to-back rescue blocks by fixing penalty calculations #1522

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
21 changes: 13 additions & 8 deletions src/blockchain_election.erl
Original file line number Diff line number Diff line change
Expand Up @@ -436,14 +436,19 @@ validator_penalties(Group, Ledger) ->

#{start_height := Start,
curr_height := End} = election_info(Ledger),
PenaltyTuples =
[begin
{ok, #block_info_v2{height = Height,
penalties = PenaltyTuple}}
= blockchain_ledger_v1:get_block_info(Ht, Ledger),
{PenaltyTuple, Height}
end
|| Ht <- lists:seq(Start + 2, End)],
ActualStart = Start + 2,
PenaltyTuples = case ActualStart > End of
true ->
[];
false ->
[begin
{ok, #block_info_v2{height = Height,
penalties = PenaltyTuple}}
= blockchain_ledger_v1:get_block_info(Ht, Ledger),
{PenaltyTuple, Height}
end
|| Ht <- lists:seq(ActualStart, End)]
end,

IndexedPenalties = get_penalties_v2(PenaltyTuples, length(Group), Ledger),
maps:fold(fun(I, Pen, Acc) ->
Expand Down