-
Notifications
You must be signed in to change notification settings - Fork 208
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
feat: generic chain with sendAnywhere demo contract #9460
Conversation
Deploying agoric-sdk with Cloudflare Pages
|
f7e2e2a
to
ab38074
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing blocking; we'll keep iterating
const agoricChainInfo = await chainHub.getChainInfo('agoric'); | ||
const { transferChannel } = await chainHub.getConnectionInfo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given that these each do remote calls to the same vat, we should have a convinience for getting both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought about it, but it's necessarily 2 round-trips: 1 to get the chainInfo, then you have to pick out the chainId and send it for the 2nd call
packages/orchestration/src/facade.js
Outdated
return { | ||
/** @returns {Promise<ChainInfo>} */ | ||
async getChainInfo() { | ||
return mockLocalChainInfo; | ||
}, | ||
|
||
async makeAccount() { | ||
const account = await E(localchain).makeAccount(); | ||
const lowLevelAccountP = E(localchain).makeAccount(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naming by "level" is a smell.
makeLocalChainAccountKit
is making something that does OrchestrationAccount and more. Let's rename it to LocalOrchestrationAccount
like the RemoteOrchestrationAccount
.
Up to you whether this PR. I'm happy to do it. If you want to land this as-is please at least leave a TODO comment.
packages/orchestration/src/facade.js
Outdated
@@ -94,6 +99,8 @@ const makeLocalChainFacade = localchain => { | |||
}; | |||
|
|||
/** | |||
* XXX should be provide...Facade |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternately keep this but also export provideOrchestrationFacade
that ensures it runs at most once per zone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provide
isn't straightforward: maker return value {"orchestrate":"[Function orchestrate]"} is not storable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the stored parts would just be the kinds. The facade need not be memoized since it's stateless.
export const makeChainHub = agoricNames => { | ||
// XXX not reachably-durable? really?? take a zone arg? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable and cheap to allow the caller to choose
export const makeChainHub = agoricNames => { | |
// XXX not reachably-durable? really?? take a zone arg? | |
export const makeChainHub = (agoricNames, zone = makeHeapZone()) => { |
we can iterate on what the best way to use it is. it might differ from contract to contract.
|
||
const info = await chain.getChainInfo(); | ||
const { chainId } = info; | ||
await E(contractAccount).deposit(await pmtP, amt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should theis be pipelined?
I really don't know what's allowed within an async flow
(and you point out, contractAccount
is not remote itself)
async (orch, { zcf }, seat, offerArgs) => { | ||
mustMatch( | ||
offerArgs, | ||
harden({ chainKey: M.scalar(), destAddr: M.string() }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider a more explicit name for chainKey
to distinguish from chainName
and chainId
(both keys)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
going with chainName
in anticipation of supporting well-known chains too
55aea8d
to
995a831
Compare
const [currentTime, timerBrand] = await Promise.all([ | ||
E(timer).getCurrentTimestamp(), | ||
brandCache || E(timer).getTimerBrand(), | ||
]); | ||
const timeout = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@0xpatrickdev I managed to avoid passing timerBrand
to every orchestration contract.
@@ -42,6 +48,7 @@ test('chain info', async t => { | |||
t.deepEqual(await result.getChainInfo(), mockChainInfo); | |||
}); | |||
|
|||
// XXX what to do with this test now that chainInfos is the caller's responsibility? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@turadg what to do with this test now that chainInfos is the caller's responsibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm yeah, the main point of it was the name registry behavior..
My first thought it so leave it around as a stub for other "contract upgrade" assertions, but if someone shows up to the test as-is they're going to be confused why it exists. So I think it best be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pruned it to a test.todo()
2f9963d
to
0431291
Compare
- update CosmosChainInfoShape to match type: stakingTokens is optional
|
||
await Promise.all(registrationPromises); | ||
for await (const [name, info] of Object.entries(wellKnownChainInfo)) { | ||
log(`registering chain ${name}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in #9477 I found it helpful to be a little more specific since this log output doesn't have any context qualifier:
log(`registering chain ${name}`); | |
log(`registering agoricName chain.${name}`); |
Though now that there's a registerChain
method the logging could go there.
packages/orchestration/src/facade.js
Outdated
@@ -94,6 +99,8 @@ const makeLocalChainFacade = localchain => { | |||
}; | |||
|
|||
/** | |||
* XXX should be provide...Facade |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the stored parts would just be the kinds. The facade need not be memoized since it's stateless.
import { wellKnownChainInfo } from '../../src/chain-info.js'; | ||
|
||
const agoricChainInfo = wellKnownChainInfo.agoric; | ||
import { commonSetup } from '../supports.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lint
@@ -38,8 +33,11 @@ export const commonSetup = async t => { | |||
// To test durability in unit tests, test a particular entity with `relaxDurabilityRules: false`. | |||
// To test durability integrating multiple vats, use a RunUtils/bootstrap test. | |||
const rootZone = makeHeapZone(); | |||
const bld = withAmountUtils(makeIssuerKit('BLD')); | |||
const ist = withAmountUtils(makeIssuerKit('IST')); | |||
const { mint: _b, ...bld } = withAmountUtils(makeIssuerKit('BLD')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could use some explaining. a perhaps more legible approach would be an option to withAmountUtils
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The concern seems specific to pourPayment
and makeFakeBankManagerKit
so explaining here seems like the way to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair. If we have to do this a lot we might want an AmountUtils for runutils tests which takes pourPayment and abstracts it.
Something to consider in the course of designing the API for writing tests that work in multiple levels of integration. (Unit, swingset, chain)
- add IST to vbankAsset - inspectLocalBridge
closes #9187
Description
DRAFT until
transfer()
maps chainId to transferChannel?Security Considerations
Scaling Considerations
Documentation Considerations
Testing Considerations
Upgrade Considerations