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

runtime: Bump tendermint-rs to 0.28.0 #5106

Merged
merged 1 commit into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/5106.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
runtime: Bump tendermint-rs to 0.28.0
37 changes: 12 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 7 additions & 3 deletions runtime/src/consensus/tendermint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -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> {
LightBlockMeta::decode_vec(&light_block.meta).map_err(|e| anyhow!("{}", e))
Expand Down Expand Up @@ -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");

Expand Down
4 changes: 3 additions & 1 deletion runtime/src/consensus/tendermint/verifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down