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

SPIKE: prototype participants in Fast USDC sequence diagram #10254

Closed
wants to merge 48 commits into from

Conversation

dckc
Copy link
Member

@dckc dckc commented Oct 10, 2024

refs: #10231

Description

quick & dirty prototype based on an early Fast USDC sequence diagram

Security Considerations

The contract code needs a careful scrub before anyone relies on it heavily.

Scaling Considerations

The detailed baseline computron count in this PR might be useful to track scaling issues going forward.

Documentation Considerations

not much

Testing Considerations

This includes several sorts of tests:

  • unit: tx lifecycle: heavily mocked unit test with diagram participants reified as object
  • bootstrap: watcher: accept, report: initial performance measurement, in computrons
  • a3p: quickSend is in agoricNames.instance - supports deployment on a running chain

Upgrade Considerations

early prototype. doesn't involve upgrading anything that's already on chain

Copy link

cloudflare-workers-and-pages bot commented Oct 10, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 74d293b
Status: ✅  Deploy successful!
Preview URL: https://e155bce6.agoric-sdk.pages.dev
Branch Preview URL: https://dc-quicksend.agoric-sdk.pages.dev

View logs

@dckc
Copy link
Member Author

dckc commented Oct 11, 2024

currently corresponds pretty closely to...

The numbered arrows in the diagram correspond to --> #1 etc. in the t.log(...) messages:

~/projects/agoric-sdk/packages/orchestration
17:34 connolly@bldbox$ yarn test test/examples/quickSend-tx.test.ts 
yarn run v1.22.22
$ ava test/examples/quickSend-tx.test.ts

  ✔ tx lifecycle (708ms)
    ℹ -- SETUP...
    ℹ chain agoric1 makeAccount agoric112
    ℹ chain agoric1 makeAccount agoric113
    ℹ chain agoric1 makeAccount agoric114
    ℹ vtransfer register {
        addr: 'agoric113',
        handler: {
          onReceive: AsyncFunction {},
        },
      }
    ℹ  agoric112 balance += 2000 = 2000
    ℹ eth advance to block 9877
    ℹ  noble1mint balance += 100000 = 100000
    ℹ ERC20 transfer {
        dest: '0xUrsula',
        numTokens: 150,
        sender: '0xcircle',
        srcBal: 10000,
      }
    ℹ -- SETUP done.
    ℹ --> #1: app got settlementBase agoric113
    ℹ chain dydx1 makeAccount dydx112
    ℹ --> #2: app initiate {
        amount: 100,
        dest: 'dydx112',
      }
    ℹ watcher found 0 txs at height 9876
    ℹ x/forwarding fwd noble117x112 -> agoric113+dydx112
    ℹ --> #3: express initiate {
        agAddr: 'agoric113+dydx112',
        base: 'agoric113',
        dest: 'dydx112',
        fwd: 'noble117x112',
        nobleFwd: 'noble117x112',
      }
    ℹ --> #4: watcher.startWatchingFor {
        amount: 100,
        dest: 'dydx112',
        nobleFwd: 'noble117x112',
      }
    ℹ watcher found 0 txs at height 9876
    ℹ app watch dest {
        balancePost: 0,
        balancePre: 0,
        dest: 'dydx112',
        tick: 0,
      }
    ℹ --> #5: eth call 0x12 . bridge ( {
        amount: 100,
        dest: 'noble117x112',
      } )
    ℹ --> #6: cctp.bridge: {
        dest: 'noble117x112',
        msg: {
          sender: '0xUrsula',
        },
      }
    ℹ ERC20 transfer {
        dest: '0x0000',
        numTokens: 100,
        sender: '0xUrsula',
        srcBal: 150,
      }
    ℹ waiting 3 blocks (TODO: 20min) before minting on noble
    ℹ eth advance to block 9878
    ℹ watcher found 0 txs at height 9877
    ℹ app watch dest {
        balancePost: 0,
        balancePre: 0,
        dest: 'dydx112',
        tick: 1,
      }
    ℹ eth advance to block 9879
    ℹ watcher found 1 txs at height 9878
    ℹ --> #7: watcher checked 12
    ℹ --> #8: watcher confirmed {
        amount: 100,
        dest: 'dydx112',
        nobleFwd: 'noble117x112',
      }
    ℹ --> #9: contract.releaseAdvance {
        amount: 100,
        dest: 'dydx112',
      }
    ℹ --> #10: orch acct agoric112 txfr 95 to dydx112
    ℹ --> #11: ibc transfer 95 to dydx112
    ℹ  agoric1IBCburn balance += 95 = 95
    ℹ  dydx112 balance += 95 = 95
    ℹ app watch dest {
        balancePost: 95,
        balancePre: 0,
        dest: 'dydx112',
        tick: 2,
      }
    ℹ eth advance to block 9880
    ℹ watcher found 0 txs at height 9879
    ℹ eth advance to block 9881
    ℹ watcher found 0 txs at height 9880
    ℹ  noble117x112 balance += 100 = 100
    ℹ --> #12: fwd {
        amount: 100,
        dest: 'noble117x112',
        fwd: 'agoric113+dydx112',
      }
    ℹ --> #13: ibc transfer 100 to agoric113+dydx112
    ℹ  noble1IBCburn balance += 100 = 100
    ℹ  agoric113 balance += 100 = 100
    ℹ vtransfer to virtual address {
        agAddr: 'agoric113',
        extra: 'dydx112',
      }
    ℹ --> #14: tap onReceive {
        amount: 100,
      }
    ℹ --> #15: orch acct agoric113 send 98 to agoric112
    ℹ --> #16: orch acct agoric113 send 2 to agoric114
    ℹ  agoric112 balance += 98 = 2003
    ℹ  agoric114 balance += 2 = 2
    ℹ eth advance to block 9882
    ℹ watcher found 0 txs at height 9881
    ℹ eth advance to block 9883
    ℹ watcher found 0 txs at height 9882
    ℹ eth advance to block 9884
    ℹ watcher found 0 txs at height 9883
    ℹ quiesced for 5 ticks
    ℹ watcher: stop at 9883
    ℹ actual result {
        dest: {
          addr: 'dydx112',
          balance: 95,
        },
        fee: {
          addr: 'agoric114',
          balance: 2,
        },
        pool: {
          addr: 'agoric112',
          balance: 2003,
          start: 2000,
        },
        settlement: {
          addr: 'agoric113',
          balance: 0,
        },
        user: {
          addr: '0xUrsula',
          balance: 50,
          start: 150,
        },
      }
  ─

  1 test passed
Done in 1.50s.

2024-10-10 14:29 cd6e57d chore(quickSend): skip bootstrap test (WIP)
2024-10-10 14:03 9556ca3 refactor: move contract logic to .contract.js file
2024-10-10 13:35 a2fabd8 test: move makeEthChain to match sequence diagram order
2024-10-10 13:27 f78c43d test: sync arrow labels with sequence diagram
2024-10-10 11:59 ff5f6ab test: separate setup
2024-10-10 05:39 b41eae2 test(quickSend): reify lifecycle participants, incl. settlement
2024-10-09 19:11 becc761 test: reify participants from Fast USDC sequence diagram (part 1)
2024-10-09 14:36 d33f900 refactor(start-quickSand): factor out makePublishingStorageKit
2024-09-19 14:43 fc62b02 test: bootstrap test for trivial quickSend contract

@dckc dckc self-assigned this Oct 18, 2024
@dckc dckc force-pushed the dc-quickSend branch 6 times, most recently from c42fbd6 to 6c05e8c Compare October 23, 2024 23:06
@dckc dckc changed the base branch from master to 10328-fu-cli October 23, 2024 23:07
Base automatically changed from 10328-fu-cli to master October 23, 2024 23:08
Copy link

Base branch is changed to master. Please re-run the integration tests by adding 'force:integration' label.

Comment on lines 91 to 73
const fundingPool = await agoric.makeAccount();
const settlement = await agoric.makeAccount();
const feeAccount = await agoric.makeAccount();
Copy link
Member

Choose a reason for hiding this comment

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

Can fee account be a Purse? Only fundingPool and settlement might need to send or accept IBC transfers?

Copy link
Member Author

Choose a reason for hiding this comment

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

In recent discussion, I confirmed with @sufyaankhan that it should be a normal cosmos account that the fee beneficiary creates before the contract launches; that way, they can withdraw at will using normal tx bank send.

But I suppose it could be a Seat, yes. (a Purse would give the contract direct access; we avoid that, normally)

