-
Notifications
You must be signed in to change notification settings - Fork 220
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
test(inter-protocol): snapshot storage/RPC API for auction, vaultFactory, reserve, psm, committees #7368
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea.
NOTE: The README says auction.books.book0, but what shows up in the snapshot is just auction.books0. Is that by design?
I missed that in review. Good thing for snapshot tests! @Chris-Hibbert could you push a commit to correct that here?
I was guessing, I'll admit. I'm definitely okay with it the way it is. If there's a reason for it to be otherwise, it should be simple to fix.
Done 3cc073a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems fine to me. @turadg says this will be valuable, so I'm for it.
@@ -1250,3 +1253,102 @@ test('bid zero', async t => { | |||
}, | |||
); | |||
}); | |||
|
|||
test('auctioneer chainStorage RPC API snapshot', async t => { | |||
//#region copied from on-exit test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of #region comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed that this one, at least, doesn't carry its weight. As noted above, I aim to "DRY out copy-pasta from on-exit test".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't find a straightforward way to DRY out the common stuff; I changed the #region
comments into a function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it occurs to me that, rather than repeating a bunch of stuff from another test, I can just add the t.snapshot()
into that test.
- `books` | ||
- `book0` | ||
- `data` | ||
- `book0` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we want book0
, book1
etc. under auction
after all?
I'm standing by to see if by "correct this" @turadg meant to change the published structure to include a book
or books
node rather than tweaking this README.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @Chris-Hibbert my earlier comment wasn't clear on the request:. I meant to fix the code so it matches the README, and the enumeration principle sketched in #6111
If keys are an index of high cardinality, they should be under their own parent key so that they don't make siblings of other types hard to find. E.g. if
manager102
sibling tometrics
is bad because the latter will be easy to miss.managers
sibling tometrics
is good.
Managers and Books are high enough cardinality to merit an grouping key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
each commit ends up separately in master so a bugfix commit is reasonable to me to include in any PR that has the appropriate reviewers. if you want to do the work in a different PR up to you.
as an issue to prioritize, #6111 encompasses the requirement. it's prioritized as a blocker for Vaults Release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried integrating the change with the existing commit stack, but the changes to the README are in a different commit than where I'd put the code changes. When I tried it, it turned into a mess, because several later commits also edit the same section of the README. It'll be far simpler as a follow-on.
}, | ||
electionType: 'survey', | ||
issue: { | ||
text: 'why3', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lacks detail on parameter change issues. I think developers of dapp-gov, i.e. us, are the most interested consumers of that API, and we already figured it out.
@@ -30,6 +30,8 @@ To maintain that the keys of vaults to liquidate are stable requires that its ke | |||
|
|||
VaultFactory publishes data using StoredPublishKit which tees writes to off-chain storage. These can then be followed off-chain like so, | |||
```js | |||
import { makeFollower } from '@agoric/casting'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does makeDefaultLeader
come from? I don't see it in @agoric/casting
.
- `governance` | ||
- `metrics` | ||
- `priceFeed` - [snapshot of details](./test/price/snapshots/test-fluxAggregator.js.md) | ||
- `${inputBrand}-${outputBrand}_price_feed` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this formerly had a _
as in ATOM_USD
when snapshotting shows it's ATOM-USD
.
- `metrics` | ||
- `priceFeed` - [snapshot of details](./test/price/snapshots/test-fluxAggregator.js.md) | ||
- `${inputBrand}-${outputBrand}_price_feed` | ||
- `${inputBrand}-${outputBrand}_price_feed.latestRound` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
latestRound
was missing.
Is it worth trying to maintain this tree of all the keys? Now that I have snapshots for all but stakeFactory, maybe it's better to just list the top level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
latestOutcome
below was missing as well.
'published.priceAggregator.LINK-USD_price_feed.latestRound', | ||
{ | ||
roundId: 3n, | ||
startedAt: 5n, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i suppose this will change to a time record in #5799 so that we can keep from exposing the whole timer below
d12900d
to
50c8e26
Compare
The technique I eventually found for the auction contract was so straightforward that I applied it to the other contracts as well (except stakeFactory). PTAL. |
Basis points vs. RatiosWe seem to publish basis points in some cases. I wonder if the econ-gov UI is set up for that. LowestRate: {
type: 'nat',
value: 4500n,
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not an expert on chainStorage, but this looks fine to me.
@@ -134,7 +134,28 @@ test('committee-open question:one', async t => { | |||
); | |||
}); | |||
|
|||
test('committee-open question:mixed', async t => { | |||
const snapshotStorage = async (t, storage) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
types please
const snapshotStorage = async (t, storage) => { | |
const snapshotStorage = async ( | |
/** @type {import('ava').ExecutionContext<unknown>} */ t, | |
/** @type {import('@agoric/internal/src/storage-test-utils.js').MockChainStorageRoot} */ storage, | |
) => { |
@@ -906,6 +924,8 @@ test.serial('onDeadline exit', async t => { | |||
currentPriceLevel: { numerator: { value: 9_350_000_000_000n } }, | |||
}); | |||
|
|||
await snapshotStorage(t, driver.mockChainStorage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
each test is defining its own snapshotStorage
but they follow the same pattern. please DRY it out. I think something like,
await snapshotStorage(t, driver.mockChainStorage); | |
await snapshotStorage(t, driver.mockChainStorage, {'mockChainStorageRoot.thisAuction': 'published.auction'}, `Under "published", the "auction" node is delegated to | |
the auctioneer contract, which publishes data as follows. | |
See also board marshalling conventions (_to appear_). | |
` ); |
or maybe more to the point: documentStorageKeys
since the note
and the rewriting to published:
is not really about testing.
storageNode: mockChainStorage | ||
.makeChildNode('psm') | ||
.makeChildNode('IST') | ||
.makeChildNode('AUSD'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like logic that is meant to be under test but is part of the driver.
consider a function to make a storage path for a PSM which can be re-used in startPSM:
agoric-sdk/packages/inter-protocol/src/proposals/startPSM.js
Lines 129 to 133 in 50c8e26
const psmStorageNode = await makeStorageNodeChild(chainStorage, 'psm'); | |
const storageNode = E( | |
E(psmStorageNode).makeChildNode(Stable.symbol), | |
).makeChildNode(keyword); | |
const note = `Under "published", the "committees.Economic_Committee" node is delegated to | ||
a committee contract, which publishes data as follows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clever way to mix docs into tests into docs!
"which publishes data as follows" isn't clear to me. The following is an instance of the possible data. A plausible instance? Just conformant? What can the reader count on it for?
Whatever language is chosen, I think it should be consistent across contract instances (see comment below on DRY)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's supposed to be illustrative. Ideally, it would illustrate all branches of any union types. I'm not sure how to be precise about what the reader can count without putting so much text in the way that it's distracting..
A plausible instance?
That's accurate and concise, if not complete. I suppose I can go with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done
pattern: 'mockChainStorageRoot.thisElectorate.', | ||
replacement: 'published.committees.Economic_Committee.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these would read more easily as a map, even if it has just one item.
pattern: 'mockChainStorageRoot.thisElectorate.', | |
replacement: 'published.committees.Economic_Committee.', | |
rekey: {'mockChainStorageRoot.thisElectorate': published.committees.Economic_Committee`}, |
f40093b
to
899c566
Compare
A couple storage keys in the vaults snapshot flip-flopped. I'm not sure how stable they were. I sorted them all an regenerated the snapshots. Also, I squashed all the inter-protocol snapshot commits together. And moved all the governance commits before inter-protocol. |
- link auction snapshot details - update docs for actual published keys
where does makeDefaultLeader come from?
899c566
to
8a4d75a
Compare
refs: #6111
in particular: #6111 (comment)
Description
Flesh out the "Reading data off-chain" section of the README with snapshots of chainStorage data produced by the inter protocol contracts.
NOTE: The README says
auction.books.book0
, but what shows up in the snapshot is justauction.books0
. Is that by design?If feedback on this draft shows that we do want this sort of test...
DRAFT TODO:
Security / Scaling Considerations
none, AFAICT.
Documentation Considerations
adds reliable docs.
rendered: Reading data off-chain
for example:
I think consumers look for "RPC API". I wonder if we should tweak the "Reading data off-chain" section heading to include that.
Testing Considerations
This adds a bit of test maintenance. As usual with ava snapshot tests:
yarn test test/auction/test-auctionContract.js -m '*snap*' --update-snapshots