Skip to content

Commit

Permalink
fix: remove testnet wordings for upcoming release (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrwbabylonlab authored Jul 17, 2024
2 parents 761a4a2 + 3266b63 commit 7088ca9
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 83 deletions.
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
NEXT_PUBLIC_MEMPOOL_API=https://babylon.mempool.space
NEXT_PUBLIC_API_URL=https://staking-api.babylonchain.io
NEXT_PUBLIC_NETWORK=signet
NEXT_PUBLIC_API_URL=https://staking-api.staging.babylonchain.io
NEXT_PUBLIC_NETWORK=signet
NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES=true
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ where,
- `NEXT_PUBLIC_API_URL` specifies the back-end API to use for the staking
system queries
- `NEXT_PUBLIC_NETWORK` specifies the BTC network environment
- `NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES` boolean value to indicate whether display
testing network related message. Default to true

Then, to start a development server:

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-staking",
"version": "0.2.11",
"version": "0.2.12",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
166 changes: 89 additions & 77 deletions src/app/components/FAQ/data/questions.ts
Original file line number Diff line number Diff line change
@@ -1,78 +1,90 @@
export const questions = (coinName: string) => [
{
title: "What is Babylon?",
content: `<p>Babylon is a suite of security-sharing protocols that bring Bitcoin\’s unparalleled security to the decentralized world. The latest protocol, Bitcoin Staking, enables Bitcoin holders to stake their Bitcoin to provide crypto-economic security to PoS (proof-of-stake) systems in a trustless and self-custodial way.</p>`,
},
{
title: "How does Bitcoin Staking Work?",
content: `<p>${coinName} holders lock their ${coinName} using the trustless and self-custodial Bitcoin Staking script for a predetermined time (timelock) in exchange for voting power in an underlying PoS protocol. In return, Bitcoin holders will earn PoS staking rewards.</p><br />
<p>Finality providers perform the voting. A ${coinName} staker can create a finality provider by itself and self-delegate or delegate its voting power to a third-party finality provider.</p><br />
<p>If a finality provider attacks the PoS system, the ${coinName}s behind the voting powers delegated to it will be subject to protocol slashing. This deters ${coinName} stakers and finality providers from attacking the PoS system.</p>
`,
},
{
title: "What is the goal of this testnet?",
content: `<p>The goal of this testnet is to ensure the security of the staked Bitcoins by testing the user's interaction with the ${coinName} network. This will be a lock-only network without any PoS chain operating, meaning that the only participants of this testnet will be finality providers and ${coinName} stakers.</p>`,
},
{
title: "What does this staking dApp allow me to do?",
content: `<p>The staking dApp allows ${coinName} holders to stake their ${coinName} and delegate their voting power to a finality provider they select. Stakers can view their past staking history and on-demand unlock their stake for early withdrawal.</p>`,
},
{
title: `Does my ${coinName} leave my wallet once staked?`,
content: `<p>Yes, it leaves your wallet. Your wallet will not show it as your available balance because it is locked. However, it is not sent to any third party. It is locked in a self-custodial contract you control. This means that any subsequent movement of the ${coinName} will need your approval, and you are the only one who can unbond the stake and withdraw.</p>`,
},
{
title: `Is my ${coinName} Safe? Could I get slashed?`,
content: `<p>In this testnet, you are not required to sign any PoS slashing-related authorizations. Thus, in theory, the ${coinName} in your self-custodial contract cannot be slashed due to the absence of your authorization.</p><br />
import { shouldDisplayTestingMsg } from "@/config";

export interface Question {
title: string;
content: string;
}

export const questions = (coinName: string): Question[] => {
const questionList = [
{
title: "What is Babylon?",
content: `<p>Babylon is a suite of security-sharing protocols that bring Bitcoin\’s unparalleled security to the decentralized world. The latest protocol, Bitcoin Staking, enables Bitcoin holders to stake their Bitcoin to provide crypto-economic security to PoS (proof-of-stake) systems in a trustless and self-custodial way.</p>`,
},
{
title: "How does Bitcoin Staking Work?",
content: `<p>${coinName} holders lock their ${coinName} using the trustless and self-custodial Bitcoin Staking script for a predetermined time (timelock) in exchange for voting power in an underlying PoS protocol. In return, Bitcoin holders will earn PoS staking rewards.</p><br />
<p>Finality providers perform the voting. A ${coinName} staker can create a finality provider by itself and self-delegate or delegate its voting power to a third-party finality provider.</p><br />
<p>If a finality provider attacks the PoS system, the ${coinName}s behind the voting powers delegated to it will be subject to protocol slashing. This deters ${coinName} stakers and finality providers from attacking the PoS system.</p>
`,
},
{
title: "What does this staking dApp allow me to do?",
content: `<p>The staking dApp allows ${coinName} holders to stake their ${coinName} and delegate their voting power to a finality provider they select. Stakers can view their past staking history and on-demand unlock their stake for early withdrawal.</p>`,
},
{
title: `Does my ${coinName} leave my wallet once staked?`,
content: `<p>Yes, it leaves your wallet. Your wallet will not show it as your available balance because it is locked. However, it is not sent to any third party. It is locked in a self-custodial contract you control. This means that any subsequent movement of the ${coinName} will need your approval, and you are the only one who can unbond the stake and withdraw.</p>`,
},
{
title: `Is my ${coinName} Safe? Could I get slashed?`,
content: `<p>You are not required to sign any PoS slashing-related authorizations. Thus, in theory, the ${coinName} in your self-custodial contract cannot be slashed due to the absence of your authorization.</p><br />
<p>However, there are still risks associated with your ${coinName}:</p><br />
<ol>
<li>
1. Code security<br />
There is an inherent risk that the code developed for Bitcoin staking has vulnerabilities or bugs. The Babylon team has open-sourced the code, and it is under security audits.
</li>
<br />
<li>
2. System reliability<br />
The Bitcoin staking system may be slow, unavailable, or compromised, which may cause the staking service to be unavailable or compromised, potentially leading to ${coinName} not being unbindable or not withdrawable.
</li>
</ol>
`,
},
{
title: "How long will it take for my stake to become active?",
content: `<p>A stake’s status demonstrates the current stage of the staking process. All stake starts in a Pending state which denotes that the ${coinName} Staking transaction does not yet have sufficient ${coinName} block confirmations. As soon as it receives 10 ${coinName} block confirmations, the status transitions to <i>Overflow</i> or <i>Active</i>. </p><br />
<p>In an amount-based cap, A stake is <i>Overflow</i> if the system has already accumulated the maximum amount of ${coinName} it can accept.</p><br />
<p>In a time-based cap, where there is a starting block height and ending block height, a stake is <i>overflow</i> if it is included in a ${coinName} block that is newer than the ending block.</p><br />
<p>Otherwise, the stake is <i>Active</i>.</p><br />
<p><i>Overflow</i> stake should be on-demand unbonded and withdrawn.</p>`,
},
{
title: "Do I get rewards for staking?",
content: `<p>No. This is a locking-only testnet without a PoS chain. There is no PoS staking reward nor incentives for participation.</p>`,
},
{
title: "Are there any other ways to stake?",
content: `<p>Hands-on stakers can operate the <a href="https://github.com/babylonchain/btc-staker/blob/dev/docs/create-phase1-staking.md" target="_blank" rel="noopener noreferrer" class="text-primary"><u>btc-staker CLI program</u></a> that allows for the creation of ${coinName} staking transactions from the CLI.</p>
`,
},
{
title: "Will I pay any fees for staking?",
content: `<p>Yes, there are three transaction fees associated with staking, all charged by the Bitcoin network:</p><br />
<ol>
<li>
1. <b>Staking Transaction Fee (Fs)</b>: This fee is for the staking transaction. To stake amount S, you need at least S + Fs in your wallet. It is calculated in real-time based on current network conditions.
</li><br />
<li>
2. <b>Unbonding Transaction Fee (Fu)</b>: If you unbond your stake before it expires, this fee is deducted from your stake S, resulting in a withdrawable amount of S - Fu. Fu is a calculated static value to ensure inclusion in busy network conditions.
</li><br />
<li>
3. <b>Withdraw Transaction Fee (Fw)</b>: This fee is for the withdrawal transaction that transfers the stake back to your wallet. It is deducted from your withdrawable stake, which is either S (if you wait until expiration) or S - Fu (if unbonded early). This fee ensures fast inclusion based on current network conditions.
</li>
</ol><br />
<p>In summary, to stake S, you need S + Fs, and upon completion, you get S - Fw or S - Fu - Fw back, depending on whether you wait for expiration or unbond early.</p>`,
},
];
<p>However, there are still risks associated with your ${coinName}:</p><br />
<ol>
<li>
1. Code security<br />
There is an inherent risk that the code developed for Bitcoin staking has vulnerabilities or bugs. The Babylon team has open-sourced the code, and it is under security audits.
</li>
<br />
<li>
2. System reliability<br />
The Bitcoin staking system may be slow, unavailable, or compromised, which may cause the staking service to be unavailable or compromised, potentially leading to ${coinName} not being unbindable or not withdrawable.
</li>
</ol>
`,
},
{
title: "How long will it take for my stake to become active?",
content: `<p>A stake’s status demonstrates the current stage of the staking process. All stake starts in a Pending state which denotes that the ${coinName} Staking transaction does not yet have sufficient ${coinName} block confirmations. As soon as it receives 10 ${coinName} block confirmations, the status transitions to <i>Overflow</i> or <i>Active</i>. </p><br />
<p>In an amount-based cap, A stake is <i>Overflow</i> if the system has already accumulated the maximum amount of ${coinName} it can accept.</p><br />
<p>In a time-based cap, where there is a starting block height and ending block height, a stake is <i>overflow</i> if it is included in a ${coinName} block that is newer than the ending block.</p><br />
<p>Otherwise, the stake is <i>Active</i>.</p><br />
<p><i>Overflow</i> stake should be on-demand unbonded and withdrawn.</p>`,
},
{
title: "Do I get rewards for staking?",
content: `<p>No. This is a locking-only phase without a PoS chain. There is no PoS staking reward nor incentives for participation.</p>`,
},
{
title: "Are there any other ways to stake?",
content: `<p>Hands-on stakers can operate the <a href="https://github.com/babylonchain/btc-staker/blob/dev/docs/create-phase1-staking.md" target="_blank" rel="noopener noreferrer" class="text-primary"><u>btc-staker CLI program</u></a> that allows for the creation of ${coinName} staking transactions from the CLI.</p>
`,
},
{
title: "Will I pay any fees for staking?",
content: `<p>Yes, there are three transaction fees associated with staking, all charged by the Bitcoin network:</p><br />
<ol>
<li>
1. <b>Staking Transaction Fee (Fs)</b>: This fee is for the staking transaction. To stake amount S, you need at least S + Fs in your wallet. It is calculated in real-time based on current network conditions.
</li><br />
<li>
2. <b>Unbonding Transaction Fee (Fu)</b>: If you unbond your stake before it expires, this fee is deducted from your stake S, resulting in a withdrawable amount of S - Fu. Fu is a calculated static value to ensure inclusion in busy network conditions.
</li><br />
<li>
3. <b>Withdraw Transaction Fee (Fw)</b>: This fee is for the withdrawal transaction that transfers the stake back to your wallet. It is deducted from your withdrawable stake, which is either S (if you wait until expiration) or S - Fu (if unbonded early). This fee ensures fast inclusion based on current network conditions.
</li>
</ol><br />
<p>In summary, to stake S, you need S + Fs, and upon completion, you get S - Fw or S - Fu - Fw back, depending on whether you wait for expiration or unbond early.</p>`,
},
];
if (shouldDisplayTestingMsg()) {
questionList.push({
title: "What is the goal of this testnet?",
content: `<p>The goal of this testnet is to ensure the security of the staked Bitcoins by testing the user's interaction with the ${coinName} network. This will be a lock-only network without any PoS chain operating, meaning that the only participants of this testnet will be finality providers and ${coinName} stakers.</p>`,
});
}
return questionList;
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
} from "@/app/components/Loading/Loading";
import { QueryMeta } from "@/app/types/api";
import { FinalityProvider as FinalityProviderInterface } from "@/app/types/finalityProviders";
import { getNetworkConfig } from "@/config/network.config";
import { Network } from "@/utils/wallet/wallet_provider";

