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

vat-timer thinks time=0 during bootstrap block #7124

Closed
warner opened this issue Mar 6, 2023 · 0 comments · Fixed by #7125
Closed

vat-timer thinks time=0 during bootstrap block #7124

warner opened this issue Mar 6, 2023 · 0 comments · Fixed by #7125
Assignees
Labels
bug Something isn't working cosmic-swingset package: cosmic-swingset SwingSet package: SwingSet

Comments

@warner
Copy link
Member

warner commented Mar 6, 2023

PR #7000 caused the loadgen/integration-test to go into a fast loop, partly because the auction code appears to require O(interval) iterations to handle a timequake of interval seconds, but equally partly because our chain startup code thinks that the current time value is "0" during the execution of the bootstrap block.

Time only updates between block boundaries, so every interaction with the TimerService during bootstrap will see the same time=0 vaue. Then, after bootstrap finishes, just before block-1 starts, the host application does a poll(blocktime), which updates the device's view of the current time. All the timer interactions during block-1 will see this new value, which of course is roughly 1.7 billion seconds larger than 0. This discontinuity may be surprising to code that assumes it will be woken up promptly.

We need the auction code (and all code that uses the TimerService) to handle such timequakes smoothly. But it would also be nice if the bootstrap block had a better idea about the current time.

When swingset is starting in a new chain, the genesis.json data (which is within consensus, and is indeed the very definition of initial TOFU-style consensus) includes a genesis_time field. This seems like a reasonable initial value for the timer device to use.

When swingset is being reinitialized in an existing chain (our upcoming "bulldozer upgrade", we want to use the blocktime of the most recent block, instead.

We aren't yet sure of the best way to get this tme value into the devce. One thought is to call poll() early, before the first controller.run() has a chance to execute the bootstrap message, however poll() depends upon some callbacl wiring code that may not have executed yet.

Another idea is to include the initial timestamp value as one of the timer device's deviceEndowments (which usually hold functions, but could hold plain data just as easily). The trick there is to not accidentally cause consensus problems after the initial step: each time we restart the validator, we'd be passing a different value into this endowment, but the device should only pay attention to it when it does not already remember the latest timestamp.

@warner warner added bug Something isn't working SwingSet package: SwingSet cosmic-swingset package: cosmic-swingset labels Mar 6, 2023
@mergify mergify bot closed this as completed in #7125 Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cosmic-swingset package: cosmic-swingset SwingSet package: SwingSet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants