Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
a9ebdbb
Update init_holders.js
unclezoro Apr 6, 2022
db8bb56
Implement bep-127 and bep-131 (#131) (#138)
cosinlink Apr 28, 2022
96107ce
[WIP]Fast Finality: reward distribution and slash parts (#8)
pythonberg1997 Mar 16, 2022
9de3519
Update for new fast finality rules and related issues
pythonberg1997 Apr 25, 2022
f6f201a
Revert code format changes
pythonberg1997 Apr 25, 2022
49393a8
Update BLS verify codes
pythonberg1997 Apr 26, 2022
c4aec01
Resolve conflict
pythonberg1997 Apr 28, 2022
dd58d05
Fix too deep stack issue
pythonberg1997 Apr 29, 2022
6da864d
Fix review comments
pythonberg1997 Apr 29, 2022
ce0bde1
Update slash evidence vote addr field
pythonberg1997 May 8, 2022
4b503fd
Update contracts' abi
pythonberg1997 May 19, 2022
4762d8c
Update finality reward related events
pythonberg1997 May 19, 2022
8929baa
Merge pull request #4 from Loverush/fast_finality
pythonberg1997 May 20, 2022
7148821
Update precompile contract related codes in SlashIndicator.sol
pythonberg1997 Jun 9, 2022
e6a481a
Fix review comments
pythonberg1997 Jun 10, 2022
8704b59
Fix format issues
pythonberg1997 Jun 10, 2022
e2b895b
Update for bytes concat
pythonberg1997 Jun 10, 2022
d39f1f5
Merge pull request #6 from Loverush/fast_finality_dev
pythonberg1997 Jun 11, 2022
7100748
Updated Links to docs.bnbchain.org (#147)
RumeelHussainbnb Jun 13, 2022
19adacc
Fix some audit comments
pythonberg1997 Jul 27, 2022
2008b6e
Minor issue fixed
pythonberg1997 Aug 15, 2022
e1c06f4
Merge remote-tracking branch 'Roshan/fast_finality_dev' into fast_fin…
pythonberg1997 Aug 15, 2022
2056f59
add brunoBlock and eulerBlock
realuncle May 5, 2022
ca34b47
add rebot address and relayer address
realuncle May 7, 2022
dd9bd84
BEP153: Native Staking Implementation (#163)
pythonberg1997 Aug 17, 2022
91c7ed2
Fix genesis-template.json error
pythonberg1997 Aug 17, 2022
1fd9fef
fix: update cross chain logic of native stake
pythonberg1997 Aug 25, 2022
ca70df1
fix: some review comments
pythonberg1997 Aug 26, 2022
6ed9417
update relayer fee design
pythonberg1997 Aug 27, 2022
64f5a2d
fix events params
pythonberg1997 Aug 29, 2022
0ff1f6d
fix some audit comments
pythonberg1997 Aug 30, 2022
9d45b31
Merge pull request #188 from bnb-chain/develop
pythonberg1997 Aug 31, 2022
a745ecc
update: fix some audit issues (#191)
pythonberg1997 Sep 30, 2022
4256ce7
fix: add height check for cross chain package
pythonberg1997 Oct 7, 2022
f63aba2
fix: refined description
pythonberg1997 Oct 8, 2022
1a675ef
close register for bsc relayers
yutianwu Oct 8, 2022
b67799d
add template and fix the tests
yutianwu Oct 8, 2022
c554c56
add missing file
yutianwu Oct 8, 2022
71dcd4c
fix test case
unclezoro Oct 8, 2022
aef88e6
remove duplicated code
unclezoro Oct 9, 2022
8a77ec8
fix: stack too deep error
pythonberg1997 Oct 9, 2022
537dc4a
update: add height check to save gas
pythonberg1997 Oct 9, 2022
c0a7af0
enhance: add whitelabe relayers
unclezoro Oct 10, 2022
c184a00
fix typo
unclezoro Oct 11, 2022
8cfa94e
fix: upload the render code (#199)
unclezoro Oct 11, 2022
ad7b631
feat: add foundry test (#194)
pythonberg1997 Dec 13, 2022
d98c857
docs: add how to generate mainnet/testnet/QA genesis file (#221)
unclezoro Dec 19, 2022
97251c4
Merge remote-tracking branch 'BNB-chain/develop' into fast_finality
pythonberg1997 Jan 10, 2023
c33c1e9
resolve conflict and adapt to new precompile bls verify contract
pythonberg1997 Jan 16, 2023
6a04bc3
fix: recover deleted verifyBLSSignature function call
pythonberg1997 Jan 16, 2023
999d32e
fix: revert modification for local unit test
pythonberg1997 Jan 16, 2023
f43d020
fix: errors with template
pythonberg1997 Jan 16, 2023
9ba6fb2
Merge pull request #13 from Pythonberg1997/fast_finality_dev
realuncle Jan 17, 2023
320f0e1
fix: delete unused files
pythonberg1997 Jan 19, 2023
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
17 changes: 13 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
node_modules/
build/
.idea
pids
logs
out/
.idea/
contracts/flattened/*.sol
pids/
logs/
cache/

contracts/flattened/*.sol

# foundry lib
lib/forge-std/

.env
package-lock.json
yarn.lock
9 changes: 0 additions & 9 deletions .soliumignore

This file was deleted.

9 changes: 0 additions & 9 deletions .soliumrc.json

This file was deleted.

45 changes: 45 additions & 0 deletions BLSkeystore.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"public_key": [
"8f2bc5decb56ad5f88d4c704f6ad616d5038cf1bc068419f4d7f3457a853d74048b1ba3531185d6d36d6bd6881034505",
"83126cd32592a6be5e9658805c5da32db2f5d39f2f294a230cf1689b52f8b8be2135802f6b6ca6b11765331de2bb8def",
"b9cafd2354b57acadd88992fd9dc38986ec29d8efd793acb693f0d0f6b8397cb2a9f8d66e01253579c7d38242d3760f6",
"b373f6a4dfc54e625c2796da0789cbb243e6a285329c3c075ab1a9268db45951a2d6c2a2aafd558efc8c5857bd71dbc0",
"ac0646a7851a75f2d0d8239e717ed1874ed83906eff3845cc7a29abd6064adb8a48c221c3d12624f136292b19c0d92de",
"992354e0ff65e8cb4088a72a241992bf68a192ea685f810bda7a193dc056af3be4bf1f65073cf5e906676d32f2eabe60",
"95d8bb8660a34a374a05a3b9c59609f4a6f5598bba8240b59ef61e94ed6161e00108bac0b817bcb4cf13001924d19539",
"b4c030c9c012ab39aea3117fc96203b18ffb5e979ae44f17de64e212a1a97975d419e2060294940a285778e2100ff023",
"ac1e598ae0ccbeeaafa31bc6faefa85c2ae3138699cac79169cd718f1a38445201454ec092a86f200e08a15266bdc6e9",
"af3ca3f530c61bf7e6b82db58dc6bd4c75192044128004510290289330ae1d33269ec873e0a8e890c2619cf3868c8880",
"987c6c786c2d293f4b5337344c8d29ab0264f80851d5698e597e201f7743af3f848a1ffb7c4802a73e06696d99f95e45",
"97d9423cb780f6a09e759a7327fc5e2542ddc54f9d2cd1b836abf30948f45059709510e8421df03ceccf2ef2ecc9c594",
"b71f0d38cc1d05995126fa0ba311541f0ed3c5c7df64e33c8037afa5d72a5a38a83103433b204f1512502748656cf06f",
"b800c8a040b76946ca14470e7a67c9ca76bf9868730336be57235505e1786f3417a969587be2ac7e6aad1ab21db9cff9",
"a625e9aa0681a842091d9cbc26daa9497a9d305acc36d04f2cb42e9aed90a561514f607625fbf84b23f98ce4baadadb5",
"98a7250b7492047cdb0b388e094db5dc073bba5a4bfc9ed2fc0ec68cba5cec1aad06d72a91ed03211f583f52e5e5d221",
"a8fa139e60271c25de8d5c83a4d0d15107152c193897d2307d334425c40d31104b6ee507e5eb3402419bca0625b58835",
"905024253dae51eb1836a3da59e5883f48d768bb73b4c8be76fd3a124af6ed252941653619ab1e429253fc2586c65383",
"a52c02e1279cbadb974a02404d7cece18d70a2835d004a4e7a25c9e120d794f62e76b9728a13ee84bc6567716238c59f",
"aacd7b81831bc19de3a26f013d2bba8cf5a76cf3c6acee742bace02e2a809a96f72245fb6cb54874b72d300a42b14fe3",
"8f16d65d4898459265d237328b419fad130b2cf2ee381e0a0fc3d5898e81b577a0157d0b99b92eda8891b46ff62c9ea9",
"90ddfd09c9af4d0b693a4013b7e42595ea7bb60ee7fb942a8460d63cd5f0e4c3138467b7c2a50518fa26fe9a2450dbc0",
"a2ec2a7e46bb5d99e7307c39b9ba96e0ef245e2588658b5ccb9a8c2f682a111de5775fec6e7508d19e06be40a260cc7d",
"86d0488587c7dd682988d13c7db0bf9994dd21fa886244a1ddd24aea753de38d32d0c762bd6fbeb137b1ae3118c65885",
"b3e34b6aff02bf146faf47e27d813e3c1bcf2a9a424c2ec95da39ea9dd974aeb239e47bd183ac75e8502ca6e610caf7c",
"b45752f376347597826c52202dd5a4695b7f73b4a111d9a39f8bd43220984ecd428280779befa314f4b24ce537b7448b",
"83c96f5cab6a2d0fb3c4c96c7a1bf992c776f10aa6e321157df8b07359bbfdc111587f529d3ed867b1c69a98f57fea6b",
"9107b995298a0a2becc7a1feecc6d8a0cae95d66384ef08adb9dc74023357fb5c1dac1ce9de936eb4015d276150a4933",
"aa7049b3ce18e503b8546b08ef48056780cfeb4a48e50f30d0da8a2b6261e77ed19c40bc8050df874e992072db591575",
"b28f8221b85d07f04d6037a56d96e621d4c25bf3aaff3e745231bcf102dfa34508ca92814854019487b6dcecdaa0bab0",
"a75e47260f047889767fc8cc7121440afa2b4fc372ebc1ef39f72912247ad2efa1e0dc4022d4c44ecab95032fa30df49",
"a76daaa9e8741e7d9a5970f10bc585ce42a3e5ce4e53faadf3327a3b7759223e35aeb30214c0ecf2bca46a2ea1c45855",
"a031dcf5b47643630aba6e0625c21da9e0f76388ea6bcdd33ede31f51a1d080ba322ba0c9aaa5137b18fd3c47453aec9",
"a9be92a80b0909c491cd9475001cc34ee1a766b95109cdc32c8cdfcf7135c8d0e862b8612d0ea79e74d02a09d5403993",
"b490893e8eb5f101b5178e6ff8279fe14eb78b764290095e6e595dfcc11371925dc0af4b9d4bce8e69ac83ce57984e3a",
"89ca38e186e1378b0778cb8d4f0f6d4eef4a15db97a4596a44621548090dfb893f833689b580b0f60a934fd31c271bb3",
"8b20e24ad933b9af0a55a6d34a08e10b832a10f389154dc0dec79b63a38b79ea2f0d9f4fa664b3c06b1b2437cb58236f",
"a1484f2b97137fb957daad064ca6cbe5b99549249ceb51f42e928ec091f94fed642ddffe3a9916769538decd0a9937bf",
"89abcc45efe76bec679ca35c27adbd66fb9712a278e3c8530ab25cfaf997765aee574f5c5745dbb873dbf7e961684347",
"8addebd6ef7609df215e006987040d0a643858f3a4d791beaa77177d67529160e645fac54f0d8acdcd5a088393cb6681",
"85e6972fc98cd3c81d64d40e325acfed44365b97a7567a27939c14dbc7512ddcf54cb1284eb637cfa308ae4e00cb5588"
]
}
91 changes: 63 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,91 @@
# bsc-genesis-contracts

This repo hold all the genesis contracts on Binance Smart chain. More details in [doc-site](https://github.com/binance-chain/docs-site/blob/add-bsc/docs/smart-chain/guides/concepts/system-contract.md).
This repo hold all the genesis contracts on Binance Smart chain. More details in [doc-site](https://docs.bnbchain.org/docs/learn/system-contract).

## Prepare

Install dependency:
Install node.js dependency:
```shell script
npm install
```

## unit test
```

Generate contracts for testing:
Install foundry:
```shell script
# the first account of ganache
node generate-system.js --mock true
node generate-systemReward.js --mock true
node generate-validatorset.js --mock true
node generate-system.js --mock true
node generate-slash.js --mock true
node generate-crosschain.js --mock true
node generate-tokenhub.js --mock true
node generate-tendermintlightclient.js --mock true
node generate-relayerincentivizecontract.js --roundSize 30 --maximumWeight 3 --mock true
```

Start ganache:
```shell script
ganache-cli --mnemonic 'clock radar mass judge dismiss just intact mind resemble fringe diary casino' --gasLimit 13000000 -e 10000
curl -L https://foundry.paradigm.xyz | bash
foundryup
forge install --no-git --no-commit foundry-rs/forge-std@v1.1.1
```

Please make sure your dependency version is as follows:

Node: v12.18.3

Truffle: v5.1.31

Solc: 0.6.4+commit.1dca32f3

Tips: You can manage multi version of Solc and Node:
```Shell
## Install solc-select and solc
pip3 install solc-select
solc-select install 0.6.4 && solc-select use 0.6.4

## Install nvm and node
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
nvm install 12.18.3 && nvm use 12.18.3
```

## Unit test

Add follow line to .env file in project dir, replace `archive_node` with a valid bsc mainnet node url which should be in archive mode:

```text
RPC_BSC=${archive_node}
```

Run truffle test:
You can get a free archive node endpoint from https://nodereal.io/.

Run forge test:
```shell script
truffle compile
truffle migrate
truffle test
forge test
```

Flatten all system contracts:
## Flatten all system contracts

```shell script
npm run flatten
```

## how to generate genesis file.

All system contracts will be flattened and output into `${workspace}/contracts/flattened/`.

## How to generate genesis file

1. Edit `init_holders.js` file to alloc the initial BNB holder.
2. Edit `validators.js` file to alloc the initial validator set.
3. Edit `generate-validatorset.js` file to change `fromChainId` and `toChainId`,
4. Edit `generate-tokenhub.js` file to change `refundRelayReward`, `minimumRelayFee` and `maxGasForCallingBEP20`.
5. Edit `generate-tendermintlightclient.js` file to change `chainID` and `initConsensusStateBytes`.
6. run ` node generate-genesis.js` will generate genesis.json

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

```shell
npm run generate-mainnet
npm run generate-testnet
npm run generate-QA
```
Check the `genesis.json` file and you can get the exact compiled bytecode for different network.

## How to update contract interface for test

```shell script
// get metadata
forge build

// generate interface
cast interface ${workspace}/out/{contract_name}.sol/${contract_name}.json -p ^0.8.10 -n ${contract_name} > ${workspace}/lib/interface/I${contract_name}.sol
```

## License

The library is licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0),
Expand Down
25 changes: 13 additions & 12 deletions abi/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# 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) |
| TendermintLightClient |0x0000000000000000000000000000000000001003 | [tendermintlightclient](tendermintlightclient.abi) |
| TokenHub |0x0000000000000000000000000000000000001004 | [tokenhub](tokenhub.abi) |
| RelayerIncentivize |0x0000000000000000000000000000000000001005 | [relayerincentivize](relayerincentivize.abi) |
| RelayerHub |0x0000000000000000000000000000000000001006 | [relayerhub](relayerhub.abi) |
| GovHub |0x0000000000000000000000000000000000001007 | [govhub](govhub.abi) |
| TokenManager |0x0000000000000000000000000000000000001008 | [tokenmanager](tokenmanager.abi) |
| CrossChain |0x0000000000000000000000000000000000002000 | [crosschain](crosschain.abi) |
| Contract Name | Address | ABI file name |
|-----------------------|--------------------------------------------|----------------------------------------------------|
| BSCValidatorSet | 0x0000000000000000000000000000000000001000 | [bscvalidatorset](bscvalidatorset.abi) |
| SlashIndicator | 0x0000000000000000000000000000000000001001 | [slashindicator](slashindicator.abi) |
| SystemReward | 0x0000000000000000000000000000000000001002 | [systemreward](systemreward.abi) |
| TendermintLightClient | 0x0000000000000000000000000000000000001003 | [tendermintlightclient](tendermintlightclient.abi) |
| TokenHub | 0x0000000000000000000000000000000000001004 | [tokenhub](tokenhub.abi) |
| RelayerIncentivize | 0x0000000000000000000000000000000000001005 | [relayerincentivize](relayerincentivize.abi) |
| RelayerHub | 0x0000000000000000000000000000000000001006 | [relayerhub](relayerhub.abi) |
| GovHub | 0x0000000000000000000000000000000000001007 | [govhub](govhub.abi) |
| TokenManager | 0x0000000000000000000000000000000000001008 | [tokenmanager](tokenmanager.abi) |
| CrossChain | 0x0000000000000000000000000000000000002000 | [crosschain](crosschain.abi) |
| Staking | 0x0000000000000000000000000000000000002001 | [staking](staking.abi) |
Loading