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

Add Counter abstraction to Swingset #2400

Closed
katelynsills opened this issue Feb 11, 2021 · 2 comments · Fixed by #2420
Closed

Add Counter abstraction to Swingset #2400

katelynsills opened this issue Feb 11, 2021 · 2 comments · Fixed by #2420
Assignees
Labels
enhancement New feature or request SwingSet package: SwingSet

Comments

@katelynsills
Copy link
Contributor

katelynsills commented Feb 11, 2021

As part of the work transitioning agoric-sdk to use the BigInt version of @agoric/nat, I realized that Swingset uses Nat extensively for asserting ids and counts. There is a open question of whether BigInt is the right thing to use for ids and counts which I will set aside for others to decide on, but to make the transition from the old versions of Nat easier, @warner suggested adding a counter abstraction such that the implementation details of using number or bigint would be hidden.

The counter would have:

  • to/from string
  • increment

And potentially:

  • decrement (for counts, not ids)
  • comparisons to 0 or initial state (for counts which decrement)
@katelynsills katelynsills added the enhancement New feature or request label Feb 11, 2021
@katelynsills katelynsills self-assigned this Feb 11, 2021
@katelynsills katelynsills added the SwingSet package: SwingSet label Feb 11, 2021
@katelynsills katelynsills added this to the Beta Launch milestone Feb 11, 2021
@erights
Copy link
Member

erights commented Feb 13, 2021

I hope this is temporary until we make up our mind, and I hope we make up our mind quickly to use BigInt. Yes, there may be a performance cost currently for BigInts compared to floats on XS. But we do know how to fix that. Yes, we probably cannot get it fixed quickly. But neither do we know whether the performance difference will be a significant cost in the interim.

Aside from the options value of enabling us to postpone this decision, #2420 does not seem like a useful abstraction beyond that already provided by Nat. None of its operations are more convenient than just doing them directly with Nats.

@katelynsills
Copy link
Contributor Author

The PR has additional benefits like:

  • Using constants for special numbers like 1n and other initial values.
  • Eliminating duplicate code in kernelKeeper.js

warner added a commit that referenced this issue Feb 15, 2021
The VatManager is responsible for maintaining a transcript of all deliveries
to their vat worker, so the vat can be reloaded later. These transcript
entries have been including the `crankNumber`: a global counter indicating
how many cranks have been delivered (to all vats, not just the one for which
the transcript entry is being created).

This removes that crankNumber from the transcript:

* each vat should be independent, this global crankNumber is revealing
information about what happens in other vats
* #2400 is changing the type of `crankNumber` to a BigInt, which cannot be
serialized by the simple `JSON.stringify` used in vatKeeper.js

It also removes the now-unnecessary `kernelKeeper` argument from
`makeTranscriptManager`, and changes one test that happened to depend upon
the presence of the crankNumber field.

closes #2428
warner added a commit that referenced this issue Feb 15, 2021
The VatManager is responsible for maintaining a transcript of all deliveries
to their vat worker, so the vat can be reloaded later. These transcript
entries have been including the `crankNumber`: a global counter indicating
how many cranks have been delivered (to all vats, not just the one for which
the transcript entry is being created).

This removes that crankNumber from the transcript:

* each vat should be independent, this global crankNumber is revealing
information about what happens in other vats
* #2400 is changing the type of `crankNumber` to a BigInt, which cannot be
serialized by the simple `JSON.stringify` used in vatKeeper.js

It also removes the now-unnecessary `kernelKeeper` argument from
`makeTranscriptManager`, and changes one test that happened to depend upon
the presence of the crankNumber field.

closes #2428
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request SwingSet package: SwingSet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants