diff --git a/evm/contracts/clients/CometblsClient.sol b/evm/contracts/clients/CometblsClient.sol index 9855e76fd4..564b7bb53a 100644 --- a/evm/contracts/clients/CometblsClient.sol +++ b/evm/contracts/clients/CometblsClient.sol @@ -68,7 +68,8 @@ library CometblsClientLib { uint64 trustingPeriod, uint64 currentTime ) internal pure returns (bool) { - return currentTime > (headerTime + trustingPeriod); + return uint256(currentTime) + > (uint256(headerTime) + uint256(trustingPeriod)); } function encodeMemory( @@ -216,11 +217,6 @@ contract CometblsClient is } clientStates[clientId] = clientState; consensusStates[clientId][clientState.latestHeight] = consensusState; - // Normalize to nanosecond because ibc-go recvPacket expects nanos... - processedMoments[clientId][clientState.latestHeight] = ProcessedMoment({ - timestamp: block.timestamp * 1e9, - height: block.number - }); return ConsensusStateUpdate({ clientStateCommitment: clientState.commit(), consensusStateCommitment: consensusState.commit(), @@ -316,7 +312,6 @@ contract CometblsClient is } uint64 maxClockDrift = currentTime + clientState.maxClockDrift; - if (untrustedTimestamp >= maxClockDrift) { revert CometblsClientLib.ErrMaxClockDriftExceeded(); } @@ -378,15 +373,10 @@ contract CometblsClient is consensusState.nextValidatorsHash = header.signedHeader.nextValidatorsHash; - ProcessedMoment storage processed = - processedMoments[clientId][header.trustedHeight]; - processed.timestamp = block.timestamp * 1e9; - processed.height = block.number; - return ConsensusStateUpdate({ clientStateCommitment: clientState.commit(), consensusStateCommitment: consensusState.commit(), - height: header.trustedHeight + height: untrustedHeightNumber }); } diff --git a/evm/tests/src/02-client/CometblsClient.t.sol b/evm/tests/src/02-client/CometblsClient.t.sol index 4bf9c939e0..70b11d1950 100644 --- a/evm/tests/src/02-client/CometblsClient.t.sol +++ b/evm/tests/src/02-client/CometblsClient.t.sol @@ -714,7 +714,7 @@ contract CometblsClientTest is Test { expectedConsensusStateCommitment, "Consensus state commitment mismatch" ); - assertEq(update.height, 100, "Height mismatch"); + assertEq(update.height, 101, "Height mismatch"); } function verifyMembership( diff --git a/voyager/modules/consensus/cometbls/src/main.rs b/voyager/modules/consensus/cometbls/src/main.rs index 638f71c2ad..17cf83738d 100644 --- a/voyager/modules/consensus/cometbls/src/main.rs +++ b/voyager/modules/consensus/cometbls/src/main.rs @@ -206,6 +206,9 @@ impl ConsensusModuleServer for Module { let unbonding_period = u64::try_from(params.unbonding_time.clone().unwrap().seconds).unwrap() * 1_000_000_000; + // Avoid low unbonding period preventing relayer from submitting slightly old headers + let unbonding_period = unbonding_period.max(3 * 24 * 3600 * 1_000_000_000); + Ok(serde_json::to_value(ClientState { chain_id: cometbls_light_client_types::ChainId::from_string(self.chain_id.to_string()) .unwrap(),