-
Notifications
You must be signed in to change notification settings - Fork 404
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 logic for claiming ibc ports in x/wasm #211
Conversation
Codecov Report
@@ Coverage Diff @@
## 0.9.1_to_cosmos-sdk-0.39-master #211 +/- ##
===================================================================
- Coverage 32.42% 27.34% -5.09%
===================================================================
Files 24 27 +3
Lines 3830 4739 +909
===================================================================
+ Hits 1242 1296 +54
- Misses 2521 3369 +848
- Partials 67 74 +7
Continue to review full report at Codecov.
|
@alpe I ported a lot of test setup code for IBC stuff from the sdk and finally tried to instantiate a contract and bind a port. Which fails:
So, my naive port naming was simply to use the full contract address, which is well-known and unique and easy to map back and forth. This doesn't work 😞 We need to think of another naming scheme for the ports. I could make an auto-sequence, but as this is the identifier when sending messages to the other chain, humans should recognize the connection. Take last 14 chars of the address??? You can comment out the test if you want and focus on your other work, but I wanted to make this visible... first semi-blocker. (I asked for feedback on the ibc slack channel) |
contractID := codeID<<32 + instanceID // as in contractAddress | ||
size := binary.PutUvarint(data, contractID) | ||
// max total length = 4 + 16 | ||
return portIDPrefix + base64.StdEncoding.WithPadding(base64.NoPadding).EncodeToString(data[0:size]) // encoded to make it readable |
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.
a bit ugly but it works
} | ||
|
||
func ContractFromPortID(portID string) (sdk.AccAddress, error) { | ||
if !strings.HasPrefix(portID, portIDPrefix) { | ||
return nil, sdkerrors.Wrapf(types.ErrInvalid, "without prefix") | ||
} | ||
return sdk.AccAddressFromBech32(portID[len(portIDPrefix):]) | ||
data, err := base64.StdEncoding.WithPadding(base64.NoPadding).DecodeString(portID[len(portIDPrefix):]) |
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.
would be good to have a test that these reverse properly (port <-> contract)
Closing and now included in Alex's IBC Spikes |
This is the beginning of adding ibc support to wasmd.
It branches off our long-lived "stargate tracking" branch.
Check the new IBC docs before working on this.
Tasks:
Requirements from ICF grant (should be covered by the above):
At the end, we should have a mock of what a contract can do with IBC and figure out if the API provides all we need, but not touch the rust code at all - that is another (bigger) task.
Also:
Update to latest (stable) cosmos-sdk:master when appropriate
Targeted PR against correct branch (see CONTRIBUTING.md)
Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
Wrote tests
Updated relevant documentation (
docs/
)Added relevant
godoc
comments.Added a relevant changelog entry to the
Unreleased
section inCHANGELOG.md
Re-reviewed
Files changed
in the Github PR explorerFor admin use:
WIP
,R4R
,docs
, etc)