Skip to content

Commit

Permalink
WIP: update to changes in tendermint 0.23.2
Browse files Browse the repository at this point in the history
Also remove chrono where it was found to be obviated by the changes.
  • Loading branch information
mzabaluev committed Dec 13, 2021
1 parent 8d67c15 commit 2b7bf02
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 42 deletions.
50 changes: 25 additions & 25 deletions Cargo.lock

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

17 changes: 12 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@ exclude = [
"proto-compiler"
]

[patch.crates-io]
tendermint = { git = "https://github.com/informalsystems/tendermint-rs", branch = "release/v0.23.2" }
tendermint-rpc = { git = "https://github.com/informalsystems/tendermint-rs", branch = "release/v0.23.2" }
tendermint-proto = { git = "https://github.com/informalsystems/tendermint-rs", branch = "release/v0.23.2" }
tendermint-light-client = { git = "https://github.com/informalsystems/tendermint-rs", branch = "release/v0.23.2" }
tendermint-testgen = { git = "https://github.com/informalsystems/tendermint-rs", branch = "release/v0.23.2" }

# [patch.crates-io]
# tendermint = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
# tendermint-rpc = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
# tendermint-proto = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
# tendermint-light-client = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
# tendermint-testgen = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
# tendermint = { path = "../tendermint-rs/tendermint" }
# tendermint-rpc = { path = "../tendermint-rs/rpc" }
# tendermint-proto = { path = "../tendermint-rs/proto" }
# tendermint-light-client = { path = "../tendermint-rs/light-client" }
# tendermint-testgen = { path = "../tendermint-rs/testgen" }
2 changes: 1 addition & 1 deletion modules/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mocks = ["tendermint-testgen"]
# Proto definitions for all IBC-related interfaces, e.g., connections or channels.
ibc-proto = { version = "0.13.0", path = "../proto" }
ics23 = { version = "0.6.7", default-features = false }
chrono = { version = "0.4.19", default-features = false }
time = { version = "0.3", default-features = false }
thiserror = { version = "1.0.30", default-features = false }
serde_derive = { version = "1.0.104", default-features = false }
serde = { version = "1.0", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions modules/src/clients/ics07_tendermint/client_def.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::convert::TryInto;

use ibc_proto::ibc::core::commitment::v1::MerkleProof;
use tendermint::Time;
use tendermint_light_client::components::verifier::{ProdVerifier, Verdict, Verifier};
use tendermint_light_client::types::{TrustedBlockState, UntrustedBlockState};
use time::OffsetDateTime;

use crate::clients::ics07_tendermint::client_state::ClientState;
use crate::clients::ics07_tendermint::consensus_state::ConsensusState;
Expand Down Expand Up @@ -107,7 +107,7 @@ impl ClientDef for TendermintClient {
untrusted_state,
trusted_state,
&options,
Time(chrono::Utc::now()),
OffsetDateTime::now_utc().try_into().unwrap(),
);

match verdict {
Expand Down
13 changes: 5 additions & 8 deletions modules/src/clients/ics07_tendermint/consensus_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::prelude::*;

use core::convert::Infallible;

use chrono::{TimeZone, Utc};
use serde::Serialize;
use tendermint::{hash::Algorithm, time::Time, Hash};
use tendermint_proto::Protobuf;
Expand Down Expand Up @@ -61,6 +60,9 @@ impl TryFrom<RawConsensusState> for ConsensusState {
let proto_timestamp = raw
.timestamp
.ok_or_else(|| Error::invalid_raw_consensus_state("missing timestamp".into()))?;
let timestamp = proto_timestamp
.try_into()
.map_err(|e| Error::invalid_raw_consensus_state(format!("invalid timestamp: {}", e)))?;

Ok(Self {
root: raw
Expand All @@ -70,9 +72,7 @@ impl TryFrom<RawConsensusState> for ConsensusState {
})?
.hash
.into(),
timestamp: Utc
.timestamp(proto_timestamp.seconds, proto_timestamp.nanos as u32)
.into(),
timestamp,
next_validators_hash: Hash::from_bytes(Algorithm::Sha256, &raw.next_validators_hash)
.map_err(|e| Error::invalid_raw_consensus_state(e.to_string()))?,
})
Expand All @@ -81,10 +81,7 @@ impl TryFrom<RawConsensusState> for ConsensusState {

impl From<ConsensusState> for RawConsensusState {
fn from(value: ConsensusState) -> Self {
let timestamp = prost_types::Timestamp {
seconds: value.timestamp.0.timestamp(),
nanos: value.timestamp.0.timestamp_subsec_nanos() as i32,
};
let timestamp: prost_types::Timestamp = value.timestamp.into();

RawConsensusState {
timestamp: Some(timestamp),
Expand Down
1 change: 0 additions & 1 deletion modules/src/clients/ics07_tendermint/header.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use core::cmp::Ordering;

use bytes::Buf;
use chrono::DateTime;
use prost::Message;
use serde_derive::{Deserialize, Serialize};
use tendermint::block::signed_header::SignedHeader;
Expand Down

0 comments on commit 2b7bf02

Please sign in to comment.