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 4 commits into
base: pc/10445-transfer-pfm
Choose a base branch
from

Conversation

0xpatrickdev
Copy link
Member

closes: #9966
refs: #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 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)"

@@ -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?

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.

@@ -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?

@@ -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; }[])',

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.

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.

2 participants