diff --git a/Cargo.lock b/Cargo.lock index 501ee450dd..a73e8f0849 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5091,6 +5091,17 @@ dependencies = [ "tracing", ] +[[package]] +name = "penumbra-cometstub" +version = "0.64.1" +dependencies = [ + "anyhow", + "ibc-proto", + "ibc-types", + "tendermint", + "tendermint-light-client-verifier", +] + [[package]] name = "penumbra-community-pool" version = "0.64.1" diff --git a/Cargo.toml b/Cargo.toml index e6ac21c3c2..773f503d07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,6 +43,7 @@ members = [ "crates/bin/pclientd", "crates/bin/pcli", "crates/wasm", + "crates/test/cometstub", "crates/test/tct-property-test", "crates/misc/measure", "crates/misc/tct-visualize", diff --git a/crates/test/cometstub/Cargo.toml b/crates/test/cometstub/Cargo.toml new file mode 100644 index 0000000000..2874ff3b8c --- /dev/null +++ b/crates/test/cometstub/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "penumbra-cometstub" +version = "0.64.1" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[features] +default = ["component", "std"] +component = [ + # "cnidarium", + # "cnidarium-component", + # "penumbra-proto/cnidarium", + # "penumbra-chain/component", +] +std = ["ibc-types/std"] + +[dependencies] +# Workspace dependencies + +# Penumbra dependencies +ibc-proto = { version = "0.40.0", default-features = false } +ibc-types = { version = "0.11.0", default-features = false } + +# Crates.io deps +anyhow = "1" +tendermint = "0.34.0" +# tendermint-proto = "0.34.0" +tendermint-light-client-verifier = "0.34.0" diff --git a/crates/test/cometstub/src/lib.rs b/crates/test/cometstub/src/lib.rs new file mode 100644 index 0000000000..ff5355bf51 --- /dev/null +++ b/crates/test/cometstub/src/lib.rs @@ -0,0 +1,89 @@ +use tendermint::{ + abci::{request::BeginBlock, types::CommitInfo}, + account, + block::{Header, Height, Round}, + chain, + validator::Set, + AppHash, Hash, Time, +}; +use tendermint_light_client_verifier::{ + options::Options, + types::{TrustedBlockState, UntrustedBlockState}, + Verdict, Verifier, +}; + +pub fn begin_block() -> BeginBlock { + BeginBlock { + hash: Hash::None, + header: header(), + last_commit_info: CommitInfo { + round: Round::default(), + votes: vec![], + }, + byzantine_validators: vec![], + } +} + +fn header() -> Header { + use tendermint::block::header::Version; + Header { + version: Version { block: 0, app: 0 }, + chain_id: chain::Id::try_from("test").unwrap(), + height: Height::default(), + time: Time::unix_epoch(), + last_block_id: None, + last_commit_hash: None, + data_hash: None, + validators_hash: validators().hash(), + next_validators_hash: validators().hash(), + consensus_hash: Hash::None, + app_hash: app_hash(), + last_results_hash: None, + evidence_hash: None, + proposer_address: account::Id::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ]), + } +} + +fn validators() -> Set { + Set::new(vec![], None) +} + +fn app_hash() -> AppHash { + AppHash::try_from(vec![1, 2, 3]).unwrap() + // AppHash::try_from is infallible, see: https://github.com/informalsystems/tendermint-rs/issues/1243 +} + +pub struct TestVerifier; +impl Verifier for TestVerifier { + fn verify_update_header( + &self, + _untrusted: UntrustedBlockState<'_>, + _trusted: TrustedBlockState<'_>, + _options: &Options, + _now: Time, + ) -> Verdict { + todo!("::verify_update_header") + } + fn verify_misbehaviour_header( + &self, + _untrusted: UntrustedBlockState<'_>, + _trusted: TrustedBlockState<'_>, + _options: &Options, + _now: Time, + ) -> Verdict { + todo!("::verify_misbehaviour_header") + } +} + +#[cfg(test)] +mod tests { + // use tendermint_light_client_verifier:: + + #[test] + fn begin_block_works() { + let _ = super::begin_block(); + // next, parse this block via a light client + } +}