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

feat(auction): auction publish all bids off-chain #7618

Closed
wants to merge 13 commits into from

Conversation

Chris-Hibbert
Copy link
Contributor

@Chris-Hibbert Chris-Hibbert commented May 4, 2023

closes: #7906

Description

The auctionBooks will publish all active bids to off-chain storage.

Security Considerations

None.

Scaling Considerations

The means that information that could be accessed on-chain or off will now be more accessible statically.

Documentation Considerations

N/A

Testing Considerations

tested in unit tests.

@Chris-Hibbert Chris-Hibbert added Vaults VaultFactor (née Treasury) auction labels May 4, 2023
@Chris-Hibbert Chris-Hibbert added this to the Vaults Validation milestone May 4, 2023
@Chris-Hibbert Chris-Hibbert self-assigned this May 4, 2023
@Chris-Hibbert Chris-Hibbert marked this pull request as draft May 4, 2023 21:24
@Chris-Hibbert
Copy link
Contributor Author

Draft until the release is in the books.

@turadg turadg removed this from the Vaults Validation milestone May 17, 2023
@Chris-Hibbert Chris-Hibbert marked this pull request as ready for review May 22, 2023 20:56
@Chris-Hibbert Chris-Hibbert marked this pull request as draft June 9, 2023 00:32
@dckc dckc mentioned this pull request Jun 16, 2023
@Chris-Hibbert Chris-Hibbert force-pushed the 7159-auctionBids branch 3 times, most recently from 5420a64 to 223451a Compare July 5, 2023 20:55
@Chris-Hibbert
Copy link
Contributor Author

@turadg, there's a test failure here in test-liquidation-1.js that I don't understand. It appears to be finding information about 'STARS-bid3', and complaining that it doesn't match the data it expected for 'STARS-bid2'. Can you help me understand what the test is trying to do so I can see about addressing this?

Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

initial feedback...

