Question for block.timestamp #13
-
EnvironmentMainnet Provide a brief description of the functionality you're trying to implement.I am trying to figure out the timestamp update of zksync era.
What is the specific issue or error you're encountering?I am trying to log the timestamp of ZkSync Era. And I send two tx on the mainet. the two tx were log the timestamp of my tx. But there are in different block but return the same block.timestamp which comfused me. Can you share the error messages or logs you're receiving, if any?![]() Have you made any recent changes to the contract before encountering this issue?no Are there any external libraries or contracts that your contract interacts with?https://explorer.zksync.io/address/0xbbdF04a4c418f09Bab41a6d74AbDC39339df9772#events Can you provide the relevant portions of your contract code where the issue is occurring?no Have you tried to isolate the problem, and if so, what were the results?no What steps have you already taken to try to resolve the issue?no Repo Link (Optional)No response Additional DetailsNo response |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 2 replies
-
Here's our docs that have more details about how block number and timestamp work on zkSync Era for now https://era.zksync.io/docs/dev/developer-guides/transactions/blocks.html#block-number-and-timestamp-considerations In the future we will be working on implementing so it returns the L2 block timestamp |
Beta Was this translation helpful? Give feedback.
-
Yeah I have already read the the doc but still have above questions. @bxpana could you give me an explanation for those questions? How often will ZkSync ERA get L1’s timestamp? |
Beta Was this translation helpful? Give feedback.
-
@bxpana and have a more question |
Beta Was this translation helpful? Give feedback.
-
block.timestamp will return the timestamp from the latest batch produed. In your case, your transactions were included in the batch #50922 which was produced at the same timestamp that your transactions emit in the event, 1685714192 (Fri Jun 02 2023 13:56:32 GMT+0000). Hope that helps understand how it currently works. A batch will include transactions from multiple blocks and the batch is sealed/produced based on different parameters like timeout or just space in the batch, so there's not a fixed time to produce batches. You can read about that in this page of the docs. The more usage in the network, the faster batches will be sealed/produced.
Yes, for the moment block.timestamp will have a delayed value as it returns the timestamp the last produced batch.
Very unlikely, only if the proof cannot be generated.
Not exactly of L1, but from the latest batch produced. Finally, we're working on different methods to allow developers to access both the L2 timestamp and the L1 timestamp. |
Beta Was this translation helpful? Give feedback.
-
Thank you so much! |
Beta Was this translation helpful? Give feedback.
block.timestamp will return the timestamp from the latest batch produed. In your case, your transactions were included in the batch #50922 which was produced at the same timestamp that your transactions emit in the event, 1685714192 (Fri Jun 02 2023 13:56:32 GMT+0000). Hope that helps understand how it currently works.
A batch will include transactions from multiple blocks and the batch is sealed/produced based on different parameters like timeout or just space in the batch, so there's not a fixed time to produce batches. You can read about that in this page of the docs. The more usage in the network, the faster batches will be sealed/produced.