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: send-anywhere pfm scenarios #10591

Open
wants to merge 25 commits into
base: pc/10445-transfer-pfm
Choose a base branch
from

Conversation

0xpatrickdev
Copy link
Member

@0xpatrickdev 0xpatrickdev commented Dec 1, 2024

closes: #9966
closes: #10445

Description

Adds multi-hop (PFM) scenarios to the examples/send-anywhere.contract.js multichain (e2e) test. To support this change, this PR also includes:

Security Considerations

@agoric/builders/scripts/testing/register-interchain-bank-assets.js allows callers overwrite assets in vbank and agoricNames. It's only intended for testing, and shouldn't be used in production. A production version might guard against accidental overrides.

Scaling Considerations

None, mostly test code. Adds a little CI time to multichain-testing for the extra CoreEval.

Documentation Considerations

None

Testing Considerations

Includes an E2E to test in multichain-testing that leverages register-interchain-bank-assets.js. Also includes the first E2E test of PFM functionality added in #10584 and #10571.

Upgrade Considerations

None, library code an NPM orch or FUSDC release.

0xpatrickdev and others added 21 commits November 29, 2024 16:38
- to facililate registering the same denom across multiple chains in `ChainHub`
- denoms are unique to a chain, but not all chains
- since denoms are only unique to a chain and all chains, require `holdingChainName` parameter for asset info lookups
- shape used for pfm ForwardInfo options
- provide `chainInfo` and `assetInfo` in commonPrivateArgs for contracts to use
- register common assets used in testing
- provide `populateChainHub` function for use in exo unit testing in favor of `registerAgoricBld`
this test can no longer rely on the IST brand being available, so we
 - added checks to ensure brands are accepted for `.transfer` and `.send`
 - filed #10449 since this surfaced a bug in `amountToCoin`
 - use Moolah issuer for "no denom for brand" failure path tests
- enables sending offers with brands
- chainInfo and assetInfo are provided as `commonPrivateArgs`. include them in `ContractMeta`
- auto-stake-it initializes `chainHub` with data so existing tests that use `.transfer()` pass
- no longer needed since we call `registerChainsAndAssets`
- no longer relies on buggy agoricNames
- continues to test async-flow resumability and cross-chain vow settlement across upgrade

Co-authored-by: 0xPatrick <[email protected]>
- test/bootstrapTests/orchestration.test.ts used a mixed of test and test.serial
- the test without `.serial` interleaved and was confusing to debug
- this mainly updates inline snapshots, which return different account and channel
  identifiers since all tests in this file share the same context
- basic-flows.contract.js is provided with `chainInfo` and `assetInfo` in `privateArgs` via builder options
- needed for tests that use `localAccount.transfer()`, now reliant on asset info, to pass
@0xpatrickdev 0xpatrickdev added the force:integration Force integration tests to run on PR label Dec 1, 2024
@0xpatrickdev 0xpatrickdev force-pushed the pc/register-interchain-bank-assets branch from 5b9326d to 46e6875 Compare December 2, 2024 00:05
Copy link

cloudflare-workers-and-pages bot commented Dec 2, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: fc4e81a
Status: ✅  Deploy successful!
Preview URL: https://9fbd8ebf.agoric-sdk.pages.dev
Branch Preview URL: https://pc-register-interchain-bank.agoric-sdk.pages.dev

View logs

- create `register-interchain-bank-assets.js` for multichain-testing environment
  - allow users to submit offers using new brands like OSMO, ION
  - override existing brands like ATOM (ibc/toyatom) with starship denom
- create `make-bank-asset-info.ts` to gather `InterchainAssetOptions` from starship env
- update `make start` and ci `multichain-e2e-template.yaml` to call these scripts
- deploy-cli.ts `deployBuilder` accepts `builderOpts`
- adds helper to fund agoric faucet with interchain tokens
- allows callers to request `OSMO`, `ATOM`, etc, via `provisionSmartWallet`
@0xpatrickdev 0xpatrickdev force-pushed the pc/register-interchain-bank-assets branch from 46e6875 to fc4e81a Compare December 2, 2024 16:13
@0xpatrickdev 0xpatrickdev marked this pull request as ready for review December 2, 2024 16:15
@0xpatrickdev 0xpatrickdev requested a review from a team as a code owner December 2, 2024 16:15
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.

looks good.

the comments here are mostly thinking-out-loud.

Putting register-interchain-bank-assets.js under packages/builders/scripts seems pretty odd; it's not a script. So I hope you'll move that. But I can still get behind this if you don't.

Comment on lines +82 to +86
register-bank-assets:
node_modules/.bin/tsx scripts/fetch-starship-chain-info.ts && \
node_modules/.bin/tsx scripts/deploy-cli.ts src/register-interchain-bank-assets.builder.js \
assets="$$(node_modules/.bin/tsx scripts/make-bank-asset-info.ts)"

Copy link
Member

Choose a reason for hiding this comment

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

what does it cost to get the scripts to know how to execute themselves?

Suggested change
register-bank-assets:
node_modules/.bin/tsx scripts/fetch-starship-chain-info.ts && \
node_modules/.bin/tsx scripts/deploy-cli.ts src/register-interchain-bank-assets.builder.js \
assets="$$(node_modules/.bin/tsx scripts/make-bank-asset-info.ts)"
register-bank-assets:
./scripts/fetch-starship-chain-info.ts && \
./scripts/deploy-cli.ts src/register-interchain-bank-assets.builder.js \
assets="$$(./scripts/make-bank-asset-info.ts)"

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'll see where we land in #10605 and incorporate that approach

@@ -101,5 +106,5 @@ wait-for-pods:
node_modules/.bin/tsx scripts/pod-readiness.ts

.PHONY: start
start: install wait-for-pods port-forward fund-provision-pool override-chain-registry
start: install wait-for-pods port-forward fund-provision-pool override-chain-registry register-bank-assets
Copy link
Member

Choose a reason for hiding this comment

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

Does deploy-cli.ts know how to run multiple evals in one chain governance proposal? How about combining override-chain-registry and register-bank-assets?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. I won't tackle that here but I'll hope to make this update soon

const main = () => {
if (!starshipChainInfo) {
throw new Error(
'starshipChainInfo not found. run `make override-chain-registry` or `node_modules/.bin/tsx scripts/fetch-starship-chain-info.ts` first.',
Copy link
Member

Choose a reason for hiding this comment

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

the node_modules/.bin/ again jumps out at me... it looks like we're peeking into the internals of something.

Suggested change
'starshipChainInfo not found. run `make override-chain-registry` or `node_modules/.bin/tsx scripts/fetch-starship-chain-info.ts` first.',
'starshipChainInfo not found. run `make override-chain-registry` or `./scripts/fetch-starship-chain-info.ts` first.',

Comment on lines +33 to +37
const fundAndTransfer = makeFundAndTransfer(
t,
retryUntilCondition,
useChain,
);
Copy link
Member

Choose a reason for hiding this comment

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

hoist this above return?

@@ -0,0 +1,190 @@
/**
* @file register-interchain-bank-assets.js
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't look like a builder script. It looks like on-chain core-eval code.

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 adjusted the @file comment to mention this. Are you suggesting this should live in a different directory?

@@ -179,7 +179,7 @@ const ChainIdArgShape = M.or(
const DefaultPfmTimeoutOpts = harden(
/** @type {const} */ ({
retries: 3,
timeout: '10min',
timeout: /** @type {GoDuration} */ ('10m'),
Copy link
Member

Choose a reason for hiding this comment

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

odd... @type {const} isn't enough?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch const should be sufficient here

@@ -82,13 +81,32 @@ export const startSendAnywhere = async (
}),
);

const safeLookup = async p =>
Copy link
Member

Choose a reason for hiding this comment

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

the name safeLookup suggests that the .lookup(...) call should be in this function. safeFulfill maybe?

const parseAssets = () => {
if (typeof assets !== 'string') {
throw Error(
'must provide --assets=JSON.stringify({ denom: Denom; keyword: string; decimalPlaces: number; }[])',
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 really a keyword? Or is it a misnomer where we really mean issuerName?

Suggested change
'must provide --assets=JSON.stringify({ denom: Denom; keyword: string; decimalPlaces: number; }[])',
'must provide --assets=JSON.stringify({ denom: Denom; issuerName: string; decimalPlaces: number; }[])',

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 remember this comment in the add-vault proposal. I'll look to make the corresponding change in the builder so we don't continue to carry the tech debt

test.serial(sendAnywhereScenario, 'cosmoshub', 1);
test.serial(sendAnywhereScenario, 'cosmoshub', 2);
test.serial(sendAnywhereScenario, 'osmosis', 1, 'IST');
test.serial(sendAnywhereScenario, 'osmosis', 2, 'ATOM'); // exercises PFM (agoric -> cosmoshub -> osmosis)
Copy link
Member

Choose a reason for hiding this comment

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

it took me a while to grok what this test does, but I think I get it now.

For ref:
https://github.com/Agoric/agoric-sdk/actions/runs/12123427233/job/33798929261?pr=10591#step:13:3141

@@ -118,14 +119,14 @@ export const makeIBCTransferMsg = (
};

export const createFundedWalletAndClient = async (
t: ExecutionContext,
log: (...args: unknown[]) => void,
chainName: string,
useChain: MultichainRegistry['useChain'],
) => {
const { chain, creditFromFaucet, getRpcEndpoint } = useChain(chainName);
const wallet = await createWallet(chain.bech32_prefix);
Copy link
Member

Choose a reason for hiding this comment

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

createWallet(...) seems to generate random key material using ambient authority.

ah... ok; it takes key material as a default arg, a la...

I'd rather see this test take advantage of that and pass in the key material, but I suppose we'll get there in due course.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree, but none of these tests rely on a specific key currently. For now, I've made mnemonic an optional parameter to createFundedWalletAndClient.

@0xpatrickdev 0xpatrickdev force-pushed the pc/10445-transfer-pfm branch 4 times, most recently from 2368fb7 to 94e4b37 Compare December 3, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
force:integration Force integration tests to run on PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants