Skip to content

Commit da3a351

Browse files
authored
fix: use execution timestamp instead of slot timestamp (#401)
1 parent a4d1830 commit da3a351

File tree

5 files changed

+10
-18
lines changed

5 files changed

+10
-18
lines changed

e2e/interchaintestv8/e2esuite/light_clients.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ func (s *TestSuite) createEthereumLightClient(
104104
proofOfIBCContract, err := eth.EthAPI.GetProof(ibcContractAddress, []string{ics26router.IbcStoreStorageSlot}, executionNumberHex)
105105
s.Require().NoError(err)
106106

107-
unixTimestamp := bootstrap.Data.Header.Execution.Timestamp
108-
109107
currentPeriod := latestSlot / spec.Period()
110108
clientUpdates, err := eth.BeaconAPIClient.GetLightClientUpdates(currentPeriod, 1)
111109
s.Require().NoError(err)
@@ -117,7 +115,7 @@ func (s *TestSuite) createEthereumLightClient(
117115
Slot: bootstrap.Data.Header.Beacon.Slot,
118116
StateRoot: bootstrap.Data.Header.Execution.StateRoot,
119117
StorageRoot: proofOfIBCContract.StorageHash,
120-
Timestamp: unixTimestamp,
118+
Timestamp: bootstrap.Data.Header.Execution.Timestamp,
121119
CurrentSyncCommittee: bootstrap.Data.CurrentSyncCommittee.AggregatePubkey,
122120
NextSyncCommittee: clientUpdates[0].Data.NextSyncCommittee.AggregatePubkey,
123121
}
-377 Bytes
Binary file not shown.

packages/ethereum/ethereum-light-client/src/consensus_state.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,23 @@ use ethereum_types::consensus::sync_committee::SyncCommittee;
88

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

11-
/// The consensus state of the Ethereum light client
11+
/// The consensus state of the Ethereum light client corresponding to a finalized header
1212
#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Debug, Clone)]
1313
pub struct ConsensusState {
14-
/// The slot number
14+
/// The slot number of the finalized header
1515
pub slot: u64,
16-
/// The state merkle root
16+
/// The state merkle root of the finalized header
1717
#[schemars(with = "String")]
1818
pub state_root: B256,
19-
/// The storage merkle root
19+
/// The storage merkle root of the tracked contract at the finalized header
2020
#[schemars(with = "String")]
2121
pub storage_root: B256,
22-
/// The unix timestamp at the time of the slot.
23-
/// It is calculated from the genesis time and slots per.
22+
/// The execution timestamp of the finalized header
2423
pub timestamp: u64,
25-
/// aggregate public key of current sync committee
24+
/// aggregate public key of current sync committee at the finalized header
2625
#[schemars(with = "String")]
2726
pub current_sync_committee: FixedBytes<48>,
28-
/// aggregate public key of next sync committee
27+
/// aggregate public key of next sync committee at the finalized header if known
2928
#[schemars(with = "String")]
3029
pub next_sync_committee: Option<FixedBytes<48>>,
3130
}

packages/ethereum/ethereum-light-client/src/update.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,9 @@ pub fn update_consensus_state(
5555

5656
if consensus_update.finalized_header.beacon.slot > current_consensus_state.slot {
5757
new_consensus_state.slot = consensus_update.finalized_header.beacon.slot;
58-
5958
new_consensus_state.state_root = consensus_update.finalized_header.execution.state_root;
6059
new_consensus_state.storage_root = header.account_update.account_proof.storage_root;
61-
62-
new_consensus_state.timestamp = current_client_state
63-
.compute_timestamp_at_slot(consensus_update.finalized_header.beacon.slot);
60+
new_consensus_state.timestamp = consensus_update.finalized_header.execution.timestamp;
6461

6562
if current_client_state.latest_slot < consensus_update.finalized_header.beacon.slot {
6663
new_client_state = Some(ClientState {

scripts/ethgenesis/main.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ func main() {
116116
}
117117
fmt.Printf("Proof of IBC contract: %+v\n", proofOfIBCContract)
118118

119-
unixTimestamp := bootstrap.Data.Header.Execution.Timestamp
120-
121119
currentPeriod := latestSlot / spec.Period()
122120
clientUpdates, err := beaconAPI.GetLightClientUpdates(currentPeriod, 1)
123121
if err != nil {
@@ -131,7 +129,7 @@ func main() {
131129
Slot: bootstrap.Data.Header.Beacon.Slot,
132130
StateRoot: bootstrap.Data.Header.Execution.StateRoot,
133131
StorageRoot: proofOfIBCContract.StorageHash,
134-
Timestamp: unixTimestamp,
132+
Timestamp: bootstrap.Data.Header.Execution.Timestamp,
135133
CurrentSyncCommittee: bootstrap.Data.CurrentSyncCommittee.AggregatePubkey,
136134
NextSyncCommittee: clientUpdates[0].Data.NextSyncCommittee.AggregatePubkey,
137135
}

0 commit comments

Comments
 (0)