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

create new @agoric/time package, move timeMath.js and types #6867

Merged
merged 7 commits into from
Feb 1, 2023

Conversation

warner
Copy link
Member

@warner warner commented Jan 27, 2023

This creates a new package named @agoric/time, to house timerMath.js, and types for TimerBrand, Timestamp, and RelativeTime.

It also holds types for a TimerService, although the service implementation remains in SwingSet (inside vat-timer).

Clients who use time must now get their types and math functions with e.g. import { TimeMath } from '@agoric/time'.

refs #6003

But does not close it yet, because the Timestamps are not yet universally branded.

@warner warner self-assigned this Jan 27, 2023
@warner warner added the SwingSet package: SwingSet label Jan 27, 2023
@warner
Copy link
Member Author

warner commented Jan 27, 2023

@erights I deleted timed-iteration.js because it was unused, but if that was too harsh of me, say the word and I'll bring it back.

Copy link
Contributor

@Chris-Hibbert Chris-Hibbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NEWS.md and CHANGELOG.md were copied in toto, and should be cut down.

packages/time/NEWS.md Outdated Show resolved Hide resolved
packages/time/CHANGELOG.md Show resolved Hide resolved
@warner
Copy link
Member Author

warner commented Jan 27, 2023

I'm iterating on types, there will be some CI back and forth as I figure out what I'm doing (thanks @turadg !)

@warner warner force-pushed the 6003-time-math-package branch from 5e7f150 to 1e8e4c6 Compare January 27, 2023 22:08
@erights
Copy link
Member

erights commented Jan 27, 2023

@erights I deleted timed-iteration.js because it was unused, but if that was too harsh of me, say the word and I'll bring it back.

Deletion is fine. Since this is the PR deleting it, I'll note here that it is a great example of how to do a cold notifier --- by simply doing a cold async iterable. Attn @michaelfig

@warner warner force-pushed the 6003-time-math-package branch from 1e8e4c6 to a09b47a Compare January 28, 2023 01:21
@@ -22,8 +22,8 @@ const makeVoterVat = async (log, vats, zoe) => {
/**
*
* @param {Pick<QuestionDetails, 'issue' | 'positions' | 'electionType'>} qDetails
* @param {TimestampValue} closingTime
* @param {{ electorateFacet: import('../../../src/committee.js').CommitteeElectorateCreatorFacet, installations: Record<string, Installation>, timer: TimerService }} tools
* @param {import('@agoric/time/src/types').Timestamp} closingTime
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: this replaces TimestampValue (which is just an integer) with the preferred TimeStamp (which is currently either an integer or a branded record, but the next step of #6003 is to require them all to be branded)

@warner
Copy link
Member Author

warner commented Jan 28, 2023

Ok, ready for review. My use of types is probably pretty bad, please recommend fixes.

I'll do some squashing/rewriting of this after review, before I land it, to make the last few "fighting with CI" commits more sensible.

@erights please see if this matches your vision for time management (knowing that I'm working on the next step, to require brands on all Timestamp and RelativeTime objects).

@turadg please be critical about types.

@Chris-Hibbert please see if this matches what you need/expect on the client side.

@warner warner marked this pull request as ready for review January 28, 2023 01:55

// This consumes O(N) RAM only for outstanding promises, via wakeAt(),
// delay(), and Notifiers/Iterators (for each actively-waiting
// client). Everything else should remain in the DB.

/**
* @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed, this faux import copies the structure but not the documentation.

I think that's acceptable for the scope of this change.

@@ -32,7 +32,7 @@ const makeApiInvocationPositions = (apiMethodName, methodArgs) => {
* @param {Instance} governedInstance
* @param {ERef<{ [methodName: string]: (...args: any) => unknown }>} governedApis
* @param {Array<string | symbol>} governedNames names of the governed API methods
* @param {ERef<TimerService>} timer
* @param {ERef<import('@agoric/time/src/types').TimerService>} timer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be worth the investment to get these on the package export:

Suggested change
* @param {ERef<import('@agoric/time/src/types').TimerService>} timer
* @param {ERef<import('@agoric/time').TimerService>} timer

But I don't think that need be a blocker. It stands out like a sore thumb so it'll get addressed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b7987bf should do it

Comment on lines +8 to +9
// These aren't in the global runtime environment. They are just types that are
// meant to be globally accessible as a side-effect of importing this module.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was for the declare global so no longer applicable.

@@ -7,9 +7,6 @@ import { CONTRACT_ELECTORATE, ParamTypes } from '@agoric/governance';
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
import { Stable } from '../tokens.js';

// Ambient types (globals)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@michaelfig
Copy link
Member

I deleted timed-iteration.js because it was unused,
I'll note here that it is a great example of how to do a cold notifier --- by simply doing a cold async iterable.

Noted. As per our discussions around the future of @agoric/notifier, I expect the unified API will help encourage people to write cold (pull-based) producers when possible.

@warner warner force-pushed the 6003-time-math-package branch 3 times, most recently from 5cb6fff to f897df4 Compare January 31, 2023 21:45
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 is a straight move, with no code changes, for the sake of
review. Of course this means that both old and new packages won't work
until the next few commits, which will fix up the necessary imports.
* zoe
* governamce
* inter-protocol
* swingset

This also removes the old type "<reference>" clause from swingset's
`exported.js`, since the timer types are no longer found there.
This updates a lot of downstream packages to get their Time-related
types from the right place, and adds package.json dependencies so they
can import those types.
@warner warner force-pushed the 6003-time-math-package branch from f897df4 to 418545a Compare February 1, 2023 07:43
@warner warner added the automerge:rebase Automatically rebase updates, then merge label Feb 1, 2023
@mergify mergify bot merged commit a7a2f9a into master Feb 1, 2023
@mergify mergify bot deleted the 6003-time-math-package branch February 1, 2023 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge SwingSet package: SwingSet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants