Skip to content

One Stake, Endless Opportunities. Build with Polkadot SDK (Substrate).

License

Notifications You must be signed in to change notification settings

bifrost-io/bifrost

Repository files navigation

Bifrost Banner

Bifrost Logo

Welcome,

Bifrost is a Web3 derivatives protocol that provides decentralized cross-chain liquidity for staked assets. By leveraging on the cross-consensus message (XCM) it can provide cross-chain liquid staking services for multiple chains.

Our mission is to provide standardized cross-chain interest-bearing derivatives for Polkadot relay chains, parachains, and heterogeneous chains bridged with Polkadot.

👉 Discover the Bifrost at bifrost.io.
👉 Learn to use the Bifrost with our docs.

🐣 Supported by

Web3 Foundation Grants Substrate Builders Program Web3 Bootcamp

master-build Codacy Badge Substrate Version License Dapp Analytics Discord Twitter

Get Build Help

make help

Install Rust and required tools

curl https://sh.rustup.rs -sSf | sh
make init

Build binary

make build-all-release

Format code

make format

Lint code

make clippy

Testing

make test-all

Generate runtime weights

if runtime logic change we may do the benchmarking to regenerate WeightInfo for dispatch calls

make generate-all-weights

Testing runtime migration

If modify the storage, should test the data migration before production upgrade.

# bifrost kusama
make try-kusama-runtime-upgrade

# bifrost polkadot
make try-polkadot-runtime-upgrade

Run development chain

run node with --chain=bifrost-polkadot-dev to enable development mode.

Before use dev mode, modify OnTimestampSet to be ()

impl pallet_timestamp::Config for Runtime {
	type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
	/// A timestamp: milliseconds since the unix epoch.
	type Moment = Moment;
   -type OnTimestampSet = Aura;
   +type OnTimestampSet = ();
	type WeightInfo = pallet_timestamp::weights::SubstrateWeight<Runtime>;
}

Run local testnet with polkadot-launch

Install polkadot-launch

yarn global add polkadot-launch
cd -

Build polkadot

# replace version with your target polkadot version
cargo install --git https://github.com/paritytech/polkadot --tag <version> polkadot --locked

Launch Polkadot and the parachain

cd -
polkadot-launch ./scripts/bifrost-launch.json

It will take about 1-2 minutes for the parachain to start producing blocks.

Run local testnet with parachain-launch

Install parachain-launch

yarn global add @open-web3/parachain-launch

Generate docker files

parachain-launch generate --config=scripts/bifrost-docker-launch.yml --yes

It will pull images and generate required docker files in a folder called output in your current working directory

Start relaychain and parachain

To start the nodes, navigate to the output folder that the generated docker scripts in and start containers:

cd ./output
docker-compose up -d --build

Run full node

Create bifrost-fullnode directory, generate node-key and get bifrost.json

mkdir -p ~/node-key
subkey generate-node-key --file ~/node-key/bifrost.key

Start full node

Replace your-fullnode-name

docker pull bifrostnetwork/bifrost:latest
docker run -d \
-v ~/node-key:/node-key \
-p 9944:9944 \
-p 9933:9933 \
-p 30333:30333 \
bifrostnetwork/bifrost:latest \
  --name your-fullnode-name \
  --base-path "/data" \
  --node-key-file "/node-key/bifrost.key" \
  --chain "/spec/bifrost.json" \
  --pruning=archive \
  --rpc-external \
  --ws-external \
  --rpc-cors all \
  --trie-cache-size 0 \
  --execution wasm

snapshot

There are also some snapshots you can use to quickly get started, these are provided by the community.

  • Pre-req .

    zstd and aria2

    sudo apt install zstd
    sudo apt install aria2

bifrost-kusama snapshots

  • relay-chain data
# download dict
wget https://snapshot-1258776962.cos.ap-hongkong.myqcloud.com/bifrost-kusama/relay.dict

# download zst data
aria2c -x10 https://snapshot-1258776962.cos.ap-hongkong.myqcloud.com/bifrost-kusama/relay.tar.zst

# decompress: node is basepath, you can replace any dicrectory you like
mkdir node
tar -I 'zstd -vd -T0 -D relay.dict' -xvf relay.tar.zst -C node/.
  • parachain data
wget https://snapshot-1258776962.cos.ap-hongkong.myqcloud.com/bifrost-kusama/para.dict
aria2c -x10  https://snapshot-1258776962.cos.ap-hongkong.myqcloud.com/bifrost-kusama/para.tar.zst

tar -I 'zstd -vd -T0 -D para.dict' -xvf para.tar.zst -C node/.

bifrost-polkadot snapshots

link: