Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinzhou-rockx authored Aug 16, 2024
2 parents 235b604 + a646f89 commit b86e22b
Show file tree
Hide file tree
Showing 12 changed files with 289 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bbn-1/finality-providers/registry/0xbojack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"description": {
"moniker": "0xbojack",
"identity": "933397D7278E6F1C",
"website": "https://x.com/coder_chao",
"security_contact": "[email protected]",
"details": "Node Runner"
},
"eots_pk": "be269d18c63f87af05b6311ed4ecc31bc3ca974b18d7f008cf717a710653c7c4",
"commission": "0.05"
}
11 changes: 11 additions & 0 deletions bbn-1/finality-providers/registry/Decentr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"description": {
"moniker": "Decentr",
"identity": "FD3C0BCE9D7F7CF5",
"website": "https://decentr.net",
"security_contact": "[email protected]",
"details": "Decentr maintain a distributed ledger, a shared copy of the blockchain's transaction history."
},
"eots_pk": "59f19690c77004d0f4222c628cb5270e5a7a5c171987e89e33ba18d3e1a28abc",
"commission": "0.05"
}
12 changes: 12 additions & 0 deletions bbn-1/finality-providers/registry/P2P_org.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"description": {
"moniker": "P2P.org",
"identity": "E12F46954695036D",
"website": "https://p2p.org/",
"security_contact": "[email protected]",
"details": "P2P.org is a leading platform for whitelable staking infrastructure and staking solutions for enterprise and intermediaries. Stake your BTC with the most trusted and secure validator in the market."
},
"eots_pk": "d7442b3c1b2c85313f9440a0a0e783f5d56390bd2e9044bb4e10c48e6b6d5536",
"commission": "0.05"
}

11 changes: 11 additions & 0 deletions bbn-1/finality-providers/registry/stakeway.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"description": {
"moniker": "Stakeway",
"identity": "8950F17AEC66D51C",
"website": "https://stakeway.com/",
"security_contact": "[email protected]",
"details": "Stakeway by Gateway.fm is a premier staking provider offering Enterprise Grade Infrastructure tailored for customers seeking reliable and secure staking solutions. With a focus on performance and trust, we deliver a robust platform. Our services are designed to optimize staking experience, ensuring seamless operation and maximum returns"
},
"eots_pk": "e245e8c85759d5410c723b69809c405fedbb2393665a43e44b40752452806555",
"commission": "0.05"
}
1 change: 1 addition & 0 deletions bbn-1/finality-providers/sigs/0xbojack.sig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d5275fe1236a67e4a0664d114ad8055432b8967b0b1b1730f6ba69d7dc85354deaaebdd7130e757db6fb94a2d92293e21f948e790112f67a407fbef7871c36e4
1 change: 1 addition & 0 deletions bbn-1/finality-providers/sigs/Decentr.sig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3986f1837854545cc23ddd0ddde8b3ac717461e609083ed73826718960c806b37d93029eaa3ddcabe918c637eb37e0de264dc3f789465092061aecbae9b0c9f4
1 change: 1 addition & 0 deletions bbn-1/finality-providers/sigs/P2P_org.sig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0eac3cd6185e25758984288ea08464cb73dc44e6b70235418452ad9d6048fae05ff5e61b4d6996bcc773b8688b9e8d469b3d0b1873fa50b11b51cff26838e888
1 change: 1 addition & 0 deletions bbn-1/finality-providers/sigs/stakeway.sig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8790c655bed9a7925b70023928943529e4e0446e29af411c1689192546eb366fbd0dda391fea74b1324dcc2e030e6849867c947f405a2469dbb0d6620c4146e0
Binary file added bbn-1/integration/assets/system-detailed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bbn-1/integration/assets/system-high-level.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 125 additions & 0 deletions bbn-1/integration/staking-backend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Operating a Bitcoin Staking Backend

In this document we describe a reference tech stack employed by Babylon for a
back-end service that collects information about the Babylon staking system from
Bitcoin and processes unbonding requests performed by users.
The entirety or part of this tech stack can be employed by staking providers
to build Bitcoin Staking applications.

This graphic demonstrates the architecture of the reference staking
back-end tech stack. In the following sections, we will go through the
components involved in more detail.
![Architecture](./assets/system-detailed.png)

## External Components

### Bitcoin

Bitcoin serves as the decentralized ledger that stores and orders the staking
transactions for the lock-only network.

The system defines a set of
[global parameters](../parameters) that specify what constitutes a valid
staking transaction that the system recognizes. Transactions that are on
Bitcoin and adhere to the staking parameters are considered as valid staking
transactions.

### Staking Transactions

The system defines three types of transactions:
- *Staking* which creates new stake by locking BTC in the self-custodial
Bitcoin Staking script,
- *Unbonding* which unbonds stake from the Bitcoin staking script before the locking expires, and
- *Withdraw* which extracts unlocked/unbonded stake to the staker's address.

