Skip to content

Commit

Permalink
Merge pull request #23 from datachainlab/remove-latest-slot
Browse files Browse the repository at this point in the history
Remove unnecessary `latest_slot` from client state proto

Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele authored Nov 5, 2024
2 parents 35f05a5 + d042717 commit 240f6d8
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 14 deletions.
5 changes: 0 additions & 5 deletions crates/ibc/src/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ pub struct ClientState<const SYNC_COMMITTEE_SIZE: usize> {
pub max_clock_drift: Duration,

/// State
pub latest_slot: Slot,
pub latest_execution_block_number: U64,
pub frozen_height: Option<Height>,

Expand Down Expand Up @@ -269,8 +268,6 @@ impl<const SYNC_COMMITTEE_SIZE: usize> ClientState<SYNC_COMMITTEE_SIZE> {
Err(Error::UninitializedClientStateField("trust_level"))
} else if self.trusting_period == Duration::default() {
Err(Error::UninitializedClientStateField("trusting_period"))
} else if self.latest_slot == Slot::default() {
Err(Error::UninitializedClientStateField("latest_slot"))
} else if self.latest_execution_block_number == U64::default() {
Err(Error::UninitializedClientStateField(
"latest_execution_block_number",
Expand Down Expand Up @@ -749,7 +746,6 @@ impl<const SYNC_COMMITTEE_SIZE: usize> TryFrom<RawClientState>
.ok_or(Error::NegativeMaxClockDrift)?
.try_into()
.map_err(|_| Error::NegativeMaxClockDrift)?,
latest_slot: value.latest_slot.into(),
latest_execution_block_number: value.latest_execution_block_number.into(),
frozen_height,
consensus_verifier: Default::default(),
Expand Down Expand Up @@ -810,7 +806,6 @@ impl<const SYNC_COMMITTEE_SIZE: usize> From<ClientState<SYNC_COMMITTEE_SIZE>> fo
}),
trusting_period: Some(value.trusting_period.into()),
max_clock_drift: Some(value.max_clock_drift.into()),
latest_slot: value.latest_slot.into(),
latest_execution_block_number: value.latest_execution_block_number.into(),
frozen_height: value.frozen_height.map(|h| ProtoHeight {
revision_number: h.revision_number(),
Expand Down
3 changes: 0 additions & 3 deletions crates/ibc/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ pub fn apply_updates<const SYNC_COMMITTEE_SIZE: usize, C: ChainContext>(
};

let mut new_client_state = client_state.clone();
if client_state.latest_slot < update_slot {
new_client_state.latest_slot = update_slot;
}
if client_state.latest_execution_block_number < block_number {
new_client_state.latest_execution_block_number = block_number;
}
Expand Down
5 changes: 2 additions & 3 deletions proto/definitions/ibc/lightclients/ethereum/v1/ethereum.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ message ClientState {
google.protobuf.Duration trusting_period = 11;
google.protobuf.Duration max_clock_drift = 12;

uint64 latest_slot = 13;
uint64 latest_execution_block_number = 14;
ibc.core.client.v1.Height frozen_height = 15;
uint64 latest_execution_block_number = 13;
ibc.core.client.v1.Height frozen_height = 14;
}

message ConsensusState {
Expand Down
4 changes: 1 addition & 3 deletions proto/src/prost/ibc.lightclients.ethereum.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ pub struct ClientState {
super::super::super::super::google::protobuf::Duration,
>,
#[prost(uint64, tag = "13")]
pub latest_slot: u64,
#[prost(uint64, tag = "14")]
pub latest_execution_block_number: u64,
#[prost(message, optional, tag = "15")]
#[prost(message, optional, tag = "14")]
pub frozen_height: ::core::option::Option<
super::super::super::core::client::v1::Height,
>,
Expand Down

0 comments on commit 240f6d8

Please sign in to comment.