const [scheduleNode, bidsNode] = await Promise.all([
bookNodeP,
E(bookNodeP).makeChildNode('schedule'),
E(bookNodeP).makeChildNode('bids'),
Copy link
Member

Choose a reason for hiding this comment

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

something goofy is happening with bidsNode. see the snapshot...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed. rearranged the tree so bids are where they should have been.

Comment on lines 164 to 172
for (const r of records.values()) {
this.self.publishOffer(r);
}
Copy link
Member

Choose a reason for hiding this comment

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

Before we land this, let's make sure we don't do O(n) work like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Member

Choose a reason for hiding this comment

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

Also, I don't think this handles the case when bids go away.

Until we have an explicit delete method in vstorage (#7405) I think setValue('') has essentially the same effect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in deleteNodeIfPresent

return E(getBidDataRecorder(key)).write(
harden({
bidScaling: record.bidScaling,
wanted: record.wanted,
Copy link
Member

Choose a reason for hiding this comment

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

the product spec calls this maxBuy. Should we

  • change it here (my preference)
  • translate the field name on the client
  • ask product if wanted is a good name?

cc @turadg

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maxBuy sounds like the total (original) cap. What's printed here is internally known in some places as stillWant, reflecting that it's a descending indicator of the amount this bid still needs to be complete.
I will publish both originalWant and stillWant, so the CLI can choose to display either or both.

wanted: record.wanted,
exitAfterBuy: record.exitAfterBuy,
timestamp: record.timestamp,
balance: record.seat.getCurrentAllocation().Bid,
Copy link
Member

@dckc dckc Jul 12, 2023

Choose a reason for hiding this comment

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

the product spec calls this give. Should we

  • change it here
  • translate the field name on the client
  • ask product if balance is a good name (my preference)

cc @turadg

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll leave this as is, since I agree. We can make the change here later if that's called for, or in the CLI.

@Chris-Hibbert Chris-Hibbert force-pushed the 7159-auctionBids branch 3 times, most recently from cbc8e62 to c47eec7 Compare July 13, 2023 17:21
@Chris-Hibbert
Copy link
Contributor Author

Corrected vstorage paths to match:

  • published.auction.schedule for global schedule info.
  • published.auction.governance
  • published.auction.books.bookN for stats about that collateral
  • published.auction.books.bookN.bids.bidN for data about that bid.

@Chris-Hibbert Chris-Hibbert marked this pull request as ready for review July 19, 2023 20:42
@Chris-Hibbert Chris-Hibbert requested a review from dckc July 19, 2023 20:42
@Chris-Hibbert
Copy link
Contributor Author

Lint test is failing, but not reporting a particular problem. It passes locally. I think this is ready for review.

Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

I don't see any critical problems.

I'd like to look closer... for example to make sure the types work for the CLI. But auction CLI work is sort of on my back burner now, so maybe it's time to land this. Thoughts, @turadg ?

Comment on lines 136 to 149
/**
* @typedef {object} BidDataNotification
*
* @property {Array<ScaledBidData>} scaledBids
* @property {Array<PricedBidData>} pricedBids
*/
export const BidDataNotificationShape = {
scaledBids: M.arrayOf(M.any()),
pricedBids: M.arrayOf(M.any()),
};
harden(BidDataNotificationShape);
Copy link
Member

Choose a reason for hiding this comment

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

I suspect this is dead code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you mean BidDataNotificationShape, it's used on lines 229 and 235.

Copy link
Member

Choose a reason for hiding this comment

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

I'm still missing something. used in what way? Do we actually publish anything at bidsNode? I don't see any code that publishes data in this shape.

While working on the CLI, I found that this shape actually matched what's published; I'd like to import it from the contract code (ideally in a client helper module a la params.js that doesn't pull in the whole contract).

const bidData = harden({
timestamp: TimeStampShape,
sequence: M.nat(),
balance: NatAmountShape,
wanted: NatAmountShape,
exitAfterBuy: M.boolean(),
});
const shapeLeaves = harden({
ScaledBidData: {
bidScaling: RatioShape,
...bidData,
},
PricedBidData: {
price: RatioShape,
...bidData,
},
});
const shape = harden({
...shapeLeaves,
BidDataNotification: M.arrayOf(
M.or(shapeLeaves.ScaledBidData, shapeLeaves.PricedBidData),
),
});

Copy link
Contributor Author

@Chris-Hibbert Chris-Hibbert Jul 24, 2023

Choose a reason for hiding this comment

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

I may not understand how to use this right, but getPublicTopics() returns this node, which is the parent of all the actual bid nodes.

I did move BidDataNotificationShape to offerBook.js, and used it to declare the type of those sub-nodes that represent the individual bids.

edit to add: This is mostly wrong. revising....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Separated BidsDataNotificationShape from BidDataNotificationShape.

Comment on lines 355 to 359
bidDataKits.delete(key);
}
void deleteNodeIfPresent(key);
Copy link
Member

Choose a reason for hiding this comment

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

it seems a bit fragile to have to do both of these delete operations here. It would be nice to wrap the bidDataKits collection in something that automatically updates the storageNodes as appropriate. But maybe the values in the collection aren't enough info to update the storage nodes. hm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would have liked to just call delete(key), but that is currently only called when it's known that the record and node were actually created. Aah! I suppose I can put the conditional in that fn at no risk and little cost.

@@ -14,8 +14,8 @@ import { makeOffer } from '@agoric/zoe/test/unitTests/makeOffer.js';
import { setup } from '@agoric/zoe/test/unitTests/setupBasicMints.js';
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to see tests of adding and deleting (exiting) bids that show that vstorage is updated correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already added. Check out test/auction/snapshots/test-auctionContract.js.md. The test multiple bidders at one auction step shows that bid1001 has an empty node, while bid1002 and bid1003 show their data.

@turadg
Copy link
Member

turadg commented Jul 21, 2023

Given #8079 I'm concerned with landing this without #7955 (which depends on #7954 and thus #8079)

That means this would be hanging around a while. But it really can't be used until all those blockers are cleared. Let's discuss.

Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

putting this in the background for a bit...

@turadg
Copy link
Member

turadg commented Sep 20, 2024

Closing to clean up project views

@turadg turadg closed this Sep 20, 2024
@Chris-Hibbert
Copy link
Contributor Author

I'm surprised. This still seems valuable. We've noticed its absence. Don't we want this to be in a list for PM to be able to prioritize?

@dckc
Copy link
Member

dckc commented Sep 20, 2024

The issue is still open:

This is a PR.

@turadg
Copy link
Member

turadg commented Sep 20, 2024

yeah, the issue is still available to prioritize. And it has a link to this PR so when it is the PR can be reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auction Vaults VaultFactor (née Treasury)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

auction publish all bids to vstorage
3 participants