import { FinalityProvider } from "./FinalityProvider";

Expand All @@ -29,12 +31,16 @@ export const FinalityProviders: React.FC<FinalityProvidersProps> = ({
return <LoadingView />;
}

const network = getNetworkConfig().network;
const createFinalityProviderLink = `https://github.com/babylonchain/networks/tree/main/${
network == Network.MAINNET ? "bbn-1" : "bbn-test-4"
}/finality-providers`;
return (
<>
<p>
Select a finality provider or{" "}
<a
href="https://github.com/babylonchain/networks/tree/main/bbn-test-4/finality-providers"
href={createFinalityProviderLink}
target="_blank"
rel="noopener noreferrer"
className="sublink text-primary hover:underline"
Expand Down
3 changes: 3 additions & 0 deletions src/app/components/TestingInfo/TestingInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { RiErrorWarningLine } from "react-icons/ri";

import { shouldDisplayTestingMsg } from "@/config";

interface TestingInfoProps {}

export const TestingInfo: React.FC<TestingInfoProps> = () => {
if (!shouldDisplayTestingMsg()) return null;
return (
<div className="flex w-full justify-center">
<div className="card flex w-full flex-col items-center gap-1 bg-base-200 p-3 text-sm lg:w-auto lg:flex-row lg:text-xs">
Expand Down
5 changes: 5 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// shouldDisplayTestingMsg function is used to check if the application is running in testing mode or not.
// Default to true if the environment variable is not set.
export const shouldDisplayTestingMsg = () => {
return process.env.NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES !== "false";
};
21 changes: 21 additions & 0 deletions tests/config/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { shouldDisplayTestingMsg } from "@/config";

describe("shouldDisplayTestingMsg", () => {
afterEach(() => {
delete process.env.NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES;
});

it("should return true if NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES is not set", () => {
expect(shouldDisplayTestingMsg()).toBe(true);
});

it('should return true if NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES is "true"', () => {
process.env.NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES = "true";
expect(shouldDisplayTestingMsg()).toBe(true);
});

it('should return false if NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES is "false"', () => {
process.env.NEXT_PUBLIC_DISPLAY_TESTING_MESSAGES = "false";
expect(shouldDisplayTestingMsg()).toBe(false);
});
});

0 comments on commit 7088ca9

Please sign in to comment.