diff --git a/ci/hermes.Dockerfile b/ci/hermes.Dockerfile index a4e58a9062..cbee1188d6 100644 --- a/ci/hermes.Dockerfile +++ b/ci/hermes.Dockerfile @@ -25,3 +25,4 @@ ENTRYPOINT ["/usr/bin/hermes"] COPY --chown=0:0 --from=build-env /usr/lib/x86_64-linux-gnu/libssl.so.1.1 /usr/lib/x86_64-linux-gnu/libssl.so.1.1 COPY --chown=0:0 --from=build-env /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 COPY --chown=0:0 --from=build-env /root/ibc-rs/target/release/hermes /usr/bin/hermes +COPY --chown=0:0 --from=build-env /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt diff --git a/e2e/e2e/client.py b/e2e/e2e/client.py index e1819f8fe1..fd71a5ae18 100644 --- a/e2e/e2e/client.py +++ b/e2e/e2e/client.py @@ -60,7 +60,7 @@ class AllowUpdate: @dataclass class ClientState: chain_id: ChainId - frozen_height: Height + frozen_height: Optional[Height] latest_height: Height max_clock_drift: Duration trust_level: TrustLevel diff --git a/modules/src/clients/ics07_tendermint/client_def.rs b/modules/src/clients/ics07_tendermint/client_def.rs index 2eace19293..351ffffa2a 100644 --- a/modules/src/clients/ics07_tendermint/client_def.rs +++ b/modules/src/clients/ics07_tendermint/client_def.rs @@ -29,19 +29,11 @@ use crate::Height; use crate::downcast; -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct TendermintClient { verifier: ProdVerifier, } -impl Default for TendermintClient { - fn default() -> Self { - Self { - verifier: ProdVerifier::default(), - } - } -} - impl ClientDef for TendermintClient { type Header = Header; type ClientState = ClientState; diff --git a/modules/src/clients/ics07_tendermint/client_state.rs b/modules/src/clients/ics07_tendermint/client_state.rs index 196152adcc..eecfcae139 100644 --- a/modules/src/clients/ics07_tendermint/client_state.rs +++ b/modules/src/clients/ics07_tendermint/client_state.rs @@ -200,6 +200,15 @@ impl TryFrom for ClientState { .clone() .ok_or_else(Error::missing_trusting_period)?; + let frozen_height = raw.frozen_height.and_then(|raw_height| { + let height = raw_height.into(); + if height == Height::zero() { + None + } else { + Some(height) + } + }); + Ok(Self { chain_id: ChainId::from_string(raw.chain_id.as_str()), trust_level: trust_level @@ -224,7 +233,7 @@ impl TryFrom for ClientState { .latest_height .ok_or_else(Error::missing_latest_height)? .into(), - frozen_height: raw.frozen_height.map(|h| h.into()), + frozen_height, upgrade_path: raw.upgrade_path, allow_update: AllowUpdate { after_expiry: raw.allow_update_after_expiry, diff --git a/modules/src/core/ics03_connection/connection.rs b/modules/src/core/ics03_connection/connection.rs index d03e22315e..5c379fe3f0 100644 --- a/modules/src/core/ics03_connection/connection.rs +++ b/modules/src/core/ics03_connection/connection.rs @@ -235,23 +235,13 @@ impl ConnectionEnd { } } -#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct Counterparty { client_id: ClientId, pub connection_id: Option, prefix: CommitmentPrefix, } -impl Default for Counterparty { - fn default() -> Self { - Counterparty { - client_id: Default::default(), - connection_id: None, - prefix: Default::default(), - } - } -} - impl Protobuf for Counterparty {} // Converts from the wire format RawCounterparty. Typically used from the relayer side diff --git a/modules/src/core/ics03_connection/events.rs b/modules/src/core/ics03_connection/events.rs index a3a8b73b5e..1ab4dbdcd3 100644 --- a/modules/src/core/ics03_connection/events.rs +++ b/modules/src/core/ics03_connection/events.rs @@ -71,7 +71,7 @@ fn extract_attributes_from_tx(event: &tendermint::abci::Event) -> Result, @@ -80,18 +80,6 @@ pub struct Attributes { pub counterparty_client_id: ClientId, } -impl Default for Attributes { - fn default() -> Self { - Attributes { - height: Default::default(), - connection_id: Default::default(), - client_id: Default::default(), - counterparty_connection_id: Default::default(), - counterparty_client_id: Default::default(), - } - } -} - /// Convert attributes to Tendermint ABCI tags /// /// # Note diff --git a/modules/src/core/ics04_channel/channel.rs b/modules/src/core/ics04_channel/channel.rs index 15e0ad946a..2965a08153 100644 --- a/modules/src/core/ics04_channel/channel.rs +++ b/modules/src/core/ics04_channel/channel.rs @@ -244,21 +244,12 @@ impl ChannelEnd { } } -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct Counterparty { pub port_id: PortId, pub channel_id: Option, } -impl Default for Counterparty { - fn default() -> Self { - Counterparty { - port_id: Default::default(), - channel_id: None, - } - } -} - impl Counterparty { pub fn new(port_id: PortId, channel_id: Option) -> Self { Self { diff --git a/modules/src/core/ics04_channel/events.rs b/modules/src/core/ics04_channel/events.rs index 8483df271f..972794c8a8 100644 --- a/modules/src/core/ics04_channel/events.rs +++ b/modules/src/core/ics04_channel/events.rs @@ -180,7 +180,7 @@ fn extract_packet_and_write_ack_from_tx( Ok((packet, write_ack)) } -#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Attributes { pub height: Height, pub port_id: PortId, @@ -199,19 +199,6 @@ impl Attributes { } } -impl Default for Attributes { - fn default() -> Self { - Attributes { - height: Default::default(), - port_id: Default::default(), - channel_id: Default::default(), - connection_id: Default::default(), - counterparty_port_id: Default::default(), - counterparty_channel_id: Default::default(), - } - } -} - /// Convert attributes to Tendermint ABCI tags /// /// # Note diff --git a/modules/src/core/ics04_channel/packet.rs b/modules/src/core/ics04_channel/packet.rs index 8273cedb01..12ec013549 100644 --- a/modules/src/core/ics04_channel/packet.rs +++ b/modules/src/core/ics04_channel/packet.rs @@ -54,15 +54,11 @@ impl core::fmt::Display for PacketMsgType { } /// The sequence number of a packet enforces ordering among packets from the same source. -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Deserialize, Serialize, PartialOrd, Ord)] +#[derive( + Copy, Clone, Debug, Default, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize, +)] pub struct Sequence(u64); -impl Default for Sequence { - fn default() -> Self { - Sequence(0) - } -} - impl FromStr for Sequence { type Err = Error; diff --git a/modules/src/timestamp.rs b/modules/src/timestamp.rs index ece5c63e67..500ea37377 100644 --- a/modules/src/timestamp.rs +++ b/modules/src/timestamp.rs @@ -20,7 +20,7 @@ pub const ZERO_DURATION: Duration = Duration::from_secs(0); /// a `u64` value and a raw timestamp. In protocol buffer, the timestamp is /// represented as a `u64` Unix timestamp in nanoseconds, with 0 representing the absence /// of timestamp. -#[derive(PartialEq, Eq, Copy, Clone, Debug, Deserialize, Serialize, Hash)] +#[derive(PartialEq, Eq, Copy, Clone, Debug, Default, Deserialize, Serialize, Hash)] pub struct Timestamp { time: Option>, } @@ -241,12 +241,6 @@ impl From