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

Implement IBC Validator Sync sub-protocol #63

Merged
merged 6 commits into from
Jun 22, 2023
Merged

Conversation

ethanfrey
Copy link
Collaborator

Send the validator sync packets from Consumer (converter) to Provider (external-staking) and process them into the CRDT type there.

Add tests on the CRDT and some queries, so we can (in a future PR) check validators before staking, or associate tendermint double-signs with valoper addresses (next milestone)

@ethanfrey ethanfrey requested a review from maurolacy June 21, 2023 15:20
Copy link
Collaborator

@maurolacy maurolacy left a comment

Choose a reason for hiding this comment

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

LGTM.

contracts/consumer/converter/src/ibc.rs Show resolved Hide resolved
}

#[cfg_attr(not(feature = "library"), entry_point)]
/// never should be called as we do not send packets
/// The most we can do here is retry the packet, hoping it will eventually arrive.
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍🏼 Perhaps we can introduce number of retries in the future.

Copy link
Collaborator

@maurolacy maurolacy left a comment

Choose a reason for hiding this comment

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

Some more comments on IBC packets design / fields.

packages/apis/src/ibc/packet.rs Show resolved Hide resolved
packages/apis/src/ibc/packet.rs Outdated Show resolved Hide resolved
@ethanfrey ethanfrey marked this pull request as ready for review June 22, 2023 07:13
Comment on lines 78 to 87

/// This is a generic ICS acknowledgement format.
/// Proto defined here: https://github.com/cosmos/cosmos-sdk/blob/v0.42.0/proto/ibc/core/channel/v1/channel.proto#L141-L147
/// This is compatible with the JSON serialization.
/// Wasmd uses this same wrapper for unhandled errors.
#[cw_serde]
pub enum AckWrapper {
Result(Binary),
Error(String),
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍🏼 Makes sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Struct copied from cw20-ics20 (and methods updated).
This is tested to work with wasmd handling

@@ -132,13 +132,13 @@ pub fn ibc_packet_receive(
};
VAL_CRDT.add_validator(deps.storage, &valoper, update)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we capture / map the error(s) here, and return ack_fail instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is done in wasmd.

If contract panics, it aborts the whole tx (no ack written)
If contract returns error, it wraps the error message in this "standard" struct, which is what I use now as AckWrapper.

Ok(IbcBasicResponse::new())
let ack: AckWrapper = from_slice(&msg.acknowledgement.data)?;
let mut res = IbcBasicResponse::new();
match ack {
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍🏼 Taking shape.

@ethanfrey ethanfrey merged commit 39712e6 into main Jun 22, 2023
@ethanfrey ethanfrey deleted the ibc-validator-sync branch June 22, 2023 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants