Skip to content

fix: rename misleading custom error name (OZ CR-03) #1141

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

Open
wants to merge 1 commit into
base: horizon-oz2/l04-fixed-point-precision
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,11 @@ interface IHorizonStakingMain {
*/
error HorizonStakingLegacySlashFailed();

/**
* @notice Thrown when there attempting to slash a provision with no tokens to slash.
*/
error HorizonStakingNoTokensToSlash();

// -- Functions --

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/horizon/contracts/staking/HorizonStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
Provision storage prov = _provisions[serviceProvider][verifier];
DelegationPoolInternal storage pool = _getDelegationPool(serviceProvider, verifier);
uint256 tokensProvisionTotal = prov.tokens + pool.tokens;
require(tokensProvisionTotal != 0, HorizonStakingInsufficientTokens(tokensProvisionTotal, tokens));
require(tokensProvisionTotal != 0, HorizonStakingNoTokensToSlash());

uint256 tokensToSlash = MathUtils.min(tokens, tokensProvisionTotal);

Expand Down
4 changes: 1 addition & 3 deletions packages/horizon/test/staking/slash/slash.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ contract HorizonStakingSlashTest is HorizonStakingTest {
function testSlash_RevertWhen_NoProvision(uint256 tokens, uint256 slashTokens) public useIndexer useStake(tokens) {
vm.assume(slashTokens > 0);
bytes memory expectedError = abi.encodeWithSelector(
IHorizonStakingMain.HorizonStakingInsufficientTokens.selector,
0,
slashTokens
IHorizonStakingMain.HorizonStakingNoTokensToSlash.selector
);
vm.expectRevert(expectedError);
vm.startPrank(subgraphDataServiceAddress);
Expand Down