Skip to content
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 block.timestamp asserter for AA #3031

Merged
merged 84 commits into from
Nov 1, 2024
Merged

Conversation

ischasny
Copy link
Collaborator

@ischasny ischasny commented Oct 8, 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

@Deniallugo Deniallugo force-pushed the ivan/add-timestamp-asserter branch from 9535470 to bc97621 Compare October 9, 2024 09:19
Signed-off-by: Danil <deniallugo@gmail.com>
@Deniallugo Deniallugo force-pushed the ivan/add-timestamp-asserter branch from bc97621 to 86cad9f Compare October 9, 2024 09:37
@ischasny ischasny enabled auto-merge October 31, 2024 14:19
Copy link
Contributor

@slowli slowli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than a potential error getting remote EN config, looks fine.

core/bin/external_node/src/config/mod.rs Outdated Show resolved Hide resolved
core/bin/external_node/src/config/mod.rs Outdated Show resolved Hide resolved
core/lib/dal/src/transactions_dal.rs Outdated Show resolved Hide resolved
core/lib/multivm/src/tracers/validator/vm_latest/mod.rs Outdated Show resolved Hide resolved
core/lib/vm_interface/src/types/tracer.rs Outdated Show resolved Hide resolved
core/node/api_server/src/tx_sender/mod.rs Show resolved Hide resolved
core/tests/ts-integration/tests/custom-account.test.ts Outdated Show resolved Hide resolved
core/tests/ts-integration/tests/custom-account.test.ts Outdated Show resolved Hide resolved
core/bin/external_node/src/config/mod.rs Show resolved Hide resolved
core/bin/external_node/src/config/mod.rs Outdated Show resolved Hide resolved
core/bin/zksync_server/src/node_builder.rs Outdated Show resolved Hide resolved
slowli
slowli previously approved these changes Nov 1, 2024
artmakh
artmakh previously approved these changes Nov 1, 2024
@ischasny ischasny added this pull request to the merge queue Nov 1, 2024
yorik
yorik previously approved these changes Nov 1, 2024
Copy link
Contributor

@yorik yorik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve for workflows.

.github/workflows/new-build-core-template.yml Outdated Show resolved Hide resolved
@ischasny ischasny removed this pull request from the merge queue due to a manual request Nov 1, 2024
@ischasny ischasny dismissed stale reviews from yorik, artmakh, and slowli via 42cc5f7 November 1, 2024 10:25
@ischasny ischasny enabled auto-merge November 1, 2024 10:26
@ischasny ischasny added this pull request to the merge queue Nov 1, 2024
Merged via the queue into main with commit 069d38d Nov 1, 2024
43 checks passed
@ischasny ischasny deleted the ivan/add-timestamp-asserter branch November 1, 2024 11:20
Artemka374 added a commit that referenced this pull request Nov 1, 2024
github-merge-queue bot pushed a commit that referenced this pull request Nov 5, 2024
🤖 I have created a release *beep* *boop*
---


##
[25.1.0](core-v25.0.0...core-v25.1.0)
(2024-11-04)


### Features

* add `block.timestamp` asserter for AA
([#3031](#3031))
([069d38d](069d38d))
* allow vm2 tracers to stop execution
([#3183](#3183))
([9dae839](9dae839))
* **api:** get rid of tx receipt root
([#3187](#3187))
([6c034f6](6c034f6))
* **api:** Integrate new VM into API server (no tracers)
([#3033](#3033))
([8e75d4b](8e75d4b))
* base token integration tests
([#2509](#2509))
([8db7e93](8db7e93))
* **consensus:** enabled syncing pregenesis blocks over p2p
([#3192](#3192))
([6adb224](6adb224))
* **da-clients:** add Celestia client
([#2983](#2983))
([d88b875](d88b875))
* **da-clients:** add EigenDA client
([#3155](#3155))
([5161eed](5161eed))
* gateway preparation
([#3006](#3006))
([16f2757](16f2757))
* Implement gas relay mode and inclusion data for data attestation
([#3070](#3070))
([561fc1b](561fc1b))
* **metadata-calculator:** Add debug endpoints for tree API
([#3167](#3167))
([3815252](3815252))
* **proof-data-handler:** add first processed batch option
([#3112](#3112))
([1eb69d4](1eb69d4))
* **proof-data-handler:** add tee_proof_generation_timeout_in_secs param
([#3128](#3128))
([f3724a7](f3724a7))
* **prover:** Add queue metric to report autoscaler view of the queue.
([#3206](#3206))
([2721396](2721396))
* **prover:** Add sending scale requests for Scaler targets
([#3194](#3194))
([767c5bc](767c5bc))
* **prover:** Add support for scaling WGs and compressor
([#3179](#3179))
([c41db9e](c41db9e))
* **vm:** Support EVM emulation in fast VM
([#3163](#3163))
([9ad1f0d](9ad1f0d))


### Bug Fixes

* **consensus:** better logging of errors
([#3170](#3170))
([a5028da](a5028da))
* **consensus:** made attestation controller non-critical
([#3180](#3180))
([6ee9f1f](6ee9f1f))
* **consensus:** payload encoding protected by protocol_version
([#3168](#3168))
([8089b78](8089b78))
* **da-clients:** add padding to the data within EigenDA blob
([#3203](#3203))
([8ae06b2](8ae06b2))
* **da-clients:** enable tls-roots feature for tonic
([#3201](#3201))
([42f177a](42f177a))
* extend allowed storage slots for validation as per EIP-7562
([#3166](#3166))
([c76da16](c76da16))
* **merkle-tree:** Fix tree truncation
([#3178](#3178))
([9654097](9654097))
* **tee_prover:** add prometheus pull listener
([#3169](#3169))
([1ffd22f](1ffd22f))
* update logging in cbt l1 behaviour
([#3149](#3149))
([d0f61b0](d0f61b0))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: zksync-era-bot <zksync-era-bot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants