This repo holds all the genesis contracts on Core blockchain, which are part of the core implementations of Satoshi Plus consensus. For more information about Core blockchain and Satoshi Plus consensus, please read the technical whitepaper.
- System.sol: This contract defines system constants (such as the genesis contract addresses) and various modifiers that can be used across the system to limit the accessibility to function.
- BTCLightClient.sol: This contract implements a BTC light client on the Core blockchain. Relayers transmit BTC block headers to Core by calling this contract.
- It also calculates powers of BTC miners in each round, which is used to calculate hybrid score and reward distribution.
- It also provides support to verify Bitcoin transactions for BTC staking.
- Burn.sol: This contract burns CORE tokens up to pre-defined CAP.
- CandidateHub.sol: This contract manages all validator candidates on the Core blockchain. It also exposes the method
turnRound
for the consensus engine to execute theturn round
workflow. - Foundation.sol: This is the DAO Treasury smart contract. The funds in this contract can only be moved through governance vote.
- GovHub.sol: This is the smart contract to manage governance votes.
- PledgeAgent.sol: This contract manages user delegation, including both delegation of CORE from token holders and delegation of PoW from Bitcoin miners. This contract is deprecated since version 1.0.12 and it is replaced by Stakehub.sol and a few agent contracts.
- RelayerHub.sol: This contract manages BTC relayers on the Core blockchain.
- SlashIndicator.sol: This contract manages all slash and jail operations pertaining to validators on the Core blockchain.
- SystemReward.sol: This smart contract manages funds for relayers and verifiers.
- ValidatorSet.sol: This contract manages elected validators in each round. All rewards for validators on Core blockchain are minted in genesis block and stored in this contract.
- StakeHub.sol: This contract deals with overall hybrid score and reward distribution logics. It replaces the existing role of PledgeAgent.sol to interact with CandidateHub.sol and other protocol contracts during the turnround process.
- CoreAgent.sol: This contract handles CORE staking.
- HashPowerAgent.sol: This contract handles Bitcoin hash power staking (measured in BTC blocks).
- BitcoinAgent.sol: This contract handles BTC staking. It interacts with BitcoinStake.sol and BitcoinLSTStake.sol for non-custodial BTC staking and LST BTC staking correspondingly.
- BitcoinStake.sol: This contract handles non-custodial BTC staking.
- BitcoinLSTStake.sol: This contract handles LST BTC staking.
- BitcoinLSTToken.sol: ERC20 token contract of Core BTC LST.
Install ganache globally:
npm install -g ganache
Install dependency:
npm install
# install test dependency
pip install -r requirements.txt
brownie pm install OpenZeppelin/openzeppelin-contracts@4.9.6
# generate contracts for testing
./generate-test-contracts.sh
# run brownie tests
brownie test -v --stateful false
# run brownie tests in a single file
brownie test tests/{the-file-name.py} -v
# run brownie with a single testcase
brownie test -k <method-name> -v
Flatten all system contracts:
npm run flatten
- Edit
init_holders.js
file to alloc the initial CORE holders. - Edit
validators.js
file to alloc the initial validator set. - Edit
init_cycle.js
file to change core blockchain parameters. - Edit
generate-btclightclient.js
file to changeinitConsensusStateBytes
. - Run
node generate-genesis.js
to generate genesis.json.
The library is licensed under the Apache License, Version 2.0, also included in our repository in the LICENSE file.