diff --git a/.github/workflows/check_build_test.yml b/.github/workflows/check_build_test.yml index fc18a59b20..67017e7be9 100644 --- a/.github/workflows/check_build_test.yml +++ b/.github/workflows/check_build_test.yml @@ -92,14 +92,14 @@ jobs: run: pnpm lint continue-on-error: true timeout-minutes: 15 - - name: Build SDK - run: pnpm rooch-sdk build + # - name: Build SDK + # run: pnpm rooch-sdk build # - name: Test SDK # run: pnpm rooch-sdk test - - name: Build SDK KIT - run: pnpm rooch-sdk-kit build - - name: Build Dashboard - run: pnpm dashboard build + # - name: Build SDK KIT + # run: pnpm rooch-sdk-kit build + # - name: Build Dashboard + # run: pnpm dashboard build - uses: CatChen/check-git-status-action@v1 with: diff --git a/Cargo.lock b/Cargo.lock index 384e98d846..f71c1935f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,7 +14,7 @@ dependencies = [ [[package]] name = "accumulator" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs-ext", @@ -930,7 +930,7 @@ dependencies = [ [[package]] name = "bitcoin-move" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -2553,7 +2553,7 @@ dependencies = [ [[package]] name = "data-verify" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -3779,7 +3779,7 @@ dependencies = [ [[package]] name = "framework-builder" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -3821,7 +3821,7 @@ dependencies = [ [[package]] name = "framework-release" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -3844,7 +3844,7 @@ dependencies = [ [[package]] name = "framework-types" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "clap 4.5.4", @@ -5651,7 +5651,7 @@ dependencies = [ [[package]] name = "metrics" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "futures", @@ -6414,7 +6414,7 @@ dependencies = [ [[package]] name = "moveos" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "backtrace", @@ -6467,7 +6467,7 @@ dependencies = [ [[package]] name = "moveos-common" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -6479,7 +6479,7 @@ dependencies = [ [[package]] name = "moveos-compiler" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "move-binary-format", @@ -6493,7 +6493,7 @@ dependencies = [ [[package]] name = "moveos-config" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "clap 4.5.4", @@ -6510,7 +6510,7 @@ dependencies = [ [[package]] name = "moveos-object-runtime" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "better_any", @@ -6546,7 +6546,7 @@ dependencies = [ [[package]] name = "moveos-stdlib" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bech32 0.11.0", @@ -6594,7 +6594,7 @@ dependencies = [ [[package]] name = "moveos-store" -version = "0.5.0" +version = "0.5.4" dependencies = [ "accumulator", "anyhow", @@ -6623,7 +6623,7 @@ dependencies = [ [[package]] name = "moveos-types" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -6652,7 +6652,7 @@ dependencies = [ [[package]] name = "moveos-verifier" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -6679,7 +6679,7 @@ dependencies = [ [[package]] name = "moveos-wasm" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "ciborium", @@ -8389,7 +8389,7 @@ dependencies = [ [[package]] name = "raw-store" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "async-trait", @@ -8876,7 +8876,7 @@ dependencies = [ [[package]] name = "rooch" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "async-trait", @@ -8954,7 +8954,7 @@ dependencies = [ [[package]] name = "rooch-benchmarks" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "async-trait", @@ -9026,7 +9026,7 @@ dependencies = [ [[package]] name = "rooch-config" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "clap 4.5.4", @@ -9052,7 +9052,7 @@ dependencies = [ [[package]] name = "rooch-da" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "async-trait", @@ -9073,7 +9073,7 @@ dependencies = [ [[package]] name = "rooch-db" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -9098,7 +9098,7 @@ dependencies = [ [[package]] name = "rooch-executor" -version = "0.5.0" +version = "0.5.4" dependencies = [ "accumulator", "anyhow", @@ -9140,7 +9140,7 @@ dependencies = [ [[package]] name = "rooch-faucet" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "async-trait", @@ -9174,7 +9174,7 @@ dependencies = [ [[package]] name = "rooch-framework" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -9212,7 +9212,7 @@ dependencies = [ [[package]] name = "rooch-framework-tests" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -9268,18 +9268,20 @@ dependencies = [ [[package]] name = "rooch-genesis" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", "better_any", "bitcoin-move", + "clap 4.5.4", "coerce", "fastcrypto", "framework-builder", "framework-release", "futures", "hex", + "include_dir", "linked-hash-map", "move-binary-format", "move-bytecode-utils", @@ -9317,7 +9319,7 @@ dependencies = [ [[package]] name = "rooch-indexer" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "async-trait", @@ -9363,7 +9365,7 @@ dependencies = [ [[package]] name = "rooch-integration-test-runner" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -9405,7 +9407,7 @@ dependencies = [ [[package]] name = "rooch-key" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "argon2", @@ -9437,7 +9439,7 @@ dependencies = [ [[package]] name = "rooch-open-rpc" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -9454,7 +9456,7 @@ dependencies = [ [[package]] name = "rooch-open-rpc-macros" -version = "0.5.0" +version = "0.5.4" dependencies = [ "derive-syn-parse", "itertools 0.10.5", @@ -9466,7 +9468,7 @@ dependencies = [ [[package]] name = "rooch-open-rpc-spec" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -9487,7 +9489,7 @@ dependencies = [ [[package]] name = "rooch-open-rpc-spec-builder" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -9507,7 +9509,7 @@ dependencies = [ [[package]] name = "rooch-pipeline-processor" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "async-trait", @@ -9545,7 +9547,7 @@ dependencies = [ [[package]] name = "rooch-proposer" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "async-trait", @@ -9578,7 +9580,7 @@ dependencies = [ [[package]] name = "rooch-relayer" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "async-trait", @@ -9622,7 +9624,7 @@ dependencies = [ [[package]] name = "rooch-rpc-api" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "async-trait", @@ -9666,7 +9668,7 @@ dependencies = [ [[package]] name = "rooch-rpc-client" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -9696,7 +9698,7 @@ dependencies = [ [[package]] name = "rooch-rpc-server" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "async-trait", @@ -9755,7 +9757,7 @@ dependencies = [ [[package]] name = "rooch-sequencer" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "async-trait", @@ -9793,7 +9795,7 @@ dependencies = [ [[package]] name = "rooch-store" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -9815,7 +9817,7 @@ dependencies = [ [[package]] name = "rooch-test-transaction-builder" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "bcs", @@ -9851,7 +9853,7 @@ dependencies = [ [[package]] name = "rooch-types" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "argon2", @@ -11011,7 +11013,7 @@ checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" [[package]] name = "smt" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "backtrace", @@ -11523,7 +11525,7 @@ dependencies = [ [[package]] name = "testsuite" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "assert_cmd", @@ -11646,7 +11648,7 @@ dependencies = [ [[package]] name = "timeout-join-handler" -version = "0.5.0" +version = "0.5.4" dependencies = [ "anyhow", "thiserror", diff --git a/Cargo.toml b/Cargo.toml index eca7f4f9e7..d2da2e52ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,6 +68,7 @@ license = "Apache-2.0" publish = false repository = "https://github.com/rooch-network/rooch" rust-version = "1.77.1" +version = "0.5.4" [workspace.dependencies] diff --git a/crates/data_verify/Cargo.toml b/crates/data_verify/Cargo.toml index c7007a0c0c..ad20c4b233 100644 --- a/crates/data_verify/Cargo.toml +++ b/crates/data_verify/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "data-verify" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-benchmarks/Cargo.toml b/crates/rooch-benchmarks/Cargo.toml index 5dd4ba6d01..e79e1acb4f 100644 --- a/crates/rooch-benchmarks/Cargo.toml +++ b/crates/rooch-benchmarks/Cargo.toml @@ -1,7 +1,15 @@ [package] name = "rooch-benchmarks" -version = "0.5.0" -edition = "2021" + +# Workspace inherited keys +version = { workspace = true } +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +publish = { workspace = true } +repository = { workspace = true } +rust-version = { workspace = true } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/rooch-config/Cargo.toml b/crates/rooch-config/Cargo.toml index c19ce9cb44..d184bd1252 100644 --- a/crates/rooch-config/Cargo.toml +++ b/crates/rooch-config/Cargo.toml @@ -1,7 +1,15 @@ [package] name = "rooch-config" -version = "0.5.0" -edition = "2021" + +# Workspace inherited keys +version = { workspace = true } +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +publish = { workspace = true } +repository = { workspace = true } +rust-version = { workspace = true } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/rooch-da/Cargo.toml b/crates/rooch-da/Cargo.toml index 60c76325e8..bd01aabcaf 100644 --- a/crates/rooch-da/Cargo.toml +++ b/crates/rooch-da/Cargo.toml @@ -1,7 +1,15 @@ [package] name = "rooch-da" -version = "0.5.0" -edition = "2021" + +# Workspace inherited keys +version = { workspace = true } +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +publish = { workspace = true } +repository = { workspace = true } +rust-version = { workspace = true } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/rooch-db/Cargo.toml b/crates/rooch-db/Cargo.toml index d397a04734..3adcc47bf3 100644 --- a/crates/rooch-db/Cargo.toml +++ b/crates/rooch-db/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-db" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-db/src/lib.rs b/crates/rooch-db/src/lib.rs index 5f7f142f99..428cdbfd34 100644 --- a/crates/rooch-db/src/lib.rs +++ b/crates/rooch-db/src/lib.rs @@ -2,9 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 use anyhow::Result; -use log::info; use moveos_store::MoveOSStore; -use moveos_types::moveos_std::object::{ObjectEntity, Root}; +use moveos_types::moveos_std::object::RootObjectEntity; use raw_store::{rocks::RocksDB, StoreInstance}; use rooch_config::store_config::StoreConfig; use rooch_indexer::{indexer_reader::IndexerReader, IndexerStore}; @@ -16,7 +15,6 @@ pub struct RoochDB { pub rooch_store: RoochStore, pub indexer_store: IndexerStore, pub indexer_reader: IndexerReader, - pub root: ObjectEntity, } impl RoochDB { @@ -46,21 +44,17 @@ impl RoochDB { let indexer_store = IndexerStore::new(indexer_store_dir.clone())?; let indexer_reader = IndexerReader::new(indexer_store_dir)?; - let startup_info = moveos_store.config_store.get_startup_info()?; - - if let Some(ref startup_info) = startup_info { - info!("Load startup info {:?}", startup_info); - } - let root = startup_info - .map(|s| s.into_root_object()) - .unwrap_or(ObjectEntity::genesis_root_object()); - Ok(Self { moveos_store, rooch_store, indexer_store, indexer_reader, - root, }) } + + pub fn latest_root(&self) -> Result> { + let startup_info = self.moveos_store.config_store.get_startup_info()?; + + Ok(startup_info.map(|s| s.into_root_object())) + } } diff --git a/crates/rooch-executor/Cargo.toml b/crates/rooch-executor/Cargo.toml index 9f5bc97fc4..b42049ecf4 100644 --- a/crates/rooch-executor/Cargo.toml +++ b/crates/rooch-executor/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-executor" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-faucet/Cargo.toml b/crates/rooch-faucet/Cargo.toml index a455fd8d01..c0653c4cbb 100644 --- a/crates/rooch-faucet/Cargo.toml +++ b/crates/rooch-faucet/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-faucet" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-framework-tests/Cargo.toml b/crates/rooch-framework-tests/Cargo.toml index 5821059062..f18d01fd93 100644 --- a/crates/rooch-framework-tests/Cargo.toml +++ b/crates/rooch-framework-tests/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-framework-tests" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-framework-tests/src/binding_test.rs b/crates/rooch-framework-tests/src/binding_test.rs index 139fdc68cf..8c1cd5f366 100644 --- a/crates/rooch-framework-tests/src/binding_test.rs +++ b/crates/rooch-framework-tests/src/binding_test.rs @@ -61,8 +61,8 @@ impl RustBindingTest { network.set_sequencer_account(sequencer.clone()); - let genesis = RoochGenesis::build(network)?; - let root = genesis.init_genesis(&rooch_db)?; + let genesis = RoochGenesis::load_or_init(network, &rooch_db)?; + let root = genesis.genesis_root().clone(); let executor = ExecutorActor::new( root.clone(), diff --git a/crates/rooch-genesis/Cargo.toml b/crates/rooch-genesis/Cargo.toml index d0a2552262..2738eb53d7 100644 --- a/crates/rooch-genesis/Cargo.toml +++ b/crates/rooch-genesis/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-genesis" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } @@ -17,6 +17,7 @@ rust-version = { workspace = true } anyhow = { workspace = true } bcs = { workspace = true } better_any = { workspace = true } +clap = { features = [ "derive", ], workspace = true } fastcrypto = { workspace = true } linked-hash-map = { workspace = true } once_cell = { workspace = true } @@ -30,6 +31,7 @@ tracing-subscriber = { workspace = true } coerce = { workspace = true } tokio = { features = ["full"], workspace = true } futures = { workspace = true } +include_dir = { workspace = true } move-binary-format = { workspace = true } diff --git a/crates/rooch-genesis/README.md b/crates/rooch-genesis/README.md new file mode 100644 index 0000000000..63a001b2ca --- /dev/null +++ b/crates/rooch-genesis/README.md @@ -0,0 +1,8 @@ +# Rooch genesis + + +## Release genesis for network + +```bash +cargo run --package rooch-genesis -- -n test +``` \ No newline at end of file diff --git a/crates/rooch-genesis/released/test b/crates/rooch-genesis/released/test new file mode 100644 index 0000000000..7b5f4a78c4 Binary files /dev/null and b/crates/rooch-genesis/released/test differ diff --git a/crates/rooch-genesis/src/lib.rs b/crates/rooch-genesis/src/lib.rs index 66edb40459..12be743c25 100644 --- a/crates/rooch-genesis/src/lib.rs +++ b/crates/rooch-genesis/src/lib.rs @@ -1,14 +1,15 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 -use anyhow::Result; +use anyhow::{ensure, Result}; use framework_builder::stdlib_version::StdlibVersion; use framework_builder::Stdlib; +use include_dir::{include_dir, Dir}; use move_core_types::{account_address::AccountAddress, identifier::Identifier}; use move_vm_runtime::native_functions::NativeFunction; use moveos::gas::table::VMGasParameters; use moveos::moveos::{MoveOS, MoveOSConfig}; -use moveos_store::{config_store::ConfigDBStore, MoveOSStore}; +use moveos_store::MoveOSStore; use moveos_types::genesis_info::GenesisInfo; use moveos_types::h256::H256; use moveos_types::move_std::string::MoveString; @@ -36,6 +37,7 @@ use rooch_types::transaction::rooch::RoochTransaction; use rooch_types::transaction::{LedgerTransaction, LedgerTxData}; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; +use std::path::PathBuf; use std::str::FromStr; use std::{fs::File, io::Write, path::Path}; @@ -47,6 +49,26 @@ pub static ROOCH_LOCAL_GENESIS: Lazy = Lazy::new(|| { RoochGenesis::build(network).expect("build rooch genesis failed") }); +pub(crate) const STATIC_GENESIS_DIR: Dir = include_dir!("released"); + +pub fn load_genesis_from_binary(chain_id: BuiltinChainID) -> Result> { + STATIC_GENESIS_DIR + .get_file(chain_id.chain_name()) + .map(|f| { + let genesis = RoochGenesis::decode(f.contents())?; + Ok(genesis) + }) + .transpose() +} + +pub fn release_dir() -> PathBuf { + path_in_crate("released") +} + +pub fn genesis_file(chain_id: BuiltinChainID) -> PathBuf { + release_dir().join(chain_id.chain_name()) +} + pub struct FrameworksGasParameters { pub max_gas_amount: u64, pub vm_gas_params: VMGasParameters, @@ -135,23 +157,11 @@ pub struct RoochGenesis { pub genesis_moveos_tx: MoveOSTransaction, } -pub enum BuildOption { - Fresh, - Release, -} - impl RoochGenesis { pub fn build(network: RoochNetwork) -> Result { - Self::build_with_option(network, BuildOption::Release) - } - - pub fn build_with_option(network: RoochNetwork, option: BuildOption) -> Result { let genesis_config = network.genesis_config; - let stdlib = match option { - BuildOption::Fresh => Self::build_stdlib()?, - BuildOption::Release => Self::load_stdlib(genesis_config.stdlib_version)?, - }; + let stdlib = Self::load_stdlib(genesis_config.stdlib_version)?; let genesis_ctx = rooch_types::framework::genesis::GenesisContext::new( network.chain_id.id, @@ -208,6 +218,15 @@ impl RoochGenesis { }) } + /// Load the genesis from binary, if not exist, build the genesis, only support the builtin chain id + pub fn load(chain_id: BuiltinChainID) -> Result { + let genesis = load_genesis_from_binary(chain_id)?; + match genesis { + Some(genesis) => Ok(genesis), + None => Self::build(RoochNetwork::builtin(chain_id)), + } + } + pub fn genesis_tx(&self) -> RoochTransaction { self.genesis_tx.clone() } @@ -217,11 +236,7 @@ impl RoochGenesis { } pub fn genesis_hash(&self) -> H256 { - h256::sha3_256_of( - bcs::to_bytes(&self) - .expect("genesis txs bcs to_bytes should success") - .as_slice(), - ) + h256::sha3_256_of(self.encode().as_slice()) } pub fn genesis_root(&self) -> &RootObjectEntity { @@ -232,37 +247,52 @@ impl RoochGenesis { GenesisInfo { genesis_package_hash: self.genesis_hash(), root: self.genesis_root().clone(), + genesis_bin: self.encode(), } } - pub fn check_genesis(&self, config_store: &ConfigDBStore) -> Result<()> { - let genesis_info_result = config_store.get_genesis(); - match genesis_info_result { - Ok(Some(genesis_info_from_store)) => { - let genesis_info_from_binary = self.genesis_info(); - - // We need to check the genesis package hash and genesis state root hash - // because the same genesis package may generate different state root hash when the Move VM is upgraded - if genesis_info_from_store != genesis_info_from_binary { - return Err(GenesisError::GenesisVersionMismatch { - from_store: Box::new(genesis_info_from_store), - from_binary: Box::new(genesis_info_from_binary), + /// Load the genesis from the rooch db, if not exist, build and init the genesis + pub fn load_or_init(network: RoochNetwork, rooch_db: &RoochDB) -> Result { + let genesis_info = rooch_db.moveos_store.get_config_store().get_genesis()?; + match genesis_info { + Some(genesis_info_from_store) => { + //if the chain_id is builtin, we should check the genesis version between the store and the binary + if let Some(builtin_id) = network.chain_id.to_builtin() { + let genesis_from_binary = Self::load(builtin_id)?; + let genesis_info_from_binary = genesis_from_binary.genesis_info(); + if genesis_info_from_store != genesis_info_from_binary { + return Err(GenesisError::GenesisVersionMismatch { + from_store: Box::new(genesis_info_from_store), + from_binary: Box::new(genesis_info_from_binary), + } + .into()); } - .into()); } + Self::decode(&genesis_info_from_store.genesis_bin) } - Err(e) => return Err(GenesisError::GenesisLoadFailure(e.to_string()).into()), - Ok(None) => { - return Err(GenesisError::GenesisNotExist( - "genesis hash from store is none".to_string(), - ) - .into()) + None => { + //if the chain_id is builtin, we should load the released genesis from binary + let genesis = if let Some(builtin_id) = network.chain_id.to_builtin() { + Self::load(builtin_id)? + } else { + Self::build(network)? + }; + genesis.init_genesis(rooch_db)?; + Ok(genesis) } } - Ok(()) } pub fn init_genesis(&self, rooch_db: &RoochDB) -> Result { + ensure!( + rooch_db + .moveos_store + .get_config_store() + .get_genesis()? + .is_none(), + "Genesis already initialized" + ); + //we load the gas parameter from genesis binary, avoid the code change affect the genesis result let genesis_gas_parameter = FrameworksGasParameters::load_from_gas_entries( self.initial_gas_config.max_gas_amount, @@ -354,7 +384,8 @@ impl RoochGenesis { .indexer_store .update_object_states(indexer_object_state_changes)?; - let genesis_info = GenesisInfo::new(self.genesis_hash(), inited_root.clone()); + let genesis_info = + GenesisInfo::new(self.genesis_hash(), inited_root.clone(), self.encode()); rooch_db .moveos_store .get_config_store() @@ -370,6 +401,14 @@ impl RoochGenesis { framework_release::load_stdlib(stdlib_version) } + pub fn decode(bytes: &[u8]) -> Result { + bcs::from_bytes(bytes).map_err(Into::into) + } + + pub fn encode(&self) -> Vec { + bcs::to_bytes(self).expect("RoochGenesis bcs::to_bytes should success") + } + pub fn load_from>(genesis_file: P) -> Result { let genesis_package = bcs::from_bytes(&std::fs::read(genesis_file)?)?; Ok(genesis_package) @@ -384,9 +423,18 @@ impl RoochGenesis { } } +pub(crate) fn path_in_crate(relative: S) -> PathBuf +where + S: AsRef, +{ + let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + path.push(relative); + path +} + #[cfg(test)] mod tests { - use crate::{BuildOption, FrameworksGasParameters}; + use super::*; use move_core_types::identifier::Identifier; use move_core_types::language_storage::ModuleId; use move_core_types::resolver::ModuleResolver; @@ -404,8 +452,8 @@ mod tests { "genesis init test case for network: {:?}", network.chain_id.id ); - let genesis = super::RoochGenesis::build_with_option(network.clone(), BuildOption::Release) - .expect("build rooch genesis failed"); + let genesis = + super::RoochGenesis::build(network.clone()).expect("build rooch genesis failed"); let opt = RoochOpt::new_with_temp_store().expect("create rooch opt failed"); let rooch_db = RoochDB::init(&opt.store_config()).expect("init rooch db failed"); @@ -483,4 +531,11 @@ mod tests { genesis_init_test_case(RoochNetwork::test()); genesis_init_test_case(RoochNetwork::main()); } + + #[test] + fn test_genesis_load_from_binary() { + assert!(load_genesis_from_binary(BuiltinChainID::Test) + .unwrap() + .is_some()); + } } diff --git a/crates/rooch-genesis/src/main.rs b/crates/rooch-genesis/src/main.rs new file mode 100644 index 0000000000..8a232881ce --- /dev/null +++ b/crates/rooch-genesis/src/main.rs @@ -0,0 +1,36 @@ +// Copyright (c) RoochNetwork +// SPDX-License-Identifier: Apache-2.0 + +use anyhow::{bail, Result}; +use clap::Parser; +use rooch_genesis::{genesis_file, RoochGenesis}; +use rooch_types::rooch_network::{BuiltinChainID, RoochNetwork}; +use tracing::info; + +#[derive(Parser)] +#[clap(name = "genesis-release", author = "The Rooch Core Contributors")] +struct GenesisOpts { + /// The builtin chain id for the genesis + #[clap(long, short = 'n', default_value = "test")] + chain_id: BuiltinChainID, +} + +fn main() -> Result<()> { + let _ = tracing_subscriber::fmt::try_init(); + let opts: GenesisOpts = GenesisOpts::parse(); + match &opts.chain_id { + BuiltinChainID::Test | BuiltinChainID::Main => {} + _ => { + bail!( + "chain_id {:?} is not supported, only support release test and main", + opts.chain_id + ); + } + } + info!("start to build genesis for chain: {:?}", opts.chain_id); + let network: RoochNetwork = RoochNetwork::builtin(opts.chain_id); + let genesis = RoochGenesis::build(network)?; + let genesis_file = genesis_file(opts.chain_id); + genesis.save_to(genesis_file)?; + Ok(()) +} diff --git a/crates/rooch-indexer/Cargo.toml b/crates/rooch-indexer/Cargo.toml index f769f04a87..80088f607f 100644 --- a/crates/rooch-indexer/Cargo.toml +++ b/crates/rooch-indexer/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-indexer" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-integration-test-runner/Cargo.toml b/crates/rooch-integration-test-runner/Cargo.toml index b898654cef..75707271b5 100644 --- a/crates/rooch-integration-test-runner/Cargo.toml +++ b/crates/rooch-integration-test-runner/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-integration-test-runner" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-key/Cargo.toml b/crates/rooch-key/Cargo.toml index 85ed20b953..a4dcc90b15 100644 --- a/crates/rooch-key/Cargo.toml +++ b/crates/rooch-key/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-key" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-open-rpc-macros/Cargo.toml b/crates/rooch-open-rpc-macros/Cargo.toml index 0575cd70b2..32cf8f3e25 100644 --- a/crates/rooch-open-rpc-macros/Cargo.toml +++ b/crates/rooch-open-rpc-macros/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-open-rpc-macros" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-open-rpc-spec-builder/Cargo.toml b/crates/rooch-open-rpc-spec-builder/Cargo.toml index 36a2299a29..719d35e7c6 100644 --- a/crates/rooch-open-rpc-spec-builder/Cargo.toml +++ b/crates/rooch-open-rpc-spec-builder/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-open-rpc-spec-builder" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-open-rpc-spec/Cargo.toml b/crates/rooch-open-rpc-spec/Cargo.toml index 53cceb0ecb..97a5b7a260 100644 --- a/crates/rooch-open-rpc-spec/Cargo.toml +++ b/crates/rooch-open-rpc-spec/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-open-rpc-spec" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-open-rpc-spec/schemas/openrpc.json b/crates/rooch-open-rpc-spec/schemas/openrpc.json index 3b791e4f4c..5f93b0f98d 100644 --- a/crates/rooch-open-rpc-spec/schemas/openrpc.json +++ b/crates/rooch-open-rpc-spec/schemas/openrpc.json @@ -12,7 +12,7 @@ "name": "Apache-2.0", "url": "https://raw.githubusercontent.com/rooch-network/rooch/main/LICENSE" }, - "version": "0.5.0" + "version": "0.5.4" }, "methods": [ { diff --git a/crates/rooch-open-rpc/Cargo.toml b/crates/rooch-open-rpc/Cargo.toml index 265f91389e..e5981b9fba 100644 --- a/crates/rooch-open-rpc/Cargo.toml +++ b/crates/rooch-open-rpc/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-open-rpc" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-pipeline-processor/Cargo.toml b/crates/rooch-pipeline-processor/Cargo.toml index e93022c4d8..692a7215c8 100644 --- a/crates/rooch-pipeline-processor/Cargo.toml +++ b/crates/rooch-pipeline-processor/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-pipeline-processor" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-proposer/Cargo.toml b/crates/rooch-proposer/Cargo.toml index dfdcce639a..10f5dbd524 100644 --- a/crates/rooch-proposer/Cargo.toml +++ b/crates/rooch-proposer/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-proposer" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-relayer/Cargo.toml b/crates/rooch-relayer/Cargo.toml index 8aaed4b8d8..2f7df85252 100644 --- a/crates/rooch-relayer/Cargo.toml +++ b/crates/rooch-relayer/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-relayer" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-rpc-api/Cargo.toml b/crates/rooch-rpc-api/Cargo.toml index fd42e59db9..2ee7ac72ec 100644 --- a/crates/rooch-rpc-api/Cargo.toml +++ b/crates/rooch-rpc-api/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-rpc-api" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-rpc-client/Cargo.toml b/crates/rooch-rpc-client/Cargo.toml index 83334e6308..5e4171163f 100644 --- a/crates/rooch-rpc-client/Cargo.toml +++ b/crates/rooch-rpc-client/Cargo.toml @@ -1,7 +1,15 @@ [package] name = "rooch-rpc-client" -version = "0.5.0" -edition = "2021" + +# Workspace inherited keys +version = { workspace = true } +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +publish = { workspace = true } +repository = { workspace = true } +rust-version = { workspace = true } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/rooch-rpc-server/Cargo.toml b/crates/rooch-rpc-server/Cargo.toml index 177ebdd14b..cdb3485189 100644 --- a/crates/rooch-rpc-server/Cargo.toml +++ b/crates/rooch-rpc-server/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-rpc-server" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-rpc-server/src/lib.rs b/crates/rooch-rpc-server/src/lib.rs index b2bd77122a..306129622d 100644 --- a/crates/rooch-rpc-server/src/lib.rs +++ b/crates/rooch-rpc-server/src/lib.rs @@ -126,7 +126,7 @@ impl RpcModuleBuilder { // Start json-rpc server pub async fn start_server(opt: RoochOpt, server_opt: ServerOpt) -> Result { - let active_env = server_opt.get_active_env(); + let chain_name = opt.chain_id().chain_name(); match run_start_server(opt, server_opt).await { Ok(server_handle) => Ok(server_handle), Err(e) => match e.downcast::() { @@ -134,7 +134,7 @@ pub async fn start_server(opt: RoochOpt, server_opt: ServerOpt) -> Result Result Result Result root, + None => genesis.genesis_root().clone(), + }; + info!( + "The latest Root object state root: {:?}, size: {}", + root.state_root(), + root.size + ); let executor_actor = ExecutorActor::new(root.clone(), moveos_store.clone(), rooch_store.clone())?; diff --git a/crates/rooch-sequencer/Cargo.toml b/crates/rooch-sequencer/Cargo.toml index f258b84584..a9b3e44dc7 100644 --- a/crates/rooch-sequencer/Cargo.toml +++ b/crates/rooch-sequencer/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-sequencer" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-sequencer/tests/test_sequencer.rs b/crates/rooch-sequencer/tests/test_sequencer.rs index c50cc66fef..7a6156d547 100644 --- a/crates/rooch-sequencer/tests/test_sequencer.rs +++ b/crates/rooch-sequencer/tests/test_sequencer.rs @@ -15,8 +15,7 @@ use rooch_types::{ fn init_rooch_db(opt: &RoochOpt) -> Result { let rooch_db = RoochDB::init(opt.store_config())?; let network = opt.network(); - let genesis = RoochGenesis::build(network)?; - genesis.init_genesis(&rooch_db)?; + let genesis = RoochGenesis::load_or_init(network, &rooch_db)?; Ok(rooch_db) } diff --git a/crates/rooch-store/Cargo.toml b/crates/rooch-store/Cargo.toml index cfe65df99f..642f3c13c9 100644 --- a/crates/rooch-store/Cargo.toml +++ b/crates/rooch-store/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-store" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-test-transaction-builder/Cargo.toml b/crates/rooch-test-transaction-builder/Cargo.toml index 092f91a76e..50b4c797b5 100644 --- a/crates/rooch-test-transaction-builder/Cargo.toml +++ b/crates/rooch-test-transaction-builder/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-test-transaction-builder" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-types/Cargo.toml b/crates/rooch-types/Cargo.toml index 822a954951..1b4a109fd1 100644 --- a/crates/rooch-types/Cargo.toml +++ b/crates/rooch-types/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-types" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch-types/src/error.rs b/crates/rooch-types/src/error.rs index a5b5589b44..7ad4b19396 100644 --- a/crates/rooch-types/src/error.rs +++ b/crates/rooch-types/src/error.rs @@ -156,7 +156,7 @@ impl From for RoochError { #[derive(Debug, Error, Eq, PartialEq)] pub enum GenesisError { - #[error("Genesis version mismatch: from store({from_store:?}), from binary({from_binary:?}).")] + #[error("Genesis version mismatch: from store({from_store}), from binary({from_binary}).")] GenesisVersionMismatch { from_store: Box, from_binary: Box, diff --git a/crates/rooch-types/src/framework/chain_id.rs b/crates/rooch-types/src/framework/chain_id.rs index 51167299ae..123d7937d6 100644 --- a/crates/rooch-types/src/framework/chain_id.rs +++ b/crates/rooch-types/src/framework/chain_id.rs @@ -3,7 +3,7 @@ use std::str::FromStr; -use crate::addresses::ROOCH_FRAMEWORK_ADDRESS; +use crate::{addresses::ROOCH_FRAMEWORK_ADDRESS, rooch_network::BuiltinChainID}; use anyhow::Result; use move_core_types::{account_address::AccountAddress, ident_str, identifier::IdentStr}; use moveos_types::{ @@ -37,6 +37,14 @@ impl ChainID { pub fn chain_id_object_id() -> ObjectID { object::named_object_id(&Self::struct_tag()) } + + pub fn is_builtin(&self) -> bool { + self.to_builtin().is_some() + } + + pub fn to_builtin(&self) -> Option { + BuiltinChainID::try_from(self.id).ok() + } } impl std::fmt::Display for ChainID { diff --git a/crates/rooch-types/src/genesis_config.rs b/crates/rooch-types/src/genesis_config.rs index fa29b54ae5..3c18e6390a 100644 --- a/crates/rooch-types/src/genesis_config.rs +++ b/crates/rooch-types/src/genesis_config.rs @@ -88,12 +88,11 @@ pub static G_DEV_CONFIG: Lazy = Lazy::new(|| GenesisConfig { }); pub static G_TEST_CONFIG: Lazy = Lazy::new(|| { - // curl -sSL "https://mempool.space/testnet/api/block/000000008dfa22c53891f9a7b48a75ae8a523dec558873b061a321fd03a93bac" - + //curl -sSL https://mempool.space/testnet/api/block/$(curl -sSL https://mempool.space/testnet/api/blocks/tip/hash) GenesisConfig { bitcoin_network: crate::bitcoin::network::Network::Testnet.to_num(), - bitcoin_block_height: 2819132, - timestamp: 1717208620000, + bitcoin_block_height: 2820883, + timestamp: 17180946540000, sequencer_account: BitcoinAddress::from_str( "bcrt1p56tdhxkcpc5xvdurfnufn9lkkywsh0gxttv5ktkvlezj0t23nasqawwrla", ) diff --git a/crates/rooch/Cargo.toml b/crates/rooch/Cargo.toml index 4b0aa36e8b..0e059f3120 100644 --- a/crates/rooch/Cargo.toml +++ b/crates/rooch/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/crates/rooch/src/commands/genesis/commands/init.rs b/crates/rooch/src/commands/genesis/commands/init.rs index 7603dce1de..8b73ec1775 100644 --- a/crates/rooch/src/commands/genesis/commands/init.rs +++ b/crates/rooch/src/commands/genesis/commands/init.rs @@ -33,12 +33,11 @@ impl InitCommand { let store_config = opt.store_config(); let rooch_db = RoochDB::init(store_config)?; let network = opt.network(); - let genesis = RoochGenesis::build(network)?; - let root = genesis.init_genesis(&rooch_db)?; + let genesis = RoochGenesis::load_or_init(network, &rooch_db)?; println!( "Genesis statedb initialized at {:?} successfully, state_root: {:?}", opt.base().data_dir(), - root.state_root() + genesis.genesis_root().state_root() ); Ok(()) } diff --git a/crates/rooch/src/commands/statedb/commands/export.rs b/crates/rooch/src/commands/statedb/commands/export.rs index 8dcc413b20..cd16c5ef64 100644 --- a/crates/rooch/src/commands/statedb/commands/export.rs +++ b/crates/rooch/src/commands/statedb/commands/export.rs @@ -160,8 +160,12 @@ impl ExportCommand { println!("Start statedb export task, batch_size: {:?}", BATCH_SIZE); let opt = RoochOpt::new_with_default(self.base_data_dir, self.chain_id, None)?; let rooch_db = RoochDB::init(opt.store_config())?; - - println!("root object: {:?}", rooch_db.root); + let root = rooch_db.latest_root()?.ok_or_else(|| { + RoochError::from(anyhow::Error::msg( + "The statedb is empty, please init genesis first.", + )) + })?; + println!("root object: {:?}", root); let mut _start_time = SystemTime::now(); let file_name = self.output.display().to_string(); @@ -172,7 +176,7 @@ impl ExportCommand { })?; let root_state_root = self .state_root - .unwrap_or(H256::from(rooch_db.root.state_root.into_bytes())); + .unwrap_or(H256::from(root.state_root.into_bytes())); let mode = ExportMode::try_from(self.mode.unwrap_or(ExportMode::Genesis.to_num()))?; match mode { diff --git a/crates/rooch/src/commands/statedb/commands/genesis_utxo.rs b/crates/rooch/src/commands/statedb/commands/genesis_utxo.rs index 2c5d57dcde..9d0a3a66b4 100644 --- a/crates/rooch/src/commands/statedb/commands/genesis_utxo.rs +++ b/crates/rooch/src/commands/statedb/commands/genesis_utxo.rs @@ -103,7 +103,7 @@ impl GenesisUTXOCommand { let opt = RoochOpt::new_with_default(self.base_data_dir, self.chain_id, None).unwrap(); let rooch_db = RoochDB::init(opt.store_config()).unwrap(); - let (root, moveos_store) = (rooch_db.root, rooch_db.moveos_store); + let root = rooch_db.latest_root().unwrap().unwrap(); let utxo_store_id = BitcoinUTXOStore::object_id(); let address_mapping_id = RoochToBitcoinAddressMapping::object_id(); @@ -119,7 +119,7 @@ impl GenesisUTXOCommand { "rooch to bitcoin address_mapping_id: {:?}", address_mapping_id ); - (root, moveos_store, start_time) + (root, rooch_db.moveos_store, start_time) } } diff --git a/crates/rooch/src/commands/statedb/commands/import.rs b/crates/rooch/src/commands/statedb/commands/import.rs index e45aa07e3f..e94f460911 100644 --- a/crates/rooch/src/commands/statedb/commands/import.rs +++ b/crates/rooch/src/commands/statedb/commands/import.rs @@ -15,6 +15,7 @@ use moveos_types::state::{KeyState, State}; use moveos_types::state_resolver::StatelessResolver; use rooch_config::{RoochOpt, R_OPT_NET_HELP}; use rooch_db::RoochDB; +use rooch_genesis::RoochGenesis; use rooch_types::error::{RoochError, RoochResult}; use rooch_types::rooch_network::RoochChainID; use serde::{Deserialize, Serialize}; @@ -83,15 +84,15 @@ impl ImportCommand { let opt = RoochOpt::new_with_default(self.base_data_dir, self.chain_id, None).unwrap(); let rooch_db = RoochDB::init(opt.store_config()).unwrap(); - let (root, moveos_store) = (rooch_db.root, rooch_db.moveos_store); - + let genesis = RoochGenesis::load_or_init(opt.network(), &rooch_db).unwrap(); + let root = genesis.genesis_root().clone(); println!( "task progress started at {}, batch_size: {}", datetime, self.batch_size.unwrap() ); println!("root object: {:?}", root); - (root, moveos_store, start_time) + (root, rooch_db.moveos_store, start_time) } } diff --git a/crates/testsuite/Cargo.toml b/crates/testsuite/Cargo.toml index 7925f66059..9811c68694 100644 --- a/crates/testsuite/Cargo.toml +++ b/crates/testsuite/Cargo.toml @@ -1,7 +1,8 @@ [package] name = "testsuite" -version = "0.5.0" +# Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } license = { workspace = true } diff --git a/frameworks/bitcoin-move/Cargo.toml b/frameworks/bitcoin-move/Cargo.toml index effaa3de07..fafa39696d 100644 --- a/frameworks/bitcoin-move/Cargo.toml +++ b/frameworks/bitcoin-move/Cargo.toml @@ -1,9 +1,9 @@ [package] #Bitcoin Move framework name = "bitcoin-move" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/frameworks/framework-builder/Cargo.toml b/frameworks/framework-builder/Cargo.toml index 845738f5b3..2b2fafefd3 100644 --- a/frameworks/framework-builder/Cargo.toml +++ b/frameworks/framework-builder/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "framework-builder" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/frameworks/framework-release/Cargo.toml b/frameworks/framework-release/Cargo.toml index 6f8e98d01f..baf86251d4 100644 --- a/frameworks/framework-release/Cargo.toml +++ b/frameworks/framework-release/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "framework-release" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/frameworks/framework-release/released/1/stdlib b/frameworks/framework-release/released/1/stdlib index 5cc0bcf122..51cd721475 100644 Binary files a/frameworks/framework-release/released/1/stdlib and b/frameworks/framework-release/released/1/stdlib differ diff --git a/frameworks/framework-types/Cargo.toml b/frameworks/framework-types/Cargo.toml index 59ba05fae8..4f90228c9e 100644 --- a/frameworks/framework-types/Cargo.toml +++ b/frameworks/framework-types/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "framework-types" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/frameworks/moveos-stdlib/Cargo.toml b/frameworks/moveos-stdlib/Cargo.toml index 132a9e9377..7cc4d17b7c 100644 --- a/frameworks/moveos-stdlib/Cargo.toml +++ b/frameworks/moveos-stdlib/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "moveos-stdlib" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/frameworks/rooch-framework/Cargo.toml b/frameworks/rooch-framework/Cargo.toml index 68e1281820..33a8574f5a 100644 --- a/frameworks/rooch-framework/Cargo.toml +++ b/frameworks/rooch-framework/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rooch-framework" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/moveos/metrics/Cargo.toml b/moveos/metrics/Cargo.toml index f8d978eaec..473643e806 100644 --- a/moveos/metrics/Cargo.toml +++ b/moveos/metrics/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "metrics" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/moveos/moveos-commons/accumulator/Cargo.toml b/moveos/moveos-commons/accumulator/Cargo.toml index 8db2140640..8c1e0c8841 100644 --- a/moveos/moveos-commons/accumulator/Cargo.toml +++ b/moveos/moveos-commons/accumulator/Cargo.toml @@ -1,7 +1,15 @@ [package] name = "accumulator" -version = "0.5.0" -edition = "2021" + +# Workspace inherited keys +version = { workspace = true } +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +publish = { workspace = true } +repository = { workspace = true } +rust-version = { workspace = true } [dependencies] anyhow = { workspace = true } diff --git a/moveos/moveos-commons/moveos-common/Cargo.toml b/moveos/moveos-commons/moveos-common/Cargo.toml index 194322babb..acabec2767 100644 --- a/moveos/moveos-commons/moveos-common/Cargo.toml +++ b/moveos/moveos-commons/moveos-common/Cargo.toml @@ -1,7 +1,15 @@ [package] name = "moveos-common" -version = "0.5.0" -edition = "2021" + +# Workspace inherited keys +version = { workspace = true } +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +publish = { workspace = true } +repository = { workspace = true } +rust-version = { workspace = true } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/moveos/moveos-commons/timeout-join-handler/Cargo.toml b/moveos/moveos-commons/timeout-join-handler/Cargo.toml index 5750920c5e..fe06efb02e 100644 --- a/moveos/moveos-commons/timeout-join-handler/Cargo.toml +++ b/moveos/moveos-commons/timeout-join-handler/Cargo.toml @@ -1,7 +1,15 @@ [package] name = "timeout-join-handler" -version = "0.5.0" -edition = "2021" + +# Workspace inherited keys +version = { workspace = true } +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +publish = { workspace = true } +repository = { workspace = true } +rust-version = { workspace = true } [dependencies] thiserror = { workspace = true } diff --git a/moveos/moveos-compiler/Cargo.toml b/moveos/moveos-compiler/Cargo.toml index f1f705cbf7..19f9e00477 100644 --- a/moveos/moveos-compiler/Cargo.toml +++ b/moveos/moveos-compiler/Cargo.toml @@ -1,7 +1,15 @@ [package] name = "moveos-compiler" -version = "0.5.0" -edition = "2021" + +# Workspace inherited keys +version = { workspace = true } +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +publish = { workspace = true } +repository = { workspace = true } +rust-version = { workspace = true } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/moveos/moveos-config/Cargo.toml b/moveos/moveos-config/Cargo.toml index 888fcc030a..cc80e1aec0 100644 --- a/moveos/moveos-config/Cargo.toml +++ b/moveos/moveos-config/Cargo.toml @@ -1,7 +1,15 @@ [package] name = "moveos-config" -version = "0.5.0" -edition = "2021" + +# Workspace inherited keys +version = { workspace = true } +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +publish = { workspace = true } +repository = { workspace = true } +rust-version = { workspace = true } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/moveos/moveos-object-runtime/Cargo.toml b/moveos/moveos-object-runtime/Cargo.toml index 4da3a275ca..2e4a35cf72 100644 --- a/moveos/moveos-object-runtime/Cargo.toml +++ b/moveos/moveos-object-runtime/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "moveos-object-runtime" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/moveos/moveos-store/Cargo.toml b/moveos/moveos-store/Cargo.toml index 2e4c0bd9ba..0609bfef26 100644 --- a/moveos/moveos-store/Cargo.toml +++ b/moveos/moveos-store/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "moveos-store" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/moveos/moveos-types/Cargo.toml b/moveos/moveos-types/Cargo.toml index 5748b4453c..7f1a4bdac6 100644 --- a/moveos/moveos-types/Cargo.toml +++ b/moveos/moveos-types/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "moveos-types" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/moveos/moveos-types/src/genesis_info.rs b/moveos/moveos-types/src/genesis_info.rs index c71cf5198e..6d8cbe691f 100644 --- a/moveos/moveos-types/src/genesis_info.rs +++ b/moveos/moveos-types/src/genesis_info.rs @@ -5,31 +5,47 @@ use crate::moveos_std::object::RootObjectEntity; use primitive_types::H256; use serde::{Deserialize, Serialize}; use std::fmt; -use std::fmt::Debug; -#[derive(Eq, PartialEq, Deserialize, Serialize, Clone, Debug)] +#[derive(Eq, PartialEq, Deserialize, Serialize, Clone)] pub struct GenesisInfo { /// genesis package hash pub genesis_package_hash: H256, /// lastest state root hash pub root: RootObjectEntity, + /// genesis binary + pub genesis_bin: Vec, +} + +impl fmt::Debug for GenesisInfo { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "GenesisInfo {{ genesis_package_hash: {:?}, state_root_hash: {:?}, size: {} }}", + self.genesis_package_hash, + self.root.state_root(), + self.root.size + ) + } } impl fmt::Display for GenesisInfo { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, - "GenesisInfo {{ genesis_package_hash: {}, state_root_hash: {}, size: {} }}", - self.genesis_package_hash, self.root.state_root, self.root.size + "GenesisInfo {{ genesis_package_hash: {:?}, state_root_hash: {:?}, size: {} }}", + self.genesis_package_hash, + self.root.state_root(), + self.root.size ) } } impl GenesisInfo { - pub fn new(genesis_package_hash: H256, root: RootObjectEntity) -> Self { + pub fn new(genesis_package_hash: H256, root: RootObjectEntity, genesis_bin: Vec) -> Self { GenesisInfo { genesis_package_hash, root, + genesis_bin, } } } diff --git a/moveos/moveos-verifier/Cargo.toml b/moveos/moveos-verifier/Cargo.toml index cf41c970fe..01cac68a7e 100644 --- a/moveos/moveos-verifier/Cargo.toml +++ b/moveos/moveos-verifier/Cargo.toml @@ -1,7 +1,15 @@ [package] name = "moveos-verifier" -version = "0.5.0" -edition = "2021" + +# Workspace inherited keys +version = { workspace = true } +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +publish = { workspace = true } +repository = { workspace = true } +rust-version = { workspace = true } [dependencies] anyhow = { workspace = true } diff --git a/moveos/moveos-wasm/Cargo.toml b/moveos/moveos-wasm/Cargo.toml index 18b6f52f9d..e0eefc853f 100644 --- a/moveos/moveos-wasm/Cargo.toml +++ b/moveos/moveos-wasm/Cargo.toml @@ -1,7 +1,15 @@ [package] name = "moveos-wasm" -version = "0.5.0" -edition = "2021" + +# Workspace inherited keys +version = { workspace = true } +authors = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +publish = { workspace = true } +repository = { workspace = true } +rust-version = { workspace = true } [dependencies] serde = { workspace = true } diff --git a/moveos/moveos/Cargo.toml b/moveos/moveos/Cargo.toml index dc7a4cdda3..3cf07be3cd 100644 --- a/moveos/moveos/Cargo.toml +++ b/moveos/moveos/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "moveos" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/moveos/raw-store/Cargo.toml b/moveos/raw-store/Cargo.toml index 465fe050e5..4545c07d9e 100644 --- a/moveos/raw-store/Cargo.toml +++ b/moveos/raw-store/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "raw-store" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/moveos/smt/Cargo.toml b/moveos/smt/Cargo.toml index bcaeb24e49..a508172bcb 100644 --- a/moveos/smt/Cargo.toml +++ b/moveos/smt/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "smt" -version = "0.5.0" # Workspace inherited keys +version = { workspace = true } authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true }