Skip to content

Commit

Permalink
imp: all linting done
Browse files Browse the repository at this point in the history
  • Loading branch information
srdtrk committed Aug 13, 2024
1 parent 80e8763 commit dfa4687
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
21 changes: 21 additions & 0 deletions contracts/src/ISP1ICS07Tendermint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 8 additions & 7 deletions contracts/src/SP1ICS07Tendermint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,22 @@ 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
ClientState private clientState;
/// @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.
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit dfa4687

Please sign in to comment.