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

[HAL-02] fix: update random number generation #53

Merged
merged 1 commit into from
Aug 25, 2022

Conversation

0xpanoramix
Copy link
Contributor

Description

When we have 3 or more node operators in the system, the contracts will try to dispatch the funds coming in between all the operators. To do this, we’re using a low entropy source: the block hash. We use the values as random numbers to select the node operator index that will receive the next validator deposit. This ensures that the distribution is fair. The issue is that we’re using the block hash of the current block, but this value is always equal to 0 and we should be using the value of the previous block hash.

Instead of blockhash(block.number), we now use blockhash(block.number - 1).

@0xpanoramix 0xpanoramix requested review from nmvalera and mortimr August 9, 2022 17:33
@0xpanoramix 0xpanoramix self-assigned this Aug 9, 2022
Signed-off-by: Luca Georges Francois <[email protected]>
@0xpanoramix 0xpanoramix force-pushed the fix/update-entropy-source-for-deposit branch from 02ab831 to 45d03ff Compare August 9, 2022 17:35
Copy link
Contributor

@nmvalera nmvalera left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@mortimr mortimr left a comment

Choose a reason for hiding this comment

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

LGTM

@0xpanoramix 0xpanoramix changed the title fix: update random number generation [HAL-02] fix: update random number generation Aug 10, 2022
@mortimr mortimr merged commit a4980bc into master Aug 25, 2022
@mortimr mortimr deleted the fix/update-entropy-source-for-deposit branch August 25, 2022 14:43
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.

3 participants