Skip to content

Commit

Permalink
Merge pull request #8 from datachainlab/max-clock-drift
Browse files Browse the repository at this point in the history
Add `max_clock_drift` option support

Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele authored Jun 30, 2024
2 parents ae3d7d5 + a75be2b commit 29cf77c
Show file tree
Hide file tree
Showing 10 changed files with 389 additions and 357 deletions.
538 changes: 233 additions & 305 deletions e2e/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"description": "A hardhat example project with ibc-solidity",
"devDependencies": {
"@hyperledger-labs/yui-ibc-solidity": "git+https://github.com/hyperledger-labs/yui-ibc-solidity.git#v0.3.29",
"@hyperledger-labs/yui-ibc-solidity": "git+https://github.com/hyperledger-labs/yui-ibc-solidity.git#v0.3.30",
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"chai": "^4.3.10",
"hardhat": "^2.19.1"
Expand Down
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 @@ -33,6 +33,7 @@
"prover": {
"@type": "/relayer.provers.qbft.config.ProverConfig",
"consensus_type": "$CONSENSUS_TYPE",
"trusting_period": "336h"
"trusting_period": "336h",
"max_clock_drift": "30s"
}
}
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 @@ -30,6 +30,7 @@
"prover": {
"@type": "/relayer.provers.qbft.config.ProverConfig",
"consensus_type": "$CONSENSUS_TYPE",
"trusting_period": "336h"
"trusting_period": "336h",
"max_clock_drift": "30s"
}
}
16 changes: 16 additions & 0 deletions module/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ func (c ProverConfig) Validate() error {
return fmt.Errorf("invalid trusting period: %s", c.TrustingPeriod)
}
}
if c.MaxClockDrift != "" {
if _, err := time.ParseDuration(c.MaxClockDrift); err != nil {
return fmt.Errorf("invalid max clock drift: %s", c.MaxClockDrift)
}
}
return nil
}

Expand All @@ -49,3 +54,14 @@ func (c ProverConfig) GetTrustingPeriod() time.Duration {
}
return d
}

func (c ProverConfig) GetMaxClockDrift() time.Duration {
if c.MaxClockDrift == "" {
return 0
}
d, err := time.ParseDuration(c.MaxClockDrift)
if err != nil {
panic(err)
}
return d
}
78 changes: 62 additions & 16 deletions module/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions module/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (pr *Prover) CreateInitialLightClientState(height exported.Height) (exporte
IbcStoreAddress: pr.chain.Config().IBCAddress().Bytes(),
LatestHeight: clienttypes.NewHeight(0, uint64(header.Number.Int64())),
TrustingPeriod: uint64(pr.config.GetTrustingPeriod().Seconds()),
MaxClockDrift: uint64(pr.config.GetMaxClockDrift().Seconds()),
}
consensusState := &ConsensusState{
Timestamp: header.Time,
Expand Down
99 changes: 66 additions & 33 deletions module/qbft.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions proto/ibc/lightclients/qbft/v1/qbft.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ message ClientState {
bytes chain_id = 1;
bytes ibc_store_address = 2;
ibc.core.client.v1.Height latest_height = 3 [(gogoproto.nullable) = false];
// 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 @@ -22,6 +26,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 [(gogoproto.nullable) = false];
Expand Down
1 change: 1 addition & 0 deletions proto/relayer/provers/qbft/config/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ option (gogoproto.goproto_getters_all) = false;
message ProverConfig {
string consensus_type = 1;
string trusting_period = 2;
string max_clock_drift = 3;
}

0 comments on commit 29cf77c

Please sign in to comment.