From dfa468704f1770f08206fe6e284f8043bb415925 Mon Sep 17 00:00:00 2001 From: srdtrk Date: Tue, 13 Aug 2024 13:55:33 +0800 Subject: [PATCH] imp: all linting done --- contracts/src/ISP1ICS07Tendermint.sol | 21 +++++++++++++++++++++ contracts/src/SP1ICS07Tendermint.sol | 15 ++++++++------- justfile | 4 ++-- package.json | 2 +- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/contracts/src/ISP1ICS07Tendermint.sol b/contracts/src/ISP1ICS07Tendermint.sol index b5f6585..b90496f 100644 --- a/contracts/src/ISP1ICS07Tendermint.sol +++ b/contracts/src/ISP1ICS07Tendermint.sol @@ -3,10 +3,31 @@ pragma solidity >=0.8.25; import { ILightClient } from "solidity-ibc/interfaces/ILightClient.sol"; import { IICS07TendermintMsgs } from "../src/msgs/IICS07TendermintMsgs.sol"; +import { ISP1Verifier } from "@sp1-contracts/ISP1Verifier.sol"; /// @title ISP1ICS07Tendermint /// @notice ISP1ICS07Tendermint is the interface for the ICS07 Tendermint light client interface ISP1ICS07Tendermint is ILightClient { + /// @notice Immutable update client program verification key. + /// @return The verification key for the update client program. + function UPDATE_CLIENT_PROGRAM_VKEY() external view returns (bytes32); + + /// @notice Immutable membership program verification key. + /// @return The verification key for the membership program. + function MEMBERSHIP_PROGRAM_VKEY() external view returns (bytes32); + + /// @notice Immutable update client and membership program verification key. + /// @return The verification key for the update client and membership program. + function UPDATE_CLIENT_AND_MEMBERSHIP_PROGRAM_VKEY() external view returns (bytes32); + + /// @notice Immutable SP1 verifier contract address. + /// @return The SP1 verifier contract. + function VERIFIER() external view returns (ISP1Verifier); + + /// @notice Constant allowed clock drift in seconds. + /// @return The allowed clock drift in seconds. + function ALLOWED_SP1_CLOCK_DRIFT() external view returns (uint16); + /// @notice Returns the client state. /// @return The client state. function getClientState() external view returns (IICS07TendermintMsgs.ClientState memory); diff --git a/contracts/src/SP1ICS07Tendermint.sol b/contracts/src/SP1ICS07Tendermint.sol index 2488aed..9b2968a 100644 --- a/contracts/src/SP1ICS07Tendermint.sol +++ b/contracts/src/SP1ICS07Tendermint.sol @@ -24,13 +24,13 @@ contract SP1ICS07Tendermint is ILightClientMsgs, ISP1ICS07Tendermint { - /// @notice The verification key for the update client program. + /// @inheritdoc ISP1ICS07Tendermint bytes32 public immutable UPDATE_CLIENT_PROGRAM_VKEY; - /// @notice The verification key for the verify (non)membership program. + /// @inheritdoc ISP1ICS07Tendermint bytes32 public immutable MEMBERSHIP_PROGRAM_VKEY; - /// @notice The verification key for the update client and membership program. + /// @inheritdoc ISP1ICS07Tendermint bytes32 public immutable UPDATE_CLIENT_AND_MEMBERSHIP_PROGRAM_VKEY; - /// @notice The SP1 verifier contract. + /// @inheritdoc ISP1ICS07Tendermint ISP1Verifier public immutable VERIFIER; /// @notice The ICS07Tendermint client state @@ -38,7 +38,8 @@ contract SP1ICS07Tendermint is /// @notice The mapping from height to consensus state keccak256 hashes. mapping(uint32 height => bytes32 hash) private consensusStateHashes; - /// Allowed clock drift in seconds + /// @notice Allowed clock drift in seconds. + /// @inheritdoc ISP1ICS07Tendermint uint16 public constant ALLOWED_SP1_CLOCK_DRIFT = 3000; // 3000 seconds /// @notice The constructor sets the program verification key and the initial client and consensus states. @@ -359,13 +360,13 @@ contract SP1ICS07Tendermint is /// @dev This function checks if the consensus state at the new height is different than the one in the mapping. /// @dev This function does not check timestamp misbehaviour (a niche case). /// @param output The public values of the update client program. + /// @return The result of the update. function checkUpdateResult(UpdateClientOutput memory output) private view returns (UpdateResult) { bytes32 consensusStateHash = consensusStateHashes[output.newHeight.revisionHeight]; if (consensusStateHash == bytes32(0)) { // No consensus state at the new height, so no misbehaviour return UpdateResult.Update; - } - if (consensusStateHash != keccak256(abi.encode(output.newConsensusState))) { + } else if (consensusStateHash != keccak256(abi.encode(output.newConsensusState))) { // The consensus state at the new height is different than the one in the mapping return UpdateResult.Misbehaviour; } else { diff --git a/justfile b/justfile index 22cf154..a344351 100644 --- a/justfile +++ b/justfile @@ -94,7 +94,7 @@ lint: @echo "Linting the Rust code..." cargo fmt --all -- --check @echo "Linting the Solidity code..." - forge fmt --check && bun solhint -w 0 -c .solhint.json 'contracts/**/*.sol' && bun natspec-smells --include 'contracts/src/**/*.sol' + forge fmt --check && bun solhint -w 0 -c .solhint.json 'contracts/**/*.sol' && bun natspec-smells --enforceInheritdoc false --include 'contracts/src/**/*.sol' @echo "Linting the Go code..." cd e2e/interchaintestv8 && golangci-lint run @@ -103,6 +103,6 @@ lint-fix: @echo "Fixing the Rust code..." cargo fmt --all @echo "Fixing the Solidity code..." - forge fmt && bun solhint -w 0 -c .solhint.json 'contracts/**/*.sol' && bun natspec-smells --include 'contracts/src/**/*.sol' + forge fmt && bun solhint -w 0 -c .solhint.json 'contracts/**/*.sol' && bun natspec-smells --enforceInheritdoc false --include 'contracts/src/**/*.sol' @echo "Fixing the Go code..." cd e2e/interchaintestv8 && golangci-lint run --fix diff --git a/package.json b/package.json index 25a2af5..b7c95e5 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "clean": "rm -rf contracts/cache contracts/out", "build": "forge build", "lint": "bun run lint:sol", - "lint:sol": "forge fmt --check && bun solhint -w 0 -c .solhint.json 'contracts/**/*.sol' && bun natspec-smells --include 'contracts/src/**/*.sol'", + "lint:sol": "forge fmt --check && bun solhint -w 0 -c .solhint.json 'contracts/**/*.sol' && bun natspec-smells --enforceInheritdoc false --include 'contracts/src/**/*.sol'", "test": "forge test", "test:coverage": "forge coverage", "test:coverage:report": "forge coverage --report lcov && genhtml lcov.info --branch-coverage --output-dir coverage"