Skip to content

Commit 20fc210

Browse files
authored
Remove unnecessary genesis params and migration func (#85)
* Remove unnecessary genesis params and migration func * Add mappings params names * Remove unused ReentrancyGuard * Use locked pragma, security contact, cancun * npm run lint:fix
1 parent 1bc06aa commit 20fc210

24 files changed

+108
-302
lines changed

contracts/common/Decimal.sol

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// SPDX-License-Identifier: UNLICENSED
2-
pragma solidity ^0.8.9;
2+
pragma solidity 0.8.27;
33

4+
/**
5+
* @custom:security-contact [email protected]
6+
*/
47
library Decimal {
58
// unit is used for decimals, e.g. 0.123456
69
function unit() internal pure returns (uint256) {

contracts/common/Initializable.sol

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

44
/**
55
* @title Initializable
@@ -12,6 +12,8 @@ pragma solidity ^0.8.9;
1212
* WARNING: When used with inheritance, manual care must be taken to not invoke
1313
* a parent initializer twice, or ensure that all initializers are idempotent,
1414
* because this is not dealt with automatically as with constructors.
15+
*
16+
* @custom:security-contact [email protected]
1517
*/
1618
contract Initializable {
1719
/**

contracts/common/ReentrancyGuard.sol

-50
This file was deleted.

contracts/interfaces/IEVMWriter.sol

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// SPDX-License-Identifier: UNLICENSED
2-
pragma solidity ^0.8.9;
2+
pragma solidity 0.8.27;
33

4+
/**
5+
* @custom:security-contact [email protected]
6+
*/
47
interface IEVMWriter {
58
function setBalance(address acc, uint256 value) external;
69

contracts/interfaces/INodeDriver.sol

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// SPDX-License-Identifier: UNLICENSED
2-
pragma solidity ^0.8.9;
2+
pragma solidity 0.8.27;
33

4+
/**
5+
* @custom:security-contact [email protected]
6+
*/
47
interface INodeDriver {
58
function setGenesisValidator(
69
address _auth,
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// SPDX-License-Identifier: UNLICENSED
2-
pragma solidity ^0.8.9;
2+
pragma solidity 0.8.27;
33

4+
/**
5+
* @custom:security-contact [email protected]
6+
*/
47
interface INodeDriverExecutable {
58
function execute() external;
69
}

contracts/interfaces/ISFC.sol

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// SPDX-License-Identifier: UNLICENSED
2-
pragma solidity ^0.8.9;
2+
pragma solidity 0.8.27;
33

4+
/**
5+
* @custom:security-contact [email protected]
6+
*/
47
interface ISFC {
58
event CreatedValidator(
69
uint256 indexed validatorID,
@@ -32,9 +35,7 @@ interface ISFC {
3235
uint256 endTime,
3336
uint256 endBlock,
3437
uint256 epochFee,
35-
uint256 totalBaseRewardWeight,
36-
uint256 totalTxRewardWeight,
37-
uint256 _baseRewardPerSecond,
38+
uint256 baseRewardPerSecond,
3839
uint256 totalStake,
3940
uint256 totalSupply
4041
);
@@ -138,10 +139,6 @@ interface ISFC {
138139

139140
function restakeRewards(uint256 toValidatorID) external;
140141

141-
function updateBaseRewardPerSecond(uint256 value) external;
142-
143-
function updateOfflinePenaltyThreshold(uint256 blocksNum, uint256 time) external;
144-
145142
function updateSlashingRefundRatio(uint256 validatorID, uint256 refundRatio) external;
146143

147144
function updateTreasuryAddress(address v) external;
@@ -170,11 +167,7 @@ interface ISFC {
170167
address auth,
171168
uint256 validatorID,
172169
bytes calldata pubkey,
173-
uint256 status,
174-
uint256 createdEpoch,
175-
uint256 createdTime,
176-
uint256 deactivatedEpoch,
177-
uint256 deactivatedTime
170+
uint256 createdTime
178171
) external;
179172

180173
function setGenesisDelegation(address delegator, uint256 toValidatorID, uint256 stake) external;
@@ -185,8 +178,6 @@ interface ISFC {
185178

186179
function updateValidatorPubkey(bytes calldata pubkey) external;
187180

188-
function migrateValidatorPubkeyUniquenessFlag(uint256 start, uint256 end) external;
189-
190181
function setRedirectionAuthorizer(address v) external;
191182

192183
function announceRedirection(address to) external;

contracts/ownership/Ownable.sol

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

44
import {Initializable} from "../common/Initializable.sol";
55

@@ -11,6 +11,8 @@ import {Initializable} from "../common/Initializable.sol";
1111
* This module is used through inheritance. It will make available the modifier
1212
* `onlyOwner`, which can be aplied to your functions to restrict their use to
1313
* the owner.
14+
*
15+
* @custom:security-contact [email protected]
1416
*/
1517
contract Ownable is Initializable {
1618
address private _owner;

contracts/sfc/ConstantsManager.sol

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
// SPDX-License-Identifier: UNLICENSED
2-
pragma solidity ^0.8.9;
2+
pragma solidity 0.8.27;
33

44
import {Ownable} from "../ownership/Ownable.sol";
55
import {Decimal} from "../common/Decimal.sol";
66

7+
/**
8+
* @custom:security-contact [email protected]
9+
*/
710
contract ConstantsManager is Ownable {
811
// Minimum amount of stake for a validator, i.e., 500000 FTM
912
uint256 public minSelfStake;

contracts/sfc/GasPriceConstants.sol

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// SPDX-License-Identifier: UNLICENSED
2-
pragma solidity ^0.8.9;
2+
pragma solidity 0.8.27;
33

44
import {Decimal} from "../common/Decimal.sol";
55

6+
/**
7+
* @custom:security-contact [email protected]
8+
*/
69
library GP {
710
function trimGasPriceChangeRatio(uint256 x) internal pure returns (uint256) {
811
if (x > (Decimal.unit() * 105) / 100) {

contracts/sfc/Migrations.sol

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// SPDX-License-Identifier: UNLICENSED
2-
pragma solidity ^0.8.9;
2+
pragma solidity 0.8.27;
33

4+
/**
5+
* @custom:security-contact [email protected]
6+
*/
47
contract Migrations {
58
address public owner;
69
uint256 public lastCompletedMigration;

contracts/sfc/NetworkInitializer.sol

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
// SPDX-License-Identifier: UNLICENSED
2-
pragma solidity ^0.8.9;
2+
pragma solidity 0.8.27;
33

44
import {ISFC} from "../interfaces/ISFC.sol";
55
import {NodeDriver, NodeDriverAuth} from "./NodeDriver.sol";
66
import {ConstantsManager} from "./ConstantsManager.sol";
77
import {Decimal} from "../common/Decimal.sol";
88

9+
/**
10+
* @custom:security-contact [email protected]
11+
*/
912
contract NetworkInitializer {
1013
// Initialize NodeDriverAuth, NodeDriver and SFC in one call to allow fewer genesis transactions
1114
function initializeAll(

contracts/sfc/NodeDriver.sol

+7-17
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
// SPDX-License-Identifier: UNLICENSED
2-
pragma solidity ^0.8.9;
2+
pragma solidity 0.8.27;
33

44
import {Initializable} from "../common/Initializable.sol";
55
import {NodeDriverAuth} from "./NodeDriverAuth.sol";
66
import {IEVMWriter} from "../interfaces/IEVMWriter.sol";
77

8+
/**
9+
* @custom:security-contact [email protected]
10+
*/
811
contract NodeDriver is Initializable {
912
NodeDriverAuth internal backend;
1013
IEVMWriter internal evmWriter;
@@ -89,25 +92,12 @@ contract NodeDriver is Initializable {
8992
// Methods which are called only by the node
9093

9194
function setGenesisValidator(
92-
address _auth,
95+
address auth,
9396
uint256 validatorID,
9497
bytes calldata pubkey,
95-
uint256 status,
96-
uint256 createdEpoch,
97-
uint256 createdTime,
98-
uint256 deactivatedEpoch,
99-
uint256 deactivatedTime
98+
uint256 createdTime
10099
) external onlyNode {
101-
backend.setGenesisValidator(
102-
_auth,
103-
validatorID,
104-
pubkey,
105-
status,
106-
createdEpoch,
107-
createdTime,
108-
deactivatedEpoch,
109-
deactivatedTime
110-
);
100+
backend.setGenesisValidator(auth, validatorID, pubkey, createdTime);
111101
}
112102

113103
function setGenesisDelegation(address delegator, uint256 toValidatorID, uint256 stake) external onlyNode {

contracts/sfc/NodeDriverAuth.sol

+7-17
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
// SPDX-License-Identifier: UNLICENSED
2-
pragma solidity ^0.8.9;
2+
pragma solidity 0.8.27;
33

44
import {Initializable} from "../common/Initializable.sol";
55
import {Ownable} from "../ownership/Ownable.sol";
66
import {ISFC} from "../interfaces/ISFC.sol";
77
import {NodeDriver} from "./NodeDriver.sol";
88
import {INodeDriverExecutable} from "../interfaces/INodeDriverExecutable.sol";
99

10+
/**
11+
* @custom:security-contact [email protected]
12+
*/
1013
contract NodeDriverAuth is Initializable, Ownable {
1114
ISFC internal sfc;
1215
NodeDriver internal driver;
@@ -117,25 +120,12 @@ contract NodeDriverAuth is Initializable, Ownable {
117120
}
118121

119122
function setGenesisValidator(
120-
address _auth,
123+
address auth,
121124
uint256 validatorID,
122125
bytes calldata pubkey,
123-
uint256 status,
124-
uint256 createdEpoch,
125-
uint256 createdTime,
126-
uint256 deactivatedEpoch,
127-
uint256 deactivatedTime
126+
uint256 createdTime
128127
) external onlyDriver {
129-
sfc.setGenesisValidator(
130-
_auth,
131-
validatorID,
132-
pubkey,
133-
status,
134-
createdEpoch,
135-
createdTime,
136-
deactivatedEpoch,
137-
deactivatedTime
138-
);
128+
sfc.setGenesisValidator(auth, validatorID, pubkey, createdTime);
139129
}
140130

141131
function setGenesisDelegation(address delegator, uint256 toValidatorID, uint256 stake) external onlyDriver {

0 commit comments

Comments
 (0)