-
Notifications
You must be signed in to change notification settings - Fork 345
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
feat: add timestamp asserter contract #843
Merged
ischasny
merged 7 commits into
release-v25-protocol-defense
from
ivan/add-time-window-asserter
Oct 31, 2024
Merged
feat: add timestamp asserter contract #843
ischasny
merged 7 commits into
release-v25-protocol-defense
from
ivan/add-time-window-asserter
Oct 31, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ischasny
requested review from
Deniallugo,
vladbochok and
StanislavBreadless
as code owners
October 8, 2024 15:49
ischasny
force-pushed
the
ivan/add-time-window-asserter
branch
from
October 16, 2024 10:07
c88da6d
to
1f4018f
Compare
ischasny
force-pushed
the
ivan/add-time-window-asserter
branch
from
October 29, 2024 17:21
b40b2d5
to
72a3e8e
Compare
vladbochok
reviewed
Oct 30, 2024
vladbochok
requested changes
Oct 30, 2024
ischasny
changed the title
[DRAFT] add timestamp asserter contract
feat: add timestamp asserter contract
Oct 31, 2024
vladbochok
approved these changes
Oct 31, 2024
Co-authored-by: Vlad Bochok <41153528+vladbochok@users.noreply.github.com>
github-merge-queue bot
pushed a commit
to matter-labs/zksync-era
that referenced
this pull request
Nov 1, 2024
This PR adds the ability to use `block.timestamp` in custom AA contracts. AAs will still not have direct access to `block.timestamp`, but can utilize it via a proxy that enforces certain constraints. The PR introduces a `TimestampAsserter` contract that is deployed on every chain to the user space, similar to `Multicall3`. This contract has a single function, `assertTimestampInRange(start, end)`, which can be used by AAs at their discretion. The `TimestampAsserter` contract ensures that `block.timestamp` falls within the specified `(start, end)` range. Additionally, the sequencer verifies that the `block.timestamp` is sufficiently far from the range’s end. This is to prevent DoS attacks where transactions pass validation but get stuck in the mempool during execution. This constraint is configurable and can be adjusted without requiring protocol update. The PR also introduces two new fields to the `transactions` table: `timestamp_asserter_range_start` and `timestamp_asserter_range_end`. These fields are extracted during transaction execution in the sandbox by the `ValidationTracer`. If multiple assertions are made in a single transaction, the system captures the maximum of the starts and the minimum of the ends, resulting in the narrowest possible time range. Transactions with time range constraints will undergo additional verification before being included in a block. If the current time falls outside the transaction’s specified time range, the transaction will be rejected with an appropriate message. Sister PR in `era-contracts`: matter-labs/era-contracts#843 --------- Signed-off-by: Danil <deniallugo@gmail.com> Co-authored-by: Danil <deniallugo@gmail.com>
github-merge-queue bot
pushed a commit
to matter-labs/zksync-era
that referenced
this pull request
Nov 1, 2024
This PR adds the ability to use `block.timestamp` in custom AA contracts. AAs will still not have direct access to `block.timestamp`, but can utilize it via a proxy that enforces certain constraints. The PR introduces a `TimestampAsserter` contract that is deployed on every chain to the user space, similar to `Multicall3`. This contract has a single function, `assertTimestampInRange(start, end)`, which can be used by AAs at their discretion. The `TimestampAsserter` contract ensures that `block.timestamp` falls within the specified `(start, end)` range. Additionally, the sequencer verifies that the `block.timestamp` is sufficiently far from the range’s end. This is to prevent DoS attacks where transactions pass validation but get stuck in the mempool during execution. This constraint is configurable and can be adjusted without requiring protocol update. The PR also introduces two new fields to the `transactions` table: `timestamp_asserter_range_start` and `timestamp_asserter_range_end`. These fields are extracted during transaction execution in the sandbox by the `ValidationTracer`. If multiple assertions are made in a single transaction, the system captures the maximum of the starts and the minimum of the ends, resulting in the narrowest possible time range. Transactions with time range constraints will undergo additional verification before being included in a block. If the current time falls outside the transaction’s specified time range, the transaction will be rejected with an appropriate message. Sister PR in `era-contracts`: matter-labs/era-contracts#843 --------- Signed-off-by: Danil <deniallugo@gmail.com> Co-authored-by: Danil <deniallugo@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TimestampAsserter
contract that allows to assertblock.timestamp
value from AA;Multicall3
;