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

220: cleanup UserWithdrawlManager tests #221

Merged
merged 1 commit into from
Apr 17, 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: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
"HOLESKY_URL": "${localEnv:HOLESKY_URL}",
"ETHERSCAN_API_KEY": "${localEnv:ETHERSCAN_API_KEY}"
}
}
}
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Dockerfile
out/
cache/
cache_forge/
artifacts/
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{
"label": "install",
"type": "shell",
"command": "npm ci",
"command": "npm ci --frozen-lockfile",
"options": {
"cwd": "${workspaceFolder}"
},
Expand Down Expand Up @@ -116,4 +116,4 @@
}
}
]
}
}
20 changes: 15 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
FROM ghcr.io/collectivexyz/foundry:latest

RUN python3 -m pip install slither-analyzer --break-system-packages

ARG PROJECT=ethx
WORKDIR /workspaces/${PROJECT}
RUN chown -R foundry:foundry .
COPY --chown=foundry:foundry . .

ENV USER=foundry
USER foundry
ENV PATH=${PATH}:~/.cargo/bin:/usr/local/go/bin

RUN python3 -m pip install slither-analyzer --break-system-packages
RUN chown -R foundry:foundry .

RUN yamlfmt -lint .github/workflows/*.yml
COPY --chown=foundry:foundry package.json .
COPY --chown=foundry:foundry package-lock.json .
COPY --chown=foundry:foundry tsconfig.json .
COPY --chown=foundry:foundry node_modules node_modules

RUN npm ci --frozen-lockfile

COPY --chown=foundry:foundry . .

RUN yamlfmt -lint .github/workflows/*.yml

RUN forge install
RUN npm run prettier:check
# RUN slither .
# RUN npm run lint
RUN forge test -v
RUN forge geiger --check contracts/*.sol contracts/*/*.sol
RUN forge geiger --check contracts/*.sol contracts/*/*.sol
14 changes: 7 additions & 7 deletions contracts/L2/ETHx.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.16;

import '@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol';
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";

