Skip to content

Commit

Permalink
master branch updated (#926)
Browse files Browse the repository at this point in the history
* fix: updated and added comments on contracts (#789)

* fix: updated and added comments in stakeManager and interface

* fix: updated and added comments on contracts

* fix: updated comment in collectionManager contract

* feat: made getstate and getepoch functions public (#795)

* feat: made getstate and getepoch function public

* fix: linting errors

* fix: fixed naming issue in RandomNoManager

* feat: hardhat-deploy (#797)

* feat(hardhatdeploy): poc hardhat-deploy

integrate hardhat-deploy plugin to deploy test contract

* feat(hardhat-deploy): integrate hardhat-deploy plugin

deploy all Razor contracts using hardhat-deploy, update deploy.sh script

* fix(hardhat-deploy): integrate hardhat-deploy plugin

hotfix remove test contract

* fix(hardhat-deploy): integrate hardhat-deploy plugin

hotfix remove unnecessary changes

* fix(hardhat-deploy): integrate hardhat-deploy plugin

hotfix remove unnecessary changes

* fix(hardhat-deploy): fix current post deployment

wait for contract deployment file to updated

* fix(hardhat-deploy): migrate contracts setup

create shared folder for contracts initialisation and grant role

* feat(hardhat-deploy): post deployment test

add post deployment script test, 1 staker to vote for 1 epoch

* feat(hardhat-deploy): clean up

hotfix

* fix: lint fix and yarn.lock

* feat(hardhat-deploy): add deployment fixtures for tests

* fix(hardhat-deploy): fix circleci errors

* feat(hardhat-deploy): remove postdeployment test and deployment fixtures. Release hardhat-deploy

* feat(hardhat-deploy): use common deploy func, code modularisation

* feat(hardhat-deploy): circleci hotfix

* fix: clean up functions,rename deploy_all

* fix: postdeployment setup code clean up and fixes for failing init contract + same contract instance

* fix: update grant role to promise

* fix: add deploy readme

* fix: move to root folder

* fix: update content

* chore: removal of hardhat-truffle (#810)

* chore: removal of hardhat-truffle

* fix: linting fixes

* feat: added skale-v2 support in hardhat config (#813)

* feat: added skale-v2 support in hardhat config

* fix: resolved linting in hardhat config

* feat: occurrence support (#793)

* feat: occurrence support

* fix: slither issues

* fix: slither issues part 2

* fix: slither issues part 3

* test: adding positive testcases to bond manager

* test: fixing tests

* test: refactored bondManager tests and added tests to governance

* feat: adding more governance params and test cases

* fix: linting fixes

* fix: solidity linting fixes

* test: add negative test cases

* fix: linting fixes

* fix: merge fixes

* fix: bond manager fixes

* fix: slither fixes

* fix: deployment scripted added for bond manager and v1.0.1 incentnet phase 2 changes incorporated

* fix: post deployment script fix

* fix: post deployment create jobs fix

* fix: post deployment create collection fix

* fix: linting fixes

* build(deps): bump semver-regex from 3.1.3 to 3.1.4 (#817)

Bumps [semver-regex](https://github.com/sindresorhus/semver-regex) from 3.1.3 to 3.1.4.
- [Release notes](https://github.com/sindresorhus/semver-regex/releases)
- [Commits](https://github.com/sindresorhus/semver-regex/commits/v3.1.4)

---
updated-dependencies:
- dependency-name: semver-regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump semantic-release from 19.0.2 to 19.0.3 (#826)

Bumps [semantic-release](https://github.com/semantic-release/semantic-release) from 19.0.2 to 19.0.3.
- [Release notes](https://github.com/semantic-release/semantic-release/releases)
- [Commits](semantic-release/semantic-release@v19.0.2...v19.0.3)

---
updated-dependencies:
- dependency-name: semantic-release
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix: sortedValues datatype fix (#850)

* fix: Post deployment testing + Fixing Governance and ContractM Initialisation (#840)

* test: use post deployment helpers in postdeployment test

* chore: remove tmp

* chore: add post deployment tmp json to gitignore

* fix: update post deployment to support databonds

* fix: fix collectionM and gov contract initialisation, clean up post deployment script

* chore: clean up

* fix: increase network timeout (#845)

* fix: increase network timeout

* chore: update timeout to 5 min

* build(deps): bump npm from 8.9.0 to 8.12.1 (#827)

Bumps [npm](https://github.com/npm/cli) from 8.9.0 to 8.12.1.
- [Release notes](https://github.com/npm/cli/releases)
- [Changelog](https://github.com/npm/cli/blob/latest/CHANGELOG.md)
- [Commits](npm/cli@v8.9.0...v8.12.1)

---
updated-dependencies:
- dependency-name: npm
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: Skanda Bhat <bhat.skanda.m@gmail.com>
Co-authored-by: Gaurav Jain <65170724+GauravJain9@users.noreply.github.com>
Co-authored-by: Yohan Nelson <yohan.nelson@gmail.com>
Co-authored-by: Shrikant upadhyay <shrikant1997upadhyay@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Raj Kharvar <rajkharvar1808@gmail.com>
  • Loading branch information
7 people authored Jul 29, 2022
1 parent 6c4ba25 commit 09c03e3
Show file tree
Hide file tree
Showing 61 changed files with 5,434 additions and 3,228 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ node_modules/
.DS_Store
.previous-deployment-addresses
.contract-deployment.tmp.json
.post-deployment-test.tmp.json
deployments
deployed/local
deployments
gasReporterOutput.json
.vscode/
docs
docs
package-lock.json
73 changes: 73 additions & 0 deletions DEPLOY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
## hardhat-deploy in a nutshell

**hardhat-deploy** allows you to write `deploy scripts` in the `deploy` folder. Each of these files that look as follows will be executed in turn when you execute the following task: `hardhat --network <networkName> deploy`

Note: `hre.deployments.deploy` function will by default only deploy a contract if the contract code has changed, making it easier to write idempotent scripts.

### An example of a deploy script :

```
module.exports = async ({
getNamedAccounts,
deployments,
getChainId,
getUnnamedAccounts,
}) => {
const {deploy} = deployments;
const {deployer} = await getNamedAccounts();
// the following will only deploy "GenericMetaTxProcessor" if the contract was never deployed or if the code changed since last deployment
await deploy('GenericMetaTxProcessor', {
from: deployer,
gasLimit: 4000000,
args: [],
});
};
```

As you can see the HRE passed in has 4 new fields :

- `getNamedAccounts` is a function that returns a promise to an object whose keys are names and values are addresses. It is parsed from the `namedAccounts` configuration.
- `getUnnamedAccounts` is a function that return a promise to an array of accounts which were not named (see `namedAccounts` ). It is useful for tests where you want to be sure that the account has no speicifc role in the system (no token given, no admin access, etc...).
- `getChainId` is a function which return a promise for the chainId, as convenience
- `deployments` is an object which contains functions to access past deployments or to save new ones, as well as helpers functions.

`deployments` contains for example the `deploy` function that allows you to deploy contract and save them.

### **1. namedAccounts (ability to name addresses)**

---

This plugin extends the `HardhatConfig`'s object with an optional `namedAccounts` field.

`namedAccounts` allows you to associate names to addresses and have them configured per chain.
This allows you to have meaningful names in your tests.

```
{
namedAccounts: {
deployer: {
default: 0, // here this will by default take the first account as deployer
1: 0, // similarly on mainnet it will take the first account as deployer. Note though that depending on how hardhat network are configured, the account 0 on one network can be different than on another
4: '0xA296a3d5F026953e17F472B497eC29a5631FB51B', // but for rinkeby it will be a specific address
"goerli": '0x84b9514E013710b9dD0811c9Fe46b837a4A0d8E0', //it can also specify a specific netwotk name (specified in hardhat.config.js)
},
feeCollector:{
default: 1, // here this will by default take the second account as feeCollector (so in the test this will be a different account than the deployer)
1: '0xa5610E1f289DbDe94F3428A9df22E8B518f65751', // on the mainnet the feeCollector could be a multi sig
4: '0xa250ac77360d4e837a13628bC828a2aDf7BabfB3', // on rinkeby it could be another account
}
}
}
```

---

Furthermore you can also ensure these scripts are executed in test’s too by calling `await deployments.fixture(['MyContract'])` in your test.
This is optimised, so if multiple tests use the same contract, the deployment will be executed once and each test will start with the exact same state.

This is a huge benefit for testing since you are not required to replicate the deployment procedure in your tests.

You can even group deploy scripts in different sub folder and ensure they are executed in their logical order.
13 changes: 3 additions & 10 deletions contracts/Core/BlockManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ contract BlockManager is Initializable, BlockStorage, StateManager, BlockManager
* and is valid. This will confirm the block and rewards the selected staker with the block reward
*/
function claimBlockReward() external initialized checkState(State.Confirm, buffer) {
uint32 epoch = _getEpoch();
uint32 epoch = getEpoch();
uint32 stakerId = stakeManager.getStakerId(msg.sender);
require(stakerId > 0, "Structs.Staker does not exist");
// slither-disable-next-line timestamp
Expand All @@ -266,7 +266,7 @@ contract BlockManager is Initializable, BlockStorage, StateManager, BlockManager

/// @inheritdoc IBlockManager
function confirmPreviousEpochBlock(uint32 stakerId) external override initialized onlyRole(BLOCK_CONFIRMER_ROLE) {
uint32 epoch = _getEpoch();
uint32 epoch = getEpoch();

if (sortedProposedBlockIds[epoch - 1].length != 0 && blockIndexToBeConfirmed != -1) {
_confirmBlock(epoch - 1, stakerId);
Expand Down Expand Up @@ -472,11 +472,6 @@ contract BlockManager is Initializable, BlockStorage, StateManager, BlockManager
return (blocks[epoch].proposerId != 0);
}

/// @inheritdoc IBlockManager
function getLatestResults(uint16 id) external view override returns (uint256) {
return latestResults[id];
}

/**
* @notice an internal function in which the block is confirmed.
* @dev The staker who confirms the block receives the block reward, creates the salt for the next epoch and stores
Expand All @@ -490,12 +485,10 @@ contract BlockManager is Initializable, BlockStorage, StateManager, BlockManager
bytes32 salt = keccak256(abi.encodePacked(epoch, blocks[epoch].medians)); // not iteration as it can be manipulated

Structs.Block memory _block = blocks[epoch];
for (uint256 i = 0; i < _block.ids.length; i++) {
latestResults[_block.ids[i]] = _block.medians[i];
}

emit BlockConfirmed(epoch, _block.proposerId, _block.ids, block.timestamp, _block.medians);

collectionManager.setResult(epoch, _block.ids, _block.medians);
voteManager.storeSalt(salt);
rewardManager.giveBlockReward(stakerId, epoch);
randomNoProvider.provideSecret(epoch, salt);
Expand Down
Loading

0 comments on commit 09c03e3

Please sign in to comment.