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

fix(orchestration): remove cancelToken + rename createAccount -> makeAccount #9312

Merged
merged 7 commits into from
May 2, 2024

Conversation

0xpatrickdev
Copy link
Member

@0xpatrickdev 0xpatrickdev commented May 1, 2024

closes: #XXXX
refs: #9207

Description

  • removes cancelToken logic from .undelegate()
  • renames createAccount to makeAccount for orchestration and localchain (Method Naming Structure)
    • make<Foo>(): Creates a new Foo object and returns only that object.
    • create<Foo>(): Creates a new Foo, but doesn't return it.
  • renames getChainAddress -> getAddress on orchestration

Security Considerations

Scaling Considerations

Documentation Considerations

Testing Considerations

Upgrade Considerations

Copy link

cloudflare-workers-and-pages bot commented May 1, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 39a980a
Status: ✅  Deploy successful!
Preview URL: https://cb3db7ec.agoric-sdk.pages.dev
Branch Preview URL: https://pc-fix-orchestration-types.agoric-sdk.pages.dev

View logs

Chris-Hibbert
Chris-Hibbert previously approved these changes May 1, 2024
Copy link
Contributor

@Chris-Hibbert Chris-Hibbert left a comment

Choose a reason for hiding this comment

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

Thanks. This seems like the right renaming.

