-
Notifications
You must be signed in to change notification settings - Fork 710
Restore Taiko FCU timestamp validation allowing equal timestamps #10810
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
Changes from 2 commits
2d3b223
e8fdfe3
8bd8bb2
3ff4ff8
be50a25
40de70b
6020b8d
8ce5731
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -288,10 +288,12 @@ protected virtual bool IsOnMainChainBehindHead(Block newHeadBlock, ForkchoiceSta | |
| return null; | ||
| } | ||
|
|
||
| protected virtual ulong GetMinRequiredTimestamp(Block newHeadBlock) => newHeadBlock.Timestamp + 1; | ||
|
|
||
| protected bool ArePayloadAttributesTimestampAndSlotNumberValid(Block newHeadBlock, ForkchoiceStateV1 forkchoiceState, PayloadAttributes payloadAttributes, | ||
| [NotNullWhen(false)] out ResultWrapper<ForkchoiceUpdatedV1Result>? errorResult) | ||
| { | ||
| if (newHeadBlock.Timestamp >= payloadAttributes.Timestamp) | ||
| if (payloadAttributes.Timestamp < GetMinRequiredTimestamp(newHeadBlock)) | ||
| { | ||
| string error = $"Payload timestamp {payloadAttributes.Timestamp} must be greater than block timestamp {newHeadBlock.Timestamp}."; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This message should be adjusted to use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also not sure which would be better here
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regarding the first comment, done! Regarding the second, I'd rather leave it as-is (that is
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I went ahead with the approach @dipkakwani suggested below because I found that even more elegant :)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But the error message for taiko is now wrong? |
||
| errorResult = ForkchoiceUpdatedV1Result.Error(error, MergeErrorCodes.InvalidPayloadAttributes); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,6 +77,10 @@ protected override bool IsOnMainChainBehindHead(Block newHeadBlock, ForkchoiceSt | |
| return blockHeader; | ||
| } | ||
|
|
||
| // Taiko Pacaya allows equal timestamps because multiple L2 blocks can be derived | ||
| // from a single L1 block, all sharing the same L1 anchor timestamp. | ||
| protected override ulong GetMinRequiredTimestamp(Block newHeadBlock) => newHeadBlock.Timestamp; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change will allow equal timestamps for all the forks, not just Pacaya right?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, we do already have similar per-fork rules during block validation: https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.Taiko/TaikoHeaderValidator.cs#L204-L226. And when it comes to fcu, nmc is actually correctly mirroring here taiko-geth because taiko-geth also allows equal timestamps for all forks unconditionally: https://github.com/taikoxyz/taiko-geth/blob/taiko/miner/worker.go#L174-L187. So I don't think there is a need for this. |
||
|
|
||
| protected override bool TryGetBranch(Block newHeadBlock, out Block[] blocks) | ||
| { | ||
| // Allow resetting to any block already on the main chain (including genesis) | ||
|
|
||
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.
This function looks a bit random, the intention of adding 1 to the timestamp is not clear.
Do you think it wil be better to have the complete logic for checking timestamp as virtual, instead of only the minimum required timestamp? Something like
IsPayloadTimestampValidin theifstatement of line 296, and each module can override that function?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.
Just noticed the linked PR, not sure why it was removed. The existing
IsPayloadTimestampValidhttps://github.com/NethermindEth/nethermind/pull/10325/changes#diff-74bac6db7a134940f36bb275f9bd355e45f5428bf5f30cd4bd2b7fccd2b1b186There 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.
Also noticed Lukaz comment, I think we can still make
IsPayloadTimestampValidone-liner in the base class instead of usingGetMinRequiredTimestamp.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 like that, done!