Skip to content

Commit

Permalink
slither: remove unused state variables
Browse files Browse the repository at this point in the history
  • Loading branch information
adu-web3 committed Jul 8, 2024
1 parent 3588987 commit 6eebbb9
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 78 deletions.
2 changes: 1 addition & 1 deletion slither.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"detectors_to_exclude": "pragma,assembly,solc-version,naming-convention,incorrect-equality,uninitialized-local,timestamp,low-level-calls,unimplemented-functions,too-many-digits,similar-names,calls-loop,arbitrary-send-eth,reentrancy-no-eth,reentrancy-benign,reentrancy-events,unused-state,incorrect-shift-in-assembly,dead-code",
"detectors_to_exclude": "pragma,assembly,solc-version,naming-convention,timestamp,low-level-calls,too-many-digits,similar-names,calls-loop,reentrancy-benign,reentrancy-events,dead-code",
"filter_paths": "lib/|test/|mocks/|BytesLib|script/",
"solc_remaps": [
"forge-std/=lib/forge-std/src/",
Expand Down
2 changes: 2 additions & 0 deletions src/core/Bootstrap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ contract Bootstrap is
_addWhitelistTokens(tokens);
}

// slither-disable-next-line reentrancy-no-eth
function _addWhitelistTokens(address[] calldata tokens) internal {
for (uint256 i; i < tokens.length; i++) {
address token = tokens[i];
Expand Down Expand Up @@ -473,6 +474,7 @@ contract Bootstrap is
}

// implementation of ILSTRestakingController
// slither-disable-next-line reentrancy-no-eth
function depositThenDelegateTo(address token, uint256 amount, string calldata operator)
external
payable
Expand Down
2 changes: 2 additions & 0 deletions src/core/ClientGatewayLzReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ abstract contract ClientGatewayLzReceiver is PausableUpgradeable, OAppReceiverUp
_;
}

