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

auction scheduler robustness #9759

Merged
merged 7 commits into from
Aug 13, 2024
Merged

auction scheduler robustness #9759

merged 7 commits into from
Aug 13, 2024

Conversation

turadg
Copy link
Member

@turadg turadg commented Jul 23, 2024

incidental

Description

Refactors the auction amount math out of the auction book and adds unit tests. I noticed an inconsistency so this adds an assertion to prevent that and a fix. Also a bunch of refactorings and docs to try to make this area of the code more clear.

Reviewers, review by commit is recommended.

Security Considerations

The auction book now calls out to another module to do the math. Module from its own package though.

Scaling Considerations

no change

Documentation Considerations

not user facing

Testing Considerations

regression test

Upgrade Considerations

This won't go out until VaultFactory gets a new auctioneer. See,

@Chris-Hibbert is working on the CoreEval and its test to deploy this

@turadg turadg requested review from dckc and iomekam July 23, 2024 21:24
Copy link

codecov bot commented Jul 23, 2024

Codecov Report

Attention: Patch coverage is 80.70175% with 22 lines in your changes missing coverage. Please review.

Project coverage is 55.83%. Comparing base (c7eca9b) to head (d4d7f42).
Report is 172 commits behind head on master.

Files Patch % Lines
packages/inter-protocol/src/auction/auctionBook.js 4.76% 20 Missing ⚠️
packages/inter-protocol/src/auction/auctionMath.js 97.53% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9759      +/-   ##
==========================================
- Coverage   56.37%   55.83%   -0.55%     
==========================================
  Files         667      656      -11     
  Lines      207560   208436     +876     
  Branches      343      360      +17     
==========================================
- Hits       117022   116374     -648     
- Misses      90420    91942    +1522     
- Partials      118      120       +2     
Files Coverage Δ
packages/zoe/src/contractSupport/ratio.js 93.23% <100.00%> (+0.39%) ⬆️
packages/inter-protocol/src/auction/auctionMath.js 97.53% <97.53%> (ø)
packages/inter-protocol/src/auction/auctionBook.js 73.29% <4.76%> (+1.38%) ⬆️

... and 77 files with indirect coverage changes

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.

nice job untangling the easily-unit-tested compute from the I/O

a few thoughts to consider...

@@ -158,17 +158,26 @@ const divideHelper = (amount, ratio, divideOp) => {
);
};

/** @type {ScaleAmount} */
/**
* Divide the amount by the ratio, truncating the remainder.
Copy link
Member

Choose a reason for hiding this comment

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

an @example would be nice. I wonder how to do them concisely...

const a = withAmountUtils(makeIssuerKit('A'));
const double = makeRatio(2n, a.brand, 1n);
t.deepEqual(floorDivideBy(a.make(5n), double), a.make(2n));

Copy link
Member

Choose a reason for hiding this comment

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

of course, the example is nearly the same as the test you added.

I'd sure like to combine them a la doctest / updoc.

packages/inter-protocol/src/auction/auctionMath.js Outdated Show resolved Hide resolved
packages/inter-protocol/src/auction/auctionMath.js Outdated Show resolved Hide resolved
packages/inter-protocol/src/auction/auctionMath.js Outdated Show resolved Hide resolved
@Chris-Hibbert
Copy link
Contributor

Nicely done. Thanks for investigating and making this PR.

What worries me still is that a similar math bug nearby will cause the same problem in a different way. I want to look for a repair that makes the auction not die when this happens.

Copy link
Member

@gibson042 gibson042 left a comment

Choose a reason for hiding this comment

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

Drive-by suggestions.

packages/zoe/src/contractSupport/ratio.js Outdated Show resolved Hide resolved
Copy link

cloudflare-workers-and-pages bot commented Aug 13, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: e9e637c
Status: ✅  Deploy successful!
Preview URL: https://09f9f19d.agoric-sdk.pages.dev
Branch Preview URL: https://ta-auction-test.agoric-sdk.pages.dev

View logs

@turadg turadg added the automerge:rebase Automatically rebase updates, then merge label Aug 13, 2024
@mergify mergify bot merged commit 13c10cc into master Aug 13, 2024
80 checks passed
@mergify mergify bot deleted the ta/auction-test branch August 13, 2024 18:19
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants