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

fix: use execution timestamp instead of slot timestamp #401

Merged
merged 10 commits into from
Mar 14, 2025
4 changes: 1 addition & 3 deletions e2e/interchaintestv8/e2esuite/light_clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ func (s *TestSuite) createEthereumLightClient(
proofOfIBCContract, err := eth.EthAPI.GetProof(ibcContractAddress, []string{ics26router.IbcStoreStorageSlot}, executionNumberHex)
s.Require().NoError(err)

unixTimestamp := bootstrap.Data.Header.Execution.Timestamp

currentPeriod := latestSlot / spec.Period()
clientUpdates, err := eth.BeaconAPIClient.GetLightClientUpdates(currentPeriod, 1)
s.Require().NoError(err)
Expand All @@ -117,7 +115,7 @@ func (s *TestSuite) createEthereumLightClient(
Slot: bootstrap.Data.Header.Beacon.Slot,
StateRoot: bootstrap.Data.Header.Execution.StateRoot,
StorageRoot: proofOfIBCContract.StorageHash,
Timestamp: unixTimestamp,
Timestamp: bootstrap.Data.Header.Execution.Timestamp,
CurrentSyncCommittee: bootstrap.Data.CurrentSyncCommittee.AggregatePubkey,
NextSyncCommittee: clientUpdates[0].Data.NextSyncCommittee.AggregatePubkey,
}
Expand Down
Binary file modified e2e/interchaintestv8/wasm/cw_ics08_wasm_eth.wasm.gz
Binary file not shown.
15 changes: 7 additions & 8 deletions packages/ethereum/ethereum-light-client/src/consensus_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@ use ethereum_types::consensus::sync_committee::SyncCommittee;

use crate::{error::EthereumIBCError, header::ActiveSyncCommittee, verify::BlsVerify};

/// The consensus state of the Ethereum light client
/// The consensus state of the Ethereum light client corresponding to a finalized header
#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Debug, Clone)]
pub struct ConsensusState {
/// The slot number
/// The slot number of the finalized header
pub slot: u64,
/// The state merkle root
/// The state merkle root of the finalized header
#[schemars(with = "String")]
pub state_root: B256,
/// The storage merkle root
/// The storage merkle root of the tracked contract at the finalized header
#[schemars(with = "String")]
pub storage_root: B256,
/// The unix timestamp at the time of the slot.
/// It is calculated from the genesis time and slots per.
/// The execution timestamp of the finalized header
pub timestamp: u64,
/// aggregate public key of current sync committee
/// aggregate public key of current sync committee at the finalized header
#[schemars(with = "String")]
pub current_sync_committee: FixedBytes<48>,
/// aggregate public key of next sync committee
/// aggregate public key of next sync committee at the finalized header if known
#[schemars(with = "String")]
pub next_sync_committee: Option<FixedBytes<48>>,
}
Expand Down
5 changes: 1 addition & 4 deletions packages/ethereum/ethereum-light-client/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,9 @@ pub fn update_consensus_state(

if consensus_update.finalized_header.beacon.slot > current_consensus_state.slot {
new_consensus_state.slot = consensus_update.finalized_header.beacon.slot;

new_consensus_state.state_root = consensus_update.finalized_header.execution.state_root;
new_consensus_state.storage_root = header.account_update.account_proof.storage_root;

new_consensus_state.timestamp = current_client_state
.compute_timestamp_at_slot(consensus_update.finalized_header.beacon.slot);
new_consensus_state.timestamp = consensus_update.finalized_header.execution.timestamp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs for this field needs to be updated, and the places we create consensus state as well (e2e + ethgenesis script)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated docs, scripts already use the correct timestamp


if current_client_state.latest_slot < consensus_update.finalized_header.beacon.slot {
new_client_state = Some(ClientState {
Expand Down
4 changes: 1 addition & 3 deletions scripts/ethgenesis/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ func main() {
}
fmt.Printf("Proof of IBC contract: %+v\n", proofOfIBCContract)

unixTimestamp := bootstrap.Data.Header.Execution.Timestamp

currentPeriod := latestSlot / spec.Period()
clientUpdates, err := beaconAPI.GetLightClientUpdates(currentPeriod, 1)
if err != nil {
Expand All @@ -131,7 +129,7 @@ func main() {
Slot: bootstrap.Data.Header.Beacon.Slot,
StateRoot: bootstrap.Data.Header.Execution.StateRoot,
StorageRoot: proofOfIBCContract.StorageHash,
Timestamp: unixTimestamp,
Timestamp: bootstrap.Data.Header.Execution.Timestamp,
CurrentSyncCommittee: bootstrap.Data.CurrentSyncCommittee.AggregatePubkey,
NextSyncCommittee: clientUpdates[0].Data.NextSyncCommittee.AggregatePubkey,
}
Expand Down
Loading