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

Basic IBC Handshake Test #4797

Merged
merged 8 commits into from
Aug 22, 2024
Merged

Basic IBC Handshake Test #4797

merged 8 commits into from
Aug 22, 2024

Conversation

zbuc
Copy link
Member

@zbuc zbuc commented Aug 8, 2024

Describe your changes

This adds a basic IBC handshake test, using the existing mock client. Some opportunistic refactoring is also included.

This PR adds a new tests::common::ibc_tests module, which contains a MockRelayer that can be extended later on.

Follow-up tasks should be basic transfer testing, transfer timeout testing, and testing with malformed requests.

While debugging this test, bugs were found in the various IBC query APIs, specifically that the proof_height was consistently being returned one lower than the height whose header would contain the app_hash necessary for validating the proof. The Go relayer is unaffected because it uses the ABCI RPC query interface instead, and Hermes uses the affected APIs but discards the affected proof_height fields and uses its own internal mechanisms for height tracking instead. Fixes were included for the affected APIs.

Issue

Closes #3758

Checklist before requesting a review

  • If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason:

    There are changes to TendermintProxy and IBC RPC responses however anyone using the affected RPCs would quickly run into the issues we saw in testing that revealed the bugs in the RPC responses, and the chain would properly block any requests made based on the incorrect response values. The changeset also affects the test code heavily however there should be nothing that affects consensus or state.

@aubrika aubrika added this to the Sprint 10 milestone Aug 12, 2024
@zbuc zbuc force-pushed the ibc_sm_tests branch 14 times, most recently from 28f1623 to 8f87b28 Compare August 15, 2024 01:16
@zbuc zbuc changed the title WIP: Skeleton of IBC tests Basic IBC Handshake Test Aug 22, 2024
@zbuc zbuc marked this pull request as ready for review August 22, 2024 00:27
Copy link
Contributor

@conorsch conorsch left a comment

Choose a reason for hiding this comment

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

Excellent work, dude. So glad to see this work coming together, and some query bugs squashed along the way. Please keep the in-line comments coming, because we discovered a lot of subtlety the past few days, and you're in a great position to reduce surprises for future maintainers by documenting your travails.


/// Collection of all keypairs required for a Penumbra validator.
/// Used to generate a stable identity for a [`NetworkValidator`].
/// TODO: copied this from pd crate
Copy link
Contributor

Choose a reason for hiding this comment

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

N.B. I've long wanted to pull out most of the network code from pd into a new crate penumbra-network, and in the process clean up the interfaces for wrangling the validator keyrings.

@@ -175,6 +175,48 @@ pub struct ValidatorKeys {
}

impl ValidatorKeys {
/// Use a hard-coded seed to generate a new set of validator keys.
pub fn from_seed(seed: [u8; 32]) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

Very cool to have this utility!

@@ -198,7 +240,7 @@ impl ValidatorKeys {
let validator_cons_pk = validator_cons_sk.public_key();

// generate P2P auth key for tendermint.
let node_key_sk = ed25519_consensus::SigningKey::new(OsRng);
let node_key_sk = ed25519_consensus::SigningKey::from(seed.0);
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume the hardcoding of a static seed is leftover from debugging—for the actual test suite, we should probably leave the keygen to be random as usual. Fine for now, because I know there'll be a lot of work coming on top of this. Mentioning it now in case you disagree with the end goal.

tonic::Status::aborted(format!("couldn't decode height: {e}"))
})?,
}),
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Regarding the get_block_height + 1 logic throughout, that unblocked so much of these state machine tests, we should be documenting those sharp edges more comprehensively. Not blocking merge, but IMO, explaining the difference in height queries in the ibc module docs makes the most sense: it'll be immediately obvious to any developers looking at that code that the various notions of height are important and distinct.

@conorsch conorsch merged commit 8ee733c into main Aug 22, 2024
13 checks passed
@conorsch conorsch deleted the ibc_sm_tests branch August 22, 2024 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

tests: ❓ implement an IBC handshake using mock consensus engine
4 participants