-
Notifications
You must be signed in to change notification settings - Fork 212
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(orchestration): send message #9195
Conversation
2f54b74
to
d717eb4
Compare
aa39e09
to
4982dda
Compare
d717eb4
to
7b7e823
Compare
4982dda
to
d0f7120
Compare
32f2624
to
25790ee
Compare
d0f7120
to
e58050b
Compare
packages/boot/tools/ibc/mocks.js
Outdated
* @param {ChannelOpenInitPacket} obj | ||
*/ | ||
channelOpenAck: obj => { | ||
const icaControllerNonce = obj?.packet?.source_port?.split('-')?.[1]; |
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 seems suspicious, since channelId's are frequently different between the subject chain and the counterparty, and also have no relation to the port number. Could you maybe separate and document what these numbers actually are:
const icaControllerNonce = obj?.packet?.source_port?.split('-')?.[1]; | |
const sourcePortSuffix = obj?.packet?.source_port?.split('-')?.at(-1); | |
const destPortSuffix = obj?.packet?.destination_port?.split('-')?.at(-1); |
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.
Agree, I will add your suggestions so this mocking is documented clearly.
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'm not sure I have enough context to be able to officially approve, but AFAIK you can merge directly into 9111-proto-messages
without my approval.
packages/boot/tools/ibc/mocks.js
Outdated
channelID: `channel-${icaControllerNonce}`, | ||
counterparty: { | ||
port_id: obj.packet.destination_port, | ||
channel_id: `channel-${icaControllerNonce}`, |
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.
channelID: `channel-${icaControllerNonce}`, | |
counterparty: { | |
port_id: obj.packet.destination_port, | |
channel_id: `channel-${icaControllerNonce}`, | |
// Fake a channel ID from its port suffix. | |
channelID: `channel-${sourcePortSuffix}`, | |
counterparty: { | |
port_id: obj.packet.destination_port, | |
// Fake a channelID from its port suffix. | |
channel_id: `channel-${destPortSuffix}`, |
/** @import { Proto3Msg } from '../types'; */ | ||
|
||
/** @typedef {string} Base64Bytes - Uint8Array, base64 encoded */ | ||
/** @typedef {{ typeUrl: string; value: Base64Bytes; }} Proto3Msg */ |
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.
Why the two different definitions of Proto3Msg
?
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.
Not intentional, thank you
@0xpatrickdev please don't. I'd like to land that branch, #9112, today. It's green and just needs approval. |
25790ee
to
e315f6d
Compare
Planning to go to |
packages/boot/tools/ibc/mocks.js
Outdated
|
||
/** | ||
* @param {string} versionString version string | ||
* @param {{ address: string; }} [params] |
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.
params
is optional but what's the point of calling this without it?
packages/boot/tools/ibc/mocks.js
Outdated
*/ | ||
|
||
/** | ||
* @param {string} versionString version 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.
please convey that this string itself must be in JSON
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.
It's an arbitrary string. ICA happens to use a JSON format, but IBC transfer uses a non-JSON string of just seven bytes: ics20-1
.
I'm increasingly hesitant to impose more structure than the IBC spec describes (more than just ICA or the "IBC transfer" protocol). There's a sweet spot to be found between making APIs with useful guard rails versus types that are flexible enough to express legitimate uses of IBC we haven't yet imagined.
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.
impose more structure than the IBC spec describes
💯 we should stick to the spec. Are there types for the spec that we could import? If not, I propose we have a separate file with just the types from the spec that code implementing parts of it imports.
But for parts of the code that do not support the full spec, shouldn't we document what they are expecting?
packages/boot/tools/ibc/mocks.js
Outdated
*/ | ||
msgDelegateResponse: (obj, sequence = 1) => { | ||
return { | ||
// {"result":"+/cosmos.staking.v1beta1.MsgDelegateResponse"} |
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.
what's this comment meant to convey?
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.
These code comments are the decoded acknowledgement packets. I refactored mocks.js
and support.ts
per your feedback, lmk if this reads better:
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.
yep!
packages/boot/tools/ibc/mocks.js
Outdated
*/ | ||
acknowledgementPacketFailure: (obj, sequence = 1) => { | ||
return { | ||
// {"error":"ABCI code: 5: error handling packet: see events for details"} (ErrPacketTimeout?) |
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.
ditto, why the commented out code?
packages/boot/tools/supports.ts
Outdated
@@ -367,6 +368,50 @@ export const makeSwingsetTestKit = async ( | |||
icaMocks.startChannelOpenInit.channelOpenAck(obj), | |||
); | |||
return undefined; | |||
case 'sendPacket': | |||
switch (obj.packet.data) { | |||
case 'eyJ0eXBlIjoxLCJkYXRhIjoiQ2xVS0l5OWpiM050YjNNdWMzUmhhMmx1Wnk1Mk1XSmxkR0V4TGsxelowUmxiR1ZuWVhSbEVpNEtDMk52YzIxdmN6RjBaWE4wRWhKamIzTnRiM04yWVd4dmNHVnlNWFJsYzNRYUN3b0ZkV0YwYjIwU0FqRXciLCJtZW1vIjoiIn0=': |
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 is pretty specific to particular tests. please make these exported constants so it's easy to see where they're used
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.
export type DestinationPort = 'icahost' | 'icqhost'; | ||
export type SourcePortPrefix = 'icacontroller' | 'icqcontroller'; | ||
export type SourcePort = `${SourcePortPrefix}-${number}`; | ||
// TODO improve. sometimes expressed uppercase, others lowercase |
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.
+1, I don't get it
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 removed this type (ChannelOrdering) in favor of the now exported @typedef {'ORDERED' | 'UNORDERED'} IBCChannelOrdering
from @agoric/vats
. It seems like the lowercase variant is used when creating an address string, and the uppercase variant in packets. There is no type checking against address strings in this PR, but we could maybe add something like type AddressChannelOrdering = Lowercase<IBCChannelOrdering>
if we wanted to do that
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.
It seems like the lowercase variant is used when creating an address string, and the uppercase variant in packets.
Agreed, but I don't understand why
03f697f
to
a1dc02a
Compare
6482df5
to
722015f
Compare
c421d1b
to
3ae138b
Compare
return E.when( | ||
E(connection).send(makeTxPacket(msgs, opts)), | ||
// if parsePacketAck cannot find a `result` key, it throws | ||
ack => parsePacketAck(ack), |
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.
note that that throw will not be caught by the catch below
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.
Correct. This was intended to capture a failure on the initial send. Since we are doing extra handling, I've removed the catch
const port = await E(network) | ||
.bind(`/ibc-port/icacontroller-${this.state.icaControllerNonce}`) | ||
.catch(e => Fail`Failed to bind port: ${e}`); | ||
const port = await E(network).bind( |
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.
out of scope but it strikes me that .bind(
is 99% of the time the JS function bind to this
.
@iomekam WDYT of a name that's less likely to be confused?
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.
Maybe bindPort
?
case "bindPort": |
I can see how E(port).bindPort()
might sound odd, though.
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.
redundant > confusing ;-)
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.
bindPort
is a perfect name. It's not E(port).bindPort()
, it's E(network).bindPort()
.
@@ -51,17 +49,17 @@ const getPower = (powers, name) => { | |||
return /** @type {OrchestrationPowers[K]} */ (powers.get(name)); | |||
}; | |||
|
|||
export const Proto3Shape = { | |||
typeUrl: M.string(), | |||
value: 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.
I still think we should have a different key for when value is bytes vs base64 string. e.g. valueB64
. not a blocker
@@ -106,4 +106,139 @@ export type BridgeManager = { | |||
) => ScopedBridgeManager; | |||
}; | |||
|
|||
export type * from './ibc.js'; | |||
export type IBCPortID = 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.
why did you move these from ibc.js
? I suppose to get .ts syntax. I expect there's a better place for these but I can't think of a good suggestion atm
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.
Yes for TS syntax, plus this ballooned to quite a few lines at the top of the file.
I attempted ibc.d.ts
in the same directory but this caused issues with things looking for exports from ibc.js
. I also did not observe a pattern of multiple .d.ts files in a single package in the repo
330fe8c
to
38c7bc3
Compare
38c7bc3
to
54d830f
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.
🚀
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js'; | ||
import { addParamsIfJsonVersion } from '../../../tools/ibc/mocks.js'; | ||
|
||
test('addParamsToVersion', t => { |
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.
nit: addParamsIfJsonVersion, not worth CI
]; | ||
|
||
for (const { version, expected, message } of scenarios) { | ||
t.is(addParamsIfJsonVersion(version, params), expected, message); |
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 the future consider an Ava macro for multiple test cases
closes: #8881
refs: #9042
Description
Implement
.executeEncodedTx
onChainAccount
{typeUrl: string, value: Base64Bytes}
. The Base64Bytes value keys are converted to Uint8Array, and the array of messages are then encoded insideTxBody
..send()
is a JSON string in the event of success or failure. If aresult
key is present it is returned. If anerror
key is present, or neither key is found, an error is thrown.Implement
delegate
for StakeAtom.delegate()
on their Account HolderImproved ibc mocks and bridge i/o in bootstrap style testing. Currently, delegating
10uatom
fromcosmos1test
tocosmosvaloper1test
should result in a successful TX. Others, like delegating tocosmosvaloper1fail
will fail.Security Considerations
Scaling Considerations
Documentation Considerations
Testing Considerations
Upgrade Considerations