-
Notifications
You must be signed in to change notification settings - Fork 208
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
change TimerService to use branded Timestamps #6003
Comments
This will house timerMath.js, and types for TimerBrand, Timestamp, and RelativeTime. It also holds types for a TimerService, although the service implementation is in SwingSet (inside `vat-timer`). refs #6003
This will house timerMath.js, and types for TimerBrand, Timestamp, and RelativeTime. It also holds types for a TimerService, although the service implementation is in SwingSet (inside `vat-timer`). refs #6003
This will house timerMath.js, and types for TimerBrand, Timestamp, and RelativeTime. It also holds types for a TimerService, although the service implementation is in SwingSet (inside `vat-timer`). refs #6003
This will house timerMath.js, and types for TimerBrand, Timestamp, and RelativeTime. It also holds types for a TimerService, although the service implementation is in SwingSet (inside `vat-timer`). refs #6003
This will house timerMath.js, and types for TimerBrand, Timestamp, and RelativeTime. It also holds types for a TimerService, although the service implementation is in SwingSet (inside `vat-timer`). refs #6003
This will house timerMath.js, and types for TimerBrand, Timestamp, and RelativeTime. It also holds types for a TimerService, although the service implementation is in SwingSet (inside `vat-timer`). refs #6003
This will house timerMath.js, and types for TimerBrand, Timestamp, and RelativeTime. It also holds types for a TimerService, although the service implementation is in SwingSet (inside `vat-timer`). refs #6003
I'm trying to work out a plan for the ongoing transition to fully-branded time. I see that Zoe and a bunch of contracts take Our desired end state is:
Of course, these types cross a lot of interface boundaries, so it's a big task to change everything in a single PR. I think the following incremental plan might work:
I don't want to hang out in step 4 forever, but I also learned that there's a lot of code that thinks it knows what Time is, and I got stuck trying to push past that point in a single PR. So I'm going to make a PR that has a commit for 1, then 3, then 3, and stop there. We'll have (one note: code which thinks it can compare timestamps with |
I've got a branch (6003-branded-timestamps) that makes a start at the first step of a different path, where we change the return values of TimerService to provide branded Record types, but we leave the inputs tolerant of both branded The branch does not yet pass all tests, but it's a start, and I think the remaining work should be a matter of adapting the changes so far to the remaining failing tests. |
The service still accepts both branded and unbranded (i.e. bigint) TimestampValue and RelativeTimeValue, but all emitted values (`getCurrentTimestamp`, `handler.wake()` callbacks, Promise resolution values, Notifier updates) will be branded records. Client code must be prepared to accept these, in particular it must use TimeMath.compareAbs() to compare two timestamps, since they are records (objects), and using `>` will give erroneous results. Client authors should begin the transition process of submitting branded TimestampRecord and RelativeTimeRecord to the TimerService. A future upgrade will stop accepting non-branded values. refs #6003
The service still accepts both branded and unbranded (i.e. bigint) TimestampValue and RelativeTimeValue, but all emitted values (`getCurrentTimestamp`, `handler.wake()` callbacks, Promise resolution values, Notifier updates) will be branded records. Also added some conveniences to manual-timer.js refs #6003
The service still accepts both branded and unbranded (i.e. bigint) TimestampValue and RelativeTimeValue, but all emitted values (`getCurrentTimestamp`, `handler.wake()` callbacks, Promise resolution values, Notifier updates) will be branded records. Client code must be prepared to accept these, in particular it must use TimeMath.compareAbs() to compare two timestamps, since they are records (objects), and using `>` will give erroneous results. Client authors should begin the transition process of submitting branded TimestampRecord and RelativeTimeRecord to the TimerService. A future upgrade will stop accepting non-branded values. Also the `TimeMath.toAbs`/`toRel` functions were replaced with `coerceTimestampRecord`/`coerceRelativeTimeRecord`, and accept any of Number, Bigint, or a correctly-branded record. They throw if given a branded record that does not match the target brand in the second argument. This should be used when converting a bare number (supplied by some external code which thinks it understands time) to a record suitable for submitting to the future (strict) TimerService. refs #6003 Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
The service still accepts both branded and unbranded (i.e. bigint) TimestampValue and RelativeTimeValue, but all emitted values (`getCurrentTimestamp`, `handler.wake()` callbacks, Promise resolution values, Notifier updates) will be branded records. The manual-timer.js mock accepts bigints on the control surface, for convenience, but returns branded TimestampRecord to API callers, just like the real vat-timer. Some additional conveniences were added. refs #6003 Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
PR #6904 just landed, which changes the TimerService (vat-timer) to exclusively emit/return branded We aren't going to try to make the second change (vat-timer only accepts branded time) in the Vaults release: we'll gradually change zoe and contracts to send branded time first, then we'll change vat-timer. So this ticket does not close yet, but can be moved out of the vaults release. We've done what we can for now. |
What is the Problem Being Solved?
Now that #5668 is complete and
TimerBrand
is available, one follow-on step is to include the brand inTimestamp
andRelativeTime
objects.On the
vat-timer
side, we this change is pretty tiny: there are alreadytoTimestamp()
andfromTimestamp()
functions in the right places, which are ready to be edited to insert/check+strip the brands as they cross the vat-timer boundary. I didn't think that far ahead ontest-vat-timer.js
but the changes are pretty mechanical.The deeper task is all the existing code that deals with Timestamps. In general, all normal code would be getting Timestamps from the timer service in the first place, so they shouldn't be synthesizing
Timestamps
de novo (and would thus need to be changed to include a brand). But there are lots of unit tests which build them manually, and those would need to be changed.Before starting this, I think I'd like to move all the
timeMath.js
code out of swingset and into its own package, tentatively named@agoric/timestamp
.cc @erights
Description of the Design
Change
vat-timer.js
toTimestamp
to insert the brand, andfromTimestamp
to assert the incoming brand matches before stripping it into aTimerValue
. Change unit tests to match.Security Considerations
none I can think of, this should be strictly more restrictive than before
Test Plan
The text was updated successfully, but these errors were encountered: