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) #510

Merged
merged 3 commits into from
Feb 26, 2024
Merged
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
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