-
Notifications
You must be signed in to change notification settings - Fork 392
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
gnodev time.Now() values are not preserved on reload #1509
Labels
🐞 bug
Something isn't working
Comments
9 tasks
r3v4s
pushed a commit
to gnoswap-labs/gno
that referenced
this issue
Dec 10, 2024
- [x] depends on gnolang#2941 resolve gnolang#1509 This PR addresses the timestamp issue on gnodev by implementing the `MetadataTX` changes from gnolang#2941. Timestamps will now be correctly handled for `Reload` and `import`/`export`. For `Reset`, the timestamp will be updated to the current time. cc @zivkovicmilos @thehowl #### ~TODOs~ - [x] test replays (I've only tested it manually) <details><summary>Contributors' checklist...</summary> - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details> --------- Signed-off-by: gfanton <[email protected]>
albttx
pushed a commit
that referenced
this issue
Jan 10, 2025
- [x] depends on #2941 resolve #1509 This PR addresses the timestamp issue on gnodev by implementing the `MetadataTX` changes from #2941. Timestamps will now be correctly handled for `Reload` and `import`/`export`. For `Reset`, the timestamp will be updated to the current time. cc @zivkovicmilos @thehowl #### ~TODOs~ - [x] test replays (I've only tested it manually) <details><summary>Contributors' checklist...</summary> - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details> --------- Signed-off-by: gfanton <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In gnodev, preserve time.Now() values on reload
Description
In gnodev, the reload operation replays all the transactions. In general this lets the realm functions restore the state. But if some realm functions use
time.Now()
then this returns the (arbitrary) time of reload, not the time of the original transaction. Therefore, reload does not actually restore the state.Your environment
Steps to reproduce
CreateThread
as follows:Expected behaviour
The boards realm uses
time.Now()
for the displayed post time. Reload should restore the realm state including timestamps fromtime.Now()
Actual behaviour
The timestamps of all message have the time of reload, erasing important information. This is because to reload gnodev resends the transactions where the block time is the current time of reload. This same timestamp is returned by every call to
time.Now()
.(Related, the boards realm in testnet3 was built by replaying transactions, similarly to gnodev reload. The original message timestamps are erased and are set to the same value "2023-08-18 11:44am UTC". https://test3.gno.land/r/demo/boards:testboard .)
Proposed solution
One possible solution: The transaction processing code should have an option to specify the block time. Instead of using a high-level broadcast during replay, gnodev should call the lower-level transaction processing code and supply the correct timestamp of the original transaction. This will be used by
time.Now()
.Here are the message times before reload:
![Screenshot 2024-01-10 at 10 15 01](https://private-user-images.githubusercontent.com/1999543/295516475-8d227bbf-8179-47f0-abba-45a39f1511bd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MTUyOTksIm5iZiI6MTczOTUxNDk5OSwicGF0aCI6Ii8xOTk5NTQzLzI5NTUxNjQ3NS04ZDIyN2JiZi04MTc5LTQ3ZjAtYWJiYS00NWEzOWYxNTExYmQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTRUMDYzNjM5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MDQ5ZjI4NjU5MjM4MDhjODA3OTgwYmY4OTY4NjBiYzY2NTlmYjI2YWE5MGVkMjRlMjY2YWVkMDFlMjkwODZmYyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.Op92S9B5iY2MUF4Wq-dTLqZnd2xY7bBItYQIhd0eB0k)
Here is where all timestamps are reset after reload:
![Screenshot 2024-01-10 at 10 17 17](https://private-user-images.githubusercontent.com/1999543/295516572-624fb6e4-605c-4a6c-b73b-5c1d54be5a90.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MTUyOTksIm5iZiI6MTczOTUxNDk5OSwicGF0aCI6Ii8xOTk5NTQzLzI5NTUxNjU3Mi02MjRmYjZlNC02MDVjLTRhNmMtYjczYi01YzFkNTRiZTVhOTAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTRUMDYzNjM5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDEwYWM5OGQyZGZiYjhkZjUxMDNjZDU3ZDI1M2I2NzEyMjc1OWU5NDIyYWM1MGNkN2Q3MmUxNDgyMTVjNmQ2ZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.Hb_Lt9P4ZMI-UDJvXo5dK0lUasfomXU43F19Y13Z4-A)
A realm developer can't use gnodev with any realm that relies on
time.Now()
. For example:time.Now()
but they introduce security risks of not having reliable timestamps from the transaction.The text was updated successfully, but these errors were encountered: