Skip to content

Commit

Permalink
fix: rewards v2 audit fixes (#987)
Browse files Browse the repository at this point in the history
* fix: default operator split during first initialization

* test: updated split tests

feat: slashing release

fix(slashing): upgrade script part 4 (#953)

fix: patch (#956)

feat: bindings (#960)

fix: remove numtocomplete interface (#966)

feat: add share helpers (#964)

* feat: add share helpers

* fix: add deposit scaling factor

* fix: rebase

fix: slashable window boundaries (#965)

* fix: slashable window boundaries

* test: regression for alm

* test: update withdrawal delay not passed reversion

* test: burning indices

* refactor: switch conditionals

* fix: added unit tests

* test: assert slashable shares in queue

* fix: typos

---------

Co-authored-by: Yash Patil <ypatil12@gmail.com>

refactor: small cleanup (#959)

refactor small cleanup

chore: `forge fmt`

fix: `getQueuedWithdrawals` + test

fix: add constructor back

test: `totalQueued` > `withdrawal.strategies.length`

test(wip): `completeQueuedWithdrawals`

currently failing

fix: effectBlock

test(wip): @8sunyuan patch

fix: one flaky test

fix: second flaky test

refactor: remove max strats list (#968)

feat: slashing patch upgrade script (#967)

* feat: initial deploy

* feat: slashing patch

fix non-present upgrade.json

chore: bindings (#969)

fix: try catch out of gas edge case (#971)

chore: slashing consolidated script (#972)

test: more slashing integration todos (#961)

* test(wip): todos

* fix: dealloc issue

* fix: remaining

* fix: forktest upgrade issue

* test: add `check_Withdrawal_AsShares_State_AfterSlash`

* refactor: cleanup

* fix: ci

* refactor: review changes

docs: wip slashing docs (#925)

* docs: add slashing docs
* chore: bindings
* docs: fixed commenting and updated queue withdrawal docs
* docs: minor cleanup

---------

Co-authored-by: Nadir Akhtar <nadirakhtar123@gmail.com>

refactor: scaled shares accounting (#975)

* fix: correct expected share calc

* chore: bindings

* fix: rounding on failing unit test

refactor: final slashing cleanup (#982)

* chore: clean comments and naming in dm

* refactor: simplify undelegate method
* feat: removed 0 address check because 0 stakers cant be delegated
* feat: condensed non-staker caller logic

* refactor: remove unnecessary check

* feat: use checks-effects-interactions when completing withdrawals
* feat: remove implicit public method for queuedWithdrawals and impl dedicated getter

* feat: deprecate withdrawer field

* chore: make bindings and clean compile errors

* refactor: redelegate reuses delegateTo and undelegate

* fix: broken integration test

* docs: update to reflect deprecated field

* feat: add getter for stakers withdrawal roots

chore: remove unused avsd events (#984)

fix: integration test initialization params (#978)

* fix: initialization params

* fix: roll blocks usage

fix: `SignatureUtils` construction (#990)

* fix: integration test initialization params (#978)

* fix: initialization params

* fix: roll blocks usage

* fix: `SignatureUtils` construction

---------

Co-authored-by: Yash Patil <40046473+ypatil12@users.noreply.github.com>
Co-authored-by: davidironblocks <david@ironblocks.com>

fix: readd manual checks (#996)

* fix: readd manual checks

* chore: forge fmt

feat: slashing 1.0.3 upgrade script (#995)

* feat: add step 1

* feat: step 1 & 2 complete; pending step 3 sanity

* test: add `_validateProxyDomainSeparators`

* feat: add rc validation

---------

Co-authored-by: clandestine.eth <96172957+0xClandestine@users.noreply.github.com>

fix: update alloc config delay bound (#985)

* fix: update alloc delay bound

* test: remove unnecessary roll

chore: storage report (#1000)

docs: shares accounting (#997)

* docs: shares accounting

* docs: fix gh markdown view

* docs: try fix gh again

* docs: cleanup

* docs: edit share accounting

* docs: wrap up share accounting doc

* docs: edit edge cases

---------

Co-authored-by: wadealexc <pragma-services@proton.me>

refactor: async burning (#1001)

* refactor: burning

* chore: fmt

* chore: update storage report

* chore: update readme

* refactor: add burnableShares for epm storage

* chore: update storage report

test: `Snapshots` lib (#1002)

docs: finish delegation manager docs (#1004)

* docs: finish delegation manager docs

* docs: update docs readme

* docs: permission controller

* fix: small typos

* docs: address feedback

* docs: nit

---------

Co-authored-by: Michael Sun <michaelsun97@gmail.com>

docs: Strategy Manager slashing updates (#999)

* docs: update StrategyManager docs with slashing delta

* docs: remove references to thirdPartyTransfersForbidden

* docs: update strategy docs to latest
* also various edits to docs and natspec

* chore: fmt and make bindings

---------

Co-authored-by: wadealexc <pragma-services@proton.me>

docs: EigenPod Manager slashing updates (#1005)

* docs: complete EigenPodManager for slashing

* docs: add in _beaconChainSlashingFactor state variable note

* docs: finish epm docs

* chore: make bindings

---------

Co-authored-by: wadealexc <pragma-services@proton.me>

fix: rebase

fix: binding

test: remove unneeded logic from integration test setup (#1023)

fix: compile
  • Loading branch information
0xrajath authored and ypatil12 committed Feb 22, 2025
1 parent 263f843 commit 524d463
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 207 deletions.
41 changes: 0 additions & 41 deletions src/test/integration/IntegrationBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,6 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
for (uint i = 0; i < strategies.length; i++) {
assertEq(prevShares[i], curShares[i], err);
}
<<<<<<< HEAD
}

/// @dev Check that the staker's withdrawable shares have increased by `addedShares`
Expand All @@ -1504,28 +1503,6 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
}

/// @dev Check that the staker's withdrawable shares have decreased by `removedShares`
=======
}

/// @dev Check that the staker's withdrawable shares have decreased by `removedShares`
function assert_Snap_Added_Staker_WithdrawableShares(
User staker,
IStrategy[] memory strategies,
uint[] memory addedShares,
string memory err
) internal {
uint[] memory curShares = _getStakerWithdrawableShares(staker, strategies);
// Use timewarp to get previous staker shares
uint[] memory prevShares = _getPrevStakerWithdrawableShares(staker, strategies);

// For each strategy, check (prev - removed == cur)
for (uint i = 0; i < strategies.length; i++) {
assertEq(prevShares[i] + addedShares[i], curShares[i], err);
}
}

/// @dev Check that the staker's withdrawable shares have decreased by `removedShares`
>>>>>>> 6eac6b5b (test: enable shared setups for integration tests (#1036))
function assert_Snap_Removed_Staker_WithdrawableShares(
User staker,
IStrategy[] memory strategies,
Expand All @@ -1542,7 +1519,6 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
}
}

<<<<<<< HEAD
/// @dev Check that all the staker's withdrawable shares have been removed
function assert_Snap_RemovedAll_Staker_WithdrawableShares(
User staker,
Expand All @@ -1568,19 +1544,6 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
/// @dev Check that the staker's withdrawable shares have decreased by `removedShares`
/// FIX THIS WHEN WORKING ON ROUNDING ISSUES
function assert_Snap_Unchanged_Staker_WithdrawableShares_Delegation(
=======
function assert_Snap_Removed_Staker_WithdrawableShares(
User staker,
IStrategy strat,
uint removedShares,
string memory err
) internal {
assert_Snap_Removed_Staker_WithdrawableShares(staker, strat.toArray(), removedShares.toArrayU256(), err);
}

/// @dev Check that the staker's withdrawable shares have decreased by `removedShares`
function assert_Snap_Unchanged_Staker_WithdrawableShares(
>>>>>>> 6eac6b5b (test: enable shared setups for integration tests (#1036))
User staker,
string memory err
) internal {
Expand All @@ -1592,11 +1555,7 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {

// For each strategy, check (prev - removed == cur)
for (uint i = 0; i < strategies.length; i++) {
<<<<<<< HEAD
assertApproxEqAbs(prevShares[i], curShares[i], 100000, err);
=======
assertEq(prevShares[i], curShares[i], err);
>>>>>>> 6eac6b5b (test: enable shared setups for integration tests (#1036))
}
}

Expand Down
8 changes: 1 addition & 7 deletions src/test/integration/IntegrationChecks.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ contract IntegrationCheckUtils is IntegrationBase {
"check_Undelegate_State: staker should have increased nonce by withdrawals.length");
assert_Snap_Removed_OperatorShares(operator, strategies, stakerDelegatedShares,
"check_Undelegate_State: failed to remove operator shares");
<<<<<<< HEAD
assert_Snap_Removed_Staker_DepositShares(staker, strategies, stakerDepositShares,
"check_Undelegate_State: failed to remove staker shares");
assert_Snap_RemovedAll_Staker_WithdrawableShares(staker, strategies,
Expand Down Expand Up @@ -283,11 +282,6 @@ contract IntegrationCheckUtils is IntegrationBase {
assert_Snap_Removed_Staker_DepositShares(staker, strategies, stakerDepositShares,
"check_Redelegate_State: failed to remove staker shares");
assert_Snap_RemovedAll_Staker_WithdrawableShares(staker, strategies,
=======
assert_Snap_Removed_Staker_DepositShares(staker, strategies, shares,
"check_Undelegate_State: failed to remove staker shares");
assert_Snap_Removed_Staker_WithdrawableShares(staker, strategies, shares,
>>>>>>> 6eac6b5b (test: enable shared setups for integration tests (#1036))
"check_QueuedWithdrawal_State: failed to remove staker withdrawable shares");
}

Expand Down Expand Up @@ -993,4 +987,4 @@ contract IntegrationCheckUtils is IntegrationBase {
}
}
}
}
}
75 changes: 59 additions & 16 deletions src/test/integration/IntegrationDeployer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
bool isUpgraded;
uint mainnetForkBlock = 21_616_692; // Post Protocol Council upgrade

string version = "v9.9.9";

// Beacon chain genesis time when running locally
// Multiple of 12 for sanity's sake
uint64 constant GENESIS_TIME_LOCAL = 1 hours * 12;
Expand Down Expand Up @@ -160,10 +162,8 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
}

/// Deploy EigenLayer locally
function _setUpLocal() public virtual {
function _setUpLocal() public noTracing virtual {
console.log("Setting up `%s` integration tests:", "LOCAL".yellow().bold());
// Bypass upgrade tests when running locally
isUpgraded = true;

// Deploy ProxyAdmin
eigenLayerProxyAdmin = new ProxyAdmin();
Expand Down Expand Up @@ -204,6 +204,7 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
ethStrats.push(BEACONCHAIN_ETH_STRAT);
allStrats.push(BEACONCHAIN_ETH_STRAT);
allTokens.push(NATIVE_ETH);
maxUniqueAssetsHeld = allStrats.length;

// Create time machine and beacon chain. Set block time to beacon chain genesis time
BEACON_GENESIS_TIME = GENESIS_TIME_LOCAL;
Expand All @@ -213,7 +214,7 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
}

/// Parse existing contracts from mainnet
function _setUpMainnet() public virtual {
function _setUpMainnet() public noTracing virtual {
console.log("Setting up `%s` integration tests:", "MAINNET_FORK".green().bold());
console.log("RPC:", cheats.rpcUrl("mainnet"));
console.log("Block:", mainnetForkBlock);
Expand All @@ -239,13 +240,20 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
allTokens.push(strategy.underlyingToken());
}

maxUniqueAssetsHeld = allStrats.length;

// Create time machine and mock beacon chain
BEACON_GENESIS_TIME = GENESIS_TIME_MAINNET;
timeMachine = new TimeMachine();
beaconChain = new BeaconChainMock(eigenPodManager, BEACON_GENESIS_TIME);

// Since we haven't done the slashing upgrade on mainnet yet, upgrade mainnet contracts
// prior to test. `isUpgraded` is true by default, but is set to false in `UpgradeTest.t.sol`
if (isUpgraded) {
_upgradeMainnetContracts();
}
}

/// Deploy current implementation contracts and upgrade existing proxies
function _upgradeMainnetContracts() public virtual {
cheats.startPrank(address(executorMultisig));

Expand Down Expand Up @@ -277,6 +285,7 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
ethStrats.push(BEACONCHAIN_ETH_STRAT);
allStrats.push(BEACONCHAIN_ETH_STRAT);
allTokens.push(NATIVE_ETH);
maxUniqueAssetsHeld = allStrats.length;
}

function _deployProxies() public {
Expand Down Expand Up @@ -310,10 +319,25 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {

/// Deploy an implementation contract for each contract in the system
function _deployImplementations() public {
allocationManagerImplementation = new AllocationManager(delegationManager, eigenLayerPauserReg, permissionController, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
permissionControllerImplementation = new PermissionController();
delegationManagerImplementation = new DelegationManager(strategyManager, eigenPodManager, allocationManager, eigenLayerPauserReg, permissionController, DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS);
strategyManagerImplementation = new StrategyManager(delegationManager, eigenLayerPauserReg);
allocationManagerImplementation = new AllocationManager(
delegationManager,
eigenLayerPauserReg,
permissionController,
DEALLOCATION_DELAY,
ALLOCATION_CONFIGURATION_DELAY,
version
);
permissionControllerImplementation = new PermissionController(version);
delegationManagerImplementation = new DelegationManager(
strategyManager,
eigenPodManager,
allocationManager,
eigenLayerPauserReg,
permissionController,
DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS,
version
);
strategyManagerImplementation = new StrategyManager(delegationManager, eigenLayerPauserReg, version);
rewardsCoordinatorImplementation = new RewardsCoordinator(
IRewardsCoordinatorTypes.RewardsCoordinatorConstructorParams({
delegationManager: delegationManager,
Expand All @@ -337,17 +361,17 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
eigenLayerPauserReg,
"v9.9.9"
);
strategyFactoryImplementation = new StrategyFactory(strategyManager, eigenLayerPauserReg);
strategyFactoryImplementation = new StrategyFactory(strategyManager, eigenLayerPauserReg, "v9.9.9");

// Beacon implementations
eigenPodImplementation = new EigenPod(DEPOSIT_CONTRACT, eigenPodManager, BEACON_GENESIS_TIME);
baseStrategyImplementation = new StrategyBase(strategyManager, eigenLayerPauserReg);
eigenPodImplementation = new EigenPod(DEPOSIT_CONTRACT, eigenPodManager, BEACON_GENESIS_TIME, "v9.9.9");
baseStrategyImplementation = new StrategyBase(strategyManager, eigenLayerPauserReg, "v9.9.9");

// Pre-longtail StrategyBaseTVLLimits implementation
// TODO - need to update ExistingDeploymentParser
}

function _upgradeProxies() public {
function _upgradeProxies() public noTracing {
// DelegationManager
eigenLayerProxyAdmin.upgrade(
ITransparentUpgradeableProxy(payable(address(delegationManager))),
Expand Down Expand Up @@ -412,7 +436,7 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
}
}

function _initializeProxies() public {
function _initializeProxies() public noTracing {
delegationManager.initialize({
initialOwner: executorMultisig,
initialPausedStatus: 0
Expand Down Expand Up @@ -486,7 +510,7 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
allTokens.push(underlyingToken);
}

function _configRand(uint24 _randomSeed, uint _assetTypes, uint _userTypes) private {
function _configRand(uint24 _randomSeed, uint _assetTypes, uint _userTypes) private noTracing {
// Using uint24 for the seed type so that if a test fails, it's easier
// to manually use the seed to replay the same test.
random = _hash(_randomSeed);
Expand All @@ -496,6 +520,25 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
_configUserTypes(_userTypes);
}

function _configAssetTypes(uint _assetTypes) internal {
assetTypes = _bitmapToBytes(_assetTypes);
assertTrue(assetTypes.length != 0, "_configRand: no asset types selected");
}

function _configAssetAmounts(uint _maxUniqueAssetsHeld) internal {
if (_maxUniqueAssetsHeld > allStrats.length) {
_maxUniqueAssetsHeld = allStrats.length;
}

maxUniqueAssetsHeld = _maxUniqueAssetsHeld;
require(maxUniqueAssetsHeld != 0, "_configAssetAmounts: invalid 0");
}

function _configUserTypes(uint _userTypes) internal {
userTypes = _bitmapToBytes(_userTypes);
assertTrue(userTypes.length != 0, "_configRand: no user types selected");
}

/**
* @dev Create a new User with a random config using the range defined in `_configRand`
*
Expand Down Expand Up @@ -795,4 +838,4 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(x));
}
}
}
Loading

0 comments on commit 524d463

Please sign in to comment.