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

fix: block.timestamp is not accurate #3533

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

thomas-nguy
Copy link
Member

What ❔

Related to zkSync-Community-Hub/zksync-developers#820

Change the l2 block creation logic to start a new l2 block only when a transaction is ready to be executed.

Why ❔

Current logic start a new l2 block as soon as the previous one is sealed.

A contract that relies on block.timestamp would be able to predict the time correctly because if the l2 block goes stale (no transaction), then it will be open indefinitely and the timestamp will not be accurate anymore

Solution has been tested locally but any feedbacks would be appreciated

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • Code has been formatted via zkstack dev fmt and zkstack dev lint.

@thomas-nguy thomas-nguy force-pushed the thomas/fix-block-timestamp-2 branch from ebd99f7 to bfa0c81 Compare January 27, 2025 02:33
@@ -222,7 +222,7 @@ async fn external_io_basics(snapshot_recovery: bool) {
let tx = create_l2_transaction(10, 100);
let tx_hash = tx.hash();
let tx = FetchedTransaction::new(tx.into());
let actions = vec![open_l1_batch, tx.into(), SyncAction::SealL2Block];
let actions = vec![open_l1_batch, tx.into(), SyncAction::SealBatch];
Copy link
Member Author

Choose a reason for hiding this comment

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

With the new changes, action that precede an OpenBatch has to be SealBatch

@thomas-nguy thomas-nguy force-pushed the thomas/fix-block-timestamp-2 branch 3 times, most recently from 2f68cec to f690e04 Compare January 27, 2025 06:03
@thomas-nguy thomas-nguy force-pushed the thomas/fix-block-timestamp-2 branch 3 times, most recently from c5db23f to 005fbe3 Compare January 28, 2025 15:12
@thomas-nguy thomas-nguy force-pushed the thomas/fix-block-timestamp-2 branch from 005fbe3 to d1594e2 Compare January 28, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant