Skip to content

Commit

Permalink
9063 getChain (#9376)
Browse files Browse the repository at this point in the history
refs: #9063

## Description

More progress on,
- #9063


### Security Considerations

Sources chain network data from chain-registry.

### Scaling Considerations

Writes each chain info node or edge to one vstorage node.

### Documentation Considerations
none

### Testing Considerations

We'll also have to solve making it work in Starship but I think that's a
concern for #8896 or a new
ticket.


### Upgrade Considerations

Not yet released. When we do want to update the chain info in
agoricNames we'll need new work.
  • Loading branch information
mergify[bot] authored Jun 11, 2024
2 parents 1dcae57 + a8f6c6c commit 4687f0d
Show file tree
Hide file tree
Showing 33 changed files with 2,348 additions and 415 deletions.
42 changes: 18 additions & 24 deletions a3p-integration/proposals/b:enable-orchestration/initial.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,25 @@ test(`vat details`, async t => {
}
});

test('chain info', async t => {
const cosmos = await agd
.query(
'vstorage',
'data',
'--output',
'json',
'published.agoricNames.chain.cosmos',
)
const queryData = path =>
agd
.query('vstorage', 'data', '--output', 'json', path)
.then(res => JSON.parse(JSON.parse(JSON.parse(res.value).values[0]).body));
console.log('chain.cosmos', cosmos);
t.like(cosmos, { chainId: 'cosmoslocal' });

const names = await agd.query(
'vstorage',
'children',
'--output',
'json',
'published.agoricNames.chain',
test('chain info', async t => {
const chain = await queryData('published.agoricNames.chain.cosmoshub');

console.log('chain.cosmoshub', chain);
t.like(chain, { chainId: 'cosmoshub-4' });
});

test.failing('chain connection', async t => {
// FIXME encoding
// message: `Command failed with exit code 1: agd query vstorage data --output json published.agoricNames.chainConnection.["agoriclocal","cosmoshub-4"] -o json␊
// Error: rpc error: code = Unknown desc = path "published.agoricNames.chainConnection.[\\"agoriclocal\\",\\"cosmoshub-4\\"]" contains invalid characters: panic␊
const connection = await queryData(
'published.agoricNames.chainConnection.["agoriclocal","cosmoshub-4"]',
);
t.deepEqual(names.children, [
'agoric',
'celestia',
'cosmos',
'osmosis',
'stride',
]);
console.log(connection);
t.like(connection, {});
});
15 changes: 8 additions & 7 deletions packages/boot/test/bootstrapTests/orchestration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import { Fail } from '@agoric/assert';
import { AmountMath } from '@agoric/ertp';
import type { CosmosValidatorAddress } from '@agoric/orchestration';
import type { start as startStakeAtom } from '@agoric/orchestration/src/examples/stakeAtom.contract.js';
import type { start as startStakeIca } from '@agoric/orchestration/src/examples/stakeIca.contract.js';
import type { Instance } from '@agoric/zoe/src/zoeService/utils.js';
import { M, matches } from '@endo/patterns';
import type { TestFn } from 'ava';
Expand Down Expand Up @@ -33,12 +33,12 @@ test.serial('config', async t => {

const agoricNames = await EV.vat('bootstrap').consumeItem('agoricNames');

const cosmosChainInfo = await EV(agoricNames).lookup('chain', 'cosmos');
const cosmosChainInfo = await EV(agoricNames).lookup('chain', 'cosmoshub');
t.like(cosmosChainInfo, {
chainId: 'cosmoslocal',
chainId: 'cosmoshub-4',
stakingTokens: [{ denom: 'uatom' }],
});
const cosmosInfo = readLatest(`published.agoricNames.chain.cosmos`);
const cosmosInfo = readLatest(`published.agoricNames.chain.cosmoshub`);
t.deepEqual(cosmosInfo, cosmosChainInfo);
});

Expand All @@ -53,9 +53,10 @@ test.serial('stakeAtom - repl-style', async t => {
);

const agoricNames = await EV.vat('bootstrap').consumeItem('agoricNames');
const instance: Instance<typeof startStakeAtom> = await EV(
agoricNames,
).lookup('instance', 'stakeAtom');
const instance: Instance<typeof startStakeIca> = await EV(agoricNames).lookup(
'instance',
'stakeAtom',
);
t.truthy(instance, 'stakeAtom instance is available');

const zoe: ZoeService = await EV.vat('bootstrap').consumeItem('zoe');
Expand Down
150 changes: 0 additions & 150 deletions packages/boot/test/bootstrapTests/snapshots/orchestration.test.ts.md

This file was deleted.

Binary file not shown.
File renamed without changes.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Snapshot report for `test/boot-config.test.js`
# Snapshot report for `test/configs.test.js`

The actual snapshot is saved in `boot-config.test.js.snap`.
The actual snapshot is saved in `configs.test.js.snap`.

Generated by [AVA](https://avajs.dev).

Expand Down
Binary file added packages/boot/test/snapshots/configs.test.js.snap
Binary file not shown.
4 changes: 2 additions & 2 deletions packages/builders/scripts/orchestration/init-stakeAtom.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const defaultProposalBuilder = async (
'getManifestForStakeAtom',
{
installKeys: {
stakeAtom: publishRef(
install('@agoric/orchestration/src/examples/stakeAtom.contract.js'),
stakeIca: publishRef(
install('@agoric/orchestration/src/examples/stakeIca.contract.js'),
),
},
hostConnectionId,
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config/eslint-config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ module.exports = {
'**/*.config.*.js',
// leading wildcard to work in CLI (package path) and IDE (repo path)
'**/test/**',
'**/demo*/**/*js',
'**/scripts/**/*js',
'**/demo*/**',
'**/scripts/**',
],
},
],
Expand Down
6 changes: 6 additions & 0 deletions packages/network/src/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,11 @@ export const preparePortAllocator = (zone, { watch }) =>
.optional(M.string())
.returns(Shape.Vow$(Shape.Port)),
}),
/**
*
* @param {object} opts
* @param {Protocol} opts.protocol
*/
({ protocol }) => ({ protocol, lastICAPortNum: 0n, lastICQPortNum: 0n }),
{
allocateCustomIBCPort(specifiedName = '') {
Expand Down Expand Up @@ -1517,3 +1522,4 @@ export const preparePortAllocator = (zone, { watch }) =>
},
},
);
/** @typedef {ReturnType<ReturnType<typeof preparePortAllocator>>} PortAllocator */
2 changes: 0 additions & 2 deletions packages/network/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,5 +200,3 @@ export {};
* ) => PromiseVow<Connection>} outbound
* Create an outbound connection
*/

/** @typedef {ReturnType<ReturnType<typeof import('@agoric/network').preparePortAllocator>>} PortAllocator */
5 changes: 4 additions & 1 deletion packages/orchestration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"scripts": {
"build": "exit 0",
"codegen": "scripts/fetch-chain-info.ts",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"test": "ava",
Expand Down Expand Up @@ -50,10 +51,12 @@
"@endo/patterns": "^1.4.0"
},
"devDependencies": {
"@chain-registry/client": "^1.47.4",
"@cosmjs/amino": "^0.32.3",
"@cosmjs/proto-signing": "^0.32.3",
"@endo/ses-ava": "^1.2.2",
"ava": "^5.3.1"
"ava": "^5.3.1",
"prettier": "^3.3.2"
},
"ava": {
"extensions": {
Expand Down
Loading

0 comments on commit 4687f0d

Please sign in to comment.