Skip to content

Commit 0bae479

Browse files
author
Mike-CZ
committed
Remove errors interface
1 parent fad15b2 commit 0bae479

8 files changed

+101
-107
lines changed

contracts/IErrors.sol

-92
This file was deleted.

contracts/common/Initializable.sol

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// SPDX-License-Identifier: UNLICENSED
22
pragma solidity ^0.8.9;
33

4-
import {IErrors} from "../IErrors.sol";
5-
64
/**
75
* @title Initializable
86
*
@@ -15,7 +13,7 @@ import {IErrors} from "../IErrors.sol";
1513
* a parent initializer twice, or ensure that all initializers are idempotent,
1614
* because this is not dealt with automatically as with constructors.
1715
*/
18-
contract Initializable is IErrors {
16+
contract Initializable {
1917
/**
2018
* @dev Indicates that the contract has been initialized.
2119
*/
@@ -29,14 +27,14 @@ contract Initializable is IErrors {
2927
/**
3028
* @dev The contract instance has already been initialized.
3129
*/
32-
error ContractInitialized();
30+
error InvalidInitialization();
3331

3432
/**
3533
* @dev Modifier to use in the initializer function of a contract.
3634
*/
3735
modifier initializer() {
3836
if (!initializing && initialized) {
39-
revert ContractInitialized();
37+
revert InvalidInitialization();
4038
}
4139

4240
bool isTopLevelCall = !initializing;

contracts/common/ReentrancyGuard.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ contract ReentrancyGuard is Initializable {
2222
/**
2323
* @dev Reentrant call.
2424
*/
25-
error ReentrantCall();
25+
error ReentrancyGuardReentrantCall();
2626

2727
function initialize() internal initializer {
2828
// The counter starts at one to prevent changing it from zero to a non-zero
@@ -42,7 +42,7 @@ contract ReentrancyGuard is Initializable {
4242
uint256 localCounter = _guardCounter;
4343
_;
4444
if (localCounter != _guardCounter) {
45-
revert ReentrantCall();
45+
revert ReentrancyGuardReentrantCall();
4646
}
4747
}
4848

contracts/sfc/NodeDriver.sol

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ contract NodeDriver is Initializable {
99
NodeDriverAuth internal backend;
1010
IEvmWriter internal evmWriter;
1111

12+
error NotNode();
13+
error NotBackend();
14+
1215
event UpdatedBackend(address indexed backend);
1316

1417
function setBackend(address _backend) external onlyBackend {

contracts/sfc/NodeDriverAuth.sol

+8-2
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@ import {Initializable} from "../common/Initializable.sol";
55
import {Ownable} from "../ownership/Ownable.sol";
66
import {SFCI} from "./SFCI.sol";
77
import {NodeDriver} from "./NodeDriver.sol";
8-
import {IErrors} from "../IErrors.sol";
98

109
interface NodeDriverExecutable {
1110
function execute() external;
1211
}
1312

14-
contract NodeDriverAuth is IErrors, Initializable, Ownable {
13+
contract NodeDriverAuth is Initializable, Ownable {
1514
SFCI internal sfc;
1615
NodeDriver internal driver;
1716

17+
error NotSFC();
18+
error NotDriver();
19+
error NotContract();
20+
error SelfCodeHashMismatch();
21+
error DriverCodeHashMismatch();
22+
error RecipientNotSFC();
23+
1824
// Initialize NodeDriverAuth, NodeDriver and SFC in one call to allow fewer genesis transactions
1925
function initialize(address payable _sfc, address _driver, address _owner) external initializer {
2026
Ownable.initialize(_owner);

contracts/sfc/SFCBase.sol

+77-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,90 @@ pragma solidity ^0.8.9;
33

44
import {Decimal} from "../common/Decimal.sol";
55
import {SFCState} from "./SFCState.sol";
6-
import {IErrors} from "../IErrors.sol";
76

8-
contract SFCBase is IErrors, SFCState {
7+
contract SFCBase is SFCState {
98
uint256 internal constant OK_STATUS = 0;
109
uint256 internal constant WITHDRAWN_BIT = 1;
1110
uint256 internal constant OFFLINE_BIT = 1 << 3;
1211
uint256 internal constant DOUBLESIGN_BIT = 1 << 7;
1312
uint256 internal constant CHEATER_MASK = DOUBLESIGN_BIT;
1413

14+
// auth
15+
error NotDriverAuth();
16+
error NotAuthorized();
17+
18+
// addresses
19+
error ZeroAddress();
20+
error SameAddress();
21+
error RecipientNotSFC();
22+
23+
// values
24+
error ZeroAmount();
25+
error ZeroRewards();
26+
27+
// pubkeys
28+
error PubkeyExists();
29+
error MalformedPubkey();
30+
error SamePubkey();
31+
error EmptyPubkey();
32+
error PubkeyAllowedOnlyOnce();
33+
34+
// redirections
35+
error SameRedirectionAuthorizer();
36+
error Redirected();
37+
38+
// validators
39+
error ValidatorNotExists();
40+
error ValidatorExists();
41+
error ValidatorNotActive();
42+
error ValidatorDelegationLimitExceeded();
43+
error WrongValidatorStatus();
44+
45+
// requests
46+
error RequestedCompleted();
47+
error RequestExists();
48+
error RequestNotExists();
49+
50+
// transfers
51+
error TransfersNotAllowed();
52+
error TransferFailed();
53+
54+
// updater
55+
error SFCAlreadyUpdated();
56+
error SFCWrongVersion();
57+
error SFCGovAlreadyUpdated();
58+
error SFCWrongGovVersion();
59+
60+
// node driver
61+
error SelfCodeHashMismatch();
62+
error DriverCodeHashMismatch();
63+
64+
// governance
65+
error GovVotesRecountFailed();
66+
67+
// staking
68+
error LockedStakeGreaterThanTotalStake();
69+
error InsufficientSelfStake();
70+
error NotEnoughUnlockedStake();
71+
error NotEnoughLockedStake();
72+
error NotEnoughTimePassed();
73+
error NotEnoughEpochsPassed();
74+
error StakeIsFullySlashed();
75+
error IncorrectDuration();
76+
error ValidatorLockupTooShort();
77+
error TooManyReLocks();
78+
error TooFrequentReLocks();
79+
error LockupDurationDecreased();
80+
error AlreadyLockedUp();
81+
error NotLockedUp();
82+
83+
// stashing
84+
error NothingToStash();
85+
86+
// slashing
87+
error ValidatorNotSlashed();
88+
error RefundRatioTooHigh();
89+
1590
event DeactivatedValidator(uint256 indexed validatorID, uint256 deactivatedEpoch, uint256 deactivatedTime);
1691
event ChangedValidatorStatus(uint256 indexed validatorID, uint256 status);
1792

contracts/sfc/Updater.sol

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {ConstantsManager} from "./ConstantsManager.sol";
88
import {SFC} from "./SFC.sol";
99
import {SFCI} from "./SFCI.sol";
1010
import {Version} from "../version/Version.sol";
11-
import {IErrors} from "../IErrors.sol";
1211

1312
interface GovI {
1413
function upgrade(address v) external;
@@ -22,7 +21,7 @@ interface GovVersion {
2221
function version() external pure returns (bytes4);
2322
}
2423

25-
contract Updater is IErrors {
24+
contract Updater {
2625
address public sfcFrom;
2726
address public sfcLib;
2827
address public sfcConsts;
@@ -31,6 +30,12 @@ contract Updater is IErrors {
3130
address public voteBook;
3231
address public owner;
3332

33+
error ZeroAddress();
34+
error SFCAlreadyUpdated();
35+
error SFCWrongVersion();
36+
error SFCGovAlreadyUpdated();
37+
error SFCWrongGovVersion();
38+
3439
constructor(
3540
address _sfcFrom,
3641
address _sfcLib,

contracts/test/UnitTestSFC.sol

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {Decimal} from "../common/Decimal.sol";
55
import {SFC} from "../sfc/SFC.sol";
66
import {SFCBase} from "../sfc/SFCBase.sol";
77
import {SFCLib} from "../sfc/SFCLib.sol";
8-
import {IErrors} from "../IErrors.sol";
98
import {NodeDriverAuth} from "../sfc/NodeDriverAuth.sol";
109
import {NodeDriver} from "../sfc/NodeDriver.sol";
1110
import {UnitTestConstantsManager} from "./UnitTestConstantsManager.sol";
@@ -114,7 +113,7 @@ contract UnitTestNetworkInitializer {
114113
}
115114
}
116115

117-
interface SFCUnitTestI is IErrors {
116+
interface SFCUnitTestI {
118117
function currentSealedEpoch() external view returns (uint256);
119118

120119
function getEpochSnapshot(

0 commit comments

Comments
 (0)