Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skale testing #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .env.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
MNEMONIC=

# Ethereum Network
NETWORK=
NETWORK=local

# Provider HOST & PORT for deployment
PROVIDER_HOST=
PROVIDER_PORT=
PROVIDER_HOST=http:/127.0.0.1
PROVIDER_PORT=8545

# Provider URL for deployment
PROVIDER_URL=
Expand Down
10 changes: 7 additions & 3 deletions contracts/Core/StateManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.0;

import "./storage/Constants.sol";
import "hardhat/console.sol";

contract StateManager is Constants {
modifier checkEpoch(uint32 epoch, uint32 epochLength) {
Expand Down Expand Up @@ -34,12 +35,15 @@ contract StateManager is Constants {
_;
}

function _getEpoch(uint32 epochLength) internal view returns (uint32) {
return (uint32(block.number) / (epochLength));
function _getEpoch(uint32 epochLength) internal view returns (uint32) { //add a buffer
console.log("Epoch :", uint32(block.timestamp) / (epochLength));
return (uint32(block.timestamp) / (epochLength));

}

function _getState(uint32 epochLength) internal view returns (State) {
uint8 state = uint8(((block.number) / (epochLength / NUM_STATES)) % (NUM_STATES));
uint8 state = uint8(((block.timestamp - 2 seconds) / (epochLength / NUM_STATES)) % (NUM_STATES));
console.log("state :", state);
return State(state);
}
}
2 changes: 1 addition & 1 deletion contracts/Core/parameters/child/AssetManagerParams.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "../ACL.sol";
import "../../storage/Constants.sol";

abstract contract AssetManagerParams is ACL, IAssetManagerParams, Constants {
uint16 public epochLength = 300;
uint16 public epochLength = 120;
uint16 public maxTolerance = 1000;

function setEpochLength(uint16 _epochLength) external override onlyRole(GOVERNANCE_ROLE) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/Core/parameters/child/BlockManagerParams.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "../../storage/Constants.sol";

abstract contract BlockManagerParams is ACL, IBlockManagerParams, Constants {
uint8 public maxAltBlocks = 5;
uint16 public epochLength = 300;
uint16 public epochLength = 120;
uint256 public blockReward = 100 * (10**18);
uint256 public minStake = 20000 * (10**18);

Expand Down
2 changes: 1 addition & 1 deletion contracts/Core/parameters/child/DelegatorParams.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "../ACL.sol";
import "../../storage/Constants.sol";

abstract contract DelegatorParams is ACL, IDelegatorParams, Constants {
uint16 public epochLength = 300;
uint16 public epochLength = 120;

function setEpochLength(uint16 _epochLength) external override onlyRole(GOVERNANCE_ROLE) {
// slither-disable-next-line events-maths
Expand Down
2 changes: 1 addition & 1 deletion contracts/Core/parameters/child/RandomNoManagerParams.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "../ACL.sol";
import "../../storage/Constants.sol";

abstract contract RandomNoManagerParams is ACL, IRandomNoManagerParams, Constants {
uint16 public epochLength = 300;
uint16 public epochLength = 120;

function setEpochLength(uint16 _epochLength) external override onlyRole(GOVERNANCE_ROLE) {
// slither-disable-next-line events-maths
Expand Down
2 changes: 1 addition & 1 deletion contracts/Core/parameters/child/RewardManagerParams.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "../../storage/Constants.sol";
abstract contract RewardManagerParams is ACL, IRewardManagerParams, Constants {
uint16 public penaltyNotRevealNum = 1;
uint16 public gracePeriod = 8;
uint16 public epochLength = 300;
uint16 public epochLength = 120;
uint32 public maxAge = 100 * 10000;
uint256 public blockReward = 100 * (10**18);
uint16 public maxTolerance = 1000;
Expand Down
2 changes: 1 addition & 1 deletion contracts/Core/parameters/child/StakeManagerParams.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ abstract contract StakeManagerParams is ACL, IStakeManagerParams, Constants {
// change the commission by 3% points
uint8 public deltaCommission = 3;
uint16 public gracePeriod = 8;
uint16 public epochLength = 300;
uint16 public epochLength = 120;
uint16 public epochLimitForUpdateCommission = 100;
SlashNums public slashNums = SlashNums(500, 9500, 0);
// Slash Penalty = bounty + burned + kept
Expand Down
2 changes: 1 addition & 1 deletion contracts/Core/parameters/child/VoteManagerParams.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "../ACL.sol";
import "../../storage/Constants.sol";

abstract contract VoteManagerParams is ACL, IVoteManagerParams, Constants {
uint16 public epochLength = 300;
uint16 public epochLength = 120;
uint256 public minStake = 20000 * (10**18);

function setEpochLength(uint16 _epochLength) external override onlyRole(GOVERNANCE_ROLE) {
Expand Down
20 changes: 10 additions & 10 deletions deployed/mumbai/addresses.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"Governance": "0x3807FE20f10dD7ff73eF32108B2C73C8f8063d56",
"BlockManager": "0x99681E7420a670a8ebAfDfd60198e05568D0a035",
"AssetManager": "0x6Cc8F3CD9f242682c94e227F27cf6a660070eB7b",
"StakeManager": "0xB0E1538A028F01b56D13d0dd179e0e83FffEeC23",
"RewardManager": "0x40894344c963CE6Ad342c78FCFC95FC8afD2ba7c",
"VoteManager": "0x47284B633C78183f19cC762D1f94C94f15CdFcBB",
"Delegator": "0x5C583496A9FD75aB00eB10ADc2b80daE58E905fF",
"RAZOR": "0x4C9c41252C1a6ccE9D1996Cc0953753CDA2d468f",
"StakedTokenFactory": "0x7bF9b6356E6F36e69A76b748468C737EDC73d3eE",
"RandomNoManager": "0xf2fC3634fD5971B3197F1c27dC39a0A4784369da"
"Governance": "0x76f3E6FD97b00145c65568c7cA230f523d1d6b87",
"BlockManager": "0xb8bb60d2d63C991358d832eb0AB452AA1bb16A77",
"AssetManager": "0xf0Bb01c16cEeD18Ebc055Eb93c526b1016d85509",
"StakeManager": "0xDEaC0c9a97B6d2C4974B9FED13A6804201408b06",
"RewardManager": "0x16B519aABA2AB5DA2b1042664Dc0eefADbe50054",
"VoteManager": "0x671F0e6a757C2C42f590f8c236278524Cc7715E6",
"Delegator": "0x78E246d4625637c465a0Be4aF11BDC7d13987C04",
"RAZOR": "0x3aDFd7E1d5932bd1F84460Df014Ea44cdD864522",
"StakedTokenFactory": "0x667BC30EEb54cf41D81eadc367238e78B8473B2e",
"RandomNoManager": "0xA82965c61F9108cEb910F9B65EC8Cc71793F5aA6"
}
9 changes: 6 additions & 3 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = {
optimizer: {
enabled: true,
runs: 100000,
},
},
},
},
],
Expand Down Expand Up @@ -73,8 +73,8 @@ module.exports = {
chainId: 31337,
logger: console,
mining: {
auto: true,
interval: 2000,
auto: false,
interval: 5000,
},
},
mumbai: {
Expand All @@ -101,4 +101,7 @@ module.exports = {
username: 'razor',
project: 'razor-network',
},
mocha:{
timeout : 200000,
}
};
4 changes: 2 additions & 2 deletions migrations/src/postDeploymentSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const {
} = process.env;

module.exports = async () => {
const MINING_INTERVAL = 2000;
const MINING_INTERVAL = 5000;
const signers = await ethers.getSigners();

const {
Expand Down Expand Up @@ -94,7 +94,7 @@ module.exports = async () => {
if (NETWORK === 'local' || NETWORK === 'hardhat') {
// Set interval mining to 2 seconds. This is to enable using razor-go with interval mining without affecting hardhat config.
await ethers.provider.send('evm_setAutomine', [false]);
await ethers.provider.send('evm_setIntervalMining', [MINING_INTERVAL]);
await ethers.provider.send('evm_setIntervalMining', [5000]);
}

pendingTransactions.push(await blockManager.initialize(stakeManagerAddress, rewardManagerAddress, voteManagerAddress,
Expand Down
29 changes: 24 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"fs": "^0.0.1-security",
"hardhat-abi-exporter": "^2.3.0",
"json-to-markdown-table": "^1.0.0",
"jsonfile": "^6.1.0"
"jsonfile": "^6.1.0",
"sleep": "^6.3.0"
},
"devDependencies": {
"@codechecks/client": "^0.1.11",
Expand Down
28 changes: 11 additions & 17 deletions test/ACL.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const {
} = require('./helpers/testHelpers');
const { setupContracts } = require('./helpers/testSetup');
const {
getEpoch, tokenAmount,
getEpoch, tokenAmount, getState, waitForConfirmState, waitForNState,
} = require('./helpers/utils');

describe('Access Control Test', async () => {
Expand Down Expand Up @@ -251,7 +251,12 @@ describe('Access Control Test', async () => {
const assetCreatorHash = ASSET_MODIFIER_ROLE;
await assetManager.grantRole(assetCreatorHash, signers[0].address);
await assetManager.createJob(25, 0, 0, 'http://testurl.com/1', 'selector/1', 'test1');
await mineToNextState();
let state = await getState();
console.log(state)
await waitForNState(1);
console.log(await getState());
state = await getState();
console.log(state);
await assetManager.updateJob(1, 25, 2, 0, 'http://testurl.com/2', 'selector/2');
await assetManager.revokeRole(assetCreatorHash, signers[0].address);
await assertRevert(assetManager.updateJob(1, 25, 2, 0, 'http://testurl.com/2', 'selector/2'), expectedRevertMessage);
Expand Down Expand Up @@ -279,10 +284,7 @@ describe('Access Control Test', async () => {
await assetManager.grantRole(assetCreatorHash, signers[0].address);
await assetManager.createJob(25, 0, 0, 'http://testurl.com/1', 'selector/1', 'test1');
const collectionName = 'Test Collection2';
await mineToNextState();
await mineToNextState();
await mineToNextState();
await mineToNextState();
await waitForNState(4);
await assetManager.createCollection(500, 0, 1, [1], collectionName);
await assetManager.setCollectionStatus(true, 2);
await assetManager.revokeRole(assetCreatorHash, signers[0].address);
Expand Down Expand Up @@ -313,10 +315,7 @@ describe('Access Control Test', async () => {
await assetManager.grantRole(assetConfirmerHash, signers[0].address);
await assetManager.createJob(25, 0, 0, 'http://testurl.com/1', 'selector/1', 'test1');
await assetManager.createJob(25, 0, 0, 'http://testurl.com/2', 'selector/2', 'test2');
await mineToNextState();
await mineToNextState();
await mineToNextState();
await mineToNextState();
await waitForNState(4);
await assetManager.createCollection(500, 1, 1, [1, 2], 'test');
await assetManager.setCollectionStatus(false, 3);
await assetManager.executePendingDeactivations(1);
Expand Down Expand Up @@ -347,10 +346,7 @@ describe('Access Control Test', async () => {
await assetManager.grantRole(assetCreatorHash, signers[0].address);
await assetManager.createJob(25, 0, 0, 'http://testurl.com/1', 'selector/1', 'test1');
await assetManager.createJob(25, 0, 0, 'http://testurl.com/2', 'selector/2', 'test2');
await mineToNextState();// reveal
await mineToNextState();// propose
await mineToNextState();// dispute
await mineToNextState();// confirm
await waitForNState(4);
await assetManager.createCollection(500, 1, 1, [1, 2], 'test');
await assetManager.revokeRole(assetCreatorHash, signers[0].address);
await assertRevert(assetManager.createCollection(500, 1, 1, [1, 2], 'test'), expectedRevertMessage);
Expand Down Expand Up @@ -379,9 +375,7 @@ describe('Access Control Test', async () => {

await assetManager.createJob(25, 0, 0, 'http://testurl.com/1', 'selector/1', 'test1');
await assetManager.createJob(25, 0, 0, 'http://testurl.com/2', 'selector/2', 'test2');
await mineToNextState();// propose
await mineToNextState();// dispute
await mineToNextState();// confirm
await waitForNState(4);
await assetManager.createCollection(500, 0, 1, [1, 2], 'test');

await assetManager.updateCollection(3, 500, 2, -2, [1, 2]);
Expand Down
Loading