-
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
Set the value of the random field to the previous randao_mix #2581
Conversation
b49968e
to
02057cb
Compare
I think this has some deeper implications than I think are being addressed in the above discussion given out applications currently likely expect DIFFICULTY to be just-in-time. I'd like to discuss a bit more before we quickly merge I see the value in shifting to I hadn't realized it, but it makes sense that BLOCKHASH[n-1] is used (otherwise it would be a circular dependency), but I worry that existing DIFFICULTY randomness applications make different assumptions about when the information is available. If you were designing randomness applications knowing this delay, you might be able to alter the game such that it is hard to profit off of the slot lookahead, but I worry that some existing applications will be vulnerable to frontrunning in unexpected ways by this change. Note -- on the long list of security improvements is an "early randao reveal slashing" where if you reveal your reveals early you can get slashed. This would potentially prevent a market where you provide your randao at slot N-1 to builders, but in practice it wouldn't really because you can't be slashed after slot N for an early reveal and you are the assigned proposer at N so not time for it to be included unless a re-org to a different N proposer. |
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.
The changeset looks good
want to discuss the change a bit more though. see comment!
Good point on the If we go deeper into the analysis of known to the miner/proposer only vs known to the whole network in advance we can deduce the following:
So, the What worries me in the perspective of proposer/builder separation is that if we use |
From a security standpoint, I think we should model any value that is known to any party at some particular point in time to be known to the whole network at that point in time. If a block builder can know timestamp and difficulty before executing transactions, then they can conditionally include transactions based on those values. Even without revealing those values to the network, they can still delegate decision making based on those values by giving transactions an opportunity to conditionally execute based on them (e.g., don't get included unless those are specific values). Today, a miner knows block.difficulty and block.timestamp prior to executing transactions. This means transactions can be included or not based on those values. Further, the miner can manipulate timestamp for the current block (I don't think they can manipulate difficulty, please correct me if I'm wrong here) to fulfill whatever needs transactions have. This means that effectively anyone wanting to extract MEV could have either direct or indirect access to these variables. After PoS with the current spec (without this PR), the situation is the same in that the proposer has access to these values in advance of execution and they can choose to provide either direct or indirect access to these values to anyone they want by way of broadcasting the values ahead of time or giving people a mechanism for executing code in an environment controlled by the proposer to "probe" those values and make decisions based on them. After PoS with this PR, the only change in the situation is that everyone will have access to one of those values (RANDAO) without needing to engage in backchannel communication with the proposer. This democratizes access to information that otherwise would be harder (but not impossible) to get, which I think is generally a good thing, not a bad thing. |
The risk of an early RANDAO reveal will be mitigated by the slashing condition that @djrtwo has mentioned (slash validator if there is a proof of revealing its |
Sorry, I've been mistaken previously by saying that the proposer will have to reveal its |
It should definitely be assumed that as soon as one person knows the next RANDAO result, then all financially motivated parties know it as well. |
I've come over to the dark side. This change makes sense to me. Re-reviewing for detail/correctness |
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.
Looks good! need to remove the unnecessary randao_reveal
arg in the validator helper functions. after that should be good to merge 👍
specs/merge/validator.md
Outdated
epoch = get_current_epoch(state) | ||
return xor(get_randao_mix(state, epoch), hash(randao_reveal)) | ||
|
||
|
||
def produce_execution_payload(state: BeaconState, | ||
parent_hash: Hash32, | ||
randao_reveal: BLSSignature, |
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.
Need to remove randao_reveal
as an arg here and from the caller in get_execution_payload
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.
Good catch! Should be fixed now
0d0eb68
to
26c78b5
Compare
72cb240
to
26c78b5
Compare
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.
great!
What is changed?
The
randao_mix
that is passed as the value to therandom
field is now the mix that is computed with the reveal of the previous block instead of the reveal of the current block as it was before this change.This PR introduces a straightforward implementation. An alternative may look as follows:
The above code makes
randao_mix
as a parameter of theprocess_execution_payload
function and requires more changes including test vectors of this function (they would require yieldingprev_randao_mix
).Rationale
Future compatibility with the proposer/builder separation. Without this change the proposer would have to communicate the most recent
randao_mix
to the block builder and make this communication in some advance to give the builder a time to re-execute a block, ideally as fast as the mix becomes known. This communication would likely need to happen over the public channel to avoid the situation when the builder needs to reveal its network identity to the proposer. There might also be an adverse effect of re-executing a block when the MEV opportunity that the builder have found is getting reduced or disappearing after the re-execution and the builder will have to adjust the proposer's bribe. So, the proposer should communicate the mix to all builders in order to see all bids after builders re-executes their blocks.Security implications
The privacy and re-execution issues makes the public communication of the randao mix that is happening in as much advance as it's possible is very likely the case with proposer/builder separation. Which is effectively not the far from using the
randao_mix
computed with the reveal of the previous block with an exception for the previous slot being empty. But we don't expect empty slots to be frequent on the mainnet. From this standpoint we might experience reduction in the level of security provided byRANDOM
opcode with the separation introduced to the system.Moreover, the most recent
randao_mix
is always known to the proposer of a block and, obviously, this knowledge might be exploited which significantly reduces the advantage of using the current mix instead of the previous one.Another argument is that currently
BLOCKHASH(n-1)
(the hash of the previous block) is used as a source of randomness by some apps. And usingrandao_mix[n-1]
would be aligned with this approach. By the end of the day, the level of randomness that is provided byrandao_mix[n-1]
is still much bigger thanBLOCKHASH(n-1)
can give.