From f225ababe75119d28e70c7d972175d9f762ecbf9 Mon Sep 17 00:00:00 2001 From: Jun Kimura Date: Wed, 20 Nov 2024 17:20:46 +0900 Subject: [PATCH] S8: fix to remove unused code Signed-off-by: Jun Kimura --- contracts/ILCPClientErrors.sol | 1 - contracts/LCPClientBase.sol | 8 -------- contracts/LCPCommitment.sol | 16 ---------------- slither.config.json | 2 +- test/TestHelper.t.sol | 14 +++++++++++--- 5 files changed, 12 insertions(+), 29 deletions(-) diff --git a/contracts/ILCPClientErrors.sol b/contracts/ILCPClientErrors.sol index ab98229..aa41eaf 100644 --- a/contracts/ILCPClientErrors.sol +++ b/contracts/ILCPClientErrors.sol @@ -8,7 +8,6 @@ interface ILCPClientErrors { error LCPClientClientStateInvalidKeyExpiration(); error LCPClientClientStateInvalidMrenclaveLength(); error LCPClientClientStateUnexpectedMrenclave(); - error LCPClientClientStateEmptyOperators(); error LCPClientClientStateInvalidOperatorAddress(); error LCPClientClientStateInvalidOperatorAddressLength(); error LCPClientClientStateInvalidOperatorsNonce(); diff --git a/contracts/LCPClientBase.sol b/contracts/LCPClientBase.sol index 614d702..e6e215c 100644 --- a/contracts/LCPClientBase.sol +++ b/contracts/LCPClientBase.sol @@ -650,14 +650,6 @@ abstract contract LCPClientBase is ILightClient, ILCPClientErrors { } } - function verifyECDSASignature(bytes32 commitment, bytes memory signature, address signer) - internal - pure - returns (bool) - { - return verifyECDSASignature(commitment, signature) == signer; - } - function verifyECDSASignature(bytes32 commitment, bytes memory signature) internal pure returns (address) { if (uint8(signature[64]) < 27) { signature[64] = bytes1(uint8(signature[64]) + 27); diff --git a/contracts/LCPCommitment.sol b/contracts/LCPCommitment.sol index ad18f95..76d64de 100644 --- a/contracts/LCPCommitment.sol +++ b/contracts/LCPCommitment.sol @@ -44,22 +44,6 @@ library LCPCommitment { bytes state; } - function parseUpdateStateProxyMessage(bytes calldata messageBytes) - internal - pure - returns (UpdateStateProxyMessage memory) - { - HeaderedProxyMessage memory hm = abi.decode(messageBytes, (HeaderedProxyMessage)); - // MSB first - // 0-1: version - // 2-3: message type - // 4-31: reserved - if (hm.header != LCP_MESSAGE_HEADER_UPDATE_STATE) { - revert LCPCommitmentUnexpectedProxyMessageHeader(); - } - return abi.decode(hm.message, (UpdateStateProxyMessage)); - } - struct MisbehaviourProxyMessage { PrevState[] prevStates; bytes context; diff --git a/slither.config.json b/slither.config.json index bbcdead..80ba075 100644 --- a/slither.config.json +++ b/slither.config.json @@ -1,4 +1,4 @@ { - "detectors_to_run": "arbitrary-send-erc20,array-by-reference,incorrect-shift,name-reused,rtlo,suicidal,uninitialized-storage,arbitrary-send-erc20-permit,controlled-array-length,controlled-delegatecall,delegatecall-loop,msg-value-loop,reentrancy-eth,unchecked-transfer,weak-prng,domain-separator-collision,erc20-interface,erc721-interface,locked-ether,mapping-deletion,shadowing-abstract,tautology,write-after-write,boolean-cst,reentrancy-no-eth,reused-constructor,tx-origin,unchecked-lowlevel,unchecked-send,variable-scope,void-cst,events-access,events-maths,incorrect-unary,boolean-equal,deprecated-standards,erc20-indexed,function-init-state,pragma,reentrancy-unlimited-gas,immutable-states,var-read-using-this", + "detectors_to_run": "arbitrary-send-erc20,array-by-reference,incorrect-shift,name-reused,rtlo,suicidal,uninitialized-storage,arbitrary-send-erc20-permit,controlled-array-length,controlled-delegatecall,delegatecall-loop,msg-value-loop,reentrancy-eth,unchecked-transfer,weak-prng,domain-separator-collision,erc20-interface,erc721-interface,locked-ether,mapping-deletion,shadowing-abstract,tautology,write-after-write,boolean-cst,reentrancy-no-eth,reused-constructor,tx-origin,unchecked-lowlevel,unchecked-send,variable-scope,void-cst,events-access,events-maths,incorrect-unary,boolean-equal,deprecated-standards,erc20-indexed,function-init-state,pragma,reentrancy-unlimited-gas,immutable-states,var-read-using-this,dead-code", "filter_paths": "(test/|node_modules/|contracts/proto/)" } \ No newline at end of file diff --git a/test/TestHelper.t.sol b/test/TestHelper.t.sol index 068f424..ec5b6c0 100644 --- a/test/TestHelper.t.sol +++ b/test/TestHelper.t.sol @@ -108,12 +108,20 @@ library LCPCommitmentTestHelper { LCPCommitment.trustingPeriodContextEval(context, currentTimestampNanos); } - function parseUpdateStateProxyMessage(bytes calldata commitmentBytes) + function parseUpdateStateProxyMessage(bytes calldata messageBytes) public pure - returns (LCPCommitment.UpdateStateProxyMessage memory commitment) + returns (LCPCommitment.UpdateStateProxyMessage memory) { - return LCPCommitment.parseUpdateStateProxyMessage(commitmentBytes); + LCPCommitment.HeaderedProxyMessage memory hm = abi.decode(messageBytes, (LCPCommitment.HeaderedProxyMessage)); + // MSB first + // 0-1: version + // 2-3: message type + // 4-31: reserved + if (hm.header != LCPCommitment.LCP_MESSAGE_HEADER_UPDATE_STATE) { + revert LCPCommitment.LCPCommitmentUnexpectedProxyMessageHeader(); + } + return abi.decode(hm.message, (LCPCommitment.UpdateStateProxyMessage)); } function parseVerifyMembershipCommitmentProofs(bytes calldata proofBytes)