Update time-related constants and fee deposit granting

This is an adaptation to the recent shift from measuring time in
blocks.
parent 916246e1
Pipeline #36205755 passed with stages
in 20 minutes and 42 seconds
......@@ -11,9 +11,9 @@
%% limitations under the License.
-define(MAX_BLOCK_HEIGHT, 4294967295). %% 2^32 - 1
-define(MAX_EPOCH_LENGTH, 31536000). %% 1 year, assuming 1 second blocks.
-define(BLOCK_LENGTH, 1000). %% In miliseconds.
-define(FEE_DEPOSIT_LONG_RATIO, (13140 * 1000 div ?BLOCK_LENGTH)). %% Inversed ratio of long fee deposit which is dispatched.
-define(MAX_EPOCH_LENGTH, 31536000). %% 1 year
-define(BLOCK_LENGTH, 3).
-define(FEE_DEPOSIT_LONG_DISPATCH_PERIOD, (3 * 31536000)).
-define(HASH(X), crypto:hash(sha256, X)).
-define(SETS, ordsets).
......
......@@ -77,11 +77,12 @@ grant_fee_deposits(
validators=Validators,
fee_deposit_long=DepositLong,
fee_deposit_short=DepositShort,
epoch_length=EpochLength,
timestamp=Timestamp,
last_epoch_end=LastEpochEnd}) ->
DisposedDepositLong = DepositLong div ?FEE_DEPOSIT_LONG_RATIO,
DisposedDeposit = DepositShort + DisposedDepositLong,
RealEpochLength = Timestamp - LastEpochEnd,
DisposedDepositLong = DepositLong * min(EpochLength, RealEpochLength) div ?FEE_DEPOSIT_LONG_DISPATCH_PERIOD,
DisposedDeposit = DepositShort + DisposedDepositLong,
SharesValidators =
[{VP, PK} || {PK, <<VP, _/binary>>} <- gb_merkle_trees:to_orddict(Validators)],
ValidatorsRewards = 'hare-niemeyer':apportion(SharesValidators, DisposedDeposit),
......
......@@ -40,12 +40,14 @@ prop_fee_deposit_granting() ->
fee_deposit_long=FeeDepositLong,
validators=Validators,
last_epoch_end=LastEpochEnd,
epoch_length=EpochLength,
timestamp=Timestamp},
ercoin_gen:data(),
begin
NewData = #data{fee_deposit_short=NewFeeDepositShort, fee_deposit_long=NewFeeDepositLong} = ercoin_data:grant_fee_deposits(Data),
ExpectedDisposedDeposit = FeeDepositShort + FeeDepositLong div ?FEE_DEPOSIT_LONG_RATIO,
RealEpochLength = Timestamp - LastEpochEnd,
ExpectedDisposedDepositLong = FeeDepositLong * min(EpochLength, RealEpochLength) div ?FEE_DEPOSIT_LONG_DISPATCH_PERIOD,
ExpectedDisposedDeposit = FeeDepositShort + ExpectedDisposedDepositLong,
SharesValidators = [{VP, PK} || {PK, <<VP, _/binary>>} <- gb_merkle_trees:to_orddict(Validators)],
ValidatorsExpectedRewards = 'hare-niemeyer':apportion(SharesValidators, ExpectedDisposedDeposit),
{BalancesOK, DestroyedSum} =
......@@ -69,7 +71,7 @@ prop_fee_deposit_granting() ->
{true, 0},
ValidatorsExpectedRewards),
NewFeeDepositShort =:= 0 andalso
NewFeeDepositLong =:= FeeDepositLong - FeeDepositLong div ?FEE_DEPOSIT_LONG_RATIO andalso
NewFeeDepositLong =:= FeeDepositLong - ExpectedDisposedDepositLong andalso
BalancesOK andalso
ercoin_data:money_supply(NewData) =< ercoin_data:money_supply(Data) - DestroyedSum
end).
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment