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

fix(fast-usdc): update noble connection info, make new ICA #11025

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

dckc
Copy link
Member

@dckc dckc commented Feb 20, 2025

closes: #11013

Description

  • feat: methods to update chainHub
    • feat: expose chainHub on creatorFacet
  • fix: write off original noble ICA vow in baggage
  • core eval to update noble connection info, make new ICA
    • builder for core eval with CLI args to handle starship connection info

TODO:

  • in fast-usdc.contract.js: address upgrade TODOs
  • consider combining this core-eval with fee updates and such

Security Considerations

creatorFacet.getChainHub() increases the surface area of the contract.
Since the creator provided chainInfo and assetInfo in privateArgs to start with, it's a small increase.

Scaling Considerations

none, I think.

Testing Considerations

  • unit tests for chainHub methods
  • bootstrap test for upgrade
    • downloads materials from fast-usdc-beta-1 release to start the contract in pre-upgrade state

TODO:

  • finish multichain-testing (I switched to working in boot/. maybe this works now?)

Upgrade / Documentation Considerations

OCW operators have to accept their invitations before the upgrade, since their invitations are attached to ephemeral offer handlers.

TODO:

  • consider making the handlers durable and issuing new invitations

@dckc dckc requested review from turadg and 0xpatrickdev February 20, 2025 17:16
Copy link

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: d613d1a
Status: ✅  Deploy successful!
Preview URL: https://e3f8675f.agoric-sdk.pages.dev
Branch Preview URL: https://dc-noble-conn.agoric-sdk.pages.dev

