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

Add optional ibc entry point #692

Closed
6 of 7 tasks
ethanfrey opened this issue Jan 5, 2021 · 8 comments · Fixed by #728
Closed
6 of 7 tasks

Add optional ibc entry point #692

ethanfrey opened this issue Jan 5, 2021 · 8 comments · Fixed by #728

Comments

@ethanfrey
Copy link
Member

ethanfrey commented Jan 5, 2021

IBC-enabled contracts will have an extra entry point (like how migrate is optional) called ibc.

Related to #147

** This is a placeholder issue that needs some clarification before starting **

This entry point will accept a fixed set of life-cycle callbacks from the IBC module. The exact format of the message is still to be defined (we will spec before starting the issue), but the general entry point would look like:

pub fn ibc(
    deps: DepsMut,
    env: Env,
    msg: IbcMsg,
) -> Result<IbcResponse, ContractError> {
  // ...
}

pub enum IbcMsg {
  // TODO: @ethanfrey @alpe define this clearly  
}

pub struct IbcResponse {
  // Do we always return the same info for all callbacks, or will we need different responses for different inputs?
  // In such case, we should have different entry points for each different return value
}

This entry point should be exported through cosmwasm-vm and wasmvm into wasmd.


This ticket is broken down into multiple PRs:

@webmaster128
Copy link
Member

Exposing accessor on Instance to see if contract has ibc entry points (needed in wasmd for how to treat it)

Why is this needed? Can't we just try to call the function and fail if it doesn't (it's better to ask forgiveness than permission)?

@ethanfrey
Copy link
Member Author

When we create a contract, if it supports IBC, we bind a port for it an allow others to connect.

It would be good to know if this contract will accept connections first, so we don't bind 100s of ports for contracts that will just refuse everything

@webmaster128
Copy link
Member

When we create a contract, if it supports IBC, we bind a port for it an allow others to connect.

Okay, thanks. At which point does this happen exactly? Store code? Instantiate?

@ethanfrey
Copy link
Member Author

ethanfrey commented Jan 14, 2021

This IBC port bind happens in instantiate.
The vm can pass the info in StoreCode and check in upon instantiation. Or it can pass the info on Instantiate.

I know the rust side of wasmvm gets a handle to the Instance. So if we expose this info on the instance, it should be possible to get it out.

We could return it on cache.save_wasm() during storage.
But simpler seems to be to expose the info on the Instance we use in do_init and return it (maybe via a *bool arg)

@webmaster128
Copy link
Member

webmaster128 commented Jan 14, 2021

But simpler seems to be to expose the info on the Instance we use in do_init and return it (maybe via a *bool arg)

Yes, we can have a getter funtion on Instance that loops over the export functions and checks if all requirements are met. This is super fast, easy to implement, can be accessed at any time and does not require storing data.

@ethanfrey
Copy link
Member Author

Sounds like you have a plan. If you could make a PR of that method, I'd appreciate it.

@webmaster128
Copy link
Member

Sounds like you have a plan. If you could make a PR of that method, I'd appreciate it.

Good. This is a nobrainer (Monday).

@ethanfrey ethanfrey mentioned this issue Jan 18, 2021
6 tasks
@ethanfrey
Copy link
Member Author

Okay, opening one last PR for the documentation / CHANGELOG items left to close this.
Please add items to #728 if you see minor enhancements needed

Will finish that up once CosmWasm/wasmvm#167 is finalized (and wasmd work can proceed).

@mergify mergify bot closed this as completed in #728 Jan 20, 2021
CosmWasm VM automation moved this from In progress to Done Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

2 participants