Skip to content

Commit 6ccd0c9

Browse files
committed
Major refactoring for SmartnodesV2 + beginning test write-out
1 parent 5571d73 commit 6ccd0c9

13 files changed

+1016
-1004
lines changed

foundry.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
src = "src"
33
out = "out"
44
libs = ["lib"]
5+
solc_version = "0.8.22"
56
remappings = [
67
"@openzeppelin/=lib/openzeppelin-contracts/",
7-
"foundry-huff/=lib/foundry-huff/src"
8+
"foundry-huff/=lib/foundry-huff/src/"
89
]
10+
via_ir = true
11+
optimizer = true
912
ffi = true
10-
11-
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

script/Deploy.s.sol

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
// SPDX-License-Identifier: MIT
2-
pragma solidity ^0.8.20;
1+
// // SPDX-License-Identifier: MIT
2+
// pragma solidity ^0.8.20;
33

4-
import {Script} from "forge-std/Script.sol";
5-
import {SmartnodesCore} from "../src/SmartnodesCore.sol";
4+
// import {Script} from "forge-std/Script.sol";
5+
// import {SmartnodesCore} from "../src/SmartnodesCore.sol";
66

7-
contract DeploySmartnodes is Script {
8-
function run() external returns (SmartnodesCore) {
9-
address[] memory validators;
10-
validators[0] = 0x1234567890123456789012345678901234567890;
11-
validators[1] = 0x0987654321098765432109876543210987654321;
7+
// contract DeploySmartnodes is Script {
8+
// function run() external returns (SmartnodesCore) {
9+
// address[] memory validators;
10+
// validators[0] = 0x1234567890123456789012345678901234567890;
11+
// validators[1] = 0x0987654321098765432109876543210987654321;
1212

13-
vm.startBroadcast();
14-
SmartnodesCore smartnodesCore = new SmartnodesCore(validators);
15-
vm.startBroadcast();
16-
return smartnodesCore;
17-
}
18-
}
13+
// vm.startBroadcast();
14+
// SmartnodesCore smartnodesCore = new SmartnodesCore(validators);
15+
// vm.startBroadcast();
16+
// return smartnodesCore;
17+
// }
18+
// }

src/SmartnodesCoordinator.sol

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
// SPDX-License-Identifier: MIT
2-
pragma solditiy ^0.8.20
1+
// // SPDX-License-Identifier: MIT
2+
// pragma solditiy ^0.8.20
33

4-
contract SmartnodesCoordinator {
5-
function activeValidator() internal {}
6-
function deactivateValidator() internal {}
7-
function submitProposal() external {}
8-
function executeProposal() external {}
9-
function vote() external {}
10-
}
4+
// contract SmartnodesCoordinator {
5+
// /** Constants */
6+
// ISmartnodesCore private immutable i_smartnodesCore;
7+
// address private immutable smartnodesContractAddress;
8+
// function activeValidator() internal {}
9+
// function deactivateValidator() internal {}
10+
// function submitProposal() external {}
11+
// function executeProposal() external {}
12+
// function vote() external {}
13+
// }

src/SmartnodesCore.sol

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity ^0.8.20;
2+
pragma solidity ^0.8.22;
33

4-
import {ISmartnodesCoordinator} from "./interfaces/ISmartnodesCoordinator.sol";
4+
// import {ISmartnodesCoordinator} from "./interfaces/ISmartnodesCoordinator.sol";
55
import {ISmartnodesToken} from "./interfaces/ISmartnodesToken.sol";
66

77
/**
@@ -64,7 +64,7 @@ contract SmartnodesCore {
6464
uint24 private constant UNLOCK_PERIOD = 14 days;
6565
uint8 private constant MAX_NETWORKS = 16;
6666

67-
ISmartnodesCoordinator private immutable i_validatorContract;
67+
// ISmartnodesCoordinator private immutable i_validatorContract;
6868
ISmartnodesToken private immutable i_tokenContract;
6969

7070
/** State Variables */
@@ -93,14 +93,14 @@ contract SmartnodesCore {
9393
event NetworkAdded(uint8 indexed networkId, string name);
9494
event NetworkRemoved(uint8 indexed networkId);
9595

96-
modifier onlyCoordinator() {
97-
if (msg.sender != address(i_validatorContract))
98-
revert SmartnodesCore__NotValidatorMultisig();
99-
_;
100-
}
96+
// modifier onlyCoordinator() {
97+
// if (msg.sender != address(i_validatorContract))
98+
// revert SmartnodesCore__NotValidatorMultisig();
99+
// _;
100+
// }
101101

102-
constructor(address _validatorContract, address _tokenContract) {
103-
i_validatorContract = ISmartnodesCoordinator(_validatorContract);
102+
constructor(address _tokenContract) {
103+
// i_validatorContract = ISmartnodesCoordinator(_validatorContract);
104104
i_tokenContract = ISmartnodesToken(_tokenContract);
105105

106106
jobCounter = 0;
@@ -112,7 +112,7 @@ contract SmartnodesCore {
112112
* @notice Add a new network to the system
113113
* @param _name Name of the network
114114
*/
115-
function addNetwork(string calldata _name) external onlyCoordinator {
115+
function addNetwork(string calldata _name) external {
116116
if (networkCounter >= MAX_NETWORKS)
117117
revert SmartnodesCore__InvalidNetworkId();
118118

@@ -130,7 +130,7 @@ contract SmartnodesCore {
130130
* @notice Remove network from the system
131131
* @param _networkId network id
132132
*/
133-
function removeNetwork(uint8 _networkId) external onlyCoordinator {
133+
function removeNetwork(uint8 _networkId) external {
134134
Network storage network = networks[_networkId];
135135

136136
if (!network.exists) revert SmartnodesCore__InvalidNetworkId();
@@ -155,7 +155,7 @@ contract SmartnodesCore {
155155
validator.exists = true;
156156

157157
// Lock tokens for the validator
158-
i_tokenContract.lockTokens(validatorAddress);
158+
i_tokenContract.lockTokens(validatorAddress, 1);
159159
}
160160

161161
function createUser(bytes32 publicKeyHash) external {
@@ -234,12 +234,7 @@ contract SmartnodesCore {
234234
_networkId
235235
);
236236
} else {
237-
i_tokenContract.escrowPayment(
238-
msg.sender,
239-
finalPayment,
240-
_networkId,
241-
paymentType
242-
);
237+
i_tokenContract.escrowPayment(msg.sender, finalPayment, _networkId);
243238
}
244239

245240
emit JobCreated(
@@ -259,7 +254,7 @@ contract SmartnodesCore {
259254
address[] calldata _validators,
260255
address[] calldata _workers,
261256
uint256[] calldata _capacities
262-
) external onlyCoordinator {
257+
) external {
263258
uint256 workersLength = _workers.length;
264259
uint256 capacitiesLength = _capacities.length;
265260
if (workersLength != capacitiesLength || _validators.length == 0) {

0 commit comments

Comments
 (0)