Skip to content

Commit

Permalink
[genesis] Fix Sequencer config for genesis (#1699)
Browse files Browse the repository at this point in the history
* [cli] remove bitcoin network option

* [cli] remove btc_start_block_height option

* [bitcoin-move] add genesis block height

* [bitcoin] Use genesis block height when sync block

* stop gas metering for L1 block trasnaction.

* [vm] Stop charge gas for bypass_visibility function, and give init gas to sequencer

* [cli] Add test env to config

* [cli] Remove relayer account config

* [genesis] Fix the genesis config for testnet

* [ci] Remove btc-network from CI config

* [testsuite] disable bitseed test

* [stdlib] release stdlib v1

* fixup

* replace rooch_queryGlobalStates to rooch_queryObjectStates

* [ci] Use pr.sh to run test

* fixup

* fix up

* fix up

* fix up
  • Loading branch information
jolestar authored May 17, 2024
1 parent e55b8c4 commit 6e4a1d6
Show file tree
Hide file tree
Showing 42 changed files with 343 additions and 301 deletions.
8 changes: 5 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
crates/rooch-framework/doc linguist-generated=true
moveos/moveos-stdlib/move-stdlib/doc linguist-generated=true
moveos/moveos-stdlib/moveos-stdlib/doc linguist-generated=true
frameworks/rooch-framework/doc linguist-generated=true
frameworks/move-stdlib/doc linguist-generated=true
frameworks/moveos-stdlib/doc linguist-generated=true
frameworks/bitcoin-move/doc linguist-generated=true
frameworks/rooch-nursery/doc linguist-generated=true
11 changes: 3 additions & 8 deletions .github/workflows/check_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,15 @@ jobs:
run: cargo build
- name: Framework compatibiliy
run: cargo run --package framework-release --bin framework-release
- name: Execute rust tests
run: cargo nextest run --workspace --all-features --exclude rooch-framework-tests --exclude rooch-integration-test-runner -v
- name: Execute the framework test with 1 thread
run: cargo test --release run -p rooch-framework-tests -p rooch-integration-test-runner
- name: Run CLI integration test
# cargo-nextest does not support the CLI integration test powered by Cucumber Rust.
# Use cargo test to run CLI integration tests.
run: cargo test --release -p testsuite --test integration
- name: Run Rooch init
run: cargo run --bin rooch init --skip-password
- name: Execute Move stdlib and framework tests
run: ./scripts/pr.sh -m
- name: Execute rust tests
run: ./scripts/pr.sh -t
- name: Build and test example projects
run: ./scripts/pr.sh -e


# web & sdk & dashboard
- name: Use Node.js
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ jobs:
chmod 600 private_key.pem
sudo apt update
sudo apt install -y --no-install-recommends openssh-server
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST bash -c "'sleep 30' && && docker image prune -a -f && docker ps | grep rooch | awk '{print \$1}' | xargs -r docker stop && docker ps -a | grep rooch | awk '{print \$1}' | xargs -r docker rm -f && docker pull 'ghcr.io/rooch-network/rooch:${{ github.event.inputs.tagName }}' && docker run -d -v /data:/root -p 50051:50051 'ghcr.io/rooch-network/rooch:${{ github.event.inputs.tagName }}' server start -n main --btc-rpc-url '${{secrets.BTC_MAIN_RPC_URL}}' --btc-rpc-username rooch-main --btc-rpc-password '${{secrets.BTC_MAIN_RPC_PWD}}' --btc-start-block-height 0 --btc-end-block-height 767420 --btc-network 1 --data-import-mode 1"
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST bash -c "'sleep 30' && && docker image prune -a -f && docker ps | grep rooch | awk '{print \$1}' | xargs -r docker stop && docker ps -a | grep rooch | awk '{print \$1}' | xargs -r docker rm -f && docker pull 'ghcr.io/rooch-network/rooch:${{ github.event.inputs.tagName }}' && docker run -d -v /data:/root -p 50051:50051 'ghcr.io/rooch-network/rooch:${{ github.event.inputs.tagName }}' server start -n main --btc-rpc-url '${{secrets.BTC_MAIN_RPC_URL}}' --btc-rpc-username rooch-main --btc-rpc-password '${{secrets.BTC_MAIN_RPC_PWD}}' --btc-start-block-height 0 --btc-end-block-height 767420 --data-import-mode 1"
2 changes: 1 addition & 1 deletion .github/workflows/deploy_testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
chmod 600 private_key.pem
sudo apt update
sudo apt install -y --no-install-recommends openssh-server
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST bash -c "'sleep 30' && docker image prune -a -f && docker ps | grep rooch | awk '{print \$1}' | xargs -r docker stop && docker ps -a | grep rooch | awk '{print \$1}' | xargs -r docker rm -f && docker pull 'ghcr.io/rooch-network/rooch:${{ steps.extract-version.outputs.tag-name }}' && docker run -d -v /data:/root -p 50051:50051 'ghcr.io/rooch-network/rooch:${{ steps.extract-version.outputs.tag-name }}' server start -n test --btc-rpc-url '${{secrets.BTC_TEST_RPC_URL}}' --btc-rpc-username rooch-test --btc-rpc-password '${{secrets.BTC_TEST_RPC_PWD}}' --btc-network 2 --da '{\"internal-da-server\": {\"servers\": [{\"open-da\": {\"scheme\": \"gcs\", \"config\": {\"bucket\": \"${{secrets.OPENDA_GCP_TESTNET_BUCKET}}\", \"credential\": \"${{secrets.OPENDA_GCP_TESTNET_CREDENTIAL}}\"}}}]}}'"
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST bash -c "'sleep 30' && docker image prune -a -f && docker ps | grep rooch | awk '{print \$1}' | xargs -r docker stop && docker ps -a | grep rooch | awk '{print \$1}' | xargs -r docker rm -f && docker pull 'ghcr.io/rooch-network/rooch:${{ steps.extract-version.outputs.tag-name }}' && docker run -d -v /data:/root -p 50051:50051 'ghcr.io/rooch-network/rooch:${{ steps.extract-version.outputs.tag-name }}' server start -n test --btc-rpc-url '${{secrets.BTC_TEST_RPC_URL}}' --btc-rpc-username rooch-test --btc-rpc-password '${{secrets.BTC_TEST_RPC_PWD}}' --da '{\"internal-da-server\": {\"servers\": [{\"open-da\": {\"scheme\": \"gcs\", \"config\": {\"bucket\": \"${{secrets.OPENDA_GCP_TESTNET_BUCKET}}\", \"credential\": \"${{secrets.OPENDA_GCP_TESTNET_CREDENTIAL}}\"}}}]}}'"
2 changes: 1 addition & 1 deletion .github/workflows/deploy_testnet_match.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ jobs:
chmod 600 private_key.pem
sudo apt update
sudo apt install -y --no-install-recommends openssh-server
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST bash -c "'sleep 30' && docker ps | grep rooch | awk '{print \$1}' | xargs -r docker stop && docker ps -a | grep rooch | awk '{print \$1}' | xargs -r docker rm -f && docker pull 'ghcr.io/rooch-network/rooch:${{ github.event.inputs.tagName }}' && docker run -d -v /data:/root -p 50051:50051 'ghcr.io/rooch-network/rooch:${{ github.event.inputs.tagName }}' server start -n test --btc-rpc-url '${{secrets.BTC_MAIN_RPC_URL}}' --btc-rpc-username rooch-main --btc-rpc-password '${{secrets.BTC_MAIN_RPC_PWD}}' --btc-network 1 --da '{\"internal-da-server\": {\"servers\": [{\"open-da\": {\"scheme\": \"gcs\", \"config\": {\"bucket\": \"${{secrets.OPENDA_GCP_TESTNET_BUCKET}}\", \"credential\": \"${{secrets.OPENDA_GCP_TESTNET_CREDENTIAL}}\"}}}]}}'"
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST bash -c "'sleep 30' && docker ps | grep rooch | awk '{print \$1}' | xargs -r docker stop && docker ps -a | grep rooch | awk '{print \$1}' | xargs -r docker rm -f && docker pull 'ghcr.io/rooch-network/rooch:${{ github.event.inputs.tagName }}' && docker run -d -v /data:/root -p 50051:50051 'ghcr.io/rooch-network/rooch:${{ github.event.inputs.tagName }}' server start -n test --btc-rpc-url '${{secrets.BTC_MAIN_RPC_URL}}' --btc-rpc-username rooch-main --btc-rpc-password '${{secrets.BTC_MAIN_RPC_PWD}}' --da '{\"internal-da-server\": {\"servers\": [{\"open-da\": {\"scheme\": \"gcs\", \"config\": {\"bucket\": \"${{secrets.OPENDA_GCP_TESTNET_BUCKET}}\", \"credential\": \"${{secrets.OPENDA_GCP_TESTNET_CREDENTIAL}}\"}}}]}}'"
2 changes: 1 addition & 1 deletion .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ jobs:
chmod 600 private_key.pem
sudo apt update
sudo apt install -y --no-install-recommends openssh-server
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST bash -c "'sleep 30' && docker image prune -a -f && docker ps | grep rooch | awk '{print \$1}' | xargs -r docker stop && docker ps -a | grep rooch | awk '{print \$1}' | xargs -r docker rm -f && docker pull 'ghcr.io/rooch-network/rooch:${{ steps.docker_meta.outputs.version }}' && docker run --rm -v /root:/root ghcr.io/rooch-network/rooch:${{ steps.docker_meta.outputs.version }} server clean -n dev && docker run -d -v /root:/root -p 50051:50051 'ghcr.io/rooch-network/rooch:${{ steps.docker_meta.outputs.version }}' server start -n dev --btc-rpc-url '${{secrets.BTC_TEST_RPC_URL}}' --btc-rpc-username rooch-test --btc-rpc-password '${{secrets.BTC_TEST_RPC_PWD}}' --btc-network 2 --da '{\"internal-da-server\": {\"servers\": [{\"open-da\": {\"scheme\": \"fs\"}}]}}'"
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST bash -c "'sleep 30' && docker image prune -a -f && docker ps | grep rooch | awk '{print \$1}' | xargs -r docker stop && docker ps -a | grep rooch | awk '{print \$1}' | xargs -r docker rm -f && docker pull 'ghcr.io/rooch-network/rooch:${{ steps.docker_meta.outputs.version }}' && docker run --rm -v /root:/root ghcr.io/rooch-network/rooch:${{ steps.docker_meta.outputs.version }} server clean -n dev && docker run -d -v /root:/root -p 50051:50051 'ghcr.io/rooch-network/rooch:${{ steps.docker_meta.outputs.version }}' server start -n dev --btc-rpc-url '${{secrets.BTC_TEST_RPC_URL}}' --btc-rpc-username rooch-test --btc-rpc-password '${{secrets.BTC_TEST_RPC_PWD}}' --da '{\"internal-da-server\": {\"servers\": [{\"open-da\": {\"scheme\": \"fs\"}}]}}'"
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST "cd /root/rooch && git pull origin main && bash scripts/check_dev_deploy_status.sh ${{ steps.docker_meta.outputs.version }} '${{ secrets.DEV_MNEMONIC_PHRASE }}'"
2 changes: 1 addition & 1 deletion crates/data_verify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Refer to the scripts in the `scripts/bitcoin` directory to initialize the Bitcoi
`ord --bitcoin-rpc-user roochuser --bitcoin-rpc-pass roochpass index export --include-addresses --tsv ord.export.tsv`

### Rooch server cli
`rooch server start -n local --btc-rpc-url http://127.0.0.1:8332 --btc-rpc-username roochuser --btc-rpc-password roochpass --btc-start-block-height 767430 --btc-end-block-height 774697 --btc-network 1 --data-verify-mode true`
`rooch server start -n local --btc-rpc-url http://127.0.0.1:8332 --btc-rpc-username roochuser --btc-rpc-password roochpass --btc-start-block-height 767430 --btc-end-block-height 774697 --data-verify-mode true`

### Run Data verify
`cargo run`
2 changes: 0 additions & 2 deletions crates/rooch-benchmarks/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@ pub async fn setup_service(

let sequencer_keypair = rooch_key_pair.copy();
let proposer_keypair = rooch_key_pair.copy();
let relayer_keypair = rooch_key_pair.copy();
let sequencer_account = RoochAddress::from(&sequencer_keypair.public());
let proposer_account = RoochAddress::from(&proposer_keypair.public());
let _relayer_account = RoochAddress::from(&relayer_keypair.public());

// Init executor
let mut network: RoochNetwork = BuiltinChainID::Dev.into();
Expand Down
26 changes: 2 additions & 24 deletions crates/rooch-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ use std::{fmt::Debug, path::Path, path::PathBuf};

use anyhow::Result;
use clap::Parser;
use moveos_config::{temp_dir, DataDirPath};
use once_cell::sync::Lazy;
use rand::Rng;
use serde::{Deserialize, Serialize};

use moveos_config::{temp_dir, DataDirPath};
use rooch_types::bitcoin::network::Network;
use rooch_types::crypto::RoochKeyPair;
use rooch_types::rooch_network::{BuiltinChainID, RoochChainID};
use serde::{Deserialize, Serialize};

use crate::da_config::DAConfig;
use crate::store_config::StoreConfig;
Expand Down Expand Up @@ -112,30 +110,17 @@ pub struct RoochOpt {
#[clap(long, id = "btc-rpc-password", env = "BTC_RPC_PASSWORD")]
pub btc_rpc_password: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
#[clap(long, env = "BTC_START_BLOCK_HEIGHT")]
/// The start block height of the Bitcoin chain to start relaying from, default is latest.
pub btc_start_block_height: Option<u64>,

#[serde(skip_serializing_if = "Option::is_none")]
#[clap(long, env = "BTC_END_BLOCK_HEIGHT")]
/// The end block height of the Bitcoin chain to stop relaying from, default is none.
pub btc_end_block_height: Option<u64>,

#[serde(skip_serializing_if = "Option::is_none")]
#[clap(long)]
/// The bitcoin network, default is regtest.
pub btc_network: Option<u8>,

/// The address of the sequencer account
#[clap(long)]
pub sequencer_account: Option<String>,
/// The address of the proposer account
#[clap(long)]
pub proposer_account: Option<String>,
/// The address of the relayer account
#[clap(long)]
pub relayer_account: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
#[clap(long)]
Expand Down Expand Up @@ -171,12 +156,9 @@ impl RoochOpt {
btc_rpc_url: None,
btc_rpc_username: None,
btc_rpc_password: None,
btc_start_block_height: None,
btc_end_block_height: None,
btc_network: Some(Network::default().to_num()),
sequencer_account: None,
proposer_account: None,
relayer_account: None,
da: None,
data_import_flag: false,
}
Expand Down Expand Up @@ -207,7 +189,6 @@ impl RoochOpt {
btc_rpc_url: self.btc_rpc_url.clone().unwrap(),
btc_rpc_user_name: self.btc_rpc_username.clone().unwrap(),
btc_rpc_password: self.btc_rpc_password.clone().unwrap(),
btc_start_block_height: self.btc_start_block_height,
btc_end_block_height: self.btc_end_block_height,
})
}
Expand All @@ -227,7 +208,6 @@ pub struct BitcoinRelayerConfig {
pub btc_rpc_url: String,
pub btc_rpc_user_name: String,
pub btc_rpc_password: String,
pub btc_start_block_height: Option<u64>,
pub btc_end_block_height: Option<u64>,
}

Expand Down Expand Up @@ -283,7 +263,6 @@ pub struct ServerOpt {
/// Sequencer, proposer and relayer keypair
pub sequencer_keypair: Option<RoochKeyPair>,
pub proposer_keypair: Option<RoochKeyPair>,
pub relayer_keypair: Option<RoochKeyPair>,
pub active_env: Option<String>,
}

Expand All @@ -302,7 +281,6 @@ impl ServerOpt {
ServerOpt {
sequencer_keypair: None,
proposer_keypair: None,
relayer_keypair: None,
active_env: None,
}
}
Expand Down
5 changes: 4 additions & 1 deletion crates/rooch-genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ impl RoochGenesis {
genesis_config.timestamp,
genesis_config.sequencer_account,
);
let bitcoin_genesis_ctx = BitcoinGenesisContext::new(genesis_config.bitcoin_network);
let bitcoin_genesis_ctx = BitcoinGenesisContext::new(
genesis_config.bitcoin_network,
genesis_config.bitcoin_block_height,
);

let bundles = stdlib.all_module_bundles()?;

Expand Down
24 changes: 9 additions & 15 deletions crates/rooch-relayer/src/actor/bitcoin_relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ use rooch_types::{
multichain_id::RoochMultiChainID,
transaction::{L1Block, L1BlockWithBody},
};
use std::cmp::max;
use tracing::{debug, info};

pub struct BitcoinRelayer {
start_block_height: Option<u64>,
genesis_block_height: u64,
// only for data import
end_block_height: Option<u64>,
rpc_client: BitcoinClientProxy,
//TODO if we want make the relayer to an independent process, we need to replace the executor proxy with a rooch rpc client
move_caller: ExecutorProxy,
buffer: Vec<BlockResult>,
sync_block_interval: u64,
Expand All @@ -44,8 +42,10 @@ impl BitcoinRelayer {
rpc_client: BitcoinClientProxy,
executor: ExecutorProxy,
) -> Result<Self> {
let bitcoin_module = executor.as_module_binding::<BitcoinModule>();
let genesis_block_height = bitcoin_module.get_genesis_block_height()?;
Ok(Self {
start_block_height: config.btc_start_block_height,
genesis_block_height,
end_block_height: config.btc_end_block_height,
rpc_client,
move_caller: executor,
Expand Down Expand Up @@ -75,17 +75,11 @@ impl BitcoinRelayer {
.get_block_header_info(latest_block_hash_in_bitcoin)
.await?;
let latest_block_height_in_bitcoin = latest_block_header_info.height as u64;
let start_block_height: u64 = match (self.start_block_height, latest_block_height_in_rooch)
{
(Some(start_block_height), Some(latest_block_height_in_rooch)) => {
max(start_block_height, latest_block_height_in_rooch + 1)
}
(Some(start_block_height), None) => start_block_height,
(None, Some(latest_block_height_in_rooch)) => latest_block_height_in_rooch + 1,
(None, None) => {
//if the start_block_height is None, and the latest_block_height_in_rooch is None
//we sync from the latest block
latest_block_height_in_bitcoin
let start_block_height: u64 = match latest_block_height_in_rooch {
Some(latest_block_height_in_rooch) => latest_block_height_in_rooch + 1,
None => {
// if the latest block height in rooch is None, then the genesis block height should be used
self.genesis_block_height
}
};
let start_block_height_usize = start_block_height as usize;
Expand Down
2 changes: 1 addition & 1 deletion crates/rooch-rpc-client/src/client_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Env {
impl Default for Env {
fn default() -> Self {
Env {
alias: BuiltinChainID::Dev.chain_name(),
alias: BuiltinChainID::Local.chain_name(),
rpc: ServerConfig::default().url(false),
ws: None,
}
Expand Down
Loading

0 comments on commit 6e4a1d6

Please sign in to comment.