fix(swingset): comms initialization check must be deterministic #3727
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The comms vat has a bunch of counters that need to be initialized exactly
once in the lifetime of the vat's durable state. There is a DB flag named
initialize
to track whether this has happened already or not. Since vatscan only do syscalls during deliveries, not startup (see #2910), the comms
vat must read this flag on every delivery, just in case this is the very
first one, and the DB needs initialization.
The comms vat was using an in-RAM flag (
needToInitializeState
) to cache theresult, to avoid a DB read for every single delivery. However this caused the
syscall behavior to change for the first delivery after a kernel restart.
There were two extra syscalls taking place: a
vatstoreGet('initialized')
,and a
vatstoreSet('meta.o+0', 'true')
. ThevatstoreSet
was causing a DBchange, which was picked up by the new kernel activityhash, and caused a
consensus failure on the first post-restart comms message.
This changes the comms vat to always read the DB flag, on every delivery,
making its behavior consistent and independent of kernel restarts. It also
moves the
vatstoreSet
to be guarded by the results of theinitialized
check, so it only happens once in the lifetime of the vat.
To remove the need for the
vatstoreGet
on each delivery, we'll need toenhance the way
setup()
is called, to provide an external flag that tellsthe vat whether this is the very first time ever, or if it's merely a kernel
restart that required the vat's
dispatch
object to be reconstructed.fixes #3726