/**
* @title ETHx token Contract for L2s
Expand All @@ -13,17 +13,17 @@ import '@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol';
contract ETHx is Initializable, ERC20Upgradeable, PausableUpgradeable, AccessControlUpgradeable {
error ZeroAddress();

bytes32 public constant MINTER_ROLE = keccak256('MINTER_ROLE');
bytes32 public constant BURNER_ROLE = keccak256('BURNER_ROLE');
bytes32 public constant PAUSER_ROLE = keccak256('PAUSER_ROLE');
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}

function initialize(address _admin) external initializer onlyNonZeroAddress(_admin) {
__ERC20_init('ETHx', 'ETHx');
__ERC20_init("ETHx", "ETHx");
__Pausable_init();
__AccessControl_init();

Expand Down
34 changes: 15 additions & 19 deletions contracts/factory/VaultFactory.sol
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.16;

import '../library/UtilLib.sol';
import '../VaultProxy.sol';
import '../interfaces/IVaultFactory.sol';
import '../interfaces/IStaderConfig.sol';
import "../library/UtilLib.sol";
import "../VaultProxy.sol";
import "../interfaces/IVaultFactory.sol";
import "../interfaces/IStaderConfig.sol";

import '@openzeppelin/contracts-upgradeable/proxy/ClonesUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol';
import "@openzeppelin/contracts-upgradeable/proxy/ClonesUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";

contract VaultFactory is IVaultFactory, AccessControlUpgradeable {
IStaderConfig public staderConfig;
address public vaultProxyImplementation;

bytes32 public constant override NODE_REGISTRY_CONTRACT = keccak256('NODE_REGISTRY_CONTRACT');
bytes32 public constant override NODE_REGISTRY_CONTRACT = keccak256("NODE_REGISTRY_CONTRACT");

/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
Expand Down Expand Up @@ -45,12 +45,10 @@ contract VaultFactory is IVaultFactory, AccessControlUpgradeable {
return withdrawVaultAddress;
}

function deployNodeELRewardVault(uint8 _poolId, uint256 _operatorId)
external
override
onlyRole(NODE_REGISTRY_CONTRACT)
returns (address)
{
function deployNodeELRewardVault(
uint8 _poolId,
uint256 _operatorId
) external override onlyRole(NODE_REGISTRY_CONTRACT) returns (address) {
bytes32 salt = sha256(abi.encode(_poolId, _operatorId));
address nodeELRewardVaultAddress = ClonesUpgradeable.cloneDeterministic(vaultProxyImplementation, salt);
VaultProxy(payable(nodeELRewardVaultAddress)).initialise(false, _poolId, _operatorId, address(staderConfig));
Expand All @@ -68,12 +66,10 @@ contract VaultFactory is IVaultFactory, AccessControlUpgradeable {
return ClonesUpgradeable.predictDeterministicAddress(vaultProxyImplementation, salt);
}

function computeNodeELRewardVaultAddress(uint8 _poolId, uint256 _operatorId)
external
view
override
returns (address)
{
function computeNodeELRewardVaultAddress(
uint8 _poolId,
uint256 _operatorId
) external view override returns (address) {
bytes32 salt = sha256(abi.encode(_poolId, _operatorId));
return ClonesUpgradeable.predictDeterministicAddress(vaultProxyImplementation, salt);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/INodeELRewardVault.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.16;

import './IStaderConfig.sol';
import "./IStaderConfig.sol";

interface INodeELRewardVault {
// errors
Expand Down
10 changes: 7 additions & 3 deletions contracts/interfaces/INodeRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.16;

import '../library/ValidatorStatus.sol';
import "../library/ValidatorStatus.sol";

struct Validator {
ValidatorStatus status; // status of validator
Expand Down Expand Up @@ -68,7 +68,9 @@ interface INodeRegistry {
) external;

// return validator struct for a validator Id
function validatorRegistry(uint256)
function validatorRegistry(
uint256
)
external
view
returns (
Expand All @@ -83,7 +85,9 @@ interface INodeRegistry {
);

// returns the operator struct given operator Id
function operatorStructById(uint256)
function operatorStructById(
uint256
)
external
view
returns (
Expand Down
17 changes: 9 additions & 8 deletions contracts/interfaces/IPermissionedNodeRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.16;

import '../library/ValidatorStatus.sol';
import './INodeRegistry.sol';
import "../library/ValidatorStatus.sol";
import "./INodeRegistry.sol";

interface IPermissionedNodeRegistry {
// Errors
Expand Down Expand Up @@ -38,19 +38,20 @@ interface IPermissionedNodeRegistry {

function whitelistPermissionedNOs(address[] calldata _permissionedNOs) external;

function onboardNodeOperator(string calldata _operatorName, address payable _operatorRewardAddress)
external
returns (address mevFeeRecipientAddress);
function onboardNodeOperator(
string calldata _operatorName,
address payable _operatorRewardAddress
) external returns (address mevFeeRecipientAddress);

function addValidatorKeys(
bytes[] calldata _pubkey,
bytes[] calldata _preDepositSignature,
bytes[] calldata _depositSignature
) external;

function allocateValidatorsAndUpdateOperatorId(uint256 _numValidators)
external
returns (uint256[] memory selectedOperatorCapacity);
function allocateValidatorsAndUpdateOperatorId(
uint256 _numValidators
) external returns (uint256[] memory selectedOperatorCapacity);

function activateNodeOperator(uint256 _operatorId) external;

Expand Down
10 changes: 5 additions & 5 deletions contracts/interfaces/IPermissionlessNodeRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.16;

import '../library/ValidatorStatus.sol';
import './INodeRegistry.sol';
import "../library/ValidatorStatus.sol";
import "./INodeRegistry.sol";

interface IPermissionlessNodeRegistry {
// Errors
Expand Down Expand Up @@ -79,9 +79,9 @@ interface IPermissionlessNodeRegistry {

function updateOperatorName(string calldata _operatorName) external;

function changeSocializingPoolState(bool _optInForSocializingPool)
external
returns (address mevFeeRecipientAddress);
function changeSocializingPoolState(
bool _optInForSocializingPool
) external returns (address mevFeeRecipientAddress);

function pause() external;

Expand Down
8 changes: 4 additions & 4 deletions contracts/interfaces/IPermissionlessPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ interface IPermissionlessPool {

function receiveRemainingCollateralETH() external payable;

function getAllSocializingPoolOptOutOperators(uint256 _pageNumber, uint256 _pageSize)
external
view
returns (address[] memory);
function getAllSocializingPoolOptOutOperators(
uint256 _pageNumber,
uint256 _pageSize
) external view returns (address[] memory);
}
14 changes: 5 additions & 9 deletions contracts/interfaces/IPoolUtils.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.16;

import './INodeRegistry.sol';
import "./INodeRegistry.sol";

// Interface for the PoolUtils contract
interface IPoolUtils {
Expand Down Expand Up @@ -85,12 +85,8 @@ interface IPoolUtils {
bytes calldata _depositSignature
) external;

function calculateRewardShare(uint8 _poolId, uint256 _totalRewards)
external
view
returns (
uint256 userShare,
uint256 operatorShare,
uint256 protocolShare
);
function calculateRewardShare(
uint8 _poolId,
uint256 _totalRewards
) external view returns (uint256 userShare, uint256 operatorShare, uint256 protocolShare);
}
2 changes: 1 addition & 1 deletion contracts/interfaces/ISDIncentiveController.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.16;

import './IStaderConfig.sol';
import "./IStaderConfig.sol";

interface ISDIncentiveController {
//errors
Expand Down
18 changes: 5 additions & 13 deletions contracts/interfaces/ISDUtilityPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ interface ISDUtilityPool {

function utilize(uint256 utilizeAmount) external;

function utilizeWhileAddingKeys(
address operator,
uint256 utilizeAmount,
uint256 nonTerminalKeyCount
) external;
function utilizeWhileAddingKeys(address operator, uint256 utilizeAmount, uint256 nonTerminalKeyCount) external;

function repayFullAmount() external returns (uint256, uint256);

Expand Down Expand Up @@ -200,16 +196,12 @@ interface ISDUtilityPool {

function getOperatorLiquidation(address) external view returns (OperatorLiquidation memory);

function delegatorWithdrawRequests(uint256)
function delegatorWithdrawRequests(
uint256
)
external
view
returns (
address owner,
uint256 amountOfCToken,
uint256 sdExpected,
uint256 sdFinalized,
uint256 requestBlock
);
returns (address owner, uint256 amountOfCToken, uint256 sdExpected, uint256 sdFinalized, uint256 requestBlock);

function requestIdsByDelegatorAddress(address, uint256) external view returns (uint256);

Expand Down
8 changes: 2 additions & 6 deletions contracts/interfaces/ISocializingPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity 0.8.16;

import './IStaderConfig.sol';
import "./IStaderConfig.sol";

/// @title RewardsData
/// @notice This struct holds rewards merkleRoot and rewards split
Expand Down Expand Up @@ -100,11 +100,7 @@ interface ISocializingPool {
function getRewardDetails()
external
view
returns (
uint256 currentIndex,
uint256 currentStartBlock,
uint256 currentEndBlock
);
returns (uint256 currentIndex, uint256 currentStartBlock, uint256 currentEndBlock);

function getRewardCycleDetails(uint256 _index) external view returns (uint256 _startBlock, uint256 _endBlock);
}
11 changes: 6 additions & 5 deletions contracts/interfaces/IStaderOracle.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.16;

import '../library/ValidatorStatus.sol';
import "../library/ValidatorStatus.sol";

import './ISocializingPool.sol';
import './IStaderConfig.sol';
import "./ISocializingPool.sol";
import "./IStaderConfig.sol";

struct SDPriceData {
uint256 reportingBlockNumber;
Expand Down Expand Up @@ -240,8 +240,9 @@ interface IStaderOracle {
* and if the submission count reaches the required threshold, it updates the markValidatorReadyToDeposit (NodeRegistry).
* @param _validatorVerificationDetail validator verification data, containing valid pubkeys, front run and invalid signature
*/
function submitValidatorVerificationDetail(ValidatorVerificationDetail calldata _validatorVerificationDetail)
external;
function submitValidatorVerificationDetail(
ValidatorVerificationDetail calldata _validatorVerificationDetail
) external;

/**
* @notice store the missed attestation penalty strike on validator
Expand Down
Loading
Loading