core-rs-albatross icon indicating copy to clipboard operation
core-rs-albatross copied to clipboard

Add a block separation time

Open jsdanielh opened this issue 2 years ago • 1 comments

  • Add a block separation time and change the micro block producer within the validator to check when a block needs to be either:
    • Immediately produced because the expected block time for a block has already passed.
    • Delayed in order to comply with the block separation time. The block separation time will be taken as a point for the reward function later to incentivize validators to produce blocks within this time.
  • Change the maximum timestamp drift to 1 minute
    • Change the maximum timestamp drift from 10 minutes to 1 minute. This is to only accept blocks whose timestamp differs less than the expected batch time which is targeting 1s * BLOCKS_PER_BATCH. The latter will have a value of 60 after #940 gets merged.
    • Change some tests utilities to set a less aggressive timestamp offset when producing blocks.
    • Change the README file to add a recommendation to run a clock synchronization protocol such as NTP.
  • Introduced a penalty for not producing batches in time
    • Each batch should be produced 'in time'. That means there is a target block time, and if validators delay the block production process, then their batch rewards would be affected proportionally to the delay.
    • Re-generate ZKP keys and proofs to make all zkp tests to pass.
  • Use a dynamic block producer timeout depending on whether the block production within the batch is on time or is delayed.
  • Change skip block timestamp generation and verification such that the expected timestamp is the producer timeout plus the greater between:
    • The original expected timestamp of the block being skipped.
    • The previous block timestamp.
  • Decrease the block producer timeout from 4s to 2s. This is to adjust the timeout to the expected time of producing 2 consecutive blocks.
  • Create a test for delayed batch rewards.

Pull request checklist

  • [X] All tests pass. Demo project builds and runs.
  • [X] I have resolved any merge conflicts.

jsdanielh avatar Nov 08 '22 16:11 jsdanielh

Codecov Report

Base: 63.65% // Head: 65.71% // Increases project coverage by +2.06% :tada:

Coverage data is based on head (2facd3c) compared to base (2f66508). Patch coverage: 96.49% of modified lines in pull request are covered.

:exclamation: Current head 2facd3c differs from pull request most recent head 530b6d7. Consider uploading reports for the commit 530b6d7 to get more accurate results

Additional details and impacted files
@@              Coverage Diff              @@
##           albatross    #1112      +/-   ##
=============================================
+ Coverage      63.65%   65.71%   +2.06%     
=============================================
  Files            384      384              
  Lines          47220    47401     +181     
=============================================
+ Hits           30059    31151    +1092     
+ Misses         17161    16250     -911     
Flag Coverage Δ
unittests 65.71% <96.49%> (+2.06%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
test-utils/src/zkp_test_data.rs 100.00% <ø> (ø)
validator/src/micro.rs 93.41% <90.00%> (+0.32%) :arrow_up:
block-production/src/lib.rs 100.00% <100.00%> (ø)
blockchain/src/blockchain/blockchain.rs 51.50% <100.00%> (+0.63%) :arrow_up:
blockchain/src/reward.rs 81.96% <100.00%> (+9.46%) :arrow_up:
consensus/src/sync/history/cluster.rs 87.45% <100.00%> (+0.25%) :arrow_up:
primitives/block/src/block.rs 61.65% <100.00%> (+0.06%) :arrow_up:
primitives/src/policy.rs 94.59% <100.00%> (+7.27%) :arrow_up:
test-utils/src/block_production.rs 98.11% <100.00%> (ø)
test-utils/src/blockchain.rs 88.44% <100.00%> (-0.06%) :arrow_down:
... and 36 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Nov 09 '22 00:11 codecov[bot]