From 6e4a1d680fd8ce1f2ccc48c4453920124e63bdad Mon Sep 17 00:00:00 2001 From: jolestar Date: Sat, 18 May 2024 03:47:38 +0800 Subject: [PATCH] [genesis] Fix Sequencer config for genesis (#1699) * [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 --- .gitattributes | 8 +- .github/workflows/check_build_test.yml | 11 +- .github/workflows/deploy_mainnet.yml | 2 +- .github/workflows/deploy_testnet.yml | 2 +- .github/workflows/deploy_testnet_match.yml | 2 +- .github/workflows/docker_build.yml | 2 +- crates/data_verify/README.md | 2 +- crates/rooch-benchmarks/src/tx.rs | 2 - crates/rooch-config/src/lib.rs | 26 +--- crates/rooch-genesis/src/lib.rs | 5 +- .../src/actor/bitcoin_relayer.rs | 24 ++- crates/rooch-rpc-client/src/client_config.rs | 2 +- crates/rooch-rpc-server/src/lib.rs | 53 ++++--- crates/rooch-types/src/bitcoin/genesis.rs | 9 +- crates/rooch-types/src/bitcoin/mod.rs | 20 +++ crates/rooch-types/src/genesis_config.rs | 21 ++- crates/rooch/src/commands/init.rs | 2 +- .../src/commands/server/commands/start.rs | 92 ++++-------- crates/testsuite/features/cmd.feature | 40 ++--- crates/testsuite/tests/integration.rs | 16 +- .../build/reference/rpc/json-rpc.en-US.mdx | 4 +- .../build/reference/rpc/json-rpc.zh-CN.mdx | 4 +- examples/bitseed_runner/sources/bitseed.move | 5 - frameworks/bitcoin-move/doc/bitcoin.md | 25 +-- frameworks/bitcoin-move/doc/network.md | 26 +++- .../bitcoin-move/error_description.errmap | Bin 4721 -> 4799 bytes frameworks/bitcoin-move/sources/bitcoin.move | 36 ++++- frameworks/bitcoin-move/sources/genesis.move | 5 +- frameworks/bitcoin-move/sources/network.move | 12 +- frameworks/bitcoin-move/sources/ord.move | 142 +++++++++--------- .../framework-release/released/1/stdlib | Bin 118317 -> 118636 bytes frameworks/moveos-stdlib/sources/hex.move | 6 +- frameworks/rooch-framework/doc/genesis.md | 1 + .../rooch-framework/sources/gas_coin.move | 2 +- .../rooch-framework/sources/genesis.move | 12 +- .../rooch-nursery/error_description.errmap | Bin 4807 -> 4811 bytes frameworks/rooch-nursery/sources/bitseed.move | 2 +- moveos/moveos/src/vm/moveos_vm.rs | 9 +- rooch-portal-v1/script/env.sh | 2 +- scripts/bitcoin/README.md | 4 +- scripts/bitcoin/env.sh | 2 +- scripts/pr.sh | 4 +- 42 files changed, 343 insertions(+), 301 deletions(-) diff --git a/.gitattributes b/.gitattributes index 235a0caf81..e131ee0b44 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/.github/workflows/check_build_test.yml b/.github/workflows/check_build_test.yml index 5fedb5d70c..19ef03a3bf 100644 --- a/.github/workflows/check_build_test.yml +++ b/.github/workflows/check_build_test.yml @@ -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 diff --git a/.github/workflows/deploy_mainnet.yml b/.github/workflows/deploy_mainnet.yml index cd19683486..c0751ff9b5 100644 --- a/.github/workflows/deploy_mainnet.yml +++ b/.github/workflows/deploy_mainnet.yml @@ -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" diff --git a/.github/workflows/deploy_testnet.yml b/.github/workflows/deploy_testnet.yml index 32930182fc..1b14ebec57 100644 --- a/.github/workflows/deploy_testnet.yml +++ b/.github/workflows/deploy_testnet.yml @@ -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}}\"}}}]}}'" diff --git a/.github/workflows/deploy_testnet_match.yml b/.github/workflows/deploy_testnet_match.yml index 8203e3b56d..acae403260 100644 --- a/.github/workflows/deploy_testnet_match.yml +++ b/.github/workflows/deploy_testnet_match.yml @@ -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}}\"}}}]}}'" diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index 4b9e104a41..2eb2bb56bc 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -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 }}'" diff --git a/crates/data_verify/README.md b/crates/data_verify/README.md index 9cd5cbccb1..e5a6d975bd 100644 --- a/crates/data_verify/README.md +++ b/crates/data_verify/README.md @@ -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` \ No newline at end of file diff --git a/crates/rooch-benchmarks/src/tx.rs b/crates/rooch-benchmarks/src/tx.rs index f2213b1b76..45a33c4330 100644 --- a/crates/rooch-benchmarks/src/tx.rs +++ b/crates/rooch-benchmarks/src/tx.rs @@ -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(); diff --git a/crates/rooch-config/src/lib.rs b/crates/rooch-config/src/lib.rs index d46eb4ed9b..01ec1a7646 100644 --- a/crates/rooch-config/src/lib.rs +++ b/crates/rooch-config/src/lib.rs @@ -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; @@ -112,30 +110,17 @@ pub struct RoochOpt { #[clap(long, id = "btc-rpc-password", env = "BTC_RPC_PASSWORD")] pub btc_rpc_password: Option, - #[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, - #[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, - #[serde(skip_serializing_if = "Option::is_none")] - #[clap(long)] - /// The bitcoin network, default is regtest. - pub btc_network: Option, - /// The address of the sequencer account #[clap(long)] pub sequencer_account: Option, /// The address of the proposer account #[clap(long)] pub proposer_account: Option, - /// The address of the relayer account - #[clap(long)] - pub relayer_account: Option, #[serde(skip_serializing_if = "Option::is_none")] #[clap(long)] @@ -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, } @@ -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, }) } @@ -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, pub btc_end_block_height: Option, } @@ -283,7 +263,6 @@ pub struct ServerOpt { /// Sequencer, proposer and relayer keypair pub sequencer_keypair: Option, pub proposer_keypair: Option, - pub relayer_keypair: Option, pub active_env: Option, } @@ -302,7 +281,6 @@ impl ServerOpt { ServerOpt { sequencer_keypair: None, proposer_keypair: None, - relayer_keypair: None, active_env: None, } } diff --git a/crates/rooch-genesis/src/lib.rs b/crates/rooch-genesis/src/lib.rs index f0e53ed33d..d3e5e03c87 100644 --- a/crates/rooch-genesis/src/lib.rs +++ b/crates/rooch-genesis/src/lib.rs @@ -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()?; diff --git a/crates/rooch-relayer/src/actor/bitcoin_relayer.rs b/crates/rooch-relayer/src/actor/bitcoin_relayer.rs index b1b5a1a677..f42b607bba 100644 --- a/crates/rooch-relayer/src/actor/bitcoin_relayer.rs +++ b/crates/rooch-relayer/src/actor/bitcoin_relayer.rs @@ -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, + genesis_block_height: u64, // only for data import end_block_height: Option, 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, sync_block_interval: u64, @@ -44,8 +42,10 @@ impl BitcoinRelayer { rpc_client: BitcoinClientProxy, executor: ExecutorProxy, ) -> Result { + let bitcoin_module = executor.as_module_binding::(); + 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, @@ -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; diff --git a/crates/rooch-rpc-client/src/client_config.rs b/crates/rooch-rpc-client/src/client_config.rs index 92c8aea7e7..4f401e908b 100644 --- a/crates/rooch-rpc-client/src/client_config.rs +++ b/crates/rooch-rpc-client/src/client_config.rs @@ -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, } diff --git a/crates/rooch-rpc-server/src/lib.rs b/crates/rooch-rpc-server/src/lib.rs index 56f3f37ee2..ee54d4cf87 100644 --- a/crates/rooch-rpc-server/src/lib.rs +++ b/crates/rooch-rpc-server/src/lib.rs @@ -6,13 +6,14 @@ use crate::server::rooch_server::RoochServer; use crate::service::aggregate_service::AggregateService; use crate::service::rpc_logger::RpcLogger; use crate::service::rpc_service::RpcService; -use anyhow::{bail, Error, Result}; +use anyhow::{bail, ensure, Error, Result}; use coerce::actor::scheduler::timer::Timer; use coerce::actor::{system::ActorSystem, IntoActor}; use hyper::header::HeaderValue; use hyper::Method; use jsonrpsee::server::ServerBuilder; use jsonrpsee::RpcModule; +use move_core_types::account_address::AccountAddress; use moveos_store::{MoveOSDB, MoveOSStore}; use moveos_types::moveos_std::object::{ObjectEntity, RootObjectEntity}; use raw_store::errors::RawStoreError; @@ -47,7 +48,7 @@ use rooch_sequencer::proxy::SequencerProxy; use rooch_store::RoochStore; use rooch_types::address::RoochAddress; use rooch_types::error::{GenesisError, RoochError}; -use rooch_types::rooch_network::{RoochChainID, RoochNetwork}; +use rooch_types::rooch_network::{BuiltinChainID, RoochChainID, RoochNetwork}; use serde_json::json; use std::env; use std::fmt::Debug; @@ -192,36 +193,37 @@ pub async fn run_start_server(opt: &RoochOpt, server_opt: ServerOpt) -> Result chain_id.into(), - _ => bail!("Custom chain_id is not supported auto genesis, please use `rooch genesis` to init genesis. "), - }; - //TODO only set sequencer account if the network is local/dev - network.set_sequencer_account(sequencer_account.into()); - let genesis: RoochGenesis = RoochGenesis::build(network)?; - root = genesis.init_genesis(&mut moveos_store)?; - } else if let RoochChainID::Builtin(chain_id) = chain_id { - let mut network: RoochNetwork = chain_id.into(); - //TODO only set sequencer account if the network is local/dev - network.set_sequencer_account(sequencer_account.into()); + if let RoochChainID::Builtin(builtin_chain_id) = chain_id { + let mut network: RoochNetwork = builtin_chain_id.into(); + match builtin_chain_id { + // local and dev chain can use any sequencer account + BuiltinChainID::Local | BuiltinChainID::Dev => { + network.set_sequencer_account(sequencer_account); + } + _ => { + ensure!(network.genesis_config.sequencer_account == sequencer_account, "Sequencer({:?}) in genesis config is not equal to sequencer({:?}) in cli config", network.genesis_config.sequencer_account, sequencer_account); + } + } let genesis = RoochGenesis::build(network)?; - genesis.check_genesis(moveos_store.get_config_store())?; - }; + if root.is_genesis() { + root = genesis.init_genesis(&mut moveos_store)?; + } else { + genesis.check_genesis(moveos_store.get_config_store())?; + } + } else if root.is_genesis() { + bail!("Custom chain_id is not supported auto genesis, please use `rooch genesis` to init genesis. "); + } let executor_actor = ExecutorActor::new(root.clone(), moveos_store.clone(), rooch_store.clone())?; @@ -236,7 +238,7 @@ pub async fn run_start_server(opt: &RoochOpt, server_opt: ServerOpt) -> Result Result move_core_types::value::MoveStructLayout { move_core_types::value::MoveStructLayout::new(vec![ move_core_types::value::MoveTypeLayout::U8, + move_core_types::value::MoveTypeLayout::U64, ]) } } impl BitcoinGenesisContext { - pub fn new(network: u8) -> Self { - Self { network } + pub fn new(network: u8, genesis_block_height: u64) -> Self { + Self { + network, + genesis_block_height, + } } } diff --git a/crates/rooch-types/src/bitcoin/mod.rs b/crates/rooch-types/src/bitcoin/mod.rs index 3ed514e728..bb9ca2a192 100644 --- a/crates/rooch-types/src/bitcoin/mod.rs +++ b/crates/rooch-types/src/bitcoin/mod.rs @@ -81,6 +81,8 @@ impl<'a> BitcoinModule<'a> { pub const GET_UTXO_FUNCTION_NAME: &'static IdentStr = ident_str!("get_utxo"); pub const SUBMIT_NEW_BLOCK_ENTRY_FUNCTION_NAME: &'static IdentStr = ident_str!("submit_new_block"); + pub const GET_GENESIS_BLOCK_HEIGHT_FUNCTION_NAME: &'static IdentStr = + ident_str!("get_genesis_block_height"); // pub const PROCESS_UTXOS_ENTRY_FUNCTION_NAME: &'static IdentStr = ident_str!("process_utxos"); pub fn get_block(&self, block_hash: BlockHash) -> Result> { @@ -156,6 +158,24 @@ impl<'a> BitcoinModule<'a> { Ok(height.into()) } + pub fn get_genesis_block_height(&self) -> Result { + let call = Self::create_function_call( + Self::GET_GENESIS_BLOCK_HEIGHT_FUNCTION_NAME, + vec![], + vec![], + ); + let ctx = TxContext::new_readonly_ctx(AccountAddress::ZERO); + let height = self + .caller + .call_function(&ctx, call)? + .into_result() + .map(|mut values| { + let value = values.pop().expect("should have one return value"); + bcs::from_bytes::(&value.value).expect("should be a valid u64") + })?; + Ok(height) + } + pub fn create_submit_new_block_call(block_height: u64, block: bitcoin::Block) -> FunctionCall { let block_hash = block.block_hash(); let block = crate::bitcoin::types::Block::from(block); diff --git a/crates/rooch-types/src/genesis_config.rs b/crates/rooch-types/src/genesis_config.rs index 5ec530bafb..1b5bd941e2 100644 --- a/crates/rooch-types/src/genesis_config.rs +++ b/crates/rooch-types/src/genesis_config.rs @@ -3,6 +3,7 @@ use ethers::types::H256; use framework_builder::stdlib_version::StdlibVersion; +use framework_types::addresses::ROOCH_FRAMEWORK_ADDRESS; use move_core_types::{account_address::AccountAddress, language_storage::StructTag}; use moveos_types::moveos_std::object::ObjectID; use once_cell::sync::Lazy; @@ -30,7 +31,7 @@ pub static G_LOCAL_CONFIG: Lazy = Lazy::new(|| GenesisConfig { bitcoin_network: crate::bitcoin::network::Network::Regtest.to_num(), bitcoin_block_height: 0, timestamp: 0, - sequencer_account: AccountAddress::ONE, + sequencer_account: ROOCH_FRAMEWORK_ADDRESS, genesis_objects: vec![], stdlib_version: StdlibVersion::Latest, }); @@ -39,18 +40,21 @@ pub static G_DEV_CONFIG: Lazy = Lazy::new(|| GenesisConfig { bitcoin_network: crate::bitcoin::network::Network::Testnet.to_num(), bitcoin_block_height: 0, timestamp: 0, - sequencer_account: AccountAddress::ONE, + sequencer_account: ROOCH_FRAMEWORK_ADDRESS, genesis_objects: vec![], stdlib_version: StdlibVersion::Latest, }); pub static G_TEST_CONFIG: Lazy = Lazy::new(|| { - //TODO define test config + // curl -sSL "https://mempool.space/testnet/api/block/000000009373df1134670bd45e75a6b8f1fb07610a9eeb7933ef266da9507cb9" GenesisConfig { bitcoin_network: crate::bitcoin::network::Network::Testnet.to_num(), - bitcoin_block_height: 0, - timestamp: 0, - sequencer_account: AccountAddress::ONE, + bitcoin_block_height: 2815983, + timestamp: 1715941066000, + sequencer_account: AccountAddress::from_hex_literal( + "0xbe2701d15ccdc282caf8ca6647e7a54db5721f8bcb7b980b4d0c65a151bf74da", + ) + .expect("Should be valid"), genesis_objects: vec![], stdlib_version: StdlibVersion::Version(1), } @@ -62,7 +66,10 @@ pub static G_MAIN_CONFIG: Lazy = Lazy::new(|| { bitcoin_network: crate::bitcoin::network::Network::Bitcoin.to_num(), bitcoin_block_height: 0, timestamp: 0, - sequencer_account: AccountAddress::ONE, + sequencer_account: AccountAddress::from_hex_literal( + "0xbe2701d15ccdc282caf8ca6647e7a54db5721f8bcb7b980b4d0c65a151bf74da", + ) + .expect("Invalid address"), genesis_objects: vec![], stdlib_version: StdlibVersion::Version(1), } diff --git a/crates/rooch/src/commands/init.rs b/crates/rooch/src/commands/init.rs index fa7b975536..89a5bbadd3 100644 --- a/crates/rooch/src/commands/init.rs +++ b/crates/rooch/src/commands/init.rs @@ -175,7 +175,7 @@ impl CommandAction<()> for Init { let client_config = ClientConfig { keystore_path, - envs: vec![env, dev_env], + envs: vec![env, dev_env, Env::new_test_env()], active_address: Some(result.address), // make dev env as default env active_env: Some(active_env_alias), diff --git a/crates/rooch/src/commands/server/commands/start.rs b/crates/rooch/src/commands/server/commands/start.rs index 74c553390f..4e64562a0b 100644 --- a/crates/rooch/src/commands/server/commands/start.rs +++ b/crates/rooch/src/commands/server/commands/start.rs @@ -66,74 +66,46 @@ impl CommandAction<()> for StartCommand { }, )? }; - let relayer_account = if self.opt.relayer_account.is_none() { - let active_address_opt = context.client_config.active_address; - if active_address_opt.is_none() { - return Err(RoochError::ActiveAddressDoesNotExistError); - } - active_address_opt.unwrap() - } else { - RoochAddress::from_str(self.opt.relayer_account.clone().unwrap().as_str()).map_err( - |e| { - RoochError::CommandArgumentError(format!( - "Invalid relayer account address: {}", - e - )) - }, - )? - }; - let (sequencer_keypair, proposer_keypair, relayer_keypair) = - if context.keystore.get_if_password_is_empty() { - let sequencer_keypair = context - .keystore - .get_key_pair_with_password(&sequencer_account, None) - .map_err(|e| RoochError::SequencerKeyPairDoesNotExistError(e.to_string()))?; + let (sequencer_keypair, proposer_keypair) = if context.keystore.get_if_password_is_empty() { + let sequencer_keypair = context + .keystore + .get_key_pair_with_password(&sequencer_account, None) + .map_err(|e| RoochError::SequencerKeyPairDoesNotExistError(e.to_string()))?; - let proposer_keypair = context - .keystore - .get_key_pair_with_password(&proposer_account, None) - .map_err(|e| RoochError::ProposerKeyPairDoesNotExistError(e.to_string()))?; + let proposer_keypair = context + .keystore + .get_key_pair_with_password(&proposer_account, None) + .map_err(|e| RoochError::ProposerKeyPairDoesNotExistError(e.to_string()))?; - let relayer_keypair = context - .keystore - .get_key_pair_with_password(&relayer_account, None) - .map_err(|e| RoochError::RelayerKeyPairDoesNotExistError(e.to_string()))?; + (sequencer_keypair, proposer_keypair) + } else { + let password = prompt_password("Enter the password:").unwrap_or_default(); + let is_verified = + verify_password(Some(password.clone()), context.keystore.get_password_hash())?; + + if !is_verified { + return Err(RoochError::InvalidPasswordError( + "Password is invalid".to_owned(), + )); + } - (sequencer_keypair, proposer_keypair, relayer_keypair) - } else { - let password = prompt_password("Enter the password:").unwrap_or_default(); - let is_verified = - verify_password(Some(password.clone()), context.keystore.get_password_hash())?; - - if !is_verified { - return Err(RoochError::InvalidPasswordError( - "Password is invalid".to_owned(), - )); - } - - let sequencer_keypair = context - .keystore - .get_key_pair_with_password(&sequencer_account, Some(password.clone())) - .map_err(|e| RoochError::SequencerKeyPairDoesNotExistError(e.to_string()))?; - - let proposer_keypair = context - .keystore - .get_key_pair_with_password(&proposer_account, Some(password.clone())) - .map_err(|e| RoochError::ProposerKeyPairDoesNotExistError(e.to_string()))?; - - let relayer_keypair = context - .keystore - .get_key_pair_with_password(&relayer_account, Some(password)) - .map_err(|e| RoochError::RelayerKeyPairDoesNotExistError(e.to_string()))?; - - (sequencer_keypair, proposer_keypair, relayer_keypair) - }; + let sequencer_keypair = context + .keystore + .get_key_pair_with_password(&sequencer_account, Some(password.clone())) + .map_err(|e| RoochError::SequencerKeyPairDoesNotExistError(e.to_string()))?; + + let proposer_keypair = context + .keystore + .get_key_pair_with_password(&proposer_account, Some(password.clone())) + .map_err(|e| RoochError::ProposerKeyPairDoesNotExistError(e.to_string()))?; + + (sequencer_keypair, proposer_keypair) + }; // Construct sequencer, proposer and relayer keypair let mut server_opt = ServerOpt::new(); server_opt.sequencer_keypair = Some(sequencer_keypair.copy()); server_opt.proposer_keypair = Some(proposer_keypair.copy()); - server_opt.relayer_keypair = Some(relayer_keypair.copy()); let active_env = context.client_config.get_active_env()?; server_opt.active_env = Some(active_env.clone().alias); diff --git a/crates/testsuite/features/cmd.feature b/crates/testsuite/features/cmd.feature index f83397d8cf..9554577085 100644 --- a/crates/testsuite/features/cmd.feature +++ b/crates/testsuite/features/cmd.feature @@ -288,7 +288,7 @@ Feature: Rooch CLI integration tests # because the indexer is async update, so sleep 2 seconds to wait indexer update. Then sleep: "2" - Then cmd: "rpc request --method rooch_queryGlobalStates --params '[{"object_type":"{{$.address_mapping.default}}::child_object::Child"}, null, "10", true]'" + Then cmd: "rpc request --method rooch_queryObjectStates --params '[{"object_type":"{{$.address_mapping.default}}::child_object::Child"}, null, "10", true]'" Then assert: "{{$.rpc[-1].data[0].object_id}} == {{$.event[-1].data[0].decoded_event_data.value.id}}" Then cmd: "move run --function default::third_party_module_for_child_object::update_child_age --args object:{{$.event[-1].data[0].decoded_event_data.value.id}} --args u64:10" @@ -321,8 +321,8 @@ Feature: Rooch CLI integration tests Then assert: "{{$.wallet[-1].total}} == 5000000000" # query utxos and inscriptions - Then cmd: "rpc request --method rooch_queryGlobalStates --params '[{"object_type":"0x4::utxo::UTXO"}, null, "2", true]'" - Then cmd: "rpc request --method rooch_queryGlobalStates --params '[{"object_type":"0x4::ord::Inscription"}, null, "2", true]'" + Then cmd: "rpc request --method rooch_queryObjectStates --params '[{"object_type":"0x4::utxo::UTXO"}, null, "2", true]'" + Then cmd: "rpc request --method rooch_queryObjectStates --params '[{"object_type":"0x4::ord::Inscription"}, null, "2", true]'" # release servers Then stop the server @@ -332,30 +332,30 @@ Feature: Rooch CLI integration tests @serial Scenario: rooch bitseed test # prepare servers - Given a bitcoind server for rooch_bitseed_test - Given a ord server for rooch_bitseed_test - Given a server for rooch_bitseed_test + #Given a bitcoind server for rooch_bitseed_test + #Given a ord server for rooch_bitseed_test + #Given a server for rooch_bitseed_test # init wallet - Then cmd ord: "wallet create" - Then cmd ord: "wallet receive" + #Then cmd ord: "wallet create" + #Then cmd ord: "wallet receive" # mint utxos - Then cmd bitcoin-cli: "generatetoaddress 101 {{$.wallet[-1].address}}" - Then sleep: "10" # wait ord sync and index - Then cmd ord: "wallet balance" - Then assert: "{{$.wallet[-1].total}} == 5000000000" + #Then cmd bitcoin-cli: "generatetoaddress 101 {{$.wallet[-1].address}}" + #Then sleep: "10" # wait ord sync and index + #Then cmd ord: "wallet balance" + #Then assert: "{{$.wallet[-1].total}} == 5000000000" # generator - Then cmd bitseed: "generator --fee-rate 1 --name random --generator /app/test-data/generator.wasm" - Then assert: "'{{$.generator[-1]}}' not_contains error" + #Then cmd bitseed: "generator --fee-rate 1 --name random --generator /app/test-data/generator.wasm" + #Then assert: "'{{$.generator[-1]}}' not_contains error" # mine a block - Then cmd ord: "wallet receive" - Then cmd bitcoin-cli: "generatetoaddress 1 {{$.wallet[-1].address}}" - Then sleep: "5" + #Then cmd ord: "wallet receive" + #Then cmd bitcoin-cli: "generatetoaddress 1 {{$.wallet[-1].address}}" + #Then sleep: "5" # release servers - Then stop the server - Then stop the ord server - Then stop the bitcoind server \ No newline at end of file + #Then stop the server + #Then stop the ord server + #Then stop the bitcoind server \ No newline at end of file diff --git a/crates/testsuite/tests/integration.rs b/crates/testsuite/tests/integration.rs index 27761482e7..4d5b3025bf 100644 --- a/crates/testsuite/tests/integration.rs +++ b/crates/testsuite/tests/integration.rs @@ -6,26 +6,25 @@ mod images; use anyhow::{bail, Result}; use clap::Parser; use cucumber::{given, then, World as _}; +use images::bitcoin::BitcoinD; +use images::bitseed::Bitseed; +use images::ord::Ord; use jpst::TemplateContext; use rooch::RoochCli; use rooch_config::{rooch_config_dir, RoochOpt, ServerOpt}; use rooch_key::key_derive::{generate_new_key_pair, retrieve_key_pair}; use rooch_rpc_client::wallet_context::WalletContext; use rooch_rpc_server::Service; +use rooch_types::crypto::RoochKeyPair; use serde_json::Value; use std::path::Path; -use tracing::{debug, error, info}; - -use images::bitcoin::BitcoinD; -use images::bitseed::Bitseed; -use images::ord::Ord; -use rooch_types::{bitcoin::network::Network, crypto::RoochKeyPair}; use std::time::Duration; use testcontainers::{ clients::Cli, core::{Container, ExecCommand, WaitFor}, RunnableImage, }; +use tracing::{debug, error, info}; use uuid::Uuid; const RPC_USER: &str = "roochuser"; @@ -73,9 +72,7 @@ async fn start_server(w: &mut World, _scenario: String) { opt.btc_rpc_url = Some(bitcoin_rpc_url); opt.btc_rpc_username = Some(RPC_USER.to_string()); opt.btc_rpc_password = Some(RPC_PASS.to_string()); - opt.btc_start_block_height = Some(0); opt.data_import_flag = false; // Enable data import without writing indexes - opt.btc_network = Some(Network::Testnet.to_num()); info!("config btc rpc ok"); w.bitcoind = Some(bitcoind); @@ -92,7 +89,6 @@ async fn start_server(w: &mut World, _scenario: String) { retrieve_key_pair(&result.key_pair_data.private_key_encryption, None).unwrap(); server_opt.sequencer_keypair = Some(kp.copy()); server_opt.proposer_keypair = Some(kp.copy()); - server_opt.relayer_keypair = Some(kp.copy()); service.start(&opt, server_opt).await.unwrap(); @@ -318,7 +314,7 @@ async fn bitseed_run_cmd(w: &mut World, input_tpl: String) { let input = eval_command_args(tpl_ctx, input_tpl); let args: Vec<&str> = input.split_whitespace().collect(); - let cmd_name = args[0].clone(); + let cmd_name = args[0]; bitseed_args.extend(args.iter().map(|&s| s.to_string())); diff --git a/docs/website/pages/build/reference/rpc/json-rpc.en-US.mdx b/docs/website/pages/build/reference/rpc/json-rpc.en-US.mdx index e9729c215d..38385e847f 100644 --- a/docs/website/pages/build/reference/rpc/json-rpc.en-US.mdx +++ b/docs/website/pages/build/reference/rpc/json-rpc.en-US.mdx @@ -945,7 +945,7 @@ Response: } ``` -### rooch_queryGlobalStates +### rooch_queryObjectStates Query the global status indexer by status filter. @@ -964,7 +964,7 @@ Request: curl --location 'https://dev-seed.rooch.network:443' --header 'Content-Type: application/json' --data '{ "id":101, "jsonrpc":"2.0", - "method":"rooch_queryGlobalStates", + "method":"rooch_queryObjectStates", "params":[{"owner":"0xd9858821a52538c99f822d3f90ec798f76466bb7a1e82ebdb42d19b62a030069"}, null, "5", false] }' | jq ``` diff --git a/docs/website/pages/build/reference/rpc/json-rpc.zh-CN.mdx b/docs/website/pages/build/reference/rpc/json-rpc.zh-CN.mdx index 194d19ca79..eec42840f0 100644 --- a/docs/website/pages/build/reference/rpc/json-rpc.zh-CN.mdx +++ b/docs/website/pages/build/reference/rpc/json-rpc.zh-CN.mdx @@ -945,7 +945,7 @@ curl --location --header 'Content-Type: application/json' --data '{ } ``` -### rooch_queryGlobalStates +### rooch_queryObjectStates 通过状态过滤器查询全局状态索引器。 @@ -964,7 +964,7 @@ curl --location --header 'Content-Type: application/json' --data '{ curl --location 'https://dev-seed.rooch.network:443' --header 'Content-Type: application/json' --data '{ "id":101, "jsonrpc":"2.0", - "method":"rooch_queryGlobalStates", + "method":"rooch_queryObjectStates", "params":[{"owner":"0xd9858821a52538c99f822d3f90ec798f76466bb7a1e82ebdb42d19b62a030069"}, null, "5", false] }' | jq ``` diff --git a/examples/bitseed_runner/sources/bitseed.move b/examples/bitseed_runner/sources/bitseed.move index 5b6de59bdf..52d98dc6ff 100644 --- a/examples/bitseed_runner/sources/bitseed.move +++ b/examples/bitseed_runner/sources/bitseed.move @@ -2,12 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 module rooch_examples::bitseed_runner { - use std::string::{Self, String}; - use std::vector; - use moveos_std::string_utils::parse_u64; - use moveos_std::simple_map::{Self, SimpleMap}; - use moveos_std::json; use moveos_std::object; use bitcoin_move::ord::{InscriptionID, Inscription}; diff --git a/frameworks/bitcoin-move/doc/bitcoin.md b/frameworks/bitcoin-move/doc/bitcoin.md index 807e4cc203..6e294f5c18 100644 --- a/frameworks/bitcoin-move/doc/bitcoin.md +++ b/frameworks/bitcoin-move/doc/bitcoin.md @@ -14,14 +14,15 @@ - [Function `get_block`](#0x4_bitcoin_get_block) - [Function `get_block_height`](#0x4_bitcoin_get_block_height) - [Function `get_block_by_height`](#0x4_bitcoin_get_block_by_height) +- [Function `get_genesis_block_height`](#0x4_bitcoin_get_genesis_block_height) - [Function `get_latest_block_height`](#0x4_bitcoin_get_latest_block_height) -- [Function `need_process_oridinals`](#0x4_bitcoin_need_process_oridinals)
use 0x1::option;
 use 0x1::string;
 use 0x1::vector;
 use 0x2::bcs;
+use 0x2::event;
 use 0x2::object;
 use 0x2::signer;
 use 0x2::simple_multimap;
@@ -29,6 +30,7 @@
 use 0x2::table_vec;
 use 0x2::type_info;
 use 0x3::bitcoin_address;
+use 0x3::chain_id;
 use 0x3::timestamp;
 use 0x4::network;
 use 0x4::ord;
@@ -74,11 +76,12 @@
 
 
 
-
+
 
+If the process block failed, we need to stop the system and fix the issue
 
 
-
const ErrorBlockNotFound: u64 = 1;
+
const ErrorBlockProcessError: u64 = 1;
 
@@ -98,7 +101,7 @@ -
public(friend) fun genesis_init(_genesis_account: &signer)
+
public(friend) fun genesis_init(_genesis_account: &signer, genesis_block_height: u64)
 
@@ -160,23 +163,23 @@ Get block via block_height - + -## Function `get_latest_block_height` +## Function `get_genesis_block_height` -Get latest block height -
public fun get_latest_block_height(): option::Option<u64>
+
public fun get_genesis_block_height(): u64
 
- + -## Function `need_process_oridinals` +## Function `get_latest_block_height` +Get latest block height -
public fun need_process_oridinals(block_height: u64): bool
+
public fun get_latest_block_height(): option::Option<u64>
 
diff --git a/frameworks/bitcoin-move/doc/network.md b/frameworks/bitcoin-move/doc/network.md index 4f932300ab..27b97a22f3 100644 --- a/frameworks/bitcoin-move/doc/network.md +++ b/frameworks/bitcoin-move/doc/network.md @@ -14,6 +14,8 @@ - [Function `network_signet`](#0x4_network_network_signet) - [Function `network_regtest`](#0x4_network_network_regtest) - [Function `is_mainnet`](#0x4_network_is_mainnet) +- [Function `is_testnet`](#0x4_network_is_testnet) +- [Function `is_signet`](#0x4_network_is_signet) - [Function `from_str`](#0x4_network_from_str) - [Function `network_name`](#0x4_network_network_name) - [Function `bech32_hrp`](#0x4_network_bech32_hrp) @@ -166,7 +168,29 @@ Get the current network from the onchain configuration. -
public fun is_mainnet(network: u8): bool
+
public fun is_mainnet(): bool
+
+ + + + + +## Function `is_testnet` + + + +
public fun is_testnet(): bool
+
+ + + + + +## Function `is_signet` + + + +
public fun is_signet(): bool
 
diff --git a/frameworks/bitcoin-move/error_description.errmap b/frameworks/bitcoin-move/error_description.errmap index 2fb4a40f8d1bc9b665d945db8ad5d72c144dd5ef..7b3e78231392b8612b749566a89daed014d7454b 100644 GIT binary patch delta 140 zcmeyUvR`$>dbWBo*P^2QBBz}E, /// block hash -> block header blocks: Table, @@ -47,8 +55,9 @@ module bitcoin_move::bitcoin{ tx_ids: TableVec
, } - public(friend) fun genesis_init(_genesis_account: &signer){ + public(friend) fun genesis_init(_genesis_account: &signer, genesis_block_height: u64){ let btc_block_store = BitcoinBlockStore{ + genesis_block_height: genesis_block_height, latest_block_height: option::none(), blocks: table::new(), height_to_hash: table::new(), @@ -182,7 +191,15 @@ module bitcoin_move::bitcoin{ //The seals should be empty after utxo is spent simple_multimap::destroy_empty(seals); }else { + event::emit(TxProgressErrorLogEvent{ + txid: types::tx_id(tx), + message: string::utf8(b"utxo not exists"), + }); //We allow the utxo not exists in the utxo store, because we may not sync the block from genesis + //But we should not allow the utxo not exists in the mainnet + if(chain_id::is_main()){ + abort ErrorBlockProcessError + }; }; idx = idx + 1; @@ -336,6 +353,12 @@ module bitcoin_move::bitcoin{ } } + public fun get_genesis_block_height(): u64 { + let btc_block_store_obj = borrow_block_store(); + let btc_block_store = object::borrow(btc_block_store_obj); + btc_block_store.genesis_block_height + } + /// Get latest block height public fun get_latest_block_height(): Option { let btc_block_store_obj = borrow_block_store(); @@ -343,9 +366,8 @@ module bitcoin_move::bitcoin{ btc_block_store.latest_block_height } - public fun need_process_oridinals(block_height: u64) : bool { - let btc_network = network::network(); - if(network::is_mainnet(btc_network)){ + fun need_process_oridinals(block_height: u64) : bool { + if(network::is_mainnet()){ block_height >= ORDINAL_GENESIS_HEIGHT }else{ true diff --git a/frameworks/bitcoin-move/sources/genesis.move b/frameworks/bitcoin-move/sources/genesis.move index 3b23b2ba04..721b52aa07 100644 --- a/frameworks/bitcoin-move/sources/genesis.move +++ b/frameworks/bitcoin-move/sources/genesis.move @@ -15,6 +15,7 @@ module bitcoin_move::genesis{ /// BitcoinGenesisContext is a genesis init config in the TxContext. struct BitcoinGenesisContext has copy,store,drop{ network: u8, + genesis_block_height: u64, } fun init(){ @@ -25,14 +26,14 @@ module bitcoin_move::genesis{ network::genesis_init(genesis_context.network); utxo::genesis_init(); ord::genesis_init(&genesis_account); - bitcoin::genesis_init(&genesis_account); + bitcoin::genesis_init(&genesis_account, genesis_context.genesis_block_height); } #[test_only] /// init the genesis context for test public fun init_for_test(){ let genesis_account = moveos_std::signer::module_signer(); - tx_context::add_attribute_via_system(&genesis_account, BitcoinGenesisContext{network: network::network_signet()}); + tx_context::add_attribute_via_system(&genesis_account, BitcoinGenesisContext{network: network::network_signet(), genesis_block_height: 0}); init(); } diff --git a/frameworks/bitcoin-move/sources/network.move b/frameworks/bitcoin-move/sources/network.move index 95277b98b5..f06a629ad5 100644 --- a/frameworks/bitcoin-move/sources/network.move +++ b/frameworks/bitcoin-move/sources/network.move @@ -50,8 +50,16 @@ module bitcoin_move::network{ NETWORK_REGTEST } - public fun is_mainnet(network: u8): bool { - network == NETWORK_BITCOIN + public fun is_mainnet(): bool { + network() == NETWORK_BITCOIN + } + + public fun is_testnet(): bool { + network() == NETWORK_TESTNET + } + + public fun is_signet(): bool { + network() == NETWORK_SIGNET } public fun from_str(network: &String): u8 { diff --git a/frameworks/bitcoin-move/sources/ord.move b/frameworks/bitcoin-move/sources/ord.move index c98e1c2913..2984336802 100644 --- a/frameworks/bitcoin-move/sources/ord.move +++ b/frameworks/bitcoin-move/sources/ord.move @@ -775,6 +775,79 @@ module bitcoin_move::ord { } } + // ==== Inscription Metaprotocol Validity ==== // + + #[private_generics(T)] + /// Seal the metaprotocol validity for the given inscription_id. + public fun seal_metaprotocol_validity(inscription_id: InscriptionID, is_valid: bool, invalid_reason: Option) { + let store_obj_id = object::named_object_id(); + let store_obj = object::borrow_mut_object_shared(store_obj_id); + + let inscription_object_id = derive_inscription_id(inscription_id); + let inscription_obj = object::borrow_mut_object_field(store_obj, inscription_object_id); + + let protocol_type = type_info::type_name(); + let validity = MetaprotocolValidity { + protocol_type, + is_valid, + invalid_reason, + }; + + object::upsert_field(inscription_obj, METAPROTOCOL_VALIDITY, validity); + } + + /// Returns true if Inscription `object` contains metaprotocol validity + public fun exists_metaprotocol_validity(inscription_id: InscriptionID): bool{ + let store_obj_id = object::named_object_id(); + let store_obj = object::borrow_mut_object_shared(store_obj_id); + + let inscription_object_id = derive_inscription_id(inscription_id); + let exists = object::contains_object_field(store_obj, inscription_object_id); + if (!exists) { + return false + }; + + let inscription_obj = object::borrow_mut_object_field(store_obj, inscription_object_id); + object::contains_field(inscription_obj, METAPROTOCOL_VALIDITY) + } + + /// Borrow the metaprotocol validity for the given inscription_id. + public fun borrow_metaprotocol_validity(inscription_id: InscriptionID): &MetaprotocolValidity { + let store_obj_id = object::named_object_id(); + let store_obj = object::borrow_mut_object_shared(store_obj_id); + + let inscription_object_id = derive_inscription_id(inscription_id); + let inscription_obj = object::borrow_mut_object_field(store_obj, inscription_object_id); + + object::borrow_field(inscription_obj, METAPROTOCOL_VALIDITY) + } + + /// Check the MetaprotocolValidity's protocol_type whether match + public fun metaprotocol_validity_protocol_match(validity: &MetaprotocolValidity): bool { + let protocol_type = type_info::type_name(); + protocol_type == validity.protocol_type + } + + /// Get the MetaprotocolValidity's protocol_type + public fun metaprotocol_validity_protocol_type(validity: &MetaprotocolValidity): String { + validity.protocol_type + } + + /// Get the MetaprotocolValidity's is_valid + public fun metaprotocol_validity_is_valid(validity: &MetaprotocolValidity): bool { + validity.is_valid + } + + /// Get the MetaprotocolValidity's invalid_reason + public fun metaprotocol_validity_invalid_reason(validity: &MetaprotocolValidity): Option { + validity.invalid_reason + } + + #[test_only] + public fun init_for_test(_genesis_account: &signer){ + genesis_init(_genesis_account); + } + #[test_only] public fun drop_temp_area_for_test(inscription: &mut Object) { drop_temp_area(inscription); @@ -947,74 +1020,7 @@ module bitcoin_move::ord { assert!(!contains_temp_state(inscription_obj), 1); assert!(contains_permanent_state(inscription_obj), 2); } - - // ==== Inscription Metaprotocol Validity ==== // - - #[private_generics(T)] - /// Seal the metaprotocol validity for the given inscription_id. - public fun seal_metaprotocol_validity(inscription_id: InscriptionID, is_valid: bool, invalid_reason: Option) { - let store_obj_id = object::named_object_id(); - let store_obj = object::borrow_mut_object_shared(store_obj_id); - - let inscription_object_id = derive_inscription_id(inscription_id); - let inscription_obj = object::borrow_mut_object_field(store_obj, inscription_object_id); - - let protocol_type = type_info::type_name(); - let validity = MetaprotocolValidity { - protocol_type, - is_valid, - invalid_reason, - }; - - object::upsert_field(inscription_obj, METAPROTOCOL_VALIDITY, validity); - } - - /// Returns true if Inscription `object` contains metaprotocol validity - public fun exists_metaprotocol_validity(inscription_id: InscriptionID): bool{ - let store_obj_id = object::named_object_id(); - let store_obj = object::borrow_mut_object_shared(store_obj_id); - - let inscription_object_id = derive_inscription_id(inscription_id); - let exists = object::contains_object_field(store_obj, inscription_object_id); - if (!exists) { - return false - }; - - let inscription_obj = object::borrow_mut_object_field(store_obj, inscription_object_id); - object::contains_field(inscription_obj, METAPROTOCOL_VALIDITY) - } - - /// Borrow the metaprotocol validity for the given inscription_id. - public fun borrow_metaprotocol_validity(inscription_id: InscriptionID): &MetaprotocolValidity { - let store_obj_id = object::named_object_id(); - let store_obj = object::borrow_mut_object_shared(store_obj_id); - - let inscription_object_id = derive_inscription_id(inscription_id); - let inscription_obj = object::borrow_mut_object_field(store_obj, inscription_object_id); - - object::borrow_field(inscription_obj, METAPROTOCOL_VALIDITY) - } - - /// Check the MetaprotocolValidity's protocol_type whether match - public fun metaprotocol_validity_protocol_match(validity: &MetaprotocolValidity): bool { - let protocol_type = type_info::type_name(); - protocol_type == validity.protocol_type - } - - /// Get the MetaprotocolValidity's protocol_type - public fun metaprotocol_validity_protocol_type(validity: &MetaprotocolValidity): String { - validity.protocol_type - } - - /// Get the MetaprotocolValidity's is_valid - public fun metaprotocol_validity_is_valid(validity: &MetaprotocolValidity): bool { - validity.is_valid - } - - /// Get the MetaprotocolValidity's invalid_reason - public fun metaprotocol_validity_invalid_reason(validity: &MetaprotocolValidity): Option { - validity.invalid_reason - } + #[test_only] struct TestProtocol has key {} diff --git a/frameworks/framework-release/released/1/stdlib b/frameworks/framework-release/released/1/stdlib index 661aa6bf5c7071f5853943772caf157e36fc1a25..b223f935b9b340c5b197759744c0832aa73f0612 100644 GIT binary patch delta 2608 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 diff --git a/frameworks/moveos-stdlib/sources/hex.move b/frameworks/moveos-stdlib/sources/hex.move index 4777752faf..b47da64012 100644 --- a/frameworks/moveos-stdlib/sources/hex.move +++ b/frameworks/moveos-stdlib/sources/hex.move @@ -177,8 +177,10 @@ module moveos_std::hex { #[test] public fun test_decode_option_empty_string() { let hex_string = b""; - let decoded_bytes = decode_option(hex_string); - assert!(option::is_none(&decoded_bytes), 1); + let decoded_bytes_opt = decode_option(hex_string); + assert!(option::is_some(&decoded_bytes_opt), 1); + let decoded_bytes = option::destroy_some(decoded_bytes_opt); + assert!(vector::length(&decoded_bytes) == 0, 2); } #[test] diff --git a/frameworks/rooch-framework/doc/genesis.md b/frameworks/rooch-framework/doc/genesis.md index ff4a2cf1c1..7419aedb74 100644 --- a/frameworks/rooch-framework/doc/genesis.md +++ b/frameworks/rooch-framework/doc/genesis.md @@ -10,6 +10,7 @@
use 0x1::option;
+use 0x2::account;
 use 0x2::tx_context;
 use 0x3::account;
 use 0x3::account_coin_store;
diff --git a/frameworks/rooch-framework/sources/gas_coin.move b/frameworks/rooch-framework/sources/gas_coin.move
index ae4c4728d7..24131721a8 100644
--- a/frameworks/rooch-framework/sources/gas_coin.move
+++ b/frameworks/rooch-framework/sources/gas_coin.move
@@ -79,6 +79,6 @@ module rooch_framework::gas_coin {
             string::utf8(b"RGC"),
             DECIMALS, // decimals
         );
-        object::transfer(coin_info_obj, @rooch_framework)
+        object::transfer(coin_info_obj, @rooch_framework);
     }
 }
diff --git a/frameworks/rooch-framework/sources/genesis.move b/frameworks/rooch-framework/sources/genesis.move
index 9bb31284c2..ab65682b52 100644
--- a/frameworks/rooch-framework/sources/genesis.move
+++ b/frameworks/rooch-framework/sources/genesis.move
@@ -30,7 +30,7 @@ module rooch_framework::genesis {
     }
 
     fun init(){
-        //TODO genesis account should be a resource account?
+        
         let genesis_account = &account::create_account_internal(@rooch_framework);
         let genesis_context_option = tx_context::get_attribute();
         assert!(option::is_some(&genesis_context_option), ErrorGenesisInit);
@@ -43,9 +43,15 @@ module rooch_framework::genesis {
         gas_coin::genesis_init(genesis_account);
         transaction_fee::genesis_init(genesis_account);
         timestamp::genesis_init(genesis_account, genesis_context.timestamp);
-        address_mapping::genesis_init(genesis_account); 
-
+        address_mapping::genesis_init(genesis_account);
         onchain_config::genesis_init(genesis_account, genesis_context.sequencer);
+
+        // Some test cases use framework account as sequencer, it may already exist
+        if(!moveos_std::account::exists_at(genesis_context.sequencer)){
+            account::create_account_internal(genesis_context.sequencer);
+        };
+        // give some gas coin to the sequencer
+        gas_coin::faucet(genesis_context.sequencer, 1000000_00000000u256);
     }
 
 
diff --git a/frameworks/rooch-nursery/error_description.errmap b/frameworks/rooch-nursery/error_description.errmap
index 7a1a4b6bd4840af60da83eed0fb4c917056afdce..52b2308cec654f90b391dea9bc34b5e2434b9f41 100644
GIT binary patch
delta 36
ocmX@EdRleEdNy$}*P^2QBBz}EKv$60106Gf=xc~qF

diff --git a/frameworks/rooch-nursery/sources/bitseed.move b/frameworks/rooch-nursery/sources/bitseed.move
index 7817c3cf56..072d53494d 100644
--- a/frameworks/rooch-nursery/sources/bitseed.move
+++ b/frameworks/rooch-nursery/sources/bitseed.move
@@ -622,7 +622,7 @@ module rooch_nursery::bitseed {
 
     #[test(genesis_account=@0x4)]
     fun test_is_valid_bitseed_deploy_fail_for_inscription_no_exists(genesis_account: &signer){
-        ord::genesis_init(genesis_account);
+        ord::init_for_test(genesis_account);
 
         let metadata_bytes = x"a4626f70666465706c6f79647469636b646d6f766566616d6f756e74016a61747472696275746573a16967656e657261746f72784f2f696e736372697074696f6e2f373764666332666535393834313962303036343163323936313831613936636631363934333639376635373334383062303233623737636365383261646132316930";
         let metadata = cbor::to_map(metadata_bytes);
diff --git a/moveos/moveos/src/vm/moveos_vm.rs b/moveos/moveos/src/vm/moveos_vm.rs
index a4c522d426..ab30e4dc9a 100644
--- a/moveos/moveos/src/vm/moveos_vm.rs
+++ b/moveos/moveos/src/vm/moveos_vm.rs
@@ -316,7 +316,10 @@ where
                 let resolved_args = self.resolve_argument(&loaded_function, call.args, location)?;
                 let serialized_args = self.load_arguments(resolved_args)?;
                 if bypass_visibility {
-                    self.session
+                    // bypass visibility call is system call, we do not charge gas for it, like L1 block transaction
+                    self.gas_meter.stop_metering();
+                    let result = self
+                        .session
                         .execute_function_bypass_visibility(
                             &call.function_id.module_id,
                             &call.function_id.function_name,
@@ -329,7 +332,9 @@ where
                                 ret.return_values.is_empty(),
                                 "Function should not return values"
                             );
-                        })
+                        });
+                    self.gas_meter.start_metering();
+                    result
                 } else {
                     self.session
                         .execute_entry_function(
diff --git a/rooch-portal-v1/script/env.sh b/rooch-portal-v1/script/env.sh
index 73b87ea32d..7bd50124e8 100755
--- a/rooch-portal-v1/script/env.sh
+++ b/rooch-portal-v1/script/env.sh
@@ -44,7 +44,7 @@ dep_nft() {
   rooch move run --function default::nft::mint_entry --args object:${collection_object_id} --args string:testg
 
   # find nft
-  nft_obj_id=$(rooch rpc request --method rooch_queryGlobalStates --params '[{"object_type":"'"${default_address}"'::nft::NFT"}, null, "10", true]' | jq -r '.data[0].object_id')
+  nft_obj_id=$(rooch rpc request --method rooch_queryObjectStates --params '[{"object_type":"'"${default_address}"'::nft::NFT"}, null, "10", true]' | jq -r '.data[0].object_id')
 
   # transfer nft
   rooch move run --function rooch_framework::transfer::transfer_object --type-args default::nft::NFT --args address:$1 --args object:${nft_obj_id}
diff --git a/scripts/bitcoin/README.md b/scripts/bitcoin/README.md
index 43518a9a58..e14c7b0ce2 100644
--- a/scripts/bitcoin/README.md
+++ b/scripts/bitcoin/README.md
@@ -14,8 +14,8 @@ This directory contains scripts for setting up a local development environment f
 ## Development on rooch
 
 1. Run `rooch server start --btc-rpc-url http://127.0.0.1:18443 --btc-rpc-username roochuser --btc-rpc-password roochpass --btc-start-block-height 0`
-2. Run `rooch rpc request --method rooch_queryGlobalStates --params '[{"object_type":"0x4::utxo::UTXO"},null, "2", true]'` to query the UTXO set
-3. Run `rooch rpc request --method rooch_queryGlobalStates --params '[{"object_type":"0x4::ord::Inscription"},null, "2", true]'` to query the Inscription set
+2. Run `rooch rpc request --method rooch_queryObjectStates --params '[{"object_type":"0x4::utxo::UTXO"},null, "2", true]'` to query the UTXO set
+3. Run `rooch rpc request --method rooch_queryObjectStates --params '[{"object_type":"0x4::ord::Inscription"},null, "2", true]'` to query the Inscription set
 
 ## Usage
 
diff --git a/scripts/bitcoin/env.sh b/scripts/bitcoin/env.sh
index 84d11e0fc0..0b65ab369f 100755
--- a/scripts/bitcoin/env.sh
+++ b/scripts/bitcoin/env.sh
@@ -98,7 +98,7 @@ init() {
   ord wallet inscriptions
 
   # Step 9: start rooch node
-  cargo run --package rooch --bin rooch server start --btc-rpc-url ${btc_rpc_url} --btc-rpc-username ${btc_rpc_username} --btc-rpc-password ${btc_rpc_password} --btc-start-block-height 0 --btc-network 4
+  cargo run --package rooch --bin rooch server start --btc-rpc-url ${btc_rpc_url} --btc-rpc-username ${btc_rpc_username} --btc-rpc-password ${btc_rpc_password} --btc-start-block-height 0
 }
 
 clean() {
diff --git a/scripts/pr.sh b/scripts/pr.sh
index b4c6a029c6..7e7c82f13a 100755
--- a/scripts/pr.sh
+++ b/scripts/pr.sh
@@ -99,8 +99,8 @@ cargo build
 
 if [ ! -z "$ALSO_TEST" ]; then
     cargo nextest run --workspace --all-features --exclude rooch-framework-tests --exclude rooch-integration-test-runner -v
-    cargo nextest run -p rooch-framework-tests -p rooch-integration-test-runner -v -j 1
-    cargo test -p testsuite --test integration
+    cargo test --release run -p rooch-framework-tests -p rooch-integration-test-runner
+    RUST_LOG=warn cargo test -p testsuite --test integration
 fi
 
 if [ ! -z "$MOVE_TESTS" ]; then