Skip to content
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

feat: verify the block delay on broadcasted blocks #193

Merged
merged 1 commit into from
Jan 16, 2023

Conversation

minh-bq
Copy link
Contributor

@minh-bq minh-bq commented Dec 20, 2022

This commit follows the approach of Ramanujan in BSC which includes the block
delay in block timestamp for verification on the recipients.

The block timestamp is calculated by the formula

  • block timestamp = max(parent timestamp + block duration + backoff time,
    current timestamp)

The block duration is 3s in the current configuration. When the validator is
inturn, the backoff time is 0, otherwise, each out of turn validator has a
different delay.

The delay equals to

  • delay = wiggle + (random multiplier * wiggle/2)

The random multiplier is in range [1, len(current validators)]. The random seed
is the block number, the recipient can use the same seed to get the same random
result for verification.

@minh-bq minh-bq requested review from DNK90 and linh-1 December 20, 2022 07:02
@minh-bq minh-bq force-pushed the feat/check-header-time branch from 8d55479 to 7df949f Compare December 20, 2022 07:26
Copy link
Contributor

@DNK90 DNK90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

consensus/consortium/v2/snapshot.go Show resolved Hide resolved
consensus/consortium/v2/snapshot.go Show resolved Hide resolved
params/config.go Show resolved Hide resolved
consensus/consortium/v2/consortium.go Show resolved Hide resolved
@minh-bq minh-bq force-pushed the feat/check-header-time branch from 7df949f to 0be2453 Compare January 5, 2023 11:03
This commit follows the approach of Ramanujan in BSC which includes the block
delay in block timestamp for verification on the recipients.

The block timestamp is calculated by the formula
- block timestamp = max(parent timestamp + block duration + backoff time,
  current timestamp)

The block duration is 3s in the current configuration. When the validator is
inturn, the backoff time is 0, otherwise, each out of turn validator has a
different delay.

The delay equals to
- delay = wiggle + (random multiplier * wiggle/2)

The random multiplier is in range [1, len(current validators)]. The random seed
is the block number, the recipient can use the same seed to get the same random
result for verification.
@minh-bq minh-bq force-pushed the feat/check-header-time branch from 0be2453 to 9bf6470 Compare January 6, 2023 06:14
@minh-bq minh-bq merged commit 81b4b94 into axieinfinity:master Jan 16, 2023
@minh-bq minh-bq deleted the feat/check-header-time branch January 16, 2023 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants