Skip to content

Commit

Permalink
fix: allow for resubmission of lc updates without next_sync_committee
Browse files Browse the repository at this point in the history
  • Loading branch information
benluelo committed Oct 12, 2023
1 parent 2066e70 commit 58cb3c0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
10 changes: 3 additions & 7 deletions light-clients/ethereum-light-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,17 +305,13 @@ impl IbcClient for EthereumLightClient {

// Next sync committee for a consensus height can be set if it is not being set
// previously, but it cannot be changed or unset after being set.
match (
if let (Some(lhs), Some(rhs)) = (
consensus_state.data.next_sync_committee,
header.consensus_update.next_sync_committee,
) {
(Some(_), None) => return Err(Error::NextSyncCommitteeCannotBeModified),
(Some(lhs), Some(rhs)) => {
if lhs != rhs.aggregate_pubkey {
return Err(Error::NextSyncCommitteeCannotBeModified);
}
if lhs != rhs.aggregate_pubkey {
return Err(Error::NextSyncCommitteeCannotBeModified);
}
_ => {}
}

// NOTE(aeryz): we don't check the timestamp here since it is calculated based on the
Expand Down
2 changes: 2 additions & 0 deletions voyager/src/chain/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,8 @@ where
let does_not_have_finality_update =
last_update_block_number >= req.update_to.revision_height;

tracing::error!(last_update_block_number, req.update_to.revision_height);

let finality_update_msg = if does_not_have_finality_update {
// do nothing
None
Expand Down
23 changes: 14 additions & 9 deletions voyager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)]
// #![deny(clippy::unwrap_used)]

use std::{ffi::OsString, fs::read_to_string, process::ExitCode};
use std::{error::Error, ffi::OsString, fs::read_to_string, process::ExitCode};

use chain_utils::{evm::Evm, union::Union};
use clap::Parser;
Expand Down Expand Up @@ -44,6 +44,9 @@ async fn main() -> ExitCode {
Ok(()) => ExitCode::SUCCESS,
Err(err) => {
eprintln!("Error: {err}");
if let Some(source) = err.source() {
eprintln!("Caused by: {source}");
}
ExitCode::FAILURE
}
}
Expand Down Expand Up @@ -232,21 +235,23 @@ mod tests {
.unwrap()
.into_deserialize::<Record>()
{
let record = record.unwrap();
let json =
serde_json::from_str::<MsgUpdateClientData<EthereumMinimal>>(&record.unwrap().data)
.unwrap();
serde_json::from_str::<MsgUpdateClientData<EthereumMinimal>>(&record.data).unwrap();

let update_from = json.update_from;

let msg = json.msg.client_message.data.consensus_update;
let msg = json.msg.client_message.data;

println!(
"update_from: {}\nattested beacon slot: {}\nattested execution block number: {}\nfinalized beacon slot: {}\nfinalized execution block number: {}\n",
"id: {}\nupdate_from: {}\nattested beacon slot: {}\nattested execution block number: {}\nfinalized beacon slot: {}\nfinalized execution block number: {}\nnext_sync_committee: {}\n",
record.id,
update_from,
msg.attested_header.beacon.slot,
msg.attested_header.execution.block_number,
msg.finalized_header.beacon.slot,
msg.finalized_header.execution.block_number,
msg.consensus_update.attested_header.beacon.slot,
msg.consensus_update.attested_header.execution.block_number,
msg.consensus_update.finalized_header.beacon.slot,
msg.consensus_update.finalized_header.execution.block_number,
msg.consensus_update.next_sync_committee.is_some(),
);
}
}
Expand Down

0 comments on commit 58cb3c0

Please sign in to comment.