@dckc dckc requested a review from iomekam October 24, 2024 22:53
@dckc dckc marked this pull request as ready for review October 24, 2024 22:53
@dckc dckc requested a review from a team as a code owner October 24, 2024 22:53
Copy link
Member

@turadg turadg left a comment

Choose a reason for hiding this comment

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

I said I think it's better to have something in master than nothing, but I want to qualify that. We should land the things we know even if they're incomplete. But there's some stuff to figure out around naming that I think we should nail down before this goes to master (so as not to teach people the wrong names and structure).

This PR still serves as a prototype even while open. Whenever someone's work depends on part of this let's land it. And if we get this to a point where what's known and what's temporary is clear, then let's land all of it.

Meanwhile, please PR the SwingSet changes in a PR to be reviewed by Kernel team. Maybe with a load test of some contract that's already in master. Perhaps price feeds because we want to optimize them at some point.

"source": "subdir",
"sdk-generate": [
"vats/init-orchestration.js",
"orchestration/init-quickSend.js"
Copy link
Member

Choose a reason for hiding this comment

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

in fast-usdc now, yes?

I'm reluctant to have quickSend around as a synonym for fast-usdc but we could use that to mean "the prototype". But what would be more clear is to call it that, like fu-prototype. Let's try to get the naming of things figured out before merging this, and document it in the fast-usdc README.md

@dckc
Copy link
Member Author

dckc commented Oct 28, 2024

Meanwhile, please PR the SwingSet changes in a PR to be reviewed by Kernel team.

Maybe with a load test of some contract that's already in master. Perhaps price feeds because we want to optimize them at some point.

I forgot that part... let's see if it's easy...

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.

Nice work 👏

Comment on lines 102 to 110
export const NobleCalc = harden({
// XXX mock only
fwdAddressFor: dest => `noble1${dest.length}${dest.slice(-4)}`,
});
Copy link
Member

Choose a reason for hiding this comment

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

Is this just for testing? if yes, can we move this to a /test directory?

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, it's just for testing.

* @param {QuickSendAccounts & Passable} accts
* @param {import('./client-types.js').CCTPTxEvidence} offerArgs
*/
export const handleCCTPCall = async (_orch, ctx, accts, offerArgs) => {
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth stubbing a notifier/subscriber for the Oracle, or adding a comment that denotes this behavior?

Copy link
Member Author

Choose a reason for hiding this comment

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

elaborate? I don't understand what you mean.

Copy link
Member

@0xpatrickdev 0xpatrickdev Oct 30, 2024

Choose a reason for hiding this comment

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

I wanted us to represent the Oracle Feed in a separate exo, but probably OK to punt on for now

dckc added 7 commits October 29, 2024 13:45
in a couple tests:

$ cd agoric-sdk/packages/boot
$ SWINGSET_WORKER_TYPE=xsnap yarn test test/bootstrapTests/price-feed-replace.test.ts
...
  ✔ setupVaults; run updatePriceFeeds proposals (1m 27.6s)
    ℹ setPrice computrons 65536531n

$ SWINGSET_WORKER_TYPE=xsnap yarn test test/bootstrapTests/orchestration.test.ts
...
  ✔ stakeAtom - smart wallet (13.8s)
    ℹ makeAccount computrons 15231491n
 - part 1: send advance
 - part 2: settlement
 - sync arrow labels with sequence diagram
dckc and others added 24 commits November 4, 2024 12:28
 - support $SWINGSET_WORKER_TYPE
... and include contract, tools
 - genesis vs. validator etc.
 - kubectl vs docker compose
 - skip mint100; gov1 has plenty
 - avoid tsx dep
mergify bot added a commit that referenced this pull request Dec 2, 2024
## Description

Support computron measurements in boostrap tests for performance testing by letting `makeRunUtils` caller provide a way to make a run policy.

### Security Considerations

A swingset controller relies on the run policy to be well-behaved. But the caller of `makeRunUtils` can only shoot themselves in the foot.

### Scaling Considerations

helps measure scaling issues

### Documentation Considerations

JSDocs with static types provide adequate docs for an internal tool such as this.

### Testing Considerations

Integration with a couple bootstrap tests is included.
See also #10254 .

### Upgrade Considerations

n/a
@turadg
Copy link
Member

turadg commented Dec 16, 2024

Helpful research. Not intended to merge or update at this point.

@turadg turadg closed this Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants