-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
24 changed files
with
108 additions
and
302 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
pragma solidity 0.8.27; | ||
|
||
/** | ||
* @custom:security-contact [email protected] | ||
*/ | ||
library Decimal { | ||
// unit is used for decimals, e.g. 0.123456 | ||
function unit() internal pure returns (uint256) { | ||
|
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
pragma solidity 0.8.27; | ||
|
||
/** | ||
* @title Initializable | ||
|
@@ -12,6 +12,8 @@ pragma solidity ^0.8.9; | |
* WARNING: When used with inheritance, manual care must be taken to not invoke | ||
* a parent initializer twice, or ensure that all initializers are idempotent, | ||
* because this is not dealt with automatically as with constructors. | ||
* | ||
* @custom:security-contact [email protected] | ||
*/ | ||
contract Initializable { | ||
/** | ||
|
This file was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
pragma solidity 0.8.27; | ||
|
||
/** | ||
* @custom:security-contact [email protected] | ||
*/ | ||
interface IEVMWriter { | ||
function setBalance(address acc, uint256 value) external; | ||
|
||
|
This file contains 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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
pragma solidity 0.8.27; | ||
|
||
/** | ||
* @custom:security-contact [email protected] | ||
*/ | ||
interface INodeDriver { | ||
function setGenesisValidator( | ||
address _auth, | ||
|
This file contains 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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
pragma solidity 0.8.27; | ||
|
||
/** | ||
* @custom:security-contact [email protected] | ||
*/ | ||
interface INodeDriverExecutable { | ||
function execute() external; | ||
} |
This file contains 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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
pragma solidity 0.8.27; | ||
|
||
/** | ||
* @custom:security-contact [email protected] | ||
*/ | ||
interface ISFC { | ||
event CreatedValidator( | ||
uint256 indexed validatorID, | ||
|
@@ -32,9 +35,7 @@ interface ISFC { | |
uint256 endTime, | ||
uint256 endBlock, | ||
uint256 epochFee, | ||
uint256 totalBaseRewardWeight, | ||
uint256 totalTxRewardWeight, | ||
uint256 _baseRewardPerSecond, | ||
uint256 baseRewardPerSecond, | ||
uint256 totalStake, | ||
uint256 totalSupply | ||
); | ||
|
@@ -138,10 +139,6 @@ interface ISFC { | |
|
||
function restakeRewards(uint256 toValidatorID) external; | ||
|
||
function updateBaseRewardPerSecond(uint256 value) external; | ||
|
||
function updateOfflinePenaltyThreshold(uint256 blocksNum, uint256 time) external; | ||
|
||
function updateSlashingRefundRatio(uint256 validatorID, uint256 refundRatio) external; | ||
|
||
function updateTreasuryAddress(address v) external; | ||
|
@@ -170,11 +167,7 @@ interface ISFC { | |
address auth, | ||
uint256 validatorID, | ||
bytes calldata pubkey, | ||
uint256 status, | ||
uint256 createdEpoch, | ||
uint256 createdTime, | ||
uint256 deactivatedEpoch, | ||
uint256 deactivatedTime | ||
uint256 createdTime | ||
) external; | ||
|
||
function setGenesisDelegation(address delegator, uint256 toValidatorID, uint256 stake) external; | ||
|
@@ -185,8 +178,6 @@ interface ISFC { | |
|
||
function updateValidatorPubkey(bytes calldata pubkey) external; | ||
|
||
function migrateValidatorPubkeyUniquenessFlag(uint256 start, uint256 end) external; | ||
|
||
function setRedirectionAuthorizer(address v) external; | ||
|
||
function announceRedirection(address to) external; | ||
|
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
pragma solidity 0.8.27; | ||
|
||
import {Initializable} from "../common/Initializable.sol"; | ||
|
||
|
@@ -11,6 +11,8 @@ import {Initializable} from "../common/Initializable.sol"; | |
* This module is used through inheritance. It will make available the modifier | ||
* `onlyOwner`, which can be aplied to your functions to restrict their use to | ||
* the owner. | ||
* | ||
* @custom:security-contact [email protected] | ||
*/ | ||
contract Ownable is Initializable { | ||
address private _owner; | ||
|
This file contains 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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
pragma solidity 0.8.27; | ||
|
||
import {Ownable} from "../ownership/Ownable.sol"; | ||
import {Decimal} from "../common/Decimal.sol"; | ||
|
||
/** | ||
* @custom:security-contact [email protected] | ||
*/ | ||
contract ConstantsManager is Ownable { | ||
// Minimum amount of stake for a validator, i.e., 500000 FTM | ||
uint256 public minSelfStake; | ||
|
This file contains 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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
pragma solidity 0.8.27; | ||
|
||
import {Decimal} from "../common/Decimal.sol"; | ||
|
||
/** | ||
* @custom:security-contact [email protected] | ||
*/ | ||
library GP { | ||
function trimGasPriceChangeRatio(uint256 x) internal pure returns (uint256) { | ||
if (x > (Decimal.unit() * 105) / 100) { | ||
|
This file contains 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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
pragma solidity 0.8.27; | ||
|
||
/** | ||
* @custom:security-contact [email protected] | ||
*/ | ||
contract Migrations { | ||
address public owner; | ||
uint256 public lastCompletedMigration; | ||
|
This file contains 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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
pragma solidity 0.8.27; | ||
|
||
import {ISFC} from "../interfaces/ISFC.sol"; | ||
import {NodeDriver, NodeDriverAuth} from "./NodeDriver.sol"; | ||
import {ConstantsManager} from "./ConstantsManager.sol"; | ||
import {Decimal} from "../common/Decimal.sol"; | ||
|
||
/** | ||
* @custom:security-contact [email protected] | ||
*/ | ||
contract NetworkInitializer { | ||
// Initialize NodeDriverAuth, NodeDriver and SFC in one call to allow fewer genesis transactions | ||
function initializeAll( | ||
|
This file contains 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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
pragma solidity 0.8.27; | ||
|
||
import {Initializable} from "../common/Initializable.sol"; | ||
import {NodeDriverAuth} from "./NodeDriverAuth.sol"; | ||
import {IEVMWriter} from "../interfaces/IEVMWriter.sol"; | ||
|
||
/** | ||
* @custom:security-contact [email protected] | ||
*/ | ||
contract NodeDriver is Initializable { | ||
NodeDriverAuth internal backend; | ||
IEVMWriter internal evmWriter; | ||
|
@@ -89,25 +92,12 @@ contract NodeDriver is Initializable { | |
// Methods which are called only by the node | ||
|
||
function setGenesisValidator( | ||
address _auth, | ||
address auth, | ||
uint256 validatorID, | ||
bytes calldata pubkey, | ||
uint256 status, | ||
uint256 createdEpoch, | ||
uint256 createdTime, | ||
uint256 deactivatedEpoch, | ||
uint256 deactivatedTime | ||
uint256 createdTime | ||
) external onlyNode { | ||
backend.setGenesisValidator( | ||
_auth, | ||
validatorID, | ||
pubkey, | ||
status, | ||
createdEpoch, | ||
createdTime, | ||
deactivatedEpoch, | ||
deactivatedTime | ||
); | ||
backend.setGenesisValidator(auth, validatorID, pubkey, createdTime); | ||
} | ||
|
||
function setGenesisDelegation(address delegator, uint256 toValidatorID, uint256 stake) external onlyNode { | ||
|
This file contains 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 |
---|---|---|
@@ -1,12 +1,15 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
pragma solidity 0.8.27; | ||
|
||
import {Initializable} from "../common/Initializable.sol"; | ||
import {Ownable} from "../ownership/Ownable.sol"; | ||
import {ISFC} from "../interfaces/ISFC.sol"; | ||
import {NodeDriver} from "./NodeDriver.sol"; | ||
import {INodeDriverExecutable} from "../interfaces/INodeDriverExecutable.sol"; | ||
|
||
/** | ||
* @custom:security-contact [email protected] | ||
*/ | ||
contract NodeDriverAuth is Initializable, Ownable { | ||
ISFC internal sfc; | ||
NodeDriver internal driver; | ||
|
@@ -117,25 +120,12 @@ contract NodeDriverAuth is Initializable, Ownable { | |
} | ||
|
||
function setGenesisValidator( | ||
address _auth, | ||
address auth, | ||
uint256 validatorID, | ||
bytes calldata pubkey, | ||
uint256 status, | ||
uint256 createdEpoch, | ||
uint256 createdTime, | ||
uint256 deactivatedEpoch, | ||
uint256 deactivatedTime | ||
uint256 createdTime | ||
) external onlyDriver { | ||
sfc.setGenesisValidator( | ||
_auth, | ||
validatorID, | ||
pubkey, | ||
status, | ||
createdEpoch, | ||
createdTime, | ||
deactivatedEpoch, | ||
deactivatedTime | ||
); | ||
sfc.setGenesisValidator(auth, validatorID, pubkey, createdTime); | ||
} | ||
|
||
function setGenesisDelegation(address delegator, uint256 toValidatorID, uint256 stake) external onlyDriver { | ||
|
Oops, something went wrong.