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

Add max_clock_drift support #2

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion e2e/relayer/configs/templates/ibc0.json.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"origin_prover": {
"@type": "/relayer.provers.qbft.config.ProverConfig",
"consensus_type": "qbft",
"trusting_period": "336h"
"trusting_period": "336h",
"max_clock_drift": "30s"
},
"lcp_service_address": "localhost:50051",
"mrenclave": "$MRENCLAVE",
Expand Down
3 changes: 2 additions & 1 deletion e2e/relayer/configs/templates/ibc1.json.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"origin_prover": {
"@type": "/relayer.provers.qbft.config.ProverConfig",
"consensus_type": "qbft",
"trusting_period": "336h"
"trusting_period": "336h",
"max_clock_drift": "30s"
},
"lcp_service_address": "localhost:50051",
"mrenclave": "$MRENCLAVE",
Expand Down
2 changes: 1 addition & 1 deletion e2e/relayer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/datachainlab/besu-qbft-elc/e2e/relayer
go 1.21

require (
github.com/datachainlab/besu-ibc-relay-prover v0.2.2
github.com/datachainlab/besu-ibc-relay-prover v0.2.3
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.4
github.com/datachainlab/lcp-go v0.2.8
github.com/hyperledger-labs/yui-relayer v0.5.4
Expand Down
4 changes: 2 additions & 2 deletions e2e/relayer/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0=
github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
github.com/datachainlab/besu-ibc-relay-prover v0.2.2 h1:FuJ3BEYdVN6KV8IfG1Xafnr2mfIASZuLcyFI/WYQr2o=
github.com/datachainlab/besu-ibc-relay-prover v0.2.2/go.mod h1:iGGXFJPvchz6iQSgqK5CrjHwVyWxzwCzIrBE6qiX0Kc=
github.com/datachainlab/besu-ibc-relay-prover v0.2.3 h1:PDs6Zsl7MpZycCFALl6ada/hhY70me+GcXe8j5ECM34=
github.com/datachainlab/besu-ibc-relay-prover v0.2.3/go.mod h1:iGGXFJPvchz6iQSgqK5CrjHwVyWxzwCzIrBE6qiX0Kc=
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.4 h1:2mbvy6W/lm11SeQBgj1100A6D/70Wk9DooMoZfE8oXU=
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.4/go.mod h1:PdSsegkRJiMWVGq+afDtXKRKg4p8hnmR1Yj5BgXkit0=
github.com/datachainlab/lcp-go v0.2.8 h1:Bd6w4CetoUibPuuwWJ75XT6Q/s69gcXfvUS5ffnpYmg=
Expand Down
4 changes: 1 addition & 3 deletions elc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::header::EthHeader;
use crate::internal_prelude::*;
use crate::message::Header;
use crate::types::{gen_state_id, Address, H256};
use core::time::Duration;
use light_client::commitments::{
EmittedState, TrustingPeriodContext, UpdateStateProxyMessage, ValidationContext,
VerifyMembershipProxyMessage,
Expand Down Expand Up @@ -124,8 +123,7 @@ impl LightClient for BesuQBFTLightClient {
} else {
ValidationContext::TrustingPeriod(TrustingPeriodContext::new(
client_state.trusting_period,
// TODO make this configurable
Duration::from_secs(30),
client_state.max_clock_drift,
new_consensus_state.timestamp,
trusted_consensus_state.timestamp,
))
Expand Down
3 changes: 3 additions & 0 deletions elc/src/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct ClientState {
pub ibc_store_address: Address,
pub latest_height: Height,
pub trusting_period: Duration,
pub max_clock_drift: Duration,
#[serde(skip)]
pub execution_verifier: ExecutionVerifier,
}
Expand All @@ -40,6 +41,7 @@ impl From<ClientState> for RawClientState {
})
},
trusting_period: value.trusting_period.as_secs(),
max_clock_drift: value.max_clock_drift.as_secs(),
}
}
}
Expand All @@ -55,6 +57,7 @@ impl TryFrom<RawClientState> for ClientState {
Height::new(height.revision_number, height.revision_height)
}),
trusting_period: Duration::from_secs(value.trusting_period),
max_clock_drift: Duration::from_secs(value.max_clock_drift),
execution_verifier: ExecutionVerifier::default(),
})
}
Expand Down
5 changes: 5 additions & 0 deletions proto/definitions/ibc/lightclients/qbft/v1/QBFT.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ message ClientState {
bytes chain_id = 1;
bytes ibc_store_address = 2;
ibc.core.client.v1.Height latest_height = 3;
// duration in seconds
// if this is set to 0, the client will not verify the header's timestamp is within the trusting period
uint64 trusting_period = 4;
// duration in seconds
uint64 max_clock_drift = 5;
}

message ConsensusState {
Expand All @@ -18,6 +22,7 @@ message ConsensusState {
}

message Header {
// RLP encoded header of Besu, which does not include the seals in the extra data
bytes besu_header_rlp = 1;
repeated bytes seals = 2;
ibc.core.client.v1.Height trusted_height = 3;
Expand Down
Binary file modified proto/src/descriptor.bin
Binary file not shown.
6 changes: 6 additions & 0 deletions proto/src/prost/ibc.lightclients.qbft.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ pub struct ClientState {
pub latest_height: ::core::option::Option<
super::super::super::core::client::v1::Height,
>,
/// duration in seconds
/// if this is set to 0, the client will not verify the header's timestamp is within the trusting period
#[prost(uint64, tag = "4")]
pub trusting_period: u64,
/// duration in seconds
#[prost(uint64, tag = "5")]
pub max_clock_drift: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -25,6 +30,7 @@ pub struct ConsensusState {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Header {
/// RLP encoded header of Besu, which does not include the seals in the extra data
#[prost(bytes = "vec", tag = "1")]
pub besu_header_rlp: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", repeated, tag = "2")]
Expand Down
Loading