View logs

);
if (contractName in instances) {
return t.log('Contract found. Skipping installation...');
if (contractBuilder.endsWith('/start-fast-usdc.core.js')) {
Copy link
Member Author

@dckc dckc Feb 20, 2025

Choose a reason for hiding this comment

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

this is a bit of a KLUDGE. Once I can tell that it's working, I expect to refactor it.

see XXX note below

Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: add a 4th opts bag argument to startContract, { skipInstanceCheck = false }, to make this declarative.

trace('noble ICA', nobleICAaddr);

// publish ICA addr at published.fastUsdc.nobleICA
// TODO: update vstorage snapshot tests
Copy link
Member Author

Choose a reason for hiding this comment

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

this is done.

Suggested change
// TODO: update vstorage snapshot tests

@@ -279,6 +285,8 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
const [_agoric, _noble, agToNoble] = await vowTools.when(
chainHub.getChainsAndConnection('agoric', 'noble'),
);
// 1) should we have used zone.makeOnce here?
Copy link
Member Author

@dckc dckc Feb 20, 2025

Choose a reason for hiding this comment

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

yes, to preserve precious state (mintedEarly). TODO.

Copy link
Member

Choose a reason for hiding this comment

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

let's discuss synchronously.

@@ -279,6 +285,8 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
const [_agoric, _noble, agToNoble] = await vowTools.when(
chainHub.getChainsAndConnection('agoric', 'noble'),
);
// 1) should we have used zone.makeOnce here?
// 2) will we get an error since we're trying to register a tap on the same LCA?
Copy link
Member Author

@dckc dckc Feb 20, 2025

Choose a reason for hiding this comment

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

no, I gather. NEEDSTEST?

likewise, no re monitorMintingDeposits below.

Copy link
Member

Choose a reason for hiding this comment

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

+1

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.

We're going to need an a3p-integration proposal test eventually (since this proposal has to go into agoric-3-proposals) but using bootstrap suffices for merging to master.


[
[
'published.fastUsdc.nobleICA',
Copy link
Member

Choose a reason for hiding this comment

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

why create this node?

Copy link
Member Author

Choose a reason for hiding this comment

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

Aside from being generally useful for grabbing the address for use in explorers and such, it's a handy way to tell whether this core eval succeeded.

Perhaps we should publish just the .value of the address?

Copy link
Member

Choose a reason for hiding this comment

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

why not put it on published.fastUsdc with the other addresses? (e.g. poolAddress)

Copy link
Member Author

Choose a reason for hiding this comment

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

sure; that will work.

@@ -294,6 +294,8 @@ export const AckBehavior = {
Queued: 'QUEUED',
/** inbound messages are delivered immediately */
Immediate: 'IMMEDIATE',
/** inbound responses never arrive (to simulate mis-configured connections etc.) */
Never: 'NEVER',
Copy link
Member

Choose a reason for hiding this comment

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

nice. do we need this implemented in all cases?

Copy link
Member Author

Choose a reason for hiding this comment

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

there are other cases? help?

Copy link
Member

Choose a reason for hiding this comment

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

just looking at that switch, you handled case 'startChannelOpenInit' but no change to case 'sendPacket'

const { writeCoreEval } = await makeHelpers(homeP, endowments);

/** @returns {{ agoricToNoble?: IBCConnectionInfo } & Passable} */
const parseConnection = () => {
Copy link
Member

Choose a reason for hiding this comment

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

usually these builder functions are almost declarative.

consider moving this up to module scope,

export const parseConnection = (args) => {

that would also allow unit testing

@@ -197,6 +197,9 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
deleteCompletedTxs() {
return statusManager.deleteCompletedTxs();
},
getChainHub() {
Copy link
Member

Choose a reason for hiding this comment

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

food for thought: withOrchestration could automatically provide such methods, wrapping the contract return value. E.g. instead of creatorFacet it could return orchestrationFacet or something.

probably too much magic as yet

@@ -258,7 +261,10 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
);
}

const nobleAccountV = zone.makeOnce('NobleAccount', () => makeNobleAccount());
// v1 has `NobleAccount` which we don't expect to ever settle. how can we delete it?
const nobleAccountV = zone.makeOnce('NobleAccount2', () =>
Copy link
Member

Choose a reason for hiding this comment

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

maybe we can give this a name that doesn't reek of "oops"

perhaps with the channel id?

Suggested change
const nobleAccountV = zone.makeOnce('NobleAccount2', () =>
const nobleAccountV = zone.makeOnce('NobleAccount-62', () =>

Copy link
Member

Choose a reason for hiding this comment

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

or, NobleICA

@@ -279,6 +285,8 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
const [_agoric, _noble, agToNoble] = await vowTools.when(
chainHub.getChainsAndConnection('agoric', 'noble'),
);
// 1) should we have used zone.makeOnce here?
Copy link
Member

Choose a reason for hiding this comment

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

let's discuss synchronously.

@@ -305,6 +313,7 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
},
});

// TODO do we need to wrap this in `if (!baggage.has(firstIncarnationKey))` ?
Copy link
Member

Choose a reason for hiding this comment

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

depends on whether settlerKit persists. it was designed at first to be per incarnation

Copy link
Member

Choose a reason for hiding this comment

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

I think with mintedEarly: MapStore in its state warrants making a singleton

bech32PrefixToChainName.delete(oldInfo.bech32Prefix);
}
chainInfos.set(chainName, chainInfo);
if (chainInfo.bech32Prefix) {
Copy link
Member

Choose a reason for hiding this comment

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

why would new info and old info have different presence of bech32prefix?

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 not sure why someone would do this, but i think it's a foreseeable state this code needs to handle

* @throws {Error} If asset not registered or referenced chains not
* registered
*/
updateAsset(denom, detail) {
Copy link
Member

Choose a reason for hiding this comment

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

since it's replacing the entry replaceAsset ?

Copy link
Member

Choose a reason for hiding this comment

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

if we want replace*, we should make the same change on the *connection, *chain methods

@@ -258,7 +261,10 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
);
}

const nobleAccountV = zone.makeOnce('NobleAccount', () => makeNobleAccount());
// v1 has `NobleAccount` which we don't expect to ever settle. how can we delete it?
const nobleAccountV = zone.makeOnce('NobleAccount2', () =>
Copy link
Member

Choose a reason for hiding this comment

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

or, NobleICA

@@ -279,6 +285,8 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
const [_agoric, _noble, agToNoble] = await vowTools.when(
chainHub.getChainsAndConnection('agoric', 'noble'),
);
// 1) should we have used zone.makeOnce here?
// 2) will we get an error since we're trying to register a tap on the same LCA?
Copy link
Member

Choose a reason for hiding this comment

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

+1

@@ -305,6 +313,7 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
},
});

// TODO do we need to wrap this in `if (!baggage.has(firstIncarnationKey))` ?
Copy link
Member

Choose a reason for hiding this comment

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

I think with mintedEarly: MapStore in its state warrants making a singleton

Comment on lines +533 to +538
if (!chainInfos.has(chainName)) {
throw makeError(`Chain ${q(chainName)} not registered`);
}
if (!chainInfos.has(baseName)) {
throw makeError(`Chain ${q(baseName)} not registered`);
}
Copy link
Member

Choose a reason for hiding this comment

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

This code was written in haste - i think this block should be above the one where we brandDenoms.delete

* @throws {Error} If asset not registered or referenced chains not
* registered
*/
updateAsset(denom, detail) {
Copy link
Member

Choose a reason for hiding this comment

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

if we want replace*, we should make the same change on the *connection, *chain methods

bech32PrefixToChainName.delete(oldInfo.bech32Prefix);
}
chainInfos.set(chainName, chainInfo);
if (chainInfo.bech32Prefix) {
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 not sure why someone would do this, but i think it's a foreseeable state this code needs to handle

);
if (contractName in instances) {
return t.log('Contract found. Skipping installation...');
if (contractBuilder.endsWith('/start-fast-usdc.core.js')) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: add a 4th opts bag argument to startContract, { skipInstanceCheck = false }, to make this declarative.

test.serial('reconfigure: fix noble ICA', async t => {
const { startContract, commonBuilderOpts } = t.context;
const builder =
'../packages/builders/scripts/fast-usdc/fast-usdc-reconfigure.build.js';
Copy link
Member

Choose a reason for hiding this comment

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

Nice. Thinking out loud...

Is it critical we have a reference to the original bundleId / build ? i.e. something without the new creator facet methods?

Probably not for now, the faulty chainInfo seems sufficient. Likely just something to think about for the future

Copy link
Member Author

Choose a reason for hiding this comment

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

Here's hoping we get a3p + multichain better connected:

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.

request for a Noble ICA for Fast USDC has yet to settle - misconfigured host
3 participants