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

test: fast-usdc contract flow #10572

Merged
merged 14 commits into from
Nov 27, 2024
Merged

test: fast-usdc contract flow #10572

merged 14 commits into from
Nov 27, 2024

Conversation

dckc
Copy link
Member

@dckc dckc commented Nov 26, 2024

refs: #10388
closes: #10577

doesn't close until

  • exercise all the code in the contract (analytic; best effort)

Description / Testing Considerations

  • test all the sequences in the product spec
    • enumerate all the sequences in the product spec
  • fix advancer/settler amount agreement bug

postponed:

some test.todo()s are out of scope of contract flow tests. Some are more feasible as exo tests:

  • [todo] C18 - forward - MUST log and alert these incidents
  • [skip] LP borrow - TODO: move to exo test
  • [skip] LP repay - TODO: move to exo test

an some are after M1:

  • [todo] PERF: Target: settlement completes in a few minutes (after USDC is minted)
  • [todo] fee levels MUST be visible to external parties - i.e., written to public storage
  • [todo] C21 - Contract MUST log / timestamp each step in the transaction flow

Security / Scaling / Upgrade Considerations

n/a

Documentation Considerations

Internal design docs are assumed background knowledge.

@dckc dckc requested review from turadg and 0xpatrickdev November 26, 2024 06:35
@dckc dckc added this to the FU1: package integration milestone Nov 26, 2024
Copy link

cloudflare-workers-and-pages bot commented Nov 26, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: dcc6feb
Status: ✅  Deploy successful!
Preview URL: https://54713ebe.agoric-sdk.pages.dev
Branch Preview URL: https://dc-fc-contract-tests.agoric-sdk.pages.dev

View logs

@dckc
Copy link
Member Author

dckc commented Nov 26, 2024

currently (e049c85) passing tests:

$ yarn test test/fast-usdc.contract.test.ts >,out 2>&1
$ grep ✔ ,out
  ✔ OCW operators redeem invitations and start watching
  ✔ C25 - LPs can deposit USDC
  ✔ STORY01: advancing happy path for 100 USDC (112ms)
  ✔ STORY03: see accounting metrics
  ✔ STORY05: LP collects fees on 100 USDC
  ✔ With 250 available, 3 race to get ~100 (242ms)
  ✔ STORY05(cont): LPs withdraw all liquidity
  ✔ STORY09: insufficient liquidity: no FastUSDC option
  ✔ C20 - Contract MUST function with an empty pool
  ✔ [expected fail] Settlement for unknown transaction (operator down)
  ✔ baggage (855ms)

@dckc dckc force-pushed the dc-fc-contract-tests branch 2 times, most recently from e4052ae to e049c85 Compare November 26, 2024 21:05
@dckc dckc changed the title test: fc contract flow tests test: fast-usdc contract flow Nov 26, 2024
@dckc dckc marked this pull request as ready for review November 26, 2024 21:19
@dckc dckc requested a review from a team as a code owner November 26, 2024 21:19
@dckc
Copy link
Member Author

dckc commented Nov 26, 2024

@0xpatrickdev , @turadg , based on today's discussion of scope, I think this is ready for review.

@dckc
Copy link
Member Author

dckc commented Nov 26, 2024

Why is this inter protocol test failing???

not ok 274 - swingsetTests › reserve › assetReserve-upgrade › assetReserve service upgrade %ava-dur=22237ms
#   buildVatController
#   REJECTED from ava test("assetReserve service upgrade"): (Error#1)
#   Error#1: config.vats.bootstrap: Failed to load module "./test/swingsetTests/reserve/bootstrap-assetReserve-upgrade.js" in package "file:///home/runner/work/agoric-sdk/agoric-sdk/packages/inter-protocol/" (1 underlying failures: Cannot find external module "module" in package file:///home/runner/work/agoric-sdk/agoric-sdk/node_modules/@endo/compartment-mapper/

strangely, it reproduces locally.

Copy link
Member

@0xpatrickdev 0xpatrickdev left a comment

Choose a reason for hiding this comment

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

LGTM. Only have one comment that really needs addressing.

I am not the craziest about the single shared test context and test.serials. It makes it so that we can't do yarn test ... -m 'STORY01:*' to debug or work on an individual test. Speaking offline it seemed more cost effective to structure this way, so I won't block on this.