@@ -140,7 +140,7 @@ test.serial('stakeAtom - smart wallet', async t => {
invitationSpec: {
source: 'agoricContract',
instancePath: ['stakeAtom'],
callPipe: [['makeCreateAccountInvitation']],
callPipe: [['makeAccountInvitation']],
Copy link
Contributor

Choose a reason for hiding this comment

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

If you hate makeMakeAccountInvitation, how about makeNewAccountInvitation?

I'm okey if you don't want to change this.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, makeAccountInvitation seems misleading

Copy link
Member

@dtribble dtribble May 2, 2024

Choose a reason for hiding this comment

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

oh is it a function to make the maker? I did not parse that. makeMakeAccountInvitation?

@0xpatrickdev 0xpatrickdev marked this pull request as draft May 1, 2024 18:18
@0xpatrickdev 0xpatrickdev force-pushed the pc/fix-orchestration-types branch 2 times, most recently from a3e4c25 to cad3dcd Compare May 1, 2024 20:11
@0xpatrickdev 0xpatrickdev requested a review from dtribble May 1, 2024 20:16
@0xpatrickdev 0xpatrickdev marked this pull request as ready for review May 1, 2024 20:16
@0xpatrickdev 0xpatrickdev dismissed Chris-Hibbert’s stale review May 1, 2024 20:25

Dismissing since initial scope has increased

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.

this looks consistent with recent feedback from @dtribble

Brand,
Payment,
Purse,
RemotableBrand,
Copy link
Member

Choose a reason for hiding this comment

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

RemotableBrand comes from @endo/eventual-send, right? Importing it from ERTP is sort of misleading, suggesting it has something to do with the ERTP Brand type.

Copy link
Member

Choose a reason for hiding this comment

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

RemotableBrand doesn't seem to be used. why add it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Artifact, removed. Thanks for surfacing

@@ -140,7 +140,7 @@ test.serial('stakeAtom - smart wallet', async t => {
invitationSpec: {
source: 'agoricContract',
instancePath: ['stakeAtom'],
callPipe: [['makeCreateAccountInvitation']],
callPipe: [['makeAccountInvitation']],
Copy link
Member

Choose a reason for hiding this comment

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

yeah, makeAccountInvitation seems misleading

Copy link
Member

@dtribble dtribble left a comment

Choose a reason for hiding this comment

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

The comments are minor and straightforward. Consider it reviewed once you've addressed them. Making it "request changes" so it doesn't autosubmit....

@@ -140,7 +140,7 @@ test.serial('stakeAtom - smart wallet', async t => {
invitationSpec: {
source: 'agoricContract',
instancePath: ['stakeAtom'],
callPipe: [['makeCreateAccountInvitation']],
callPipe: [['makeNewAccountInvitation']],
Copy link
Member

Choose a reason for hiding this comment

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

should be makeAccountInvitation?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was discussed above - it's a function that makes an invitation to make an account, makeMakeAccountInvitation .

I don't feel strongly either way - makeAccountInvitation is potentially misleading, makeNewAccountInvitation could be too since we don't use "new" anywhere here.

Copy link
Member

Choose a reason for hiding this comment

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

I think the historical pattern for this would be makeAcountInvitationMaker, which then would produce something you would call makeAccountInvitation

const {
runUtils: { EV },
} = t.context;

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

const account = await EV(orchestration).createAccount(
const account = await EV(orchestration).makeAccount(
Copy link
Member

Choose a reason for hiding this comment

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

Why does this need EV?

Copy link
Member Author

Choose a reason for hiding this comment

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

EV is a testing utility for bootstrap tests

Copy link
Member

Choose a reason for hiding this comment

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

It's like E but works through RunUtils.

// IMPORTANT WARNING TO USERS OF `EV`
//
// `EV` presents an abstraction that can be used (within tests only!) to get
// much of the convenience with respect to messaging that `E` provides in
// normal code. However, this convenience comes with a huge caveat that all
// users of this convenience feature MUST keep in mind.
//

hostConnectionId,
controllerConnectionId,
);
const accountAddress = await E(account).getAccountAddress();
trace('account address', accountAddress);
const address = await E(account).getAddress();
Copy link
Member

Choose a reason for hiding this comment

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

btw feel free to name the variable accountAddress if that seems more informative

Copy link
Member Author

@0xpatrickdev 0xpatrickdev May 1, 2024

Choose a reason for hiding this comment

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

👍 going to keep it as address for consistency. I might lobby to change getRemoteAddress() to getRemoteChannelAddress() (and getLocalAddress() -> getLocalChannelAddress()) so no one gets confused by these.

Copy link
Member Author

@0xpatrickdev 0xpatrickdev May 1, 2024

Choose a reason for hiding this comment

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

On second thought, since I am going to change things to use ChainAddress, i will call the local variable chainAddress. Was awkward typing this.state.address.address to form a message.

},
makeCreateAccountInvitation() {
makeNewAccountInvitation() {
Copy link
Member

@dtribble dtribble May 1, 2024

Choose a reason for hiding this comment

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

-makeAccountInvitation? (make implies new)-
Discussion above; this proposed name misses the usage. makeAcountInvitationMaker would follow historical patterns for this, but it's not critical.

* account: ChainAccount;
* chainAddress: string;
* account: ChainAccountKit['account'];
* address: ChainAddress['address'];
Copy link
Member

Choose a reason for hiding this comment

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

Why are we not including the chainID as well? If we have staking reports that are Eth, it should clear from the log?

I would love to have a standard simple format that encompasses all addresses, but we just aren't seeing it yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have #9162 for work around the ChainAddress object. I will stub that out now in this PR so we can remove the ChainAccountKit['account'] references.

@@ -59,7 +59,7 @@ export const Proto3Shape = {
};

export const ChainAccountI = M.interface('ChainAccount', {
getAccountAddress: M.call().returns(M.string()),
getAddress: M.call().returns(M.string()),
Copy link
Member

Choose a reason for hiding this comment

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

This should also return a ChainAddress.

Copy link
Member

Choose a reason for hiding this comment

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

otherwise it cannot be passed as an arg to the various "send" operations

Copy link
Member Author

Choose a reason for hiding this comment

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

* }}
*/ (
harden({
port,
connection: undefined,
requestedRemoteAddress,
remoteAddress: undefined,
accountAddress: undefined,
address: undefined,
Copy link
Member

Choose a reason for hiding this comment

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

should this be "localAddress" in comparison to remote address? or is it "sourceAddress"?

Copy link
Member Author

@0xpatrickdev 0xpatrickdev May 1, 2024

Choose a reason for hiding this comment

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

localAddress means something different - it's the channel address on the local chain. Here is console output from a test:

 ICA Account Addresses {
        accountAddress: 'cosmos1test',
        localAddress: '/ibc-port/icacontroller-1/ordered/{"version":"ics27-1","controllerConnectionId":"connection-0","hostConnectionId":"connection-0","address":"cosmos1test","encoding":"proto3","txType":"sdk_multi_msg"}/ibc-channel/channel-1',
        remoteAddress: '/ibc-hop/connection-0/ibc-port/icahost/ordered/{"version":"ics27-1","controllerConnectionId":"connection-0","hostConnectionId":"connection-0","address":"cosmos1test","encoding":"proto3","txType":"sdk_multi_msg"}/ibc-channel/channel-NaN',
      }

We need to extract address from the negotiated remote channel address.

@@ -252,9 +252,9 @@ const prepareOrchestration = (zone, createChainAccount) =>
* the counterparty connection_id
* @param {IBCConnectionID} controllerConnectionId
* self connection_id
* @returns {Promise<ChainAccount>}
* @returns {Promise<ChainAccountKit['account']>}
Copy link
Member

Choose a reason for hiding this comment

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

This kind of type seems like a source of confusion rather than help. They well defined type that it should return is a ChainAccount?

Copy link
Member Author

@0xpatrickdev 0xpatrickdev May 1, 2024

Choose a reason for hiding this comment

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

Added a6360a5 to remove the confusion

@@ -430,7 +421,7 @@ export type TransferMsg = {

// Example
// await icaNoble.transferSteps(usdcAmt,
// osmosisSwap(tiaBrand, { pool: 1224, slippage: 0.05 }, icaCel.getAddress()));
// osmosisSwap(tiaBrand, { pool: 1224, slippage: 0.05 }, icaCel.getChainAddress()));
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be getAddress?

@0xpatrickdev 0xpatrickdev force-pushed the pc/fix-orchestration-types branch 2 times, most recently from 2de7c5a to a6360a5 Compare May 2, 2024 13:44
@0xpatrickdev 0xpatrickdev requested review from dckc and dtribble May 2, 2024 13:45
this.state.localAddress = localAddr;
// XXX parseAddress currently throws, should it return '' instead?
this.state.chainAddress = harden({
address: parseAddress(remoteAddr) || UNPARSABLE_CHAIN_ADDRESS,
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 parseAddress suggests that it's taking something like agoric123lj23kj2... and picking it apart. I had to read the source code -- well, the tests, actually -- to figure out what it's doing. How about changing its argument type to RemoteIbcAddress? and maybe rename it to findAddressField?

p.s. I sure wish we used tools that make it easier to re-use tests as documentation a la doctest.

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 naming suggestion. Will tackle it here if there's add'l feedback, or tackle it as part of #9198.

Also planning to rename makeICAConnectionAddress to makeICAChannelAddress

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.

seems like forward progress

*/
undelegate: (delegations: Delegation[]) => Promise<Undelegation[]>;
undelegate: (delegations: Delegation[]) => Promise<void>;
Copy link
Member

Choose a reason for hiding this comment

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

why not return at least MsgUndelegateResponse?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think cosmjs types like that show up anywhere else in OrchestrationAccount, do they?

Copy link
Member

Choose a reason for hiding this comment

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

I was going to say that MsgUndelegateResponse is empty anyway, but it's not; it has vital info: completion_time.

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 think this makes sense. Should we also include MsgUndelegateResponse, MsgBeginRedelegateResponse, and MsgTransferResponse? MsgDelegateResponse and MsgSend are empty objects

@0xpatrickdev 0xpatrickdev added the automerge:rebase Automatically rebase updates, then merge label May 2, 2024
@0xpatrickdev 0xpatrickdev dismissed dtribble’s stale review May 2, 2024 17:56

Consider it reviewed once you've addressed them. Making it "request changes" so it doesn't autosubmit....

@0xpatrickdev 0xpatrickdev added automerge:rebase Automatically rebase updates, then merge and removed automerge:rebase Automatically rebase updates, then merge labels May 2, 2024
@mergify mergify bot merged commit 5a4779a into master May 2, 2024
64 checks passed
@mergify mergify bot deleted the pc/fix-orchestration-types branch May 2, 2024 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants