Skip to content

Commit

Permalink
Implement bep-127 and bep-131 (#131)
Browse files Browse the repository at this point in the history
* [R4R]: new implement of BEP-127 (#3)

* feat: new implement of bep-127 and test

* fix: review comments

* fix: add re-init for validatorExtraSet

* fix: template file sync

* fix: validatorExtraSet should init at the same time as `maxNumOfMaintaining` init

* modify config

* fix: maintainInfo leak at next 24-hours

* chores: add comment

* fix: `isCurrentValidator` error before `validatorExtraSet` init

* chore

* test: add test case for BSCValidatorSet

* test: add view test case for BSCValidatorSet

* chore: modify comments

* fix: numOfMaintaining modification on edge case

* fix: review comments

* test: add code size log

* chore: optimize new ValidatorExtra

* fix: numOfMaintaining edge case

* fix: add exitMaintenance event

* fix: add exitMaintenance event

* chore

* fix: remove unused code

* chore

* implement bep-131

* update ut

* update logic of felony function

* update the getMiningValidators function

* update logic of the update maxNumOfCandidates function

* fix calculating epoch number

* update _exitMaintenance

* fix comments

* update readme

* fix testcase on slash and validator contract

* fix update maxNumOfMaintaining

* fix: bug that validatorSet order was changed incorrectly while _felony in _forceMaintainingValidatorsExit, using numOfCabinets not init

* feat: modify slots number

* chore: rename var in loop

* Fix audit report of BEP-127 and BEP-131 (#17)

* fix: issue #BSC-007, add more comment to explain `enterMaintenanceHeight` check

* fix: issue #BSC-001 and #BSC-002, #BSC-003, improve code to save gas

* fix: issue #BSC-008, add comment to explain this

* feat: sync template code with origin code

* feat: rename len to validatorsNum

* chore: modify comment for check

* chore: sync template code

* chore: add more comments to explain `24-hour period`

* fix: k = 0 => k

* fix: j = 0 => j

* feat: sync template code for SlashIndicator.template

Co-authored-by: gothery001 <gothery001>

* fix: Bug fix that incorrectly modification of fixing audit report (#18)

* fix: incorrectly modified `initValidatorExtraSet`

* chore: sync template code

Co-authored-by: gothery001 <gothery001>

* fix: bug that slash count calculation problem while update validator set (#19)

* feat: add more test case to test slashCount calc problem

* fix: fix workValidatorCount calc incorrectly changed while updateValidatorSet

* chores: sync tmeplate code

* feat: add generate-qa script

* feat: close gas report as default

* feat: modify tests

* chores: add more comments

* chores: add more comments

Co-authored-by: gothery001 <gothery001>

Co-authored-by: dean65 <dean950605@gmail.com>
Co-authored-by: dean <97718205+dean65@users.noreply.github.com>
Co-authored-by: realuncle <walt@nodereal.io>
Co-authored-by: realuncle <90668111+realuncle@users.noreply.github.com>
Co-authored-by: realuncle <uncledude@sina.com>
Co-authored-by: gothery001 <gothery001>
  • Loading branch information
6 people committed Apr 27, 2022
1 parent ce622fe commit d3c441a
Show file tree
Hide file tree
Showing 19 changed files with 12,930 additions and 227 deletions.
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@ build/
pids
logs
.idea/
contracts/flattened/*.sol
contracts/flattened/*.sol

#Hardhat files
cache
artifacts

.env

types
typechain-types
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
artifacts
cache
node_modules
16 changes: 16 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"printWidth": 100,
"trailingComma": "es5",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"overrides": [
{
"files": "*.sol",
"options": {
"semi": true,
"printWidth": 100
}
}
]
}
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Install dependency:
npm install
```

Node: v12.18.3
Truffle: Truffle v5.1.31
Solc: 0.6.4+commit.1dca32f3.Darwin.appleclang
Ganache-cli: v6.10.1


## unit test

Generate contracts for testing:
Expand All @@ -27,7 +33,7 @@ node generate-relayerincentivizecontract.js --roundSize 30 --maximumWeight 3 --m

Start ganache:
```shell script
ganache-cli --mnemonic 'clock radar mass judge dismiss just intact mind resemble fringe diary casino' --gasLimit 13000000 -e 10000
ganache-cli --mnemonic 'clock radar mass judge dismiss just intact mind resemble fringe diary casino' --gasLimit 100000000 -e 10000 --allowUnlimitedContractSize
```

Run truffle test:
Expand All @@ -37,6 +43,12 @@ truffle migrate
truffle test
```

Run hardhat test:
```shell script
npx hardhat compile
npx hardhat test --network development
```

Flatten all system contracts:
```shell script
npm run flatten
Expand Down
Loading

0 comments on commit d3c441a

Please sign in to comment.