diff --git a/contracts/contracts/TACoApplication.sol b/contracts/contracts/TACoApplication.sol index d95a2a6f..cf312f27 100644 --- a/contracts/contracts/TACoApplication.sol +++ b/contracts/contracts/TACoApplication.sol @@ -146,13 +146,6 @@ contract TACoApplication is uint256 startTimestamp ); - /** - * @notice Signals that a staking provider made a commitment - * @param stakingProvider Staking provider address - * @param endCommitment End of commitment - */ - event CommitmentMade(address indexed stakingProvider, uint256 endCommitment); - /** * @notice Signals that manual child synchronization was called * @param stakingProvider Staking provider address @@ -190,7 +183,7 @@ contract TACoApplication is uint64 endDeauthorization; uint96 tReward; uint160 rewardPerTokenPaid; - uint64 endCommitment; + uint64 legacyEndCommitment; uint256 stub; uint192 penaltyPercent; uint64 endPenalty; @@ -208,12 +201,6 @@ contract TACoApplication is uint256 public immutable penaltyDuration; uint192 public immutable penaltyIncrement; - uint64 public immutable commitmentDurationOption1; - uint64 public immutable commitmentDurationOption2; - uint64 public immutable commitmentDurationOption3; - uint64 public immutable commitmentDurationOption4; - uint64 public immutable commitmentDeadline; - IStaking public immutable tStaking; IERC20 public immutable token; @@ -241,8 +228,6 @@ contract TACoApplication is * @param _minOperatorSeconds Min amount of seconds while an operator can't be changed * @param _rewardDuration Duration of one reward cycle in seconds * @param _deauthorizationDuration Duration of decreasing authorization in seconds - * @param _commitmentDurationOptions Options for commitment duration - * @param _commitmentDeadline Last date to make a commitment * @param _penaltyDefault Default penalty percentage (as a value out of 10000) * @param _penaltyDuration Duration of penalty * @param _penaltyIncrement Increment of penalty if violation occurs during an existing penalty period @@ -254,8 +239,6 @@ contract TACoApplication is uint256 _minOperatorSeconds, uint256 _rewardDuration, uint256 _deauthorizationDuration, - uint64[] memory _commitmentDurationOptions, - uint64 _commitmentDeadline, uint192 _penaltyDefault, uint256 _penaltyDuration, uint192 _penaltyIncrement @@ -265,8 +248,6 @@ contract TACoApplication is _rewardDuration != 0 && _tStaking.authorizedStake(address(this), address(this)) == 0 && totalSupply > 0 && - _commitmentDurationOptions.length >= 1 && - _commitmentDurationOptions.length <= 4 && _penaltyDefault > 0 && _penaltyDefault <= PENALTY_BASE && _penaltyDuration > 0 && @@ -286,17 +267,6 @@ contract TACoApplication is token = _token; tStaking = _tStaking; minOperatorSeconds = _minOperatorSeconds; - commitmentDurationOption1 = _commitmentDurationOptions[0]; - commitmentDurationOption2 = _commitmentDurationOptions.length >= 2 - ? _commitmentDurationOptions[1] - : 0; - commitmentDurationOption3 = _commitmentDurationOptions.length >= 3 - ? _commitmentDurationOptions[2] - : 0; - commitmentDurationOption4 = _commitmentDurationOptions.length >= 4 - ? _commitmentDurationOptions[3] - : 0; - commitmentDeadline = _commitmentDeadline; penaltyDefault = _penaltyDefault; penaltyDuration = _penaltyDuration; penaltyIncrement = _penaltyIncrement; @@ -663,10 +633,6 @@ contract TACoApplication is _toAmount == 0 || _toAmount >= minimumAuthorization, "Resulting authorization will be less than minimum" ); - require( - info.endCommitment <= block.timestamp, - "Can't request deauthorization before end of commitment" - ); if (info.operatorConfirmed) { resynchronizeAuthorizedOverall(info, _fromAmount); } @@ -736,31 +702,6 @@ contract TACoApplication is _updateAuthorization(_stakingProvider, info); } - /** - * @notice Make a commitment to not request authorization decrease for specified duration - * @param _stakingProvider Staking provider address - * @param _commitmentDuration Duration of commitment - */ - function makeCommitment( - address _stakingProvider, - uint64 _commitmentDuration - ) external onlyOwnerOrStakingProvider(_stakingProvider) { - require(block.timestamp < commitmentDeadline, "Commitment window closed"); - require( - _commitmentDuration > 0 && - (_commitmentDuration == commitmentDurationOption1 || - _commitmentDuration == commitmentDurationOption2 || - _commitmentDuration == commitmentDurationOption3 || - _commitmentDuration == commitmentDurationOption4), - "Commitment duration must be equal to one of options" - ); - StakingProviderInfo storage info = stakingProviderInfo[_stakingProvider]; - require(info.endDeauthorization == 0, "Commitment can't be made during deauthorization"); - require(info.endCommitment == 0, "Commitment already made"); - info.endCommitment = uint64(block.timestamp) + _commitmentDuration; - emit CommitmentMade(_stakingProvider, info.endCommitment); - } - //-------------------------Main------------------------- /** * @notice Returns staking provider for specified operator @@ -1020,7 +961,6 @@ contract TACoApplication is info.operator = address(0); info.operatorConfirmed = false; info.endDeauthorization = 0; - info.endCommitment = 0; childApplication.updateOperator(_stakingProvider, address(0)); } diff --git a/tests/application/conftest.py b/tests/application/conftest.py index 8b5efc12..89da192f 100644 --- a/tests/application/conftest.py +++ b/tests/application/conftest.py @@ -26,10 +26,6 @@ REWARD_DURATION = 60 * 60 * 24 * 7 # one week in seconds DEAUTHORIZATION_DURATION = 60 * 60 * 24 * 60 # 60 days in seconds -COMMITMENT_DURATION_1 = 182 * 60 * 24 * 60 # 182 days in seconds -COMMITMENT_DURATION_2 = 2 * COMMITMENT_DURATION_1 # 365 days in seconds -COMMITMENT_DURATION_3 = 3 * COMMITMENT_DURATION_1 # 365 days in seconds -COMMITMENT_DEADLINE = 60 * 60 * 24 * 200 # 200 days after deploymwent PENALTY_DEFAULT = 1000 # 10% penalty PENALTY_INCREMENT = 2500 # 25% penalty increment @@ -71,7 +67,6 @@ def encode_function_data(initializer=None, *args): @pytest.fixture() def taco_application(project, creator, token, threshold_staking, oz_dependency, chain): - now = chain.pending_timestamp contract = creator.deploy( project.TACoApplication, token.address, @@ -80,8 +75,6 @@ def taco_application(project, creator, token, threshold_staking, oz_dependency, MIN_OPERATOR_SECONDS, REWARD_DURATION, DEAUTHORIZATION_DURATION, - [COMMITMENT_DURATION_1, COMMITMENT_DURATION_2, COMMITMENT_DURATION_3], - now + COMMITMENT_DEADLINE, PENALTY_DEFAULT, PENALTY_DURATION, PENALTY_INCREMENT, diff --git a/tests/application/test_authorization.py b/tests/application/test_authorization.py index eaacdf3a..9f3856c2 100644 --- a/tests/application/test_authorization.py +++ b/tests/application/test_authorization.py @@ -22,7 +22,6 @@ OPERATOR_CONFIRMED_SLOT = 1 AUTHORIZATION_SLOT = 3 END_DEAUTHORIZATION_SLOT = 5 -END_COMMITMENT_SLOT = 8 MIN_AUTHORIZATION = Web3.to_wei(40_000, "ether") DEAUTHORIZATION_DURATION = 60 * 60 * 24 * 60 # 60 days in seconds PENALTY_DEFAULT = 1000 # 10% penalty @@ -355,7 +354,6 @@ def test_involuntary_authorization_decrease( assert taco_application.stakingProviderInfo(staking_provider)[AUTHORIZATION_SLOT] == 0 assert taco_application.pendingAuthorizationDecrease(staking_provider) == 0 assert taco_application.stakingProviderInfo(staking_provider)[END_DEAUTHORIZATION_SLOT] == 0 - assert taco_application.stakingProviderInfo(staking_provider)[END_COMMITMENT_SLOT] == 0 assert taco_application.authorizedOverall() == 0 assert taco_application.authorizedStake(staking_provider) == 0 assert child_application.stakingProviderInfo(staking_provider) == (0, 0, 0) @@ -412,18 +410,6 @@ def test_involuntary_authorization_decrease( assert child_application.stakingProviderInfo(staking_provider) == (authorization, 0, 0) chain.pending_timestamp += PENALTY_DURATION - # Decrease everything again with previous commitment - commitment_duration = taco_application.commitmentDurationOption1() - taco_application.makeCommitment(staking_provider, commitment_duration, sender=staking_provider) - threshold_staking.involuntaryAuthorizationDecrease( - staking_provider, authorization, 0, sender=creator - ) - assert taco_application.stakingProviderToOperator(staking_provider) == ZERO_ADDRESS - assert taco_application.stakingProviderInfo(staking_provider)[AUTHORIZATION_SLOT] == 0 - assert taco_application.pendingAuthorizationDecrease(staking_provider) == 0 - assert taco_application.stakingProviderInfo(staking_provider)[END_DEAUTHORIZATION_SLOT] == 0 - assert taco_application.stakingProviderInfo(staking_provider)[END_COMMITMENT_SLOT] == 0 - def test_authorization_decrease_request( accounts, threshold_staking, taco_application, child_application, chain @@ -568,25 +554,6 @@ def test_authorization_decrease_request( assert taco_application.authorizedOverall() == value // 2 * 9 // 10 chain.pending_timestamp += PENALTY_DURATION - # Try to request decrease before ending of commitment - chain.pending_timestamp += deauthorization_duration - taco_application.approveAuthorizationDecrease(staking_provider, sender=creator) - threshold_staking.authorizationIncreased(staking_provider, 0, value, sender=creator) - commitment_duration = taco_application.commitmentDurationOption1() - taco_application.makeCommitment(staking_provider, commitment_duration, sender=staking_provider) - - # Commitment is still active - with ape.reverts("Can't request deauthorization before end of commitment"): - threshold_staking.authorizationDecreaseRequested( - staking_provider, value, value // 2, sender=creator - ) - chain.pending_timestamp += commitment_duration - - # Now decrease can be requested - threshold_staking.authorizationDecreaseRequested( - staking_provider, value, value // 2, sender=creator - ) - def test_finish_authorization_decrease( accounts, threshold_staking, taco_application, child_application, chain @@ -602,9 +569,6 @@ def test_finish_authorization_decrease( # Prepare staking providers threshold_staking.authorizationIncreased(staking_provider, 0, value, sender=creator) - commitment_duration = taco_application.commitmentDurationOption1() - taco_application.makeCommitment(staking_provider, commitment_duration, sender=staking_provider) - chain.pending_timestamp += commitment_duration # Can't approve decrease without request with ape.reverts("There is no deauthorizing in process"): @@ -662,7 +626,6 @@ def test_finish_authorization_decrease( assert taco_application.stakingProviderInfo(staking_provider)[AUTHORIZATION_SLOT] == new_value assert taco_application.pendingAuthorizationDecrease(staking_provider) == 0 assert taco_application.stakingProviderInfo(staking_provider)[END_DEAUTHORIZATION_SLOT] == 0 - assert taco_application.stakingProviderInfo(staking_provider)[END_COMMITMENT_SLOT] != 0 assert taco_application.authorizedOverall() == 0 assert taco_application.authorizedStake(staking_provider) == new_value assert child_application.stakingProviderInfo(staking_provider) == (new_value, 0, 0) @@ -692,7 +655,6 @@ def test_finish_authorization_decrease( assert taco_application.stakingProviderInfo(staking_provider)[AUTHORIZATION_SLOT] == new_value assert taco_application.pendingAuthorizationDecrease(staking_provider) == 0 assert taco_application.stakingProviderInfo(staking_provider)[END_DEAUTHORIZATION_SLOT] == 0 - assert taco_application.stakingProviderInfo(staking_provider)[END_COMMITMENT_SLOT] != 0 assert taco_application.stakingProviderToOperator(staking_provider) == staking_provider assert taco_application.operatorToStakingProvider(staking_provider) == staking_provider assert taco_application.authorizedOverall() == new_value @@ -734,7 +696,6 @@ def test_finish_authorization_decrease( assert taco_application.stakingProviderInfo(staking_provider)[AUTHORIZATION_SLOT] == 0 assert taco_application.pendingAuthorizationDecrease(staking_provider) == 0 assert taco_application.stakingProviderInfo(staking_provider)[END_DEAUTHORIZATION_SLOT] == 0 - assert taco_application.stakingProviderInfo(staking_provider)[END_COMMITMENT_SLOT] == 0 assert taco_application.stakingProviderToOperator(staking_provider) == ZERO_ADDRESS assert taco_application.operatorToStakingProvider(staking_provider) == ZERO_ADDRESS assert taco_application.authorizedOverall() == 0 @@ -784,9 +745,6 @@ def test_resync(accounts, threshold_staking, taco_application, child_application # Prepare staking providers threshold_staking.authorizationIncreased(staking_provider, 0, value, sender=creator) - commitment_duration = taco_application.commitmentDurationOption1() - taco_application.makeCommitment(staking_provider, commitment_duration, sender=staking_provider) - chain.pending_timestamp += commitment_duration # Nothing to resync with ape.reverts(): @@ -828,7 +786,6 @@ def test_resync(accounts, threshold_staking, taco_application, child_application tx = taco_application.resynchronizeAuthorization(staking_provider, sender=creator) assert taco_application.stakingProviderInfo(staking_provider)[AUTHORIZATION_SLOT] == new_value assert taco_application.pendingAuthorizationDecrease(staking_provider) == 0 - assert taco_application.stakingProviderInfo(staking_provider)[END_COMMITMENT_SLOT] != 0 assert taco_application.authorizedOverall() == new_value assert taco_application.stakingProviderToOperator(staking_provider) == staking_provider assert taco_application.operatorToStakingProvider(staking_provider) == staking_provider @@ -895,7 +852,6 @@ def test_resync(accounts, threshold_staking, taco_application, child_application assert taco_application.stakingProviderInfo(staking_provider)[AUTHORIZATION_SLOT] == 0 assert taco_application.pendingAuthorizationDecrease(staking_provider) == 0 assert taco_application.stakingProviderInfo(staking_provider)[END_DEAUTHORIZATION_SLOT] == 0 - assert taco_application.stakingProviderInfo(staking_provider)[END_COMMITMENT_SLOT] == 0 assert taco_application.authorizedOverall() == 0 assert taco_application.stakingProviderToOperator(staking_provider) == ZERO_ADDRESS assert taco_application.operatorToStakingProvider(staking_provider) == ZERO_ADDRESS @@ -915,104 +871,6 @@ def test_resync(accounts, threshold_staking, taco_application, child_application ] -def test_commitment(accounts, threshold_staking, taco_application, chain, child_application): - """ - Tests for authorization method: makeCommitment - """ - - creator, staking_provider, another_staking_provider = accounts[0:3] - deauthorization_duration = DEAUTHORIZATION_DURATION - minimum_authorization = MIN_AUTHORIZATION - value = 2 * minimum_authorization - commitment_duration_1 = taco_application.commitmentDurationOption1() - commitment_duration_2 = taco_application.commitmentDurationOption2() - commitment_duration_3 = taco_application.commitmentDurationOption3() - commitment_deadline = taco_application.commitmentDeadline() - - # Commitment can be made only for authorized staking provider - with ape.reverts("Not owner or provider"): - taco_application.makeCommitment( - staking_provider, commitment_duration_1, sender=staking_provider - ) - - # Prepare staking provider - threshold_staking.authorizationIncreased(staking_provider, 0, value, sender=creator) - - # Begin deauthorization - threshold_staking.authorizationDecreaseRequested( - staking_provider, value, minimum_authorization, sender=creator - ) - - # Commitment can't be made during deauthorization - with ape.reverts("Commitment can't be made during deauthorization"): - taco_application.makeCommitment( - staking_provider, commitment_duration_3, sender=staking_provider - ) - - # Finish deauthorization - chain.pending_timestamp += deauthorization_duration - taco_application.approveAuthorizationDecrease(staking_provider, sender=creator) - - # Commitment can be made only by staking provider - with ape.reverts("Not owner or provider"): - taco_application.makeCommitment( - staking_provider, commitment_duration_3, sender=another_staking_provider - ) - - # Commitment duration must be equal to one of options - with ape.reverts("Commitment duration must be equal to one of options"): - taco_application.makeCommitment(staking_provider, 0, sender=staking_provider) - with ape.reverts("Commitment duration must be equal to one of options"): - taco_application.makeCommitment( - staking_provider, commitment_duration_1 + 1, sender=staking_provider - ) - - # And make a commitment for shorter duration - tx = taco_application.makeCommitment( - staking_provider, commitment_duration_1, sender=staking_provider - ) - timestamp = chain.pending_timestamp - 1 - end_commitment = timestamp + commitment_duration_1 - assert ( - taco_application.stakingProviderInfo(staking_provider)[END_COMMITMENT_SLOT] - == end_commitment - ) - assert tx.events == [ - taco_application.CommitmentMade( - stakingProvider=staking_provider, endCommitment=end_commitment - ) - ] - - # Commitment can't be made twice - with ape.reverts("Commitment already made"): - taco_application.makeCommitment( - staking_provider, commitment_duration_2, sender=staking_provider - ) - - # Another staking provider makes a commitment for longer period of time - threshold_staking.authorizationIncreased(another_staking_provider, 0, value, sender=creator) - tx = taco_application.makeCommitment( - another_staking_provider, commitment_duration_3, sender=another_staking_provider - ) - timestamp = chain.pending_timestamp - 1 - end_commitment = timestamp + commitment_duration_3 - assert ( - taco_application.stakingProviderInfo(another_staking_provider)[END_COMMITMENT_SLOT] - == end_commitment - ) - assert tx.events == [ - taco_application.CommitmentMade( - stakingProvider=another_staking_provider, endCommitment=end_commitment - ) - ] - - # Wait until deadline - chain.pending_timestamp = commitment_deadline - threshold_staking.authorizationIncreased(creator, 0, value, sender=creator) - with ape.reverts("Commitment window closed"): - taco_application.makeCommitment(creator, commitment_duration_1, sender=creator) - - def test_child_sync(accounts, threshold_staking, taco_application, child_application, chain): """ Tests for x-chain method: manualChildSynchronization