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

feat: implement BEP294 and BEP297 #436

Merged
merged 70 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
3224c0a
feat: implement BEP294 and BEP297 (#404)
pythonberg1997 Nov 27, 2023
ab8b38e
feat: implement BEP299 (#391)
j75689 Nov 29, 2023
66bd1bc
chore: add init lock amount (#425)
pythonberg1997 Nov 29, 2023
cfc0bd1
chore: add redelegate fee (#426)
pythonberg1997 Nov 30, 2023
bfe54a9
feat: add comments and pause for governor (#428)
cosinlink Nov 30, 2023
a8f2b65
chore: fix typo and update scripts (#429)
pythonberg1997 Dec 4, 2023
1416b07
feat: add apy and reward record of validators (#430)
pythonberg1997 Dec 5, 2023
4a77036
feat: add ci to bc-fusion contracts and lint code (#431)
cosinlink Dec 5, 2023
843e4e3
feat: add python script (#433)
pythonberg1997 Dec 7, 2023
7b0e0be
Merge branch 'develop' into bc-fusion-bak
pythonberg1997 Dec 7, 2023
9350642
chore: fix bugs and add annotation for error msgs
pythonberg1997 Dec 8, 2023
1ed3964
Merge pull request #437 from Pythonberg1997/bc-fusion
unclezoro Dec 8, 2023
1c23cbe
fix: init params error in BSCGovernor (#439)
cosinlink Dec 11, 2023
3ca5fa6
chore: update storages and generate.py (#440)
pythonberg1997 Dec 11, 2023
5d9b19a
chore: disable editing moniker (#442)
pythonberg1997 Dec 12, 2023
a964f98
fix: update slash logic to avoid malicious slash (#444)
pythonberg1997 Dec 13, 2023
8fefaaa
chore: add check for moniker and update script (#445)
pythonberg1997 Dec 14, 2023
a913595
chore: ensure burnRatio plus systemRewardRatio not greater than 100% …
buddh0 Dec 15, 2023
e077181
fix: ensure validator incoming will be clear after distribution (#447)
pythonberg1997 Dec 15, 2023
710d0b7
chore: add view function and update annotations (#448)
pythonberg1997 Dec 21, 2023
9a2d43e
fix: recover sig failed in token recover portal (#451)
j75689 Dec 22, 2023
e06f8d4
fix: `felonySlashScope` not initialized (#452)
pythonberg1997 Dec 22, 2023
4e92c86
fix: resolve review comments (#454)
pythonberg1997 Jan 3, 2024
7dc57a4
fix: audit report (#455)
j75689 Jan 4, 2024
46c522b
feat: add whenNotPaused for queue in BSCGovernor (#456)
cosinlink Jan 4, 2024
1abdfbf
feat: add `handleSynPackage` to `StakeHub` (#457)
pythonberg1997 Jan 6, 2024
fe8749f
feat: add comment for governorProtector (#460)
cosinlink Jan 8, 2024
ea00161
chore: revert transaction when delegator in blacklist (#461)
pythonberg1997 Jan 8, 2024
14c65e8
chore: add `tmpValidatorSetUpdated` event (#462)
pythonberg1997 Jan 11, 2024
1e21529
fix: sync govToken in `_doMigration` (#463)
pythonberg1997 Jan 11, 2024
c069e9e
fix: add `isAutoUndelegate` for auto `DistributeUndelegatedSynPackage…
pythonberg1997 Jan 12, 2024
8e5e491
chore: fix issues from audit report (#465)
pythonberg1997 Jan 15, 2024
0c7a24f
feat: deprecate `transferOut` in `TokenHub` (#466)
pythonberg1997 Jan 15, 2024
4080c8a
fix: wrong jail time in `_checkValidatorSelfDelegation` (#471)
pythonberg1997 Jan 17, 2024
592b3fe
feat: add `whenNotPaused` to slash functions (#472)
pythonberg1997 Jan 22, 2024
32b126f
chore: add annotation (#474)
pythonberg1997 Jan 23, 2024
385240f
fix: disable burn in GovToken (#473)
cosinlink Jan 23, 2024
fdeb738
fix: check approval address is not 0x0 (#476)
j75689 Jan 29, 2024
2471ef8
feat: emit NotBoundToken event (#479)
j75689 Jan 29, 2024
adf418a
chore: update contracts init params to be consistent with mainnet set…
pythonberg1997 Jan 30, 2024
29886ae
docs: update tokenhub abi (#482)
j75689 Jan 30, 2024
0976d5d
fix: add upper limit for some params (#481)
pythonberg1997 Jan 30, 2024
1c4b711
chore: fix review comments (#483)
pythonberg1997 Jan 31, 2024
d859fff
chore: fix audit issues (#485)
pythonberg1997 Feb 1, 2024
59aa645
chore: refactor codes (#486)
pythonberg1997 Feb 4, 2024
a4082ef
chore: fix review comments (#489)
pythonberg1997 Feb 4, 2024
71aa8b6
fix: wrong flags passed in generate:dev (#490)
j75689 Feb 5, 2024
9721e51
feat: add governor test (#491)
cosinlink Feb 7, 2024
82d4ebc
test: add unit-test for TokenRecoverPortal (#492)
j75689 Feb 7, 2024
4c8af3c
fix report 8 issue 1
pythonberg1997 Feb 14, 2024
c990f51
fix report 8 issue 2
pythonberg1997 Feb 14, 2024
74c0dca
fix report 9 issue 2
pythonberg1997 Feb 14, 2024
f6b4d0f
fix report 9 issue 4
pythonberg1997 Feb 14, 2024
ffe4c8e
fix report 9 issue 7
pythonberg1997 Feb 14, 2024
197d78a
fix ToB report issue 5
pythonberg1997 Feb 15, 2024
7d89be2
fix ToB report issue 1
pythonberg1997 Feb 16, 2024
024babd
test: add failed cases to TokenRecoverPortal unit-test (#495)
j75689 Feb 16, 2024
94e556b
docs: update token recover portal abi (#498)
j75689 Feb 16, 2024
a454fa3
fix review comments
pythonberg1997 Feb 16, 2024
e1bc6ce
fix lint issue
pythonberg1997 Feb 16, 2024
915412e
Merge pull request #496 from Pythonberg1997/bc-fusion
unclezoro Feb 18, 2024
44e886b
fix: improve the code readablity (#499)
unclezoro Feb 18, 2024
5b4125b
fix: add check in `_forceMaintainingValidatorsExit` (#500)
pythonberg1997 Feb 18, 2024
1b0e806
chore: update npm script (#501)
pythonberg1997 Feb 19, 2024
e235f3b
feat: add more tests for governor (#502)
cosinlink Feb 19, 2024
0d9e767
feat: remove whitelist check while propose, move the check to queue a…
cosinlink Feb 19, 2024
ff4a2b1
fix: add check to make sure there is at least one validator in `_forc…
pythonberg1997 Feb 21, 2024
84995f8
fix: add empty address check and clear state before extracall (#507)
unclezoro Feb 26, 2024
7e38246
chore: update tokenrecoverportal.abi (#508)
pythonberg1997 Feb 26, 2024
9560688
chore: update testnet legacy address bytes (#509)
pythonberg1997 Feb 26, 2024
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
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
RPC_BSC=https://bsc-dataseed1.ninicoin.io

UNLOCK_RECEIVER=
OPERATOR_PRIVATE_KEY=
17 changes: 17 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
### Description

add a description of your changes here...

### Rationale

tell us why we need these changes...

### Example

add an example CLI or API response...

### Changes

Notable changes:
* add each change in a bullet point here
* ...
30 changes: 30 additions & 0 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Lint PR"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v4.5.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
feat
fix
docs
style
refactor
perf
test
build
ci
chore
revert
release
59 changes: 59 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Unit Test
on:
push:
branches:
- master
- develop
- bc-fusion
pull_request:
branches:
- master
- develop
- bc-fusion
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install Project Dependencies
run: |
npm install
forge install --no-git --no-commit foundry-rs/forge-std@v1.7.3

- name: Lint Check
run: |
npm run lint:check

- name: Build
run: |
forge build

- name: Start Local Chain
run: |
npm install pm2 -g
pm2 start --name local-chain "anvil -f https://bsc-dataseed1.ninicoin.io"
sleep 5
env:
PORT: 8545

- name: Unit Test
run: |
forge test --rpc-url http://127.0.0.1:8545
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ out/
pids/
logs/
cache/
broadcast/

contracts/flattened/*.sol

# foundry lib
lib/forge-std/

.env
**/.bak
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ Install foundry:
```shell script
curl -L https://foundry.paradigm.xyz | bash
foundryup
forge install --no-git --no-commit foundry-rs/forge-std@v1.1.1
forge install --no-git --no-commit foundry-rs/forge-std@v1.7.3
```

Please make sure your dependency version is as follows:

Node: v12.18.3

Install poetry:
```shell script
curl -sSL https://install.python-poetry.org | python3 -
poetry install
```

Tips: You can manage multi version of Node:
```Shell
Expand All @@ -46,7 +47,7 @@ forge test
## Flatten all system contracts

```shell script
bash flatten.sh
bash scripts/flatten.sh
```

All system contracts will be flattened and output into `${workspace}/contracts/flattened/`.
Expand All @@ -55,18 +56,18 @@ All system contracts will be flattened and output into `${workspace}/contracts/f

1. Edit `init_holders.js` file to alloc the initial BNB holder.
2. Edit `validators.js` file to alloc the initial validator set.
3. Run `bash scripts/generate-*.sh` to change system contracts setting.
3. Edit system contracts setting as needed.
4. Run `node scripts/generate-genesis.js` will generate genesis.json

## How to generate mainnet/testnet/QA genesis file
## How to generate mainnet/testnet/dev genesis file

```shell
bash scripts/generate.sh mainnet
bash scripts/generate.sh testnet
bash scripts/generate.sh QA
bash scripts/generate.sh local
poetry run python -m scripts.generate ${network}
```
Check the `genesis.json` file, and you can get the exact compiled bytecode for different network.
(`poetry run python -m scripts.generate --help ` for more details)

You can refer to `generate:dev` in `package.json` for more details about how to custom params for local dev-net.

## How to update contract interface for test

Expand Down
10 changes: 8 additions & 2 deletions abi/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ABI Files for Build-In System Contracts

| Contract Name | Address | ABI file name |
|-----------------------|--------------------------------------------|----------------------------------------------------|
| --------------------- | ------------------------------------------ | -------------------------------------------------- |
| BSCValidatorSet | 0x0000000000000000000000000000000000001000 | [bscvalidatorset](bscvalidatorset.abi) |
| SlashIndicator | 0x0000000000000000000000000000000000001001 | [slashindicator](slashindicator.abi) |
| SystemReward | 0x0000000000000000000000000000000000001002 | [systemreward](systemreward.abi) |
Expand All @@ -12,4 +12,10 @@
| GovHub | 0x0000000000000000000000000000000000001007 | [govhub](govhub.abi) |
| TokenManager | 0x0000000000000000000000000000000000001008 | [tokenmanager](tokenmanager.abi) |
| CrossChain | 0x0000000000000000000000000000000000002000 | [crosschain](crosschain.abi) |
| Staking | 0x0000000000000000000000000000000000002001 | [staking](staking.abi) |
| Staking | 0x0000000000000000000000000000000000002001 | [staking](staking.abi) |
| StakeHub | 0x0000000000000000000000000000000000002002 | [stakehub](staking.abi) |
| StakeCredit | 0x0000000000000000000000000000000000002003 | [stakecredit](stakecredit.abi) |
| BSCGovernor | 0x0000000000000000000000000000000000002004 | [bscgovernor](bscgovernor.abi) |
| GovToken | 0x0000000000000000000000000000000000002005 | [govtoken](govtoken.abi) |
| BSCTimelock | 0x0000000000000000000000000000000000002006 | [bsctimelock](bsctimelock.abi) |
| TokenRecoverPortal | 0x0000000000000000000000000000000000003000 | [tokenrecoverportal](tokenrecoverportal.abi) |
Loading
Loading