diff --git a/contracts/common/Decimal.sol b/contracts/common/Decimal.sol index b3f8894..76614c0 100644 --- a/contracts/common/Decimal.sol +++ b/contracts/common/Decimal.sol @@ -1,6 +1,9 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.9; +pragma solidity 0.8.27; +/** + * @custom:security-contact security@fantom.foundation + */ library Decimal { // unit is used for decimals, e.g. 0.123456 function unit() internal pure returns (uint256) { diff --git a/contracts/common/Initializable.sol b/contracts/common/Initializable.sol index 97d2ff7..70af4df 100644 --- a/contracts/common/Initializable.sol +++ b/contracts/common/Initializable.sol @@ -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 security@fantom.foundation */ contract Initializable { /** diff --git a/contracts/common/ReentrancyGuard.sol b/contracts/common/ReentrancyGuard.sol deleted file mode 100644 index 5919a27..0000000 --- a/contracts/common/ReentrancyGuard.sol +++ /dev/null @@ -1,50 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.9; - -import {Initializable} from "./Initializable.sol"; - -/** - * @dev Contract module that helps prevent reentrant calls to a function. - * - * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier - * available, which can be applied to functions to make sure there are no nested - * (reentrant) calls to them. - * - * Note that because there is a single `nonReentrant` guard, functions marked as - * `nonReentrant` may not call one another. This can be worked around by making - * those functions `private`, and then adding `external` `nonReentrant` entry - * points to them. - */ -contract ReentrancyGuard is Initializable { - // counter to allow mutex lock with only one SSTORE operation - uint256 private _guardCounter; - - /** - * @dev Reentrant call. - */ - error ReentrancyGuardReentrantCall(); - - function initialize() internal initializer { - // The counter starts at one to prevent changing it from zero to a non-zero - // value, which is a more expensive operation. - _guardCounter = 1; - } - - /** - * @dev Prevents a contract from calling itself, directly or indirectly. - * Calling a `nonReentrant` function from another `nonReentrant` - * function is not supported. It is possible to prevent this from happening - * by making the `nonReentrant` function external, and make it call a - * `private` function that does the actual work. - */ - modifier nonReentrant() { - _guardCounter += 1; - uint256 localCounter = _guardCounter; - _; - if (localCounter != _guardCounter) { - revert ReentrancyGuardReentrantCall(); - } - } - - uint256[50] private ______gap; -} diff --git a/contracts/interfaces/IEVMWriter.sol b/contracts/interfaces/IEVMWriter.sol index 02f14ad..0e9e8b4 100644 --- a/contracts/interfaces/IEVMWriter.sol +++ b/contracts/interfaces/IEVMWriter.sol @@ -1,6 +1,9 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.9; +pragma solidity 0.8.27; +/** + * @custom:security-contact security@fantom.foundation + */ interface IEVMWriter { function setBalance(address acc, uint256 value) external; diff --git a/contracts/interfaces/INodeDriver.sol b/contracts/interfaces/INodeDriver.sol index a8519de..108b99a 100644 --- a/contracts/interfaces/INodeDriver.sol +++ b/contracts/interfaces/INodeDriver.sol @@ -1,6 +1,9 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.9; +pragma solidity 0.8.27; +/** + * @custom:security-contact security@fantom.foundation + */ interface INodeDriver { function setGenesisValidator( address _auth, diff --git a/contracts/interfaces/INodeDriverExecutable.sol b/contracts/interfaces/INodeDriverExecutable.sol index 9bc78cc..aef5acd 100644 --- a/contracts/interfaces/INodeDriverExecutable.sol +++ b/contracts/interfaces/INodeDriverExecutable.sol @@ -1,6 +1,9 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.9; +pragma solidity 0.8.27; +/** + * @custom:security-contact security@fantom.foundation + */ interface INodeDriverExecutable { function execute() external; } diff --git a/contracts/interfaces/ISFC.sol b/contracts/interfaces/ISFC.sol index 1a5a304..dda7107 100644 --- a/contracts/interfaces/ISFC.sol +++ b/contracts/interfaces/ISFC.sol @@ -1,6 +1,9 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.9; +pragma solidity 0.8.27; +/** + * @custom:security-contact security@fantom.foundation + */ 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; diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index a7292d7..036ccac 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -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 security@fantom.foundation */ contract Ownable is Initializable { address private _owner; diff --git a/contracts/sfc/ConstantsManager.sol b/contracts/sfc/ConstantsManager.sol index 42c50c0..99774da 100644 --- a/contracts/sfc/ConstantsManager.sol +++ b/contracts/sfc/ConstantsManager.sol @@ -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 security@fantom.foundation + */ contract ConstantsManager is Ownable { // Minimum amount of stake for a validator, i.e., 500000 FTM uint256 public minSelfStake; diff --git a/contracts/sfc/GasPriceConstants.sol b/contracts/sfc/GasPriceConstants.sol index 2bc7be3..a871309 100644 --- a/contracts/sfc/GasPriceConstants.sol +++ b/contracts/sfc/GasPriceConstants.sol @@ -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 security@fantom.foundation + */ library GP { function trimGasPriceChangeRatio(uint256 x) internal pure returns (uint256) { if (x > (Decimal.unit() * 105) / 100) { diff --git a/contracts/sfc/Migrations.sol b/contracts/sfc/Migrations.sol index 3b5d39f..1bb7c77 100644 --- a/contracts/sfc/Migrations.sol +++ b/contracts/sfc/Migrations.sol @@ -1,6 +1,9 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.9; +pragma solidity 0.8.27; +/** + * @custom:security-contact security@fantom.foundation + */ contract Migrations { address public owner; uint256 public lastCompletedMigration; diff --git a/contracts/sfc/NetworkInitializer.sol b/contracts/sfc/NetworkInitializer.sol index ce34811..6e9857d 100644 --- a/contracts/sfc/NetworkInitializer.sol +++ b/contracts/sfc/NetworkInitializer.sol @@ -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 security@fantom.foundation + */ contract NetworkInitializer { // Initialize NodeDriverAuth, NodeDriver and SFC in one call to allow fewer genesis transactions function initializeAll( diff --git a/contracts/sfc/NodeDriver.sol b/contracts/sfc/NodeDriver.sol index 99f1a69..c8979d6 100644 --- a/contracts/sfc/NodeDriver.sol +++ b/contracts/sfc/NodeDriver.sol @@ -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 security@fantom.foundation + */ 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 { diff --git a/contracts/sfc/NodeDriverAuth.sol b/contracts/sfc/NodeDriverAuth.sol index eab3348..fe87a3d 100644 --- a/contracts/sfc/NodeDriverAuth.sol +++ b/contracts/sfc/NodeDriverAuth.sol @@ -1,5 +1,5 @@ // 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"; @@ -7,6 +7,9 @@ import {ISFC} from "../interfaces/ISFC.sol"; import {NodeDriver} from "./NodeDriver.sol"; import {INodeDriverExecutable} from "../interfaces/INodeDriverExecutable.sol"; +/** + * @custom:security-contact security@fantom.foundation + */ 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 { diff --git a/contracts/sfc/SFC.sol b/contracts/sfc/SFC.sol index 55a740a..0cce6b2 100644 --- a/contracts/sfc/SFC.sol +++ b/contracts/sfc/SFC.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.9; +pragma solidity 0.8.27; import {Ownable} from "../ownership/Ownable.sol"; import {Initializable} from "../common/Initializable.sol"; @@ -11,6 +11,7 @@ import {Version} from "../version/Version.sol"; /** * @dev SFC contract for Sonic network. + * @custom:security-contact security@fantom.foundation */ contract SFC is Initializable, Ownable, Version { uint256 internal constant OK_STATUS = 0; @@ -36,9 +37,9 @@ contract SFC is Initializable, Ownable, Version { // last sealed epoch (currentEpoch - 1) uint256 public currentSealedEpoch; - mapping(uint256 => Validator) public getValidator; - mapping(address => uint256) public getValidatorID; - mapping(uint256 => bytes) public getValidatorPubkey; + mapping(uint256 validatorID => Validator) public getValidator; + mapping(address auth => uint256 validatorID) public getValidatorID; + mapping(uint256 validatorID => bytes pubkey) public getValidatorPubkey; uint256 public lastValidatorID; @@ -49,10 +50,10 @@ contract SFC is Initializable, Ownable, Version { uint256 public totalActiveStake; // delegator => validator ID => stashed rewards (to be claimed/restaked) - mapping(address => mapping(uint256 => uint256)) internal _rewardsStash; + mapping(address delegator => mapping(uint256 validatorID => uint256 stashedRewards)) internal _rewardsStash; // delegator => validator ID => last epoch number for which were rewards stashed - mapping(address => mapping(uint256 => uint256)) public stashedRewardsUntilEpoch; + mapping(address delegator => mapping(uint256 validatorID => uint256 epoch)) public stashedRewardsUntilEpoch; struct WithdrawalRequest { uint256 epoch; // epoch where undelegated @@ -61,10 +62,11 @@ contract SFC is Initializable, Ownable, Version { } // delegator => validator ID => withdrawal ID => withdrawal request - mapping(address => mapping(uint256 => mapping(uint256 => WithdrawalRequest))) public getWithdrawalRequest; + mapping(address delegator => mapping(uint256 validatorID => mapping(uint256 wrID => WithdrawalRequest))) + public getWithdrawalRequest; - // delegator => validator ID => current stake (locked+unlocked) - mapping(address => mapping(uint256 => uint256)) public getStake; + // delegator => validator ID => current stake + mapping(address delegator => mapping(uint256 validatorID => uint256 stake)) public getStake; struct EpochSnapshot { // validator ID => validator weight in the epoch @@ -90,10 +92,10 @@ contract SFC is Initializable, Ownable, Version { uint256 public totalSupply; // epoch id => epoch snapshot - mapping(uint256 => EpochSnapshot) public getEpochSnapshot; + mapping(uint256 epoch => EpochSnapshot) public getEpochSnapshot; // validator ID -> slashing refund ratio (allows to withdraw slashed stake) - mapping(uint256 => uint256) public slashingRefundRatio; + mapping(uint256 validatorID => uint256 refundRatio) public slashingRefundRatio; // the minimal gas price calculated for the current epoch uint256 public minGasPrice; @@ -106,20 +108,20 @@ contract SFC is Initializable, Ownable, Version { // the governance contract (to recalculate votes when the stake changes) address public voteBookAddress; - // validator ID => amount of pubkey updates - mapping(uint256 => uint256) internal validatorPubkeyChanges; + // validator ID => amount of pubkey changes + mapping(uint256 validatorID => uint256 changes) internal validatorPubkeyChanges; // keccak256(pubkey bytes) => validator ID (prevents using the same key by multiple validators) - mapping(bytes32 => uint256) internal pubkeyHashToValidatorID; + mapping(bytes32 pubkeyHash => uint256 validatorID) internal pubkeyHashToValidatorID; // address authorized to initiate redirection address public redirectionAuthorizer; // delegator => withdrawals receiver - mapping(address => address) public getRedirectionRequest; + mapping(address delegator => address receiver) public getRedirectionRequest; // delegator => withdrawals receiver - mapping(address => address) public getRedirection; + mapping(address delegator => address receiver) public getRedirection; struct SealEpochRewardsCtx { uint256[] baseRewardWeights; @@ -158,7 +160,7 @@ contract SFC is Initializable, Ownable, Version { error ValidatorExists(); error ValidatorNotActive(); error ValidatorDelegationLimitExceeded(); - error WrongValidatorStatus(); + error NotDeactivatedStatus(); // requests error RequestExists(); @@ -238,18 +240,6 @@ contract SFC is Initializable, Ownable, Version { revert TransfersNotAllowed(); } - function migrateValidatorPubkeyUniquenessFlag(uint256 start, uint256 end) external { - for (uint256 vid = start; vid < end; vid++) { - bytes memory pubkey = getValidatorPubkey[vid]; - if (pubkey.length > 0 && pubkeyHashToValidatorID[keccak256(pubkey)] != vid) { - if (pubkeyHashToValidatorID[keccak256(pubkey)] != 0) { - revert PubkeyUsedByOtherValidator(); - } - pubkeyHashToValidatorID[keccak256(pubkey)] = vid; - } - } - } - function updateValidatorPubkey(bytes calldata pubkey) external { if (pubkey.length != 66 || pubkey[0] != 0xc0) { revert MalformedPubkey(); @@ -355,21 +345,17 @@ contract SFC is Initializable, Ownable, Version { address auth, uint256 validatorID, bytes calldata pubkey, - uint256 status, - uint256 createdEpoch, - uint256 createdTime, - uint256 deactivatedEpoch, - uint256 deactivatedTime + uint256 createdTime ) external onlyDriver { _rawCreateValidator( auth, validatorID, pubkey, - status, - createdEpoch, + OK_STATUS, + 0, // createdEpoch createdTime, - deactivatedEpoch, - deactivatedTime + 0, // deactivatedEpoch - not deactivated + 0 // deactivatedTime - not deactivated ); if (validatorID > lastValidatorID) { lastValidatorID = validatorID; @@ -426,7 +412,7 @@ contract SFC is Initializable, Ownable, Version { function deactivateValidator(uint256 validatorID, uint256 status) external onlyDriver { if (status == OK_STATUS) { - revert WrongValidatorStatus(); + revert NotDeactivatedStatus(); } _setValidatorDeactivated(validatorID, status); diff --git a/contracts/sfc/Updater.sol b/contracts/sfc/Updater.sol index e3380a2..fbb41fd 100644 --- a/contracts/sfc/Updater.sol +++ b/contracts/sfc/Updater.sol @@ -1,5 +1,5 @@ // 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"; @@ -20,6 +20,9 @@ interface GovVersion { function version() external pure returns (bytes4); } +/** + * @custom:security-contact security@fantom.foundation + */ contract Updater { address public sfcFrom; address public sfcConsts; diff --git a/contracts/sfc/assets/signatures.txt b/contracts/sfc/assets/signatures.txt deleted file mode 100644 index 079dd41..0000000 --- a/contracts/sfc/assets/signatures.txt +++ /dev/null @@ -1,99 +0,0 @@ -6 Sending addresses: - -{ - "address": "0x983261d8023ecae9582d2ae970ebaeeb04d96e02", - "msg": "0x4920726564697265637420534643207769746864726177616c7320746f206163636f756e74203078653664623033373045453662353438633237343032386531363136633764303737366132343144392064756520746f206120706f74656e7469616c2061747461636b6572206761696e696e672061636365737320746f206d79206163636f756e742e0a", - "sig": "857a36cc8aaf07e85a4a29d93941f91acc70fedeec5916e74541e6ddd247c71c4a39c0e216f22b4ede9985f1e502379e2400b86e8c34f26a74bf29480f959a9b1b", - "version": "3", - "signer": "MEW" -} - -{ - "address": "0x08cf56e956cc6a0257ade1225e123ea6d0e5cbaf", - "msg": "0x4920726564697265637420534643207769746864726177616c7320746f206163636f756e74203078304435343265366562354637383439373534446163436338633336643232306334633437353131342064756520746f206120706f74656e7469616c2061747461636b6572206761696e696e672061636365737320746f206d79206163636f756e742e", - "sig": "cfdda3cdabf5f6de7a8ff881a7a7aa29679c9d22ca6990ce33a1bd5d1ebb5dee4ec0a7c234d304ecc0fdaa7267e5bd522e7b352869b959773bcc453c9cbc3cbd1b", - "version": "3", - "signer": "MEW" -} - -{ - "address": "0x496ec43bae0f622b0eba72e4241c6dc4f9c81695", - "msg": "0x4920726564697265637420534643207769746864726177616c7320746f206163636f756e74203078636666323734633630313444663931356139373144444330663635334243353038416465363939352064756520746f206120706f74656e7469616c2061747461636b6572206761696e696e672061636365737320746f206d79206163636f756e742e", - "sig": "2d8e005b3c0f256cdf09564c637f6bc7fbdcd0ce3a0752994b88cbfe7634d9d335a662e31cccebdc21a65d6a9dda34cf23bc041fe14e9323eb9ff59bb66c39bb1c", - "version": "3", - "signer": "MEW" -} - -{ - "address": "0x1f3e52a005879f0ee3554da41cb0d29b15b30d82", - "msg": "0x4920726564697265637420534643207769746864726177616c7320746f206163636f756e74203078363635454432333230463261324136613733363330353834426161623962373961333333323532322064756520746f206120706f74656e7469616c2061747461636b6572206761696e696e672061636365737320746f206d79206163636f756e742e0a", - "sig": "6c3801e64d1f48f2be33d6301437192b788b176ddbe58bc392e9be06466c1b8f4fa165b24425ec4581e7db4d66ac58b8af419ec6f4c1d1bf59ceff87a01a3d5e1c", - "version": "3", - "signer": "MEW" -} - -{ - "address": "0x124cb46cebd37ef9bf8b41c47f2f1bd5136656af", - "msg": "0x224920726564697265637420534643207769746864726177616c7320746f206163636f756e74203078426535616234326364323038396434453263436166443233444165333838464641353736333161422064756520746f206120706f74656e7469616c2061747461636b6572206761696e696e672061636365737320746f206d79206163636f756e742e22", - "sig": "503cf3f8af5c6f8f95859289a19e3c2a11c40d8f13b494347ea9239ccc78f9cb6ccd96d4dd7332ce870abd28335d9d3ddf218c017d808de7919fee51314b6b4f1b", - "version": "3", - "signer": "MEW" -} - -{ - "address": "0xdc3d7bca4c9db233ae10f4af3c1bd105a5818cce", - "msg": "0x4920726564697265637420534643207769746864726177616c7320746f206163636f756e74203078656339416436386436384266453232344133433442326635303662643937333533303536624435462064756520746f206120706f74656e7469616c2061747461636b6572206761696e696e672061636365737320746f206d79206163636f756e742e", - "sig": "d1d43dc91980f24a897bafe2d51ae522fb352111eb985be691a0cbdaf7f46d470a7d04ae8a3b1df016e8f9e0f35a5235daf5154c0b356e4c02434026006a12971b", - "version": "3", - "signer": "MEW" -} - -6 Receiving addresses: - -{ - "address": "0xe6db0370ee6b548c274028e1616c7d0776a241d9", - "msg": "0x4920616363657074207265646972656374656420534643207769746864726177616c732066726f6d2074686520666f6c6c6f77696e6720616464726573732030783938333236316438303233656341453935383244326165393730456261654542303464393645303220746f207468697320736563757265206163636f756e742e0a", - "sig": "0f23151c788e38e41c1cd8868a0cc529e9e07e64ecfe22a0e552daa61ea124425c2eafe5da84b0cf5c05ae207f316e0ce8f00964b884c70c03d8b2eca0a1f9f71c", - "version": "3", - "signer": "MEW" -} - -{ - "address": "0x0d542e6eb5f7849754daccc8c36d220c4c475114", - "msg": "0x4920616363657074207265646972656374656420534643207769746864726177616c732066726f6d2074686520666f6c6c6f77696e6720616464726573732030783038436635366539353643633641303235376164653132323565313233456136443065354342614620746f207468697320736563757265206163636f756e742e0a", - "sig": "b936ffa00b283a7acb2540f3e34caad8d0f246e10fef98d7a976bdd7a1b275d407aed35b829dca3c6c480b68a5306d7344769649722791dbf3fd07c6875496a21c", - "version": "3", - "signer": "MEW" -} - -{ - "address": "0xcff274c6014df915a971ddc0f653bc508ade6995", - "msg": "0x4920616363657074207265646972656374656420534643207769746864726177616c732066726f6d2074686520666f6c6c6f77696e6720616464726573732030783439364563343342414530663632324230456241373265343234314336646334663943383136393520746f207468697320736563757265206163636f756e742e0a", - "sig": "07d7ddd3544abc2379838741aaebd2dc472bec1cd7e3c868146f044a6a0392db691fdda4ed08492e93d99b17b05c808c7bf8d94627907b5570fe47091d73cb3d1c", - "version": "3", - "signer": "MEW" -} - -{ - "address": "0x665ed2320f2a2a6a73630584baab9b79a3332522", - "msg": "0x4920616363657074207265646972656374656420534643207769746864726177616c732066726f6d2074686520666f6c6c6f77696e6720616464726573732030783146334535324130303538373966304565333535346441343143623064323962313542333044383220746f207468697320736563757265206163636f756e742e0a", - "sig": "54a881c2a09d91561c387d00debd57202532ccf1fad281445e3bdb9c03f442a44c0f24f5479410c27ee00964ae9b37f8b5623cf92061ec872a63f009b456ec361c", - "version": "3", - "signer": "MEW" -} - -{ - "address": "0xbe5ab42cd2089d4e2ccafd23dae388ffa57631ab", - "msg": "0x4920616363657074207265646972656374656420534643207769746864726177616c732066726f6d2074686520666f6c6c6f77696e6720616464726573732030783132346362343663656264333765663962663862343163343766326631626435313336363536616620746f207468697320736563757265206163636f756e742e", - "sig": "df0f40742b3195e3c555b50cff073a1fedda3e202c38345c267dd63893dbad2b1cb2761900384d904feff97a21e756f98de1730329c829754e6bcf3a492e0efd1b", - "version": "3", - "signer": "MEW" -} - -{ - "address": "0xec9ad68d68bfe224a3c4b2f506bd97353056bd5f", - "msg": "0x4920616363657074207265646972656374656420534643207769746864726177616c732066726f6d2074686520666f6c6c6f77696e672061646472657373203078646333643762636134633964623233336165313066346166336331626431303561353831386363654620746f207468697320736563757265206163636f756e742e", - "sig": "b582022b800b95080933b6edb89ba067c22d6744552c56cc1457ae3681364ee36e7f47089a7707b0528855e73b7864d267d0000ccb09f28bffc11c37329ecb891b", - "version": "3", - "signer": "MEW" -} diff --git a/contracts/test/StubEvmWriter.sol b/contracts/test/StubEvmWriter.sol index 20f03fc..850ac33 100644 --- a/contracts/test/StubEvmWriter.sol +++ b/contracts/test/StubEvmWriter.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.9; +pragma solidity 0.8.27; import {IEVMWriter} from "../interfaces/IEVMWriter.sol"; diff --git a/contracts/test/UnitTestConstantsManager.sol b/contracts/test/UnitTestConstantsManager.sol index 275a8c7..4062152 100644 --- a/contracts/test/UnitTestConstantsManager.sol +++ b/contracts/test/UnitTestConstantsManager.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.9; +pragma solidity 0.8.27; import {ConstantsManager} from "../sfc/ConstantsManager.sol"; diff --git a/contracts/test/UnitTestSFC.sol b/contracts/test/UnitTestSFC.sol index 6b4567c..18c53fb 100644 --- a/contracts/test/UnitTestSFC.sol +++ b/contracts/test/UnitTestSFC.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.9; +pragma solidity 0.8.27; import {Decimal} from "../common/Decimal.sol"; import {SFC} from "../sfc/SFC.sol"; diff --git a/contracts/version/Version.sol b/contracts/version/Version.sol index df0cf60..70f9988 100644 --- a/contracts/version/Version.sol +++ b/contracts/version/Version.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.9; +pragma solidity 0.8.27; /** * @dev Version contract gives the versioning information of the implementation contract diff --git a/hardhat.config.ts b/hardhat.config.ts index 283a533..01a1dfd 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -11,9 +11,9 @@ dotenv.config(); const config: HardhatUserConfig = { solidity: { - version: '0.8.24', + version: '0.8.27', settings: { - evmVersion: 'london', + evmVersion: 'cancun', optimizer: { enabled: true, runs: 200, diff --git a/test/NodeDriver.ts b/test/NodeDriver.ts index 75b1ee3..9d55595 100644 --- a/test/NodeDriver.ts +++ b/test/NodeDriver.ts @@ -119,16 +119,7 @@ describe('NodeDriver', () => { it('Should revert when not node', async function () { const account = ethers.Wallet.createRandom(); await expect( - this.nodeDriver.setGenesisValidator( - account, - 1, - account.publicKey, - 0, - await this.sfc.currentEpoch(), - Date.now(), - 0, - 0, - ), + this.nodeDriver.setGenesisValidator(account, 1, account.publicKey, Date.now()), ).to.be.revertedWithCustomError(this.nodeDriver, 'NotNode'); }); }); @@ -142,9 +133,10 @@ describe('NodeDriver', () => { describe('Set genesis delegation', () => { it('Should revert when not node', async function () { const account = ethers.Wallet.createRandom(); - await expect( - this.nodeDriver.setGenesisDelegation(account, 1, 100, 0, 0, 0, 0, 0, 1000), - ).to.be.revertedWithCustomError(this.nodeDriver, 'NotNode'); + await expect(this.nodeDriver.setGenesisDelegation(account, 1, 100)).to.be.revertedWithCustomError( + this.nodeDriver, + 'NotNode', + ); }); }); diff --git a/test/SFC.ts b/test/SFC.ts index b4623c8..6041bfc 100644 --- a/test/SFC.ts +++ b/test/SFC.ts @@ -56,16 +56,8 @@ describe('SFC', () => { beforeEach(async function () { const validator = ethers.Wallet.createRandom(); await this.sfc.enableNonNodeCalls(); - await this.sfc.setGenesisValidator( - validator.address, - 1, - validator.publicKey, - 1 << 3, - await this.sfc.currentEpoch(), - Date.now(), - 0, - 0, - ); + await this.sfc.setGenesisValidator(validator.address, 1, validator.publicKey, Date.now()); + await this.sfc.deactivateValidator(1, 1 << 3); await this.sfc.disableNonNodeCalls(); }); @@ -315,22 +307,13 @@ describe('SFC', () => { it('Should revert when setGenesisValidator is not called not node', async function () { const validator = ethers.Wallet.createRandom(); await expect( - this.sfc.setGenesisValidator( - validator, - 1, - validator.publicKey, - 0, - await this.sfc.currentEpoch(), - Date.now(), - 0, - 0, - ), + this.sfc.setGenesisValidator(validator, 1, validator.publicKey, Date.now()), ).to.be.revertedWithCustomError(this.sfc, 'NotDriverAuth'); }); it('Should revert when setGenesisDelegation is not called not node', async function () { const delegator = ethers.Wallet.createRandom(); - await expect(this.sfc.setGenesisDelegation(delegator, 1, 100, 0, 0, 0, 0, 0, 1000)).to.be.revertedWithCustomError( + await expect(this.sfc.setGenesisDelegation(delegator, 1, 100)).to.be.revertedWithCustomError( this.sfc, 'NotDriverAuth', ); @@ -977,23 +960,15 @@ describe('SFC', () => { it('Should revert when calling setGenesisValidator if not NodeDriver', async function () { const key = ethers.Wallet.createRandom().publicKey; await expect( - this.nodeDriverAuth.setGenesisValidator( - this.delegator, - 1, - key, - 1 << 3, - await this.sfc.currentEpoch(), - Date.now(), - 0, - 0, - ), + this.nodeDriverAuth.setGenesisValidator(this.delegator, 1, key, Date.now()), ).to.be.revertedWithCustomError(this.nodeDriverAuth, 'NotDriver'); }); it('Should revert when calling setGenesisDelegation if not NodeDriver', async function () { - await expect( - this.nodeDriverAuth.setGenesisDelegation(this.delegator, 1, 100, 0, 0, 0, 0, 0, 1000), - ).to.be.revertedWithCustomError(this.nodeDriverAuth, 'NotDriver'); + await expect(this.nodeDriverAuth.setGenesisDelegation(this.delegator, 1, 100)).to.be.revertedWithCustomError( + this.nodeDriverAuth, + 'NotDriver', + ); }); it('Should revert when calling deactivateValidator if not NodeDriver', async function () { @@ -1131,7 +1106,7 @@ describe('SFC', () => { }); it('Should succeed and setGenesisDelegation Validator', async function () { - await this.sfc.setGenesisDelegation(this.delegator, this.validatorId, ethers.parseEther('1'), 0, 0, 0, 0, 0, 100); + await this.sfc.setGenesisDelegation(this.delegator, this.validatorId, ethers.parseEther('1')); // delegator has already delegated 0.4 in fixture expect(await this.sfc.getStake(this.delegator, this.validatorId)).to.equal(ethers.parseEther('1.4')); });