*/
onRejected(_result, _ctx) {
onRejected(reason, ctx) {
trace('transfer rejected!', reason, ctx);
Copy link
Member

Choose a reason for hiding this comment

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

should this have a ⚠️ emoji?

@@ -98,7 +98,7 @@ export const connectionKey = (chainId1, chainId2) => {
*/
const reverseConnInfo = connInfo => {
const { transferChannel } = connInfo;
return {
return harden({
Copy link
Member

Choose a reason for hiding this comment

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

I hit this as well: 33f26e9


console.log('chainHub: registering assets', Object.keys(assetInfo || {}));
Copy link
Member

Choose a reason for hiding this comment

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

Nice additions

const assetInfo = harden(
Object.fromEntries([
assetOn('uusdc', 'noble'),
[uusdcOnAgoric, agUSDCDetail],
Copy link
Member

Choose a reason for hiding this comment

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

assetOn is nifty. Why not also use it here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was used to define these 2.
uusdOnAgoric is exported for use elsewhere.

@@ -264,13 +275,13 @@ export const prepareSettler = (
* @param {SettlerTransferCtx} ctx
*
* @typedef {{
* txHash: EvmHash;
* txHash: EvmHash | undefined;
Copy link
Member

Choose a reason for hiding this comment

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

When can this be undefined?

Copy link
Member Author

Choose a reason for hiding this comment

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

Only in the case that we're not handling correctly (#10577). I might as well fix it now.

});

test.todo(
'PERF: Target: settlement completes in a few minutes (after USDC is minted)',
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this will be the right place for this, since much of the latency is dependent on blocks and bridges, so maybe we should omit this todo. Would we do this in multichain-testing? a testnet?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think this will be the right place for this,

I agree, but this is where I was taking notes on product requirements. I'll take this one out, but note that there are also TODOs here that should be satisfied by exo tests. When the TODOs get done, we can prune these notes.

since much of the latency is dependent on blocks and bridges, so maybe we should omit this todo. Would we do this in multichain-testing? a testnet?

We have plans for bootstrap tests to measure computrons as well as multichain-testing and testnets.

Comment on lines +880 to +886
// TODO/WIP: cust.racer3.checkSent(t, since(bridgePos), 'forward - LP depleted');
await transmitTransferAck();
// Nothing we can check here, unless we want to inspect calls to `trace`.
// `test/exos/advancer.test.ts` covers calls to `log: LogFn` with mocks.
// This is still helpful to call, so we can observe "Advance transfer
// fulfilled" in the test output.
await transmitTransferAck();
await transmitTransferAck();
await Promise.all([mint(sent1), mint(sent2), mint(sent3)]);
Copy link
Member

Choose a reason for hiding this comment

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

This is cool, but I'm struggling to understand how we plan to check the results of the Promise.all. I don't think we'll have any bridge messages that indicate insufficient funds (advancer's log would know though.) Will we wait for txs to be posted to vstorage?

Regardless, consider specifying in the TODO/WIP

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, as I was working on this test, I realized that our mock bridge stuff only works one tx at a time. I'm not inclined to go on at any length about what's TODO/WIP here just now.

Comment on lines +936 to +941
const bridgeTraffic = since(bridgePos);
await mint(sent);
custEmpty.checkSent(t, bridgeTraffic, 'forward');
t.log('No advancement, just settlement');
Copy link
Member

Choose a reason for hiding this comment

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

Consider a TODO somewhere here to ensure Observed and/or Forwarded statuses are recorded in vstorage

Copy link
Member Author

Choose a reason for hiding this comment

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

M2


// advancedEarly stuff
test.todo(
'C12 - Contract MUST only pay back the Pool only if they started the advance before USDC is minted',
Copy link
Member

Choose a reason for hiding this comment

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

This is advance early, but also could be the same scenario about. We could inspect the outgoing LCA bridge messages to confirm they sent the requested amount and not the net of fees amount

Copy link
Member Author

Choose a reason for hiding this comment

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

We could inspect the outgoing LCA bridge messages to confirm they sent the requested amount and not the net of fees amount

checkSent with 'forward' does check that.

But we didn't test the advancedEarly case, i.e. the case where the mint comes in between ADVANCING and ADVANCED.


test.todo('C18 - forward - MUST log and alert these incidents');

test.serial.failing(
Copy link
Member

Choose a reason for hiding this comment

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

Why is this failing?

Copy link
Member Author

Choose a reason for hiding this comment

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

As I say, might as well fix it now.

dckc added 13 commits November 27, 2024 13:15
non-hardened objects can't go in stores such as `connectionInfos`.
 10 tests passed
  1 known failure
  2 tests skipped
  7 tests todo
Done in 3.43s.

  - [skip] LP borrow - TODO: move to exo test
  - [skip] LP repay - TODO: move to exo test
  - [todo] PERF: Target: settlement completes in a few minutes (after USDC is minted)
  - [todo] C21 - Contract MUST log / timestamp each step in the transaction flow
  - [todo] document metrics storage schema
  - [todo] get metrics from vstorage
  - [todo] C12 - Contract MUST only pay back the Pool only if they started the advance before USDC is minted
  - [todo] C18 - forward - MUST log and alert these incidents
  - [todo] fee levels MUST be visible to external parties - i.e., written to public storage

 - known failure: unknown transaction
   settler should Leave funds in SettlementAccount.
 - use oracle, customer in advance happy path
   - factor out makeOracleOperator
 - registerAsset() from the test jig doesn't work:
   brands in the contract are in a different "address space"
 - use realistic USDC denom
 - shared context for contract tests
   - customer sends before LPs deposit
 - racer tests
 - flatten makeLP
   - don't mix with pourPayment
   - derive publicFacet etc. from instance as client would
 - skip LP test that used test-only methods
 - prune outdated Oracle rights test
@dckc dckc force-pushed the dc-fc-contract-tests branch from ee85747 to 2f4bafe Compare November 27, 2024 19:18
@dckc dckc added the automerge:rebase Automatically rebase updates, then merge label Nov 27, 2024
@dckc dckc force-pushed the dc-fc-contract-tests branch 2 times, most recently from 17b6d85 to dcc6feb Compare November 27, 2024 22:35
@mergify mergify bot merged commit 45d0417 into master Nov 27, 2024
81 checks passed
@mergify mergify bot deleted the dc-fc-contract-tests branch November 27, 2024 23:19
@dckc dckc mentioned this pull request Dec 3, 2024
2 tasks
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.

settler should not forward unknown transactions
2 participants