The full spec of the transactions involved in the Bitcoin staking protocol can be found
[here](https://github.com/babylonlabs-io/babylon/blob/v0.9.x/docs/staking-script.md).

Participants of the system can create staking transactions either through the
staking dApp or the staker CLI:
- The [Staking dApp](https://github.com/babylonlabs-io/simple-staking/tree/main)
is a user-friendly application allowing users to create, sign, and submit
staking transactions to the Bitcoin ledger.
It can either be built directly inside the Bitcoin wallet or can connect
to a wallet. It communicates with a back-end service (described later) that
has access to an unbonding pipeline in order to submit unbonding requests.
- The [Staker CLI](https://github.com/babylonlabs-io/btc-staker/tree/v0.5.x)
is a command line tool for power users that want full control
on how their staking transaction is constructed. Stakers utilize the CLI to
construct Bitcoin staking transactions and are responsible for signing them
through a wallet of their choice and submitting them to the Bitcoin ledger or
the Staking API service in the case of unbonding.

One could also build their own staking application and interact with the staking backend.

### Covenant Emulation Committee

The covenant emulation committee is a set of entities responsible for approving
on-demand unbonding requests. The members of the committee operate a
[covenant signer](https://github.com/babylonlabs-io/covenant-signer/tree/v0.2.x)
program which involves a server that accepts requests that contain unbonding
requests that require the covenant emulator’s signature.
If the requests are valid, then the signature is returned in the response.
The covenant signer servers are contacted by a back-end unbonding pipeline
(described later) which collects their signatures before forwarding the fully
signed transaction to Bitcoin.
Note that the unbonding transaction requires the staker's signature, so the
covenant committee cannot consume the staking transaction
without the staker's approval.

The list of covenant emulation committee members is a global parameter, and the
signer servers can be accessed from all instances of the staking back-ends.

## BackEnd Staking System Components

### [Staking Indexer](https://github.com/babylonlabs-io/staking-indexer/tree/v0.2.x)

The staking indexer is a daemon that monitors the Bitcoin ledger for Bitcoin
Staking and Unbonding transactions. It consumes the
[system parameters](../parameters) to identify whether a staking transaction
is valid and its activity status. Valid staking transactions are stored in a
database and sent to RabbitMQ queues for further consumption by clients.

### [Staking API](https://github.com/babylonlabs-io/staking-api-service/tree/v0.2.x)

The staking API is a service that provides information about the state
of the staking system and collects unbonding requests for further processing.

The API consumes staking events from the RabbitMQ queues the staking indexer
writes to. Based on those events, it calculates the status of delegations
(e.g. delegation has been successfully unbonded) and calculates information
about the state of the system (e.g. staker delegations, TVL, etc.) to provide
to consumers. It monitors for delegation expiration by consuming from the
RabbitMQ queue the expiry checker writes to.

In the case of an unbonding request, the API verifies it and stores it in
a database for further consumption by the unbonding pipeline.

### [Expiry Checker](https://github.com/babylonlabs-io/staking-expiry-checker/tree/v0.1.x)

The staking expiry checker is a micro-service that reads staking transactions
from a database and checks whether their timelock has expired by comparing it
to the current Bitcoin height.
Once a delegation expires,
the expiry checker submits an event to a RabbitMQ queue for further consumption
by clients.

### [Unbonding Pipeline](https://github.com/babylonlabs-io/cli-tools/tree/v0.2.x)

The unbonding pipeline is a process that is run periodically to execute
pending unbonding requests.
It reads from the database the API writes unbonding requests to,
verifies the validity of the requests, and
connects to the covenant emulator committee members to collect their signatures.
Once a sufficient number of signatures is collected,
the fully signed unbonding transaction is sent to Bitcoin.

## Interoperability

Interoperability between staking providers requires that
there’s consensus on the following:
- *Staking Parameters*: All staking providers have utilize the same
staking parameters.
- *Staking Transactions*: All staking providers validate the
staking transactions in the same way and reach the same conclusions on their
status (e.g. actie, expired, unbonding, etc.)
115 changes: 115 additions & 0 deletions bbn-1/integration/wallet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Wallet Integration

The `bbn-1` network will focus on the security of the staked Bitcoins by
allowing the user's to interaction with the BTC mainnet network directly for staking.
It will be a lock-only network in which Bitcoin stake is going to be
created without a Babylon chain operating. Stakers can lock their funds for a
specific timelock and on-demand unbond if they want to unlock earlier than
that.

The system is thus quite simple. It involves:
- A UI/UX that can generate Bitcoin Staking and Unbonding transactions
and sign them through an interaction with a Bitcoin signer (e.g. a wallet).
- A Bitcoin node that propagates transactions to the Bitcoin network and
is accessible by the UI/UX, either directly or through a wallet.
- A back-end system that indexes Bitcoin to collect information about the
system and identify which stake is valid, as well as process unbonding
requests.

The following figure shows a high-level overview of the system:

![System High Level](./assets/system-high-level.png)

In the following sections we explore the different ways a wallet can integrate
Bitcoin Staking and the materials required for each kind of integration.

## Ways to Integrate Bitcoin Staking

### 1. Extension Wallet

**Option-1**, be added to a third-party’s Bitcoin staking website.
This requires collaboration with the host of the website and
exposing compatible APIs.
To integrate with the Babylon hosted staking website, please check the
interface your wallet (or a wrapper of it) should adhere to
[here](https://github.com/babylonlabs-io/simple-staking/blob/main/docs/WalletIntegration.md).

**Option-2**, host your own Bitcoin staking website that
connects to your extension wallet that retrieves staking
information from a back-end you operate.
- To integrate with a staking website that uses the Babylon reference staking
dApp [implementation](https://github.com/babylonlabs-io/simple-staking/tree/main), please
check the interface your wallet (or a wrapper of it) should adhere to
[here](https://github.com/babylonlabs-io/simple-staking/blob/main/docs/WalletIntegration.md).
- For information about developing your own Bitcoin staking website, please check
- our [TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/tree/main)
and [Golang](https://github.com/babylonlabs-io/babylon/tree/v0.9.x/btcstaking/identifiable_staking.go)
Bitcoin Staking libraries.
- our reference web application [implementation](https://github.com/babylonlabs-io/simple-staking/tree/main).
- For information about operating your own back-end, please read this
[document](./staking-backend.md)

**Option-3**, develop Bitcoin staking as a feature of your extension wallet,
which connects to either third party APIs
(such as the Babylon [API](https://staking-api.babylonlabs.io/swagger/index.html)) or a back-end you operate.
- For information about developing your own Bitcoin staking as a feature, please check
- our [TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/tree/main)
and [Golang](https://github.com/babylonlabs-io/babylon/tree/v0.9.x/btcstaking/identifiable_staking.go)
Bitcoin Staking libraries.
- our reference web application [implementation](https://github.com/babylonlabs-io/simple-staking/tree/main).
- For information about operating your own back-end, please read this
[document](./staking-backend.md)

### 2. Mobile App Wallet

**Option-1**, embed a third-party Bitcoin staking website to your mobile app
wallet, which interacts with the BTC signer inside your wallet via
app window interface.
To embed on the Babylon hosted staking website, please check the
interface your mobile wallet (or a wrapper of it) should adhere to
[here](https://github.com/babylonlabs-io/simple-staking/blob/main/docs/WalletIntegration.md).

**Option-2**, host your own Bitcoin staking website that connects to your
extension wallet that retrieves staking information from a back-end you
operate. Then embed your own Bitcoin staking website to your mobile app wallet.
- To integrate with a staking website that uses the Babylon reference staking
dApp [implementation](https://github.com/babylonlabs-io/simple-staking/tree/main), please
check the interface your mobile wallet (or a wrapper of it) should adhere to
[here](https://github.com/babylonlabs-io/simple-staking/blob/main/docs/WalletIntegration.md).
- For information about developing your own Bitcoin staking website, please check
- our [TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/tree/main)
and [Golang](https://github.com/babylonlabs-io/babylon/tree/v0.9.x/btcstaking/identifiable_staking.go)
Bitcoin Staking libraries.
- our reference web application [implementation](https://github.com/babylonlabs-io/simple-staking/tree/main).
- For information about operating your own back-end, please read this
[document](./staking-backend.md)

**Option-3**, develop Bitcoin staking as a feature of your extension wallet,
which connects to either third party APIs
(such as the Babylon [API](https://staking-api.babylonlabs.io/swagger/index.html)) or a back-end you operate.
- For information about developing Bitcoin staking as a feature, please check
- our [TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/tree/main)
and [Golang](https://github.com/babylonlabs-io/babylon/tree/v0.9.x/btcstaking/identifiable_staking.go)
Bitcoin Staking libraries.
- our reference web application [implementation](https://github.com/babylonlabs-io/simple-staking/tree/main).
- For information about operating your own back=end, please read this
[document](./staking-backend.md)

### 3. Hardware Wallet

**Option-1**, develop Bitcoin staking as a feature of your extension wallet,
which connects to either third party APIs
(such as the Babylon [API](https://staking-api.babylonlabs.io/swagger/index.html)) or a back-end you operate.
- For information about developing your own Bitcoin staking website, please check
- our [TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/tree/main)
and [Golang](https://github.com/babylonlabs-io/babylon/tree/v0.9.x/btcstaking/identifiable_staking.go)
Bitcoin Staking libraries.
- our reference web application [implementation](https://github.com/babylonlabs-io/simple-staking/tree/main).
- For information about operating your own back-end, please read this
[document](./staking-backend.md)

**Option-2**, integrate via a compatible software wallet (extension or mobile)
that is Bitcoin staking enabled.
To embed on the Babylon hosted staking website, please check the
interface your hardware wallet (or a wrapper of it) should adhere to
[here](https://github.com/babylonlabs-io/simple-staking/blob/main/docs/WalletIntegration.md).

0 comments on commit b86e22b

Please sign in to comment.