Skip to content

Commit

Permalink
Merge pull request #2608 from aeternity/PT-167642082-fsm-fork-depende…
Browse files Browse the repository at this point in the history
…nt-behaviour

PT-167642082 FSM future proof
  • Loading branch information
gorbak25 committed Aug 2, 2019
2 parents 0e107c5 + 8602ef5 commit d877a85
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions apps/aechannel/src/aesc_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ channel_closing(cast, {?CHANNEL_UNLOCKED, #{chan_id := ChId}} = Msg,
end,
keep_state(D1);
channel_closing(cast, {?SHUTDOWN, Msg}, D) ->
case {is_fork_active(?LIMA_PROTOCOL_VSN), check_shutdown_msg(Msg, D)} of
case {was_fork_activated(?LIMA_PROTOCOL_VSN), check_shutdown_msg(Msg, D)} of
{false, _} ->
%% TODO: send an ?UPDATE_ERR (which isn't yet defined)
lager:debug("Shutdown while channel_closing not allowed before the Lima fork"),
Expand Down Expand Up @@ -3264,7 +3264,7 @@ handle_call_(open, shutdown, From, D) ->
gen_statem:reply(From, ok),
next_state(awaiting_signature, set_ongoing(D1));
handle_call_(channel_closing, shutdown, From, #data{strict_checks = Strict} = D) ->
case (not Strict) or is_fork_active(?LIMA_PROTOCOL_VSN) of
case (not Strict) or was_fork_activated(?LIMA_PROTOCOL_VSN) of
true ->
%% Initiate mutual close
{ok, CloseTx, Updates} = close_mutual_tx_for_signing(D),
Expand Down Expand Up @@ -3522,6 +3522,6 @@ init_checks(Opts) ->
ok
end.

is_fork_active(ProtocolVSN) ->
was_fork_activated(ProtocolVSN) ->
%% Enable a new fork only after MINIMUM_DEPTH generations in order to avoid fork changes
ProtocolVSN == aec_hard_forks:protocol_effective_at_height(max(curr_height() - ?MINIMUM_DEPTH, aec_block_genesis:height())).
ProtocolVSN =< aec_hard_forks:protocol_effective_at_height(max(curr_height() - ?MINIMUM_DEPTH, aec_block_genesis:height())).

0 comments on commit d877a85

Please sign in to comment.