Conversation
🦋 Changeset detectedLatest commit: dad6fd9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report
@@ Coverage Diff @@
## develop #1982 +/- ##
========================================
Coverage 74.42% 74.42%
========================================
Files 79 79
Lines 2545 2545
Branches 397 397
========================================
Hits 1894 1894
Misses 651 651
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
0ef4e81 to
9d30e0e
Compare
e8e9e8d to
77a81b1
Compare
|
This is now ready for review and includes tests. I need to double check two things before this is ready to merge:
|
|
| expect(l1BlockNumber.toNumber()).to.deep.equal(l1Block.number) | ||
|
|
||
| // L1 and L2 blocks will have the same timestamp. | ||
| // L1 and L2 blocks will have approximately the same timestamp. |
There was a problem hiding this comment.
Can we make the assertion of "strictly greater than" in addition to "approximately equal to"?
There was a problem hiding this comment.
Which do you mean should be greater than? - an L1 block can have at highest a timestamp of time.Now() + 15s which could be larger than the time.Now that the sequencer assigns to a transaction. This only applies if we do not trail L1 by any amount - then the configurable amount that we trail L1 by impacts which is larger
There was a problem hiding this comment.
I added another test that asserts that the L1 blocknumber and timestamps are ascending, it runs after the stress tests run
| log.Error("Could not update execution context", "error", err) | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Just leaving myself a mental note that we'll need to update the documentation to reflect this new behavior.
| // If enough time has passed, then assign the | ||
| // transaction to have the timestamp now. Otherwise, | ||
| // use the current timestamp | ||
| if now.Sub(current) > s.timestampRefreshThreshold { |
There was a problem hiding this comment.
What is this threshold set to? How often can we expect timestamps to refresh?
There was a problem hiding this comment.
Why even have a threshold at all?
There was a problem hiding this comment.
If we are required to have a threshold, it's worth noting that we're using the same threshold for both this logic and for the L1 block number updating logic. If we set the threshold too low we may have monotonicity issues with the L1 block number (wouldn't be good).
There was a problem hiding this comment.
There is a threshold here because otherwise we would blow up our batch context overhead, basically every tx would have its own context. The idea would be to set the threshold to 10-15 seconds and then all transactions that happen within that range would get the same timestamp
| log.Error("No tx timestamp found when running as verifier", "hash", tx.Hash().Hex()) | ||
| } else if tx.L1Timestamp() < s.GetLatestL1Timestamp() { | ||
| // This should never happen, but sometimes does | ||
| log.Error("Timestamp monotonicity violation", "hash", tx.Hash().Hex()) |
There was a problem hiding this comment.
Unrelated but since I'm seeing it, do we keep track of these errors @optimisticben?
There was a problem hiding this comment.
We do not track these errors, but that is a good idea
l2geth/rollup/sync_service.go
Outdated
| } | ||
|
|
||
| // Store the latest timestamp value | ||
| s.SetLatestL1Timestamp(tx.L1Timestamp()) |
There was a problem hiding this comment.
Are we sure we want to set this in all cases? Because we still get to this point even if tx.L1Timestamp() == 0 && s.verifier or tx.L1Timestamp() < s.GetLatestL1Timestamp() gets triggered. Maybe we only want to set if tx.L1Timestamp() > ts.
There was a problem hiding this comment.
So tx.L1Timestamp() == 0 && s.verifier should never happen. The only time when tx.L1Timestamp() == 0 is when a transaction is fresh from a user coming in via RPC
There was a problem hiding this comment.
I've noted the above via a comment
There was a problem hiding this comment.
Still wondering if we should gate on tx.L1Timestamp() > s.GetLatestL1Timestamp().
e65889b to
7c27306
Compare
l2geth/rollup/sync_service.go
Outdated
There was a problem hiding this comment.
The latest L1 blocknumber logic is now updated, it simply will see if the remote tip is greater than the known latest L1 block number and update it if so
7c27306 to
fb59ed4
Compare
This commit updates the timestamp updating logic such that `time.Now` is used instead of relying on L1 timestamps. This gives a higher fidelity for the `TIMESTAMP` opcode as well as makes the time on L2 be closer to the time on L1. L1 to L2 transactions no longer have the property of having the same timestamp on L2 as the timestamp of the L1 block they were included in. This should be able to be turned on without needing hardfork logic as replicas should always accept the timestamp that the sequencer sets. The sequencer is a trusted entity in the existing implementation and it is expected that the sequencer will become more trustless in future iterations of the protocol. This change is added to improve both UX and devex. Users are confused by the timestamps on Etherscan being ~15 minutes behind. This is due to the timestamps being set based on L1 block numbers, and the system only pulls L1 data once a secure amount of PoW is placed on top. Developers would like the timestamps to have a higher fidelity and be closer to the timestamps on L1.
Update the assertion to not expect that the timestamps are exactly equal but instead assert that the values are within 5%. This is because now the timestamps in L2 no longer correspond to L1 timestamps and may be updated arbitrarily by the sequencer.
fb59ed4 to
dad6fd9
Compare
|
Any ETA for this release on mainnet ? 😇 🙏 |
ETA for kovan as well? |
|
@0xged @Madalosso It's already live on Optimism Kovan. As far as I know, it will be live on mainnet on 25th if everything goes well on testnet. |
|
My bad @vinta I thought this would make the timestamps unique until I saw the comment (#1982 (comment)). |
### Description Sets up the first set of metrics for `kona-derive`. Closes #1981 Closes #1982
### Description Sets up the first set of metrics for `kona-derive`. Closes #1981 Closes #1982
Description
This commit updates the timestamp updating logic
such that
time.Nowis used instead of relying onL1 timestamps. This gives a higher fidelity for the
TIMESTAMPopcode as well as makes the time on L2be closer to the time on L1.
L1 to L2 transactions no longer have the property of
having the same timestamp on L2 as the timestamp
of the L1 block they were included in.
This should be able to be turned on without needing
hardfork logic as replicas should always accept the
timestamp that the sequencer sets. The sequencer is
a trusted entity in the existing implementation and
it is expected that the sequencer will become more
trustless in future iterations of the protocol.
This change is added to improve both UX and devex.
Users are confused by the timestamps on Etherscan
being ~15 minutes behind. This is due to the timestamps
being set based on L1 block numbers, and the system
only pulls L1 data once a secure amount of PoW
is placed on top. Developers would like the timestamps
to have a higher fidelity and be closer to the timestamps
on L1.
Metadata