-
Notifications
You must be signed in to change notification settings - Fork 477
test: remaining upgrade tests #1187
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
Merged
ypatil12
merged 8 commits into
test/slashing-integration-testing
from
yash/remaining-upgrade-tests
Mar 4, 2025
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0656d2a
chore: push failing test
ypatil12 b2c6b97
chore: push
ypatil12 48c8b76
test: remaining ugprade tests
ypatil12 670fb4b
chore: cleanup
ypatil12 ef9e640
chore: cleanup
ypatil12 849dba1
chore: remove unnecessary helper
ypatil12 7a7306a
chore: rand instead of half slash
ypatil12 d89c909
chore: delete unused file
ypatil12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ pragma solidity ^0.8.27; | |
|
|
||
| import "src/test/integration/UpgradeTest.t.sol"; | ||
|
|
||
| contract Integration_Upgrade_Complete_PreSlashing_Withdrawal is UpgradeTest { | ||
| contract Integration_Upgrade_Complete_PreSlashing_Withdrawal_Base is UpgradeTest { | ||
| struct TestState { | ||
| User staker; | ||
| User operator; | ||
|
|
@@ -17,13 +17,16 @@ contract Integration_Upgrade_Complete_PreSlashing_Withdrawal is UpgradeTest { | |
| bool completeAsTokens; | ||
| } | ||
|
|
||
| function _init_(uint24 randomness, bool withOperator, bool withDelegation) internal returns (TestState memory state) { | ||
| function _init_(uint24 randomness, bool withOperator, bool withDelegation) internal virtual returns (TestState memory state) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can probably just use the randomness library and do |
||
| // Create staker | ||
| (state.staker, state.strategies, state.tokenBalances) = _newRandomStaker(); | ||
| state.shares = _calculateExpectedShares(state.strategies, state.tokenBalances); | ||
|
|
||
| // Delegate staker to operator | ||
| state.operator = withOperator ? _newRandomOperator_NoAssets() : User(payable(0)); | ||
| if (withDelegation) state.staker.delegateTo(state.operator); | ||
|
|
||
| // Deposit into EigenLayer | ||
| state.staker.depositIntoEigenlayer(state.strategies, state.tokenBalances); | ||
|
|
||
| // Setup withdrawal shares (full or partial) | ||
|
|
@@ -48,6 +51,9 @@ contract Integration_Upgrade_Complete_PreSlashing_Withdrawal is UpgradeTest { | |
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| contract Integration_Upgrade_Complete_PreSlashing_Withdrawal is Integration_Upgrade_Complete_PreSlashing_Withdrawal_Base { | ||
|
|
||
| function testFuzz_deposit_queue_upgrade_complete(uint24 r) public rand(r) { | ||
| TestState memory state = _init_({randomness: r, withOperator: false, withDelegation: false}); | ||
|
|
@@ -84,3 +90,93 @@ contract Integration_Upgrade_Complete_PreSlashing_Withdrawal is UpgradeTest { | |
| _completeWithdrawal(state); | ||
| } | ||
| } | ||
|
|
||
| contract Integration_Upgrade_Complete_PreSlashing_Withdrawal_Slash is Integration_Upgrade_Complete_PreSlashing_Withdrawal_Base { | ||
| using ArrayLib for *; | ||
|
|
||
| AVS avs; | ||
| OperatorSet operatorSet; | ||
| AllocateParams allocateParams; | ||
|
|
||
| function _init_(uint24 randomness, bool withOperator, bool withDelegation) internal override returns (TestState memory state) { | ||
| // Initialize state, queue a full withdrawal | ||
| state = super._init_({randomness: randomness, withOperator: withOperator, withDelegation: withDelegation}); | ||
|
|
||
| state.withdrawals = state.staker.queueWithdrawals(state.strategies, state.withdrawalShares); | ||
|
|
||
| // Upgrade contracts | ||
| _upgradeEigenLayerContracts(); | ||
|
|
||
| // Set allocation delay, register for operatorSet & allocate fully | ||
| state.operator.setAllocationDelay(1); | ||
| rollForward({blocks: ALLOCATION_CONFIGURATION_DELAY + 1}); | ||
| (avs,) = _newRandomAVS(); | ||
| operatorSet = avs.createOperatorSet(state.strategies); | ||
| allocateParams = _genAllocation_AllAvailable(state.operator, operatorSet); | ||
|
|
||
| state.operator.registerForOperatorSet(operatorSet); | ||
| check_Registration_State_NoAllocation(state.operator, operatorSet, allStrats); | ||
|
|
||
| state.operator.modifyAllocations(allocateParams); | ||
| check_Base_IncrAlloc_State(state.operator, allocateParams); | ||
| _rollBlocksForCompleteAllocation(state.operator, operatorSet, state.strategies); | ||
| } | ||
|
|
||
| function testFuzz_delegate_deposit_queue_upgrade_slashFully_revertCompleteAsShares(uint24 r) public rand(r) { | ||
| TestState memory state = _init_({randomness: r, withOperator: true, withDelegation: true}); | ||
|
|
||
| // Slash operator by AVS | ||
| SlashingParams memory slashParams = _genSlashing_Full(state.operator, operatorSet); | ||
| avs.slashOperator(slashParams); | ||
| check_Base_Slashing_State(state.operator, allocateParams, slashParams); | ||
|
|
||
| // Complete withdrawals as shares | ||
| state.completeAsTokens = false; | ||
| _rollBlocksForCompleteWithdrawals(state.withdrawals); | ||
| cheats.expectRevert(IDelegationManagerErrors.FullySlashed.selector); | ||
| state.staker.completeWithdrawalsAsShares(state.withdrawals); | ||
| } | ||
|
|
||
| function testFuzz_delegate_deposit_queue_upgrade_slashFully_completeAsTokens(uint24 r) public rand(r) { | ||
| TestState memory state = _init_({randomness: r, withOperator: true, withDelegation: true}); | ||
|
|
||
| // Slash operator by AVS | ||
| SlashingParams memory slashParams = _genSlashing_Full(state.operator, operatorSet); | ||
| avs.slashOperator(slashParams); | ||
| check_Base_Slashing_State(state.operator, allocateParams, slashParams); | ||
|
|
||
| // Complete withdrawals as tokens | ||
| state.completeAsTokens = true; | ||
| _rollBlocksForCompleteWithdrawals(state.withdrawals); | ||
| _completeWithdrawal(state); | ||
| } | ||
|
|
||
| function testFuzz_delegate_deposit_queue_upgrade_slash_completeAsShares(uint24 r) public rand(r) { | ||
| TestState memory state = _init_({randomness: r, withOperator: true, withDelegation: true}); | ||
|
|
||
| // Slash operator by AVS | ||
| SlashingParams memory slashParams = _genSlashing_Rand(state.operator, operatorSet); | ||
| avs.slashOperator(slashParams); | ||
| check_Base_Slashing_State(state.operator, allocateParams, slashParams); | ||
|
|
||
| // Complete withdrawals as shares. Shares need to be recalculated to handle slight round down after slashing. | ||
| state.completeAsTokens = false; | ||
|
|
||
| _rollBlocksForCompleteWithdrawals(state.withdrawals); | ||
| _completeWithdrawal(state); | ||
| } | ||
|
|
||
| function testFuzz_delegate_deposit_queue_upgrade_slash_completeAsTokens(uint24 r) public rand(r) { | ||
| TestState memory state = _init_({randomness: r, withOperator: true, withDelegation: true}); | ||
|
|
||
| // Slash operator by AVS | ||
| SlashingParams memory slashParams = _genSlashing_Rand(state.operator, operatorSet); | ||
| avs.slashOperator(slashParams); | ||
| check_Base_Slashing_State(state.operator, allocateParams, slashParams); | ||
|
|
||
| // Complete withdrawals as tokens | ||
| state.completeAsTokens = true; | ||
| _rollBlocksForCompleteWithdrawals(state.withdrawals); | ||
| _completeWithdrawal(state); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.