// slither-disable-next-line reentrancy-no-eth
function _lzReceive(Origin calldata _origin, bytes calldata payload) internal virtual override whenNotPaused {
if (_origin.srcEid != EXOCORE_CHAIN_ID) {
revert UnexpectedSourceChain(_origin.srcEid);
Expand Down Expand Up @@ -183,6 +184,7 @@ abstract contract ClientGatewayLzReceiver is PausableUpgradeable, OAppReceiverUp
emit DepositThenDelegateResult(delegateSuccess, delegator, operator, token, amount);
}

// slither-disable-next-line reentrancy-no-eth
function afterReceiveAddWhitelistTokensRequest(bytes calldata requestPayload)
public
onlyCalledFromThis
Expand Down
1 change: 1 addition & 0 deletions src/core/CustomProxyAdmin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ contract CustomProxyAdmin is Initializable, ProxyAdmin {
bootstrapper = newBootstrapper;
}

// slither-disable-next-line reentrancy-no-eth
function changeImplementation(address proxy, address implementation, bytes memory data) public virtual {
require(msg.sender == bootstrapper, "CustomProxyAdmin: sender must be bootstrapper");
require(msg.sender == proxy, "CustomProxyAdmin: sender must be the proxy itself");
Expand Down
4 changes: 1 addition & 3 deletions src/core/ExoCapsule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ contract ExoCapsule is Initializable, ExoCapsuleStorage, IExoCapsule {

function withdraw(uint256 amount, address payable recipient) external onlyGateway {
require(recipient != address(0), "ExoCapsule: recipient address cannot be zero or empty");
require(
amount >0 && amount <= withdrawableBalance, "ExoCapsule: invalid withdrawal amount"
);
require(amount > 0 && amount <= withdrawableBalance, "ExoCapsule: invalid withdrawal amount");

withdrawableBalance -= amount;
(bool sent,) = recipient.call{value: amount}("");
Expand Down
1 change: 1 addition & 0 deletions src/core/ExocoreGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ contract ExocoreGateway is
super.setPeer(clientChainId, clientChainGateway);
}

// slither-disable-next-line reentrancy-no-eth
function addWhitelistTokens(
uint32 clientChainId,
bytes32[] calldata tokens,
Expand Down
1 change: 1 addition & 0 deletions src/core/NativeRestakingController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ abstract contract NativeRestakingController is
}

// slither-disable-next-line encode-packed-collision
// slither-disable-next-line reentrancy-no-eth
function createExoCapsule() public whenNotPaused nativeRestakingEnabled returns (address) {
require(
address(ownerToCapsule[msg.sender]) == address(0),
Expand Down
68 changes: 1 addition & 67 deletions src/libraries/BeaconChainProofs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,12 @@ library BeaconChainProofs {

// constants are the number of fields and the heights of the different merkle trees used in merkleizing
// beacon chain containers
uint256 internal constant NUM_BEACON_BLOCK_HEADER_FIELDS = 5;
uint256 internal constant BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT = 3;

uint256 internal constant NUM_BEACON_BLOCK_BODY_FIELDS = 11;
uint256 internal constant BEACON_BLOCK_BODY_FIELD_TREE_HEIGHT = 4;

uint256 internal constant NUM_BEACON_STATE_FIELDS = 21;
uint256 internal constant BEACON_STATE_FIELD_TREE_HEIGHT = 5;

uint256 internal constant NUM_ETH1_DATA_FIELDS = 3;
uint256 internal constant ETH1_DATA_FIELD_TREE_HEIGHT = 2;

uint256 internal constant NUM_VALIDATOR_FIELDS = 8;
uint256 internal constant VALIDATOR_FIELD_TREE_HEIGHT = 3;

uint256 internal constant NUM_EXECUTION_PAYLOAD_HEADER_FIELDS = 15;
uint256 internal constant EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT = 4;

uint256 internal constant NUM_EXECUTION_PAYLOAD_FIELDS = 15;
uint256 internal constant EXECUTION_PAYLOAD_FIELD_TREE_HEIGHT = 4;

// HISTORICAL_ROOTS_LIMIT = 2**24, so tree height is 24
uint256 internal constant HISTORICAL_ROOTS_TREE_HEIGHT = 24;

// HISTORICAL_BATCH is root of state_roots and block_root, so number of leaves = 2^1
uint256 internal constant HISTORICAL_BATCH_TREE_HEIGHT = 1;

// SLOTS_PER_HISTORICAL_ROOT = 2**13, so tree height is 13
uint256 internal constant STATE_ROOTS_TREE_HEIGHT = 13;
uint256 internal constant BLOCK_ROOTS_TREE_HEIGHT = 13;

//HISTORICAL_ROOTS_LIMIT = 2**24, so tree height is 24
uint256 internal constant HISTORICAL_SUMMARIES_TREE_HEIGHT = 24;

//Index of block_summary_root in historical_summary container
uint256 internal constant BLOCK_SUMMARY_ROOT_INDEX = 0;

uint256 internal constant NUM_WITHDRAWAL_FIELDS = 4;
// tree height for hash tree of an individual withdrawal container
uint256 internal constant WITHDRAWAL_FIELD_TREE_HEIGHT = 2;

uint256 internal constant VALIDATOR_TREE_HEIGHT = 40;

// MAX_WITHDRAWALS_PER_PAYLOAD = 2**4, making tree height = 4
Expand All @@ -65,45 +30,15 @@ library BeaconChainProofs {

// in beacon block header
// https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconblockheader
uint256 internal constant SLOT_INDEX = 0;
uint256 internal constant PROPOSER_INDEX_INDEX = 1;
uint256 internal constant STATE_ROOT_INDEX = 3;
uint256 internal constant BODY_ROOT_INDEX = 4;
// in beacon state
// https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#beaconstate
uint256 internal constant HISTORICAL_BATCH_STATE_ROOT_INDEX = 1;
uint256 internal constant BEACON_STATE_SLOT_INDEX = 2;
uint256 internal constant LATEST_BLOCK_HEADER_ROOT_INDEX = 4;
uint256 internal constant BLOCK_ROOTS_INDEX = 5;
uint256 internal constant STATE_ROOTS_INDEX = 6;
uint256 internal constant HISTORICAL_ROOTS_INDEX = 7;
uint256 internal constant ETH_1_ROOT_INDEX = 8;
uint256 internal constant VALIDATOR_TREE_ROOT_INDEX = 11;
uint256 internal constant EXECUTION_PAYLOAD_HEADER_INDEX = 24;
uint256 internal constant HISTORICAL_SUMMARIES_INDEX = 27;

// in validator
// https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator
uint256 internal constant VALIDATOR_PUBKEY_INDEX = 0;
uint256 internal constant VALIDATOR_WITHDRAWAL_CREDENTIALS_INDEX = 1;
uint256 internal constant VALIDATOR_BALANCE_INDEX = 2;
uint256 internal constant VALIDATOR_SLASHED_INDEX = 3;
uint256 internal constant VALIDATOR_WITHDRAWABLE_EPOCH_INDEX = 7;

// in execution payload header
uint256 internal constant TIMESTAMP_INDEX = 9;
uint256 internal constant WITHDRAWALS_ROOT_INDEX = 14;

//in execution payload
uint256 internal constant WITHDRAWALS_INDEX = 14;

// in withdrawal
uint256 internal constant WITHDRAWAL_VALIDATOR_INDEX_INDEX = 1;
uint256 internal constant WITHDRAWAL_VALIDATOR_AMOUNT_INDEX = 3;

//In historicalBatch
uint256 internal constant HISTORICALBATCH_STATEROOTS_INDEX = 1;

//Misc Constants

/// @notice The number of slots each epoch in the beacon chain
Expand All @@ -113,10 +48,9 @@ library BeaconChainProofs {
uint64 internal constant SECONDS_PER_SLOT = 12;

/// @notice Number of seconds per epoch: 384 == 32 slots/epoch * 12 seconds/slot
// slither-disable-next-line unused-state
uint64 internal constant SECONDS_PER_EPOCH = SLOTS_PER_EPOCH * SECONDS_PER_SLOT;

bytes8 internal constant UINT64_MASK = 0xffffffffffffffff;

/// @notice This struct contains the merkle proofs and leaves needed to verify a partial/full withdrawal
struct WithdrawalProof {
bytes withdrawalProof;
Expand Down
4 changes: 4 additions & 0 deletions src/storage/ClientChainGatewayStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ contract ClientChainGatewayStorage is BootstrapStorage {
IBeacon public immutable EXO_CAPSULE_BEACON;

// constant state variables
uint256 internal constant TOKEN_ADDRESS_BYTES_LENGTH = 32;
uint256 internal constant GWEI_TO_WEI = 1e9;
address internal constant VIRTUAL_STAKED_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
IETHPOSDeposit internal constant ETH_POS = IETHPOSDeposit(0x00000000219ab540356cBB839Cbe05303d7705Fa);
// constants used for layerzero messaging
uint128 internal constant DESTINATION_GAS_LIMIT = 500_000;
uint128 internal constant DESTINATION_MSG_VALUE = 0;

uint256[40] private __gap;

Expand Down
6 changes: 4 additions & 2 deletions src/storage/ExocoreGatewayStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ contract ExocoreGatewayStorage is GatewayStorage {
uint256 internal constant CLAIM_REWARD_REQUEST_LENGTH = 96;
// bytes32 token + bytes32 delegator + bytes(42) operator + uint256 amount
uint256 internal constant DEPOSIT_THEN_DELEGATE_REQUEST_LENGTH = DELEGATE_REQUEST_LENGTH;
uint256 internal constant UINT8_BYTES_LENGTH = 1;
uint256 internal constant UINT256_BYTES_LENGTH = 32;

// constants used for layerzero messaging
uint128 internal constant DESTINATION_GAS_LIMIT = 500_000;
uint128 internal constant DESTINATION_MSG_VALUE = 0;

mapping(uint32 clienChainId => bool) public chainToBootstrapped;
mapping(uint32 clienChainId => bool registered) public isRegisteredClientChain;
Expand Down
5 changes: 0 additions & 5 deletions src/storage/GatewayStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ contract GatewayStorage {
RESPOND
}

/* ----------------- constants used for layerzero messaging ----------------- */
uint256 internal constant TOKEN_ADDRESS_BYTES_LENGTH = 32;
uint128 internal constant DESTINATION_GAS_LIMIT = 500_000;
uint128 internal constant DESTINATION_MSG_VALUE = 0;

mapping(Action => bytes4) internal _whiteListFunctionSelectors;
address payable public exocoreValidatorSetAddress;

Expand Down

0 comments on commit 6eebbb9

Please sign in to comment.