-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Random implementation #2481
Random implementation #2481
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.
I think it still allows Primary to pre-execute transactions and see how the last block hash affects random number generated and then choose some combination that benefits Primary for some reason. And it also still can generate/insert transaction of its own to see if it allows to win the lottery.
} | ||
|
||
// Double Sha256 | ||
return BitConverter.ToUInt64(hash.Sha256().Sha256()); |
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.
One hash is enough maybe?
@@ -133,7 +133,8 @@ protected internal ulong GetRandom() | |||
// Block related | |||
for (int count = 0; count < ProtocolSettings.ValidatorsCount; index--, count++) | |||
{ | |||
System.Array.Copy(NativeContract.Ledger.GetBlockHash(Snapshot, index).ToArray(), 0, hash, offset + (UInt256.Length * count), UInt256.Length); | |||
var blockHash = count == 0 ? PersistingBlock.Hash : NativeContract.Ledger.GetBlockHash(Snapshot, index); |
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.
PersistingBlock.Hash is decidable to the primary, this makes the random number not unique.
Alternative to #2477 without consensus changes