From ab3dda26041922ea6dd9e2908a033041677c6477 Mon Sep 17 00:00:00 2001 From: Jernej Kos Date: Mon, 19 Dec 2022 11:49:32 +0100 Subject: [PATCH] runtime: Bump tendermint-rs to 0.28.0 --- .changelog/5106.internal.md | 1 + Cargo.lock | 37 ++++++------------- runtime/Cargo.toml | 8 ++-- runtime/src/consensus/tendermint/mod.rs | 10 +++-- .../src/consensus/tendermint/verifier/mod.rs | 4 +- 5 files changed, 27 insertions(+), 33 deletions(-) create mode 100644 .changelog/5106.internal.md diff --git a/.changelog/5106.internal.md b/.changelog/5106.internal.md new file mode 100644 index 00000000000..36922d66418 --- /dev/null +++ b/.changelog/5106.internal.md @@ -0,0 +1 @@ +runtime: Bump tendermint-rs to 0.28.0 diff --git a/Cargo.lock b/Cargo.lock index cdd9392dfb4..a17e33423a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -169,17 +169,6 @@ dependencies = [ "syn 1.0.103", ] -[[package]] -name = "async-trait" -version = "0.1.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" -dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.103", -] - [[package]] name = "atty" version = "0.2.14" @@ -2959,11 +2948,10 @@ dependencies = [ [[package]] name = "tendermint" -version = "0.26.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baa1d2d0ec1b531ba7d196f0dbee5e78ed2a82bfba928e88dff64aeec0b26073" +checksum = "c518c082146825f10d6f9a32159ae46edcfd7dae8ac630c8067594bb2a784d72" dependencies = [ - "async-trait", "bytes 1.2.1", "ed25519", "ed25519-dalek", @@ -2988,9 +2976,9 @@ dependencies = [ [[package]] name = "tendermint-config" -version = "0.26.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "202a2f19502c03b353d8157694ed24fbc58c3dd64a92a5b0cb80b79c82af5be4" +checksum = "6f58b86374e3bcfc8135770a6c55388fce101c00de4a5f03224fa5830c9240b7" dependencies = [ "flex-error", "serde", @@ -3002,9 +2990,9 @@ dependencies = [ [[package]] name = "tendermint-light-client" -version = "0.26.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5267362414f3ba254a10b704330db053959e321d71866ef5d1f203f3f3127" +checksum = "9ab1450566e4347f3a81e27d3e701d74313f9fc2efb072fc3f49e0a762cb2a0f" dependencies = [ "contracts", "crossbeam-channel 0.4.4", @@ -3023,9 +3011,9 @@ dependencies = [ [[package]] name = "tendermint-light-client-verifier" -version = "0.26.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f66e3e75f9be6260fab5d5c9a6688885c478c3d3a14c66c2fde80c78769c20ee" +checksum = "c742bb914f9fb025ce0e481fbef9bb59c94d5a4bbd768798102675a2e0fb7440" dependencies = [ "derive_more", "flex-error", @@ -3036,9 +3024,9 @@ dependencies = [ [[package]] name = "tendermint-proto" -version = "0.26.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "974d6330a19dfa6720e9f663fc59101d207a817db3f9c730d3f31caaa565b574" +checksum = "890f1fb6dee48900c85f0cdf711ebf130e505ac09ad918cee5c34ed477973b05" dependencies = [ "bytes 1.2.1", "flex-error", @@ -3054,9 +3042,9 @@ dependencies = [ [[package]] name = "tendermint-rpc" -version = "0.26.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5d87fa5429bd2ee39c4809dd546096daf432de9b71157bc12c182ab5bae7ea7" +checksum = "06df4715f9452ec0a21885d6da8d804799455ba50d8bc40be1ec1c800afd4bd8" dependencies = [ "bytes 1.2.1", "flex-error", @@ -3070,7 +3058,6 @@ dependencies = [ "subtle-encoding", "tendermint", "tendermint-config", - "tendermint-proto", "thiserror", "time 0.3.17", "url", diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 335db11f5a3..7189f692501 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -33,10 +33,10 @@ rustc-hex = "2.0.1" rand = "0.7.3" futures = "0.3.25" tokio = { version = "~1.21.1", features = ["rt", "sync"] } -tendermint = "0.26.0" -tendermint-proto = "0.26.0" -tendermint-light-client = { version = "0.26.0", default-features = false } -tendermint-rpc = { version = "0.26.0", default-features = false } +tendermint = "0.28.0" +tendermint-proto = "0.28.0" +tendermint-light-client = { version = "0.28.0", default-features = false } +tendermint-rpc = { version = "0.28.0", default-features = false } io-context = "0.2.0" curve25519-dalek = "3.2.0" x25519-dalek = "1.1.0" diff --git a/runtime/src/consensus/tendermint/mod.rs b/runtime/src/consensus/tendermint/mod.rs index ee0f2fb57a1..ce98903cb14 100644 --- a/runtime/src/consensus/tendermint/mod.rs +++ b/runtime/src/consensus/tendermint/mod.rs @@ -7,7 +7,7 @@ use std::convert::{TryFrom, TryInto}; use anyhow::{anyhow, Result}; use tendermint::{ - block::signed_header::SignedHeader as TMSignedHeader, validator::Set as TMValidatorSet, + block::signed_header::SignedHeader as TMSignedHeader, chain, validator::Set as TMValidatorSet, }; use tendermint_proto::{types::LightBlock as RawLightBlock, Protobuf}; @@ -23,6 +23,11 @@ pub const BACKEND_NAME: &str = "tendermint"; /// The domain separation context used by Oasis Core for Tendermint cryptography. pub const TENDERMINT_CONTEXT: &[u8] = b"oasis-core/tendermint"; +/// Convert an Oasis Core chain context into a Tendermint chain ID. +pub fn chain_id(chain_context: &str) -> chain::Id { + chain_context[..chain::id::MAX_LENGTH].try_into().unwrap() +} + /// Decode the light block metadata as a Tendermint light block. pub fn decode_light_block(light_block: LightBlock) -> Result { LightBlockMeta::decode_vec(&light_block.meta).map_err(|e| anyhow!("{}", e)) @@ -54,8 +59,7 @@ pub fn state_root_from_header(signed_header: &TMSignedHeader) -> Root { let height: u64 = header.height.into(); let hash: [u8; 32] = header .app_hash - .value() - .as_slice() + .as_bytes() .try_into() .expect("invalid app hash"); diff --git a/runtime/src/consensus/tendermint/verifier/mod.rs b/runtime/src/consensus/tendermint/verifier/mod.rs index dc54e51f52a..6e084be3fe6 100644 --- a/runtime/src/consensus/tendermint/verifier/mod.rs +++ b/runtime/src/consensus/tendermint/verifier/mod.rs @@ -33,7 +33,7 @@ use crate::{ ConsensusState, }, tendermint::{ - decode_light_block, state_root_from_header, + chain_id, decode_light_block, state_root_from_header, verifier::{ clock::InsecureClock, io::Io, @@ -881,6 +881,8 @@ impl Verifier { height, next_validators: &lbm.validators, next_validators_hash: header.validators_hash, + // We need to use the target chain ID as we know it has changed. + chain_id: &chain_id(&host_info.consensus_chain_context), }; // Verify the new block using +2/3 trust threshold rule.