-
Notifications
You must be signed in to change notification settings - Fork 8
Dev Branch - staking backend docs + audit section update #65
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
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a5d60bb
moved staking backend content locally
web3jenks 37aac6b
Update docusaurus.config.js
web3jenks 3093d2d
moved content
web3jenks 92df527
Jenks/move staking backend docs (#64)
web3jenks bfc8f60
updated as per vitalis fieedback
web3jenks f539dcb
Update audit_reports.mdx
web3jenks 1b5f00e
Restructruing of wallet integration (#67)
web3jenks 738eaf4
Jenks/move wallet integration (#68)
web3jenks c2d0474
fix: remove useless auth code
fb9796c
feat: adjust the crawling method
97e919c
fix: Card style disorder
03f0556
fix: move the backend to developer part
8a4dbc8
chore: del useless code & optimization build warning (#70)
kkkk666 7b0bc3e
moved Staking Backend sidebar position up
web3jenks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| title: Staking Backend | ||
| sidebar_label: Staking Backend | ||
| sidebar_position: 4 | ||
| --- | ||
|
|
||
| # Staking Backend | ||
|
|
||
| import { Redirect } from '@docusaurus/router'; | ||
|
|
||
| <Redirect to="/guides/networks/phase-2/testnet/staking_backend/" /> | ||
8 changes: 8 additions & 0 deletions
8
docs/developers/wallet_integration/babylon_wallet_integration/_category_.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "label": "Babylon Wallet Integration", | ||
| "position": 1, | ||
| "link": { | ||
| "type": "generated-index", | ||
| "description": "Guides for wallets to integrate with Babylon Genesis chain." | ||
| } | ||
| } |
129 changes: 129 additions & 0 deletions
129
...rs/wallet_integration/babylon_wallet_integration/babylon_wallet_integration.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| --- | ||
| sidebar_label: Wallet Integration Guide | ||
| sidebar_position: 1 | ||
| --- | ||
|
|
||
| # Babylon Genesis Chain Wallet Integration | ||
|
|
||
| The Babylon Genesis is a PoS chain built using the | ||
| Cosmos SDK and utilises most of the vanilla Cosmos SDK functionality | ||
| shared among chains developed using it. Therefore, | ||
| a wallet already supporting chains built using | ||
| Cosmos SDK should find it straightforward to add | ||
| Babylon Genesis as a supported blockchain. | ||
|
|
||
| In this document, we will walk through the considerations of integrating | ||
| the Babylon Genesis blockchain into your wallet: | ||
| * [Babylon Genesis network information](#babylon-genesis-network-information) | ||
| * [Accounts, message signing, token balance, and token transfer](#accounts-message-signing-token-balance-and-token-transfer) | ||
| * [Staking](#staking) | ||
| * [Unbonding](#unbonding) | ||
|
|
||
| ### Babylon Genesis Network Information | ||
|
|
||
| Following is a list of the key network details of | ||
| Babylon Genesis: | ||
| * RPC nodes can be found for the network you are interested in | ||
| [our networks registry](https://github.com/babylonlabs-io/networks). | ||
| * Token minimum denomination: `ubbn` (6 decimals) | ||
| * Human-readable denomination: `BABY` | ||
|
|
||
| ### Accounts, message signing, token balance, and token transfer | ||
|
|
||
| The Babylon Genesis chain utilises the default Cosmos SDK | ||
| functionality for accounts, message signing, | ||
| token balance, and token transfer. | ||
| Please refer to the relevant | ||
| [Cosmos SDK documentation](https://docs.cosmos.network/) | ||
| for more details. | ||
|
|
||
| ### Staking | ||
|
|
||
| The Babylon blockchain uses an epochised staking | ||
| mechanism where staking transactions are executed | ||
| at the end of an epoch rather than immediately. | ||
|
|
||
| * An epoch is defined as a specific block range, | ||
| determined by an epoch interval defined | ||
| in the `x/epoching` module's | ||
| [parameters](https://github.com/babylonlabs-io/babylon/blob/release/v1.x/proto/babylon/epoching/v1/params.proto). | ||
| * During each epoch, staking messages are queued | ||
| in a delayed execution queue. | ||
| * At the epoch's end, all queued staking messages | ||
| are processed in a batch, resulting in | ||
| epoch based voting power transitions. | ||
|
|
||
| To enable this mechanism, | ||
| Babylon modifies the standard Cosmos SDK staking process: | ||
| * Babylon replaces the default Cosmos SDK `x/staking` module | ||
| with a custom module, `x/epoching`. | ||
| * This custom module wraps the standard staking functionality | ||
| to enforce epoch-based voting power transitions. | ||
| * The wrapped staking messages are largely similar | ||
| to those in the default `x/staking` module. | ||
| The specifications of these wrapped messages are available | ||
| [here](https://github.com/babylonlabs-io/babylon/tree/main/x/epoching). | ||
|
|
||
| Wallets wishing to support Babylon PoS delegations | ||
| natively must use the custom `x/epoching` mechanism. | ||
|
|
||
| The epochised staking approach introduces the following | ||
| UX considerations for wallet integration: | ||
| * **Delayed Staking Activation**: Although wrapped staking messages are | ||
| executed immediately, the actual staking operation takes effect only | ||
| at the epoch's end. Wallets should clearly communicate this | ||
| delay to users to set proper expectations. | ||
| * **Delayed Funds Locking**: Users' funds remain liquid until staking | ||
| activation occurs at the epoch's conclusion. This creates a for staking failure: | ||
| if users transfer or spend their funds before staking takes effect, | ||
| the staking transaction will fail. | ||
| Wallets should warn users about this possibility. | ||
|
|
||
| Wallets can provide users with visibility into pending staking | ||
| messages using the | ||
| [LastEpochMsgs query in x/epoching](https://github.com/babylonlabs-io/babylon/blob/main/proto/babylon/epoching/v1/query.proto#L46). | ||
| This query allows wallets to display the messages queued | ||
| for execution at the end of the current epoch. | ||
|
|
||
| ### Unbonding | ||
|
|
||
| Babylon speeds up the unbonding process by leveraging | ||
| Bitcoin timestamping, significantly reducing | ||
| the unbonding period from the default 21 days in the | ||
| Cosmos SDK to approximately ~50 hours. | ||
|
|
||
| This process works as follows: | ||
| * **Epoch Timestamping**: At the end of each epoch, | ||
| Babylon records its blockchain state onto the | ||
| Bitcoin blockchain through a Bitcoin timestamp. | ||
| * **Bitcoin Confirmations**: Once the timestamp receives | ||
| a sufficient number of confirmations on the Bitcoin blockchain | ||
| (a parameter configurable in Babylon), the state of the epoch | ||
| if considered finalized. | ||
| * The number of required Bitcoin confirmations is set by the | ||
| `x/btccheckpoint` module, detailed | ||
| [here](https://github.com/babylonlabs-io/babylon/blob/main/proto/babylon/btccheckpoint/v1/params.proto#L24) | ||
| * For example, on the Babylon Genesis mainnet, | ||
| this value will be set to 300 confirmations, | ||
| corresponding to roughly ~33 hours for unbonding to be completed, | ||
| assuming an average Bitcoin block time of 10 minutes. | ||
| * **Unbonding Finalization**: All unbonding requests submitted | ||
| up to the end of that epoch are processed and finalized | ||
| after the required Bitcoin confirmations are reached. | ||
|
|
||
| An example scenario demonstrating how fast unbonding | ||
| works in practice: | ||
| * **Setup** | ||
| * Epoch interval: 300 blocks | ||
| * Bitcoin confirmations for finalization: 300 blocks | ||
| * **Unbonding Request**: | ||
| * A user submits an unbonding transaction at block `157` | ||
| * **Epoch Processing**: | ||
| * The unbonding transaction is queued and processed at | ||
| the end of the epoch (block 300). | ||
| * The user’s status is updated to unbonding, and the epoch’s | ||
| state is timestamped on Bitcoin. | ||
| * **Finalization**: | ||
| * After ~50 hours, the Bitcoin timestamp reaches 300 confirmations. | ||
| * Babylon Genesis detects this and completes the unbonding process, | ||
| fully unbonds the user’s stake. |
4 changes: 4 additions & 0 deletions
4
docs/developers/wallet_integration/bitcoin_wallet_integration/_category_.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "label": "Bitcoin Wallet Integration", | ||
| "position": 2 | ||
| } |
18 changes: 18 additions & 0 deletions
18
...rs/wallet_integration/bitcoin_wallet_integration/bitcoin_wallet_integration.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| title: Bitcoin Wallet Integration | ||
| sidebar_position: 1 | ||
| --- | ||
|
|
||
| # Bitcoin Wallet Integration | ||
|
|
||
| This section provides documentation for integrating Babylon Bitcoin Staking to different | ||
| types of Bitcoin wallets. Whether you're building a web application, mobile app, | ||
| or hardware wallet, specific guides are provided for each wallet type. | ||
|
|
||
| ## Integration Guides | ||
|
|
||
| import DocCardList from '@theme/DocCardList'; | ||
|
|
||
| <DocCardList /> | ||
|
|
||
| Let's get started with your preferred wallet integration. |
63 changes: 63 additions & 0 deletions
63
.../developers/wallet_integration/bitcoin_wallet_integration/extension_wallets.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| --- | ||
| sidebar_label: Extension Wallets | ||
| sidebar_position: 2 | ||
| --- | ||
|
|
||
| # Bitcoin Staking for Extension Wallets | ||
|
|
||
| This guide outlines the various approaches for integrating Babylon bitcoin staking | ||
| functionality into browser extension wallets. | ||
|
|
||
| ## Option 1 | ||
|
|
||
| Be added to a third party’s bitcoin staking website as | ||
| a wallet for either Bitcoin or Babylon or both. | ||
| This requires collaboration with the host of the | ||
| website and exposing compatible wallet APIs. | ||
| * To be supported in the Babylon hosted staking website as a Bitcoin or Babylon | ||
| wallet, please integrate with the Tomo Wallet Connect | ||
| by following the | ||
| [docs](https://docs.tomo.inc/tomo-sdk/tomo-connect-sdk-lite). | ||
| * This is the preferred method for wallet integration that will achieve | ||
| the most timely results. The Babylon hosted website will also support | ||
| native wallet integrations for select wallets with long-established | ||
| support. | ||
|
|
||
| ## Option 2 | ||
|
|
||
| Host your own bitcoin staking website | ||
| that connects to your extension wallet and retrieves | ||
| staking information from a backend you operate. | ||
| * For information about `developing/hosting` your own bitcoin staking website, | ||
| please check: | ||
| * our reference web application | ||
| [implementation](https://github.com/babylonlabs-io/simple-staking/). | ||
| * our | ||
| [TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/) | ||
| and [Golang](https://github.com/babylonlabs-io/babylon/tree/main/btcstaking/) | ||
| Bitcoin Staking libraries for creating bitcoin Staking transactions. | ||
| * our [documentation](https://github.com/babylonlabs-io/babylon/tree/main/x/btcstaking) | ||
| on the flow of bitcoin staking transaction creation and submission in | ||
| conjunction with Bitcoin and Babylon Genesis blockchains. | ||
| * For information about the reference Babylon staking backend, please read this | ||
| [document](/guides/networks/phase-2/testnet/staking_backend/). | ||
|
|
||
| ## Option 3 | ||
|
|
||
| Develop bitcoin staking as a feature on your extension wallet, | ||
| which connects to either third party APIs | ||
| (such as the Babylon [Staking API](https://docs.babylonlabs.io/api/staking-api/babylon-staking-api/)) or a backend you operate. | ||
|
|
||
| * For information about developing your own bitcoin staking as a feature, | ||
| please check: | ||
| * our reference web application [implementation](https://github.com/babylonlabs-io/simple-staking/tree/main). | ||
| * our | ||
| [TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/) | ||
| and [Golang](https://github.com/babylonlabs-io/babylon/tree/main/btcstaking/) | ||
| Bitcoin Staking libraries. | ||
| * our [documentation](https://github.com/babylonlabs-io/babylon/tree/main/x/btcstaking) | ||
| on the flow of bitcoin staking transaction creation and submission in | ||
| conjunction with Bitcoin and Babylon Genesis blockchains. | ||
|
|
||
| * For information about the reference babylon staking backend, please read this | ||
| [document](/guides/networks/phase-2/testnet/staking_backend/). |
35 changes: 35 additions & 0 deletions
35
docs/developers/wallet_integration/bitcoin_wallet_integration/hardware_wallets.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| --- | ||
| title: Hardware Wallets | ||
| sidebar_label: Hardware Wallets | ||
| sidebar_position: 4 | ||
| --- | ||
|
|
||
| # Hardware Wallets | ||
|
|
||
| This guide outlines the various approaches for integrating Babylon bitcoin staking | ||
| functionality into hardware wallets. | ||
|
|
||
| ## Option 1 | ||
|
|
||
| Develop bitcoin staking as a feature of your hardware wallet, | ||
| which connects to either third party APIs | ||
| (such as the Babylon [Staking API](https://staking-api.babylonlabs.io/swagger/doc.json)) or a backend you operate. | ||
|
|
||
| * For information about developing your own Bitcoin staking as a feature, | ||
| please check: | ||
| * our reference web application [implementation](https://github.com/babylonlabs-io/simple-staking/tree/main). | ||
| * our | ||
| [TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/) | ||
| and [Golang](https://github.com/babylonlabs-io/babylon/tree/main/btcstaking/) | ||
| Bitcoin Staking libraries. | ||
| * our [documentation](https://github.com/babylonlabs-io/babylon/tree/main/x/btcstaking) | ||
| on the flow of bitcoin staking transaction creation and submission in | ||
| conjunction with Bitcoin and Babylon Genesis blockchains. | ||
|
|
||
| * For information about the reference Babylon staking backend, please read this | ||
| [document](/guides/networks/phase-2/testnet/staking_backend/). | ||
|
|
||
| ## Option 2 | ||
|
|
||
| Integrate via a compatible software wallet (extension or mobile) | ||
| that is bitcoin staking enabled. |
59 changes: 59 additions & 0 deletions
59
...developers/wallet_integration/bitcoin_wallet_integration/mobile_app_wallets.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| --- | ||
| sidebar_label: Mobile App Wallets | ||
| sidebar_position: 3 | ||
| --- | ||
|
|
||
| # Bitcoin Staking for Mobile App Wallets | ||
|
|
||
| This guide outlines the various options for integrating Babylon bitcoin staking | ||
| functionality into mobile app wallets. | ||
|
|
||
| ## Option 1 | ||
|
|
||
| Embed a third-party Bitcoin staking website to your mobile app | ||
| wallet, which interacts with the Bitcoin and Babylon signers inside your wallet via | ||
| the application window interface. | ||
| To embed on the Babylon hosted staking website, please ensure | ||
| that the interface of your mobile wallet (or a wrapper of it) | ||
| adheres to the | ||
| [Injectable Wallet interface](https://github.com/babylonlabs-io/wallet-connector?tab=readme-ov-file#wallet-integration). | ||
|
|
||
|
|
||
| ## Option 2 | ||
|
|
||
| Host your own Bitcoin staking website that connects to your | ||
| extension wallet that retrieves staking information from a backend you | ||
| operate. Then embed your own Bitcoin staking website to your mobile app wallet. | ||
| * For information about developing/hosting your own Bitcoin staking website, | ||
| please check: | ||
| * our reference web application | ||
| [implementation](https://github.com/babylonlabs-io/simple-staking/). | ||
| * our | ||
| [TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/) | ||
| and [Golang](https://github.com/babylonlabs-io/babylon/tree/main/btcstaking/) | ||
| Bitcoin Staking libraries for creating bitcoin Staking transactions. | ||
| * our [documentation](https://github.com/babylonlabs-io/babylon/tree/main/x/btcstaking) | ||
| on the flow of bitcoin Staking transaction creation and submission in | ||
| conjunction with Bitcoin and Babylon blockchains. | ||
| * For information about the reference Babylon staking backend, please read this | ||
| [document](/guides/networks/phase-2/testnet/staking_backend/). | ||
|
|
||
| ## Option 3 | ||
|
|
||
| Develop bitcoin staking as a feature of your mobile wallet, | ||
| which connects to either third party APIs | ||
| (such as the Babylon | ||
| [Staking API](/api/staking-api/babylon-staking-api/)) or a backend you operate. | ||
|
|
||
| * For information about developing your own bitcoin staking as a feature, | ||
| please check: | ||
| * our reference web application [implementation](https://github.com/babylonlabs-io/simple-staking/tree/main). | ||
| * our | ||
| [TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/) | ||
| and [Golang](https://github.com/babylonlabs-io/babylon/tree/main/btcstaking/) | ||
| Bitcoin Staking libraries. | ||
| * our [documentation](https://github.com/babylonlabs-io/babylon/tree/main/x/btcstaking) | ||
| on the flow of bitcoin staking transaction creation and submission in | ||
| conjunction with Bitcoin and Babylon blockchains. | ||
| * For information about the reference Babylon staking backend, please read this | ||
| [document](/guides/networks/phase-2/testnet/staking_backend/). |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.