Skip to content

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
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
@thomas-nguy thomas-nguy closed this Feb 3, 2025
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