Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S8: fix to remove unused code #28

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contracts/Asn1Decode.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ library NodePtr {
}
}

// slither-disable-start dead-code
library Asn1Decode {
using NodePtr for uint256;
using BytesUtils for bytes;
Expand Down Expand Up @@ -226,3 +227,4 @@ library Asn1Decode {
return NodePtr.getPtr(ix, ixFirstContentByte, ixLastContentByte);
}
}
// slither-disable-end dead-code
1 change: 0 additions & 1 deletion contracts/ILCPClientErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ interface ILCPClientErrors {
error LCPClientClientStateInvalidKeyExpiration();
error LCPClientClientStateInvalidMrenclaveLength();
error LCPClientClientStateUnexpectedMrenclave();
error LCPClientClientStateEmptyOperators();
error LCPClientClientStateInvalidOperatorAddress();
error LCPClientClientStateInvalidOperatorAddressLength();
error LCPClientClientStateInvalidOperatorsNonce();
Expand Down
8 changes: 0 additions & 8 deletions contracts/LCPClientBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
32 changes: 0 additions & 32 deletions contracts/LCPCommitment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -71,22 +55,6 @@ library LCPCommitment {
bytes32 stateId;
}

function parseMisbehaviourProxyMessage(bytes calldata messageBytes)
internal
pure
returns (MisbehaviourProxyMessage 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_MISBEHAVIOUR) {
revert LCPCommitmentUnexpectedProxyMessageHeader();
}
return abi.decode(hm.message, (MisbehaviourProxyMessage));
}

struct ValidationContext {
bytes32 header;
bytes context;
Expand Down
2 changes: 2 additions & 0 deletions contracts/LCPOperator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ library LCPOperator {
// chainTypeSalt(CHAIN_TYPE_EVM, hex"")
bytes32 internal constant CHAIN_TYPE_EVM_SALT = keccak256(abi.encodePacked(CHAIN_TYPE_EVM, hex""));

// slither-disable-next-line dead-code
function chainTypeSalt(ChainType chainType, bytes memory args) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(chainType, args));
}

// slither-disable-next-line dead-code
function domainSeparatorUniversal() internal pure returns (bytes32) {
return keccak256(
abi.encode(
Expand Down
2 changes: 1 addition & 1 deletion slither.config.json
Original file line number Diff line number Diff line change
@@ -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/)"
}
24 changes: 20 additions & 4 deletions test/TestHelper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -129,7 +137,15 @@ library LCPCommitmentTestHelper {
pure
returns (LCPCommitment.MisbehaviourProxyMessage memory)
{
return LCPCommitment.parseMisbehaviourProxyMessage(messageBytes);
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_MISBEHAVIOUR) {
revert LCPCommitment.LCPCommitmentUnexpectedProxyMessageHeader();
}
return abi.decode(hm.message, (LCPCommitment.MisbehaviourProxyMessage));
}
}

Expand Down