-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[ARC-0042] Adjust reward algorithms to utilize timestamps #2569
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just nits today, will review the tests and ideas for testcases tomorrow
Since the code is the defacto documentation on the reward mechanisms at the moment, do you mind adding slightly more detail:
- In the docblock for
fn puzzle_reward
what the conceptual meaning is compared to e.g. thecoinbase_reward
- In the docblock for
fn anchor_block_reward_at_timestamp
what the conceptual meaning is compared to e.g. thecoinbase_reward
(namely, it is an upper bound, ultimate payout depends on the target of the solutions)
We simulated the block rewards without coinbase rewards and observed the following results.
These results are consistent with desired goals of this PR. Below is a plot of anchor block rewards over time for the same set of block times. |
@d0cd I think they're consistent with the goals of this PR and are a faithful prototype of The monte-carlo simulation shows the emission rate increasing (sometimes with quite a significant slope increase) for block times beyond 10 seconds. This doesn't reduce inflation if block times increase with the addition of further validators or more traffic. The discussion should be brought to |
@iamalwaysuncomfortable Are you calculating the emission rate against timestamp for block time >10s? For per-block reward it's expected to increase because the block did cover more time, so it should have emitted more credits. If you plot it against the actual time though, the emission rate should remain the same. (EDIT: remember that we are trying to address the issue that credits emission is too high relative to time, as the design is 5% block reward per year regardless of how many blocks we have generated over the year. If the block interval is longer than the max block interval, the emission rate will actually decrease as the exceeded time won't be rewarded. This in turn could actually become an incentive to make validators push out blocks faster.) EDIT: also thanks for mentioning me, wasn't aware there is already a PR for this. |
@iamalwaysuncomfortable @HarukaMa The algorithm will have a However, I do see your point that reducing this would incentivize block times that are always lower than I would suggest keeping at 60 seconds to be conservative or 30 seconds if we want to be a bit more aggressive. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L G T M
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if block times are consistently 60 seconds exactly, the emission rate should remain 5%. If the blocktime is consistently larger than V2_MAX_BLOCK_INTERVAL (because of network load or too many validators), then the emission rate will be lower than expected for the year and be less than 5% because we are capping the amount of rewards.
The tradeoff of block time vs. rewards emission rate is something all the members of the Aleo community should do some deeper analysis of ultimately. However, if the community is currently staunchly committed to the 5%
inflation rate 60
seconds likely provides reasonable statistical guarantees that this rate will be preserved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Motivation
This PR is intended to implement and address the concerns highlighted in ARC-0042.
The gist is that the current block times are not aligned with our current algorithms and causing the following:
block_reward
is emitting at a higher inflation rate than the expected 5%coinbase_reward
is reducing too quickly and not over the expected 10 year timeline.This PR addresses the problem by using
timestamps
as the peg rather thanblock_height
. Both the inflation rate and thecoinbase_reward
reduction-over-time are on human timescales; it makes sense for us to align the formulas to the human timescale withtimestamps
rather than relying onblock_heights
, which are on a network timescale.block_reward
:block_reward_v1
block_reward_v2
time_since_last_block
to determine how much reward to emit for that particular block in relation to how much inflation thattime_since_last_block
seconds should cause.time_since_last_block
is bound by a block interval of 60 seconds to prevent the block reward from becoming too large in the event of a long block interval such as a network outage or network upgrade.coinbase_reward
:coinbase_reward_v1
coinbase_reward_v2
anchor_block_reward_at_timestamp
instead ofanchor_block_reward_at_height
Some emission analysis can be seen in the comments below - #2569 (comment)
Migration:
N::CONSENSUS_V2_HEIGHT
to Network traitv1
reward impls to thev2
reward impls.N::CONSENSUS_V2_HEIGHT
, otherwise there may be some issues.The migration and reward logic change will occur at the following block heights (These heights are subject to change):
Canary - Block 2,900,000 (~Nov 15, 2024 at the current 3.3s block times)
Testnet - Block 2,950,000 (~Nov 22, 2024 at the current 3.3s block times)
Mainnet - Block 2,800,000 (~Dec 10, 2024 at the current 3.0s block times)
These numbers were calculated by determining the planned release schedule and backing into the block height using the current block speeds and including a buffer between release and consensus change. This buffer is intended to give leeway for nodes to upgrade before the consensus change. The following table is the approximate timeline and buffers for the networks:
Test Plan
Tests have been added to ensure that the V2
block_reward
andcoinbase_reward
implementations match the expected behavior.CI can be found here.