Skip to content

Commit

Permalink
Merge branch 'main' into invitation_user_record
Browse files Browse the repository at this point in the history
  • Loading branch information
mx819812523 authored Dec 5, 2024
2 parents 3fda9ce + c11d285 commit 65dfb2d
Show file tree
Hide file tree
Showing 14 changed files with 249 additions and 82 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ smallvec = "1.6.1"
thiserror = "1.0.69"
tiny-keccak = { version = "2", features = ["keccak", "sha3"] }
tiny-bip39 = "2.0.0"
tokio = { version = "1.41.1", features = ["full"] }
tokio-util = "0.7.12"
tokio = { version = "1.42.0", features = ["full"] }
tokio-util = "0.7.13"
tokio-tungstenite = { version = "0.24.0", features = ["native-tls"] }
tokio-stream = "0.1.16"
tonic = { version = "0.8", features = ["gzip"] }
Expand Down Expand Up @@ -282,7 +282,7 @@ uint = "0.9.5"
rlp = "0.5.2"
const-hex = "1.14.0"
cached = "0.43.0"
diesel = { version = "2.2.5", features = [
diesel = { version = "2.2.6", features = [
"chrono",
"sqlite",
"r2d2",
Expand Down
25 changes: 13 additions & 12 deletions crates/rooch-da/src/backend/openda/avail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub(crate) const DEFAULT_AVAIL_MAX_SEGMENT_SIZE: u64 = 256 * 1024;
const BACK_OFF_MIN_DELAY: Duration = Duration::from_millis(3000);
const SUBMIT_API_PATH: &str = "v2/submit";

#[derive(Clone)]
pub(crate) struct AvailClient {
endpoint: String,
client: Client,
Expand Down Expand Up @@ -53,19 +54,19 @@ impl Operator for AvailClient {
) -> anyhow::Result<()> {
let submit_url = format!("{}/{}", self.endpoint, SUBMIT_API_PATH);
let data = general_purpose::STANDARD.encode(&segment_bytes);
let max_retries = self.max_retries;
let mut retries = 0;
let max_attempts = self.max_retries + 1; // max_attempts = max_retries + first attempt
let mut attempts = 0;
let mut retry_delay = BACK_OFF_MIN_DELAY;

loop {
attempts += 1;
let response = self
.client
.post(&submit_url)
.header("Content-Type", "application/json")
.body(json!({ "data": data }).to_string())
.send()
.await?;

match response.status() {
StatusCode::OK => {
let submit_response: AvailSubmitResponse = response.json().await?;
Expand All @@ -85,22 +86,22 @@ impl Operator for AvailClient {
))
}
_ => {
if retries <= max_retries {
retries += 1;
sleep(retry_delay).await;
retry_delay *= 3; // Exponential backoff
if attempts < max_attempts {
tracing::warn!(
"Failed to submit segment: {:?} to Avail, retrying after {}ms, attempt: {}",
"Failed to submit segment: {:?} to Avail: {}, attempts: {},retrying after {}ms",
segment_id,
response.status(),
attempts,
retry_delay.as_millis(),
retries
);
sleep(retry_delay).await;
retry_delay *= 3; // Exponential backoff
} else {
return Err(anyhow!(
"Failed to submit segment: {:?} to Avail after {} attempts: {}",
"Failed to submit segment: {:?} to Avail: {} after {} attempts",
segment_id,
retries,
response.status()
response.status(),
attempts,
));
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/rooch-da/src/backend/openda/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use crate::backend::openda::avail::AvailClient;
use crate::backend::openda::celestia::{CelestiaClient, WrappedNamespace};
use crate::backend::openda::fs::BACK_OFF_MIN_DELAY;
use crate::backend::openda::opendal::BACK_OFF_MIN_DELAY;
use crate::backend::openda::operator::{Operator, OperatorConfig};
use crate::backend::DABackend;
use async_trait::async_trait;
Expand Down
23 changes: 12 additions & 11 deletions crates/rooch-da/src/backend/openda/celestia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ impl Operator for CelestiaClient {
_prefix: Option<String>,
) -> anyhow::Result<()> {
let blob = Blob::new(self.namespace, segment_bytes)?;
let max_retries = self.max_retries;
let mut retries = 0;
let max_attempts = self.max_retries + 1; // max_attempts = max_retries + first attempt
let mut attempts = 0;
let mut retry_delay = BACK_OFF_MIN_DELAY;

loop {
attempts += 1;
match self
.client
.blob_submit(&[blob.clone()], SubmitOptions::default())
Expand All @@ -72,22 +73,22 @@ impl Operator for CelestiaClient {
return Ok(());
}
Err(e) => {
if retries <= max_retries {
retries += 1;
sleep(retry_delay).await;
retry_delay *= 3;
if attempts < max_attempts {
tracing::warn!(
"Failed to submit segment: {:?} to Celestia, retrying after {}ms, attempt: {}",
"Failed to submit segment: {:?} to Celestia: {:?}, attempts: {}, retrying after {}ms",
segment_id,
e,
attempts,
retry_delay.as_millis(),
retries
);
sleep(retry_delay).await;
retry_delay *= 3;
} else {
return Err(anyhow!(
"Failed to submit segment: {:?} to Celestia after {} attempts: {:?}",
"Failed to submit segment: {:?} to Celestia: {:?} after {} attempts",
segment_id,
retries,
e
e,
attempts,
));
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/rooch-da/src/backend/openda/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
mod avail;
mod backend;
mod celestia;
mod fs;
mod opendal;
mod operator;

pub use self::backend::OpenDABackend;
File renamed without changes.
2 changes: 1 addition & 1 deletion crates/testsuite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ assert_cmd = "2.0"
cucumber = "0.21.1"
futures = { workspace = true }
testcontainers = { version = "0.15.0", git = "https://github.com/yubing744/testcontainers-rs", rev = "6b87dc53ab3bc6eb4d15c7e73a3c57dcbf40d0af" }
tokio = { version = "1.41", features = ["macros", "rt-multi-thread", "sync", "time"] }
tokio = { version = "1.42", features = ["macros", "rt-multi-thread", "sync", "time"] }
jpst = "0.1.1"
tracing = "0.1"
backtrace = "0.3"
Expand Down
5 changes: 3 additions & 2 deletions docs/website/pages/blog/grow-bitcoin-main.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ As a Bitcoin staker or user, you get to earn BitXP as well as the project XP by
As a Bitcoin project builder, you are free to list your project on the Grow Bitcoin platform and get attentions from potential Bitcoin users; users will endorse your project with their votes and with more votes you get to earn BitXP as well!

- Website:https://grow.rooch.network
- Grow Bitcoin FAQ: https://rooch.network/learn/miscellaneous/grow-bitcion#faq

## Connect wallet

Expand All @@ -32,9 +33,9 @@ Click the `Connect` button to authorize.

Make sure you have UTXOs in your Bitcoin wallet, no matter how many.

Rooch provides new Bitcoin addresses with the opportunity to claim an `RGas` airdrop. You can `Claim` your `RGas` at this URL:
Rooch provides the mainnet RGas faucet in the Portal. Each new Bitcoin address can claim `RGas` once. You can `Claim` your `RGas` at this URL:

- RGas Airdrop: https://portal.rooch.network/faucet
- RGas Faucet: https://portal.rooch.network/faucet

## Interaction

Expand Down
5 changes: 3 additions & 2 deletions docs/website/pages/blog/grow-bitcoin-main.zh-CN.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Grow Bitcoin 是一个生态系统加速平台,专注于将比特币用户和
作为比特币项目建设者,您可以自由地在 Grow Bitcoin 平台上列出您的项目,并获得潜在比特币用户的关注;用户将用他们的选票支持您的项目,并且选票越多,您也可以获得 BitXP!

- 网站链接:https://grow.rooch.network
- Grow Bitcoin FAQ:https://rooch.network/zh-CN/learn/miscellaneous/grow-bitcion#faq

## 连接钱包

Expand All @@ -32,9 +33,9 @@ Grow Bitcoin 是一个生态系统加速平台,专注于将比特币用户和

确保你的 Bitcoin 钱包有 UTXO,无论多少都可以。

Rooch 为新的 Bitcoin 地址提供领取一次 `RGas` 空投的机会,可以在这个网址 `Claim` 你的 `RGas`
Rooch 在 Portal 中提供了主网 RGas 水龙头,每个新的 Bitcoin 地址可以领取一次 `RGas`,可以在这个网址 `Claim` 你的 `RGas`

- RGas Airdrop: https://portal.rooch.network/faucet
- RGas 水龙头: https://portal.rooch.network/faucet

## 交互

Expand Down
32 changes: 30 additions & 2 deletions docs/website/pages/learn/miscellaneous/grow-bitcion.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ As a Bitcoin project builder, you are free to list your project on the Grow Bitc

Self Staking only has `Read` permissions for Bitcoin, without `Transfer`, ensuring the ownership of BTC. Having `Write` permission at the Rooch layer provides scalability.

Therefore, Self Staking in Grwo Bitcoin is risk-free staking mining.
Therefore, Self Staking in Grow Bitcoin is risk-free staking mining.

For example, I want to go shopping in a newly opened supermarket and I want to apply for a membership card. The membership card will only read my identity information and cannot do any more operations. Grow Bitcoin's stake mining is this model. It can only read the UTXO of the Bitcoin wallet and has no authority to operate your Bitcoin assets.

Expand All @@ -42,6 +42,12 @@ Please refer to the [Grow Bitcion Testnet User Guide](https://rooch.network/blog

Only needs to ensure that the UniSat wallet has UTXO and [Claim RGas](https://portal.rooch.network/faucet) here to stake.

RGas is the native gas token on the Rooch Network and is used to cover transaction and operating costs.

#### The account has BTC but no UTXO

BTC transfer transactions need to wait for three blocks to be confirmed before UTXO can be used in Rooch.

#### How to mine Grow

You only need to hold BTC in your own wallet to stake for mining and obtain `GROW`. Grow Bitcoin adopts `Hold Mining`’s staking model to obtain `GROW`.
Expand Down Expand Up @@ -76,10 +82,20 @@ No.

If you don't have RGas anymore, you can buy them [here](https://portal.rooch.network/gas-swap).

> Tip: Currently, only BTC -> RGas is provided. RGas -> BTC is temporarily unavailable. The function of purchasing RGas with USTD will be provided in the future.
#### UTXO has changed, are there still GROW rewards?

Because it is a holding mining mode, if the UTXO is spent, the unclaimed `GROW` cannot be claimed. It is recommended to claim the staking reward before spending BTC.

#### How many times can the GROW obtained through staking be claimed per day?

There is no limit on the number of times, you can claim as long as you have staking income.

#### How many RGas are consumed for each Claim?

About 0.02 ~ 0.03 RGas.

#### Babylon Stakes

The same UTXO cannot be Self-Staking and then staked on Babylon.
Expand All @@ -94,6 +110,10 @@ There are currently oracles for Bitcoin.

> Source code: https://github.com/rooch-network/rooch/blob/main/apps/gas_market/sources/trusted_oracle.move
#### Is Grow the mainnet token of Rooch?

no.

#### What does GROW do?

You can use `GROW` to vote for projects and earn `BitXP` points. `BitXP` is used to obtain airdrops.
Expand All @@ -109,9 +129,17 @@ GROW will be burned after voting, reducing the supply.
`GROW` is launched completely fairly, with a fixed supply and no upper limit for `BitXP`. `BitXP` can only be obtained by voting for the project using `GROW`.

#### Can I receive RGas with a new Bitcoin address?
#

A new Bitcoin address can `Claim` RGas once.

#### What type of Bitcoin address to use?

Taproot.

#### Where GROW trades

GROW’s trading market will be launched in the future.

### Testnet Frequently Asked Questions

#### How to get UTXO and RGas
Expand Down
30 changes: 29 additions & 1 deletion docs/website/pages/learn/miscellaneous/grow-bitcion.zh-CN.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Grow Bitcoin 是一个生态系统加速平台,专注于将比特币用户和

Self Staking 对 Bitcoin 来说只有 `Read` 权限,没有 `Transfer`,保证了 BTC 的所有权。在 Rooch 层具有 `Write` 权限,提供了扩展性。

因此 Grwo Bitcoin 中的 Self Staking 是零风险的质押挖矿。
因此 Grow Bitcoin 中的 Self Staking 是零风险的质押挖矿。

举个例子,我要去一个新开的超市买东西,我想办一张会员卡,会员卡只会读取我的身份信息,无法再做更多的操作。Grow Bitcoin 的质押挖矿就是这种模式,只能读取 Bitcoin 钱包的 UTXO,没有权限去操作您的 Bitcoin 资产。

Expand All @@ -42,6 +42,12 @@ Session Key 的详细描述请参考这篇文档 https://rooch.network/zh-CN/lea

只需要确保 UniSat 钱包有 UTXO,并在这里 [Claim RGas](https://portal.rooch.network/faucet) 即可质押。

RGas 是 Rooch 网络上的原生 gas 代币,用于支付交易和运营成本。

#### 账户有 BTC 了但是没有 UTXO

BTC 转账交易,需要等待三个区块确认后,`UTXO` 才可以在 Rooch 中使用。

#### Grow 怎么挖矿

只需要自己的钱包持有 BTC 即可质押挖矿,获取 `GROW`。Grow Bitcoin 采取的是 `Hold Mining` 的质押模式来获取 `GROW`
Expand Down Expand Up @@ -76,10 +82,20 @@ GROW 总量为 `210,000,000,000`,`180` 天挖完。

如果没有 RGas 了,可以在[这里](https://portal.rooch.network/gas-swap)购买。

> 提示:目前只提供了 BTC -> RGas,暂时无法 RGas -> BTC,后续将提供 USTD 购买 RGas 功能。
#### UTXO 改变了,GROW 奖励还有吗

因为是持有挖矿模式,如果 UTXO 被花费了,没有领取的 `GROW` 就无法 Claim 了,建议花费 BTC 之前先领取质押奖励。

#### 质押获得的 GROW 可以每天可以 Claim 多少次

没有次数限制,只要有质押收益就可以 Claim。

#### 每次 Claim 消耗多少 RGas

大约 0.02 ~ 0.03 RGas。

#### Babylon Stake

同一个 UTXO 不能 Self Staking 然后再到 Babylon 上 Stake。
Expand All @@ -94,6 +110,10 @@ Babylon 的质押带有时间锁,它的质押具有时间权重。

> 源码:https://github.com/rooch-network/rooch/blob/main/apps/gas_market/sources/trusted_oracle.move
#### Grow 是 Rooch 的主网代币吗

不是。

#### GROW 有什么作用

可以使用 `GROW` 给项目投票,获取 `BitXP` 积分。`BitXP` 用于获取空投。
Expand All @@ -112,6 +132,14 @@ Babylon 的质押带有时间锁,它的质押具有时间权重。

新的 Bitcoin 地址可以 `Claim` 一次 RGas。

#### 使用哪种类型的 Bitcoin 地址

Taproot。

#### GROW 在哪里交易

后续将推出 GROW 的交易市场。

### 测试网常见问题

#### 如何获取 UTXO 和 RGas
Expand Down
Loading

0 comments on commit 65dfb2d

Please sign in to comment.