From 1aeb4c377c4cc16873538af45b9bc049f8543cea Mon Sep 17 00:00:00 2001 From: Bryan Lee Date: Wed, 13 Apr 2022 02:28:10 +0800 Subject: [PATCH] [refactor] Add prefix `G_` to global static variables (#3336) --- account/api/src/rich_wallet.rs | 6 +- account/service/src/service.rs | 6 +- block-relayer/src/block_relayer.rs | 4 +- cmd/airdrop/src/main.rs | 4 +- cmd/faucet/src/web.rs | 7 +- cmd/generator/src/gen_genesis.rs | 2 +- cmd/generator/src/gen_genesis_config.rs | 2 +- cmd/generator/src/main.rs | 6 +- cmd/starcoin/src/account/transfer_cmd.rs | 4 +- cmd/starcoin/src/cli_state.rs | 6 +- cmd/starcoin/src/dev/get_coin_cmd.rs | 4 +- cmd/starcoin/src/dev/tests.rs | 10 +- cmd/starcoin/src/main.rs | 58 ++-- commons/accumulator/src/node.rs | 4 +- commons/accumulator/src/node_index.rs | 2 +- commons/logger/src/lib.rs | 14 +- commons/logger/src/structured_log.rs | 16 +- commons/scmd/src/context.rs | 10 +- commons/utils/src/metrics.rs | 12 +- commons/utils/src/mpsc.rs | 10 +- commons/utils/src/stop_watch.rs | 16 +- config/src/account_vault_config.rs | 4 +- config/src/available_port.rs | 6 +- config/src/genesis_config.rs | 282 +++++++++--------- config/src/lib.rs | 48 +-- config/src/logger_config.rs | 4 +- config/src/metrics_config.rs | 23 +- config/src/network_config.rs | 10 +- config/src/storage_config.rs | 4 +- config/src/tests.rs | 2 +- consensus/src/consensus_test.rs | 6 +- consensus/src/lib.rs | 40 +-- executor/src/error_code_test.rs | 12 +- executor/tests/executor_test.rs | 6 +- executor/tests/module_upgrade_test.rs | 12 +- executor/tests/on_chain_config_test.rs | 4 +- executor/tests/sip_flag_test.rs | 4 +- executor/tests/treasury_withdraw_test.rs | 8 +- genesis/src/lib.rs | 2 +- genesis/src/main.rs | 4 +- network-p2p/src/service_test.rs | 4 +- network-rpc/api/src/lib.rs | 2 +- network/src/worker.rs | 2 +- node/src/network_service_factory.rs | 2 +- rpc/server/src/module/txfactory_rpc.rs | 8 +- state/api/src/chain_state.rs | 10 +- state/statedb/src/lib.rs | 6 +- .../block_connector_service.rs | 4 +- .../src/block_connector/test_illegal_block.rs | 8 +- sync/src/tasks/block_sync_task.rs | 6 +- sync/src/tasks/mock.rs | 4 +- sync/src/verified_rpc_client.rs | 16 +- testsuite/tests/steps/cmd.rs | 10 +- vm/compiler/src/lib.rs | 24 +- vm/move-package-manager/src/lib.rs | 7 +- vm/move-package-manager/src/main.rs | 2 +- vm/move-prover/tests/testsuite.rs | 8 +- .../src/lib.rs | 4 +- vm/stdlib/src/lib.rs | 18 +- vm/transaction-builder-generator/src/rust.rs | 8 +- vm/transaction-builder/src/lib.rs | 10 +- .../src/account_config/constants/account.rs | 16 +- .../src/account_config/constants/chain.rs | 22 +- .../src/account_config/constants/event.rs | 14 +- .../src/on_chain_config/consensus_config.rs | 6 +- .../on_chain_config/genesis_gas_schedule.rs | 4 +- vm/types/src/on_chain_config/mod.rs | 6 +- vm/types/src/on_chain_config/version.rs | 6 +- vm/types/src/on_chain_config/vm_config.rs | 12 +- vm/types/src/sips.rs | 6 +- vm/types/src/token/stc.rs | 24 +- vm/types/src/token/token_code.rs | 4 +- vm/vm-runtime/src/errors.rs | 4 +- vm/vm-runtime/src/starcoin_vm.rs | 46 +-- 74 files changed, 511 insertions(+), 506 deletions(-) diff --git a/account/api/src/rich_wallet.rs b/account/api/src/rich_wallet.rs index a408b8f75f..31a819d49f 100644 --- a/account/api/src/rich_wallet.rs +++ b/account/api/src/rich_wallet.rs @@ -4,7 +4,7 @@ use serde::Serialize; use serde::{Deserialize, Deserializer}; use starcoin_types::account_address::AccountAddress; use starcoin_types::account_config::token_code::TokenCode; -use starcoin_types::account_config::STC_TOKEN_CODE; +use starcoin_types::account_config::G_STC_TOKEN_CODE; use starcoin_types::transaction::{RawUserTransaction, SignedUserTransaction, TransactionPayload}; use std::fmt; use std::marker::PhantomData; @@ -62,7 +62,7 @@ impl Setting { Setting { default_expiration_timeout: 3600, default_gas_price: 1, - default_gas_token: STC_TOKEN_CODE.clone(), + default_gas_token: G_STC_TOKEN_CODE.clone(), is_default: false, is_readonly: false, } @@ -72,7 +72,7 @@ impl Setting { Setting { default_expiration_timeout: 3600, default_gas_price: 1, - default_gas_token: STC_TOKEN_CODE.clone(), + default_gas_token: G_STC_TOKEN_CODE.clone(), is_default: false, is_readonly: true, } diff --git a/account/service/src/service.rs b/account/service/src/service.rs index 8cd9942b51..46a18d9807 100644 --- a/account/service/src/service.rs +++ b/account/service/src/service.rs @@ -10,7 +10,7 @@ use starcoin_crypto::ValidCryptoMaterial; use starcoin_logger::prelude::*; use starcoin_service_registry::mocker::MockHandler; use starcoin_service_registry::{ActorService, ServiceContext, ServiceFactory, ServiceHandler}; -use starcoin_types::account_config::{association_address, STC_TOKEN_CODE}; +use starcoin_types::account_config::{association_address, G_STC_TOKEN_CODE}; use starcoin_types::genesis_config::ChainId; use std::any::Any; use std::sync::Arc; @@ -177,8 +177,8 @@ impl ServiceHandler for AccountService { AccountRequest::AccountAcceptedTokens { address } => { let mut tokens = self.manager.accepted_tokens(address)?; //auto add STC to accepted tokens. - if !tokens.contains(&STC_TOKEN_CODE) { - tokens.push(STC_TOKEN_CODE.clone()) + if !tokens.contains(&G_STC_TOKEN_CODE) { + tokens.push(G_STC_TOKEN_CODE.clone()) } AccountResponse::AcceptedTokens(tokens) } diff --git a/block-relayer/src/block_relayer.rs b/block-relayer/src/block_relayer.rs index a85a590eba..01a4a37c3f 100644 --- a/block-relayer/src/block_relayer.rs +++ b/block-relayer/src/block_relayer.rs @@ -4,7 +4,7 @@ use crate::metrics::BlockRelayerMetrics; use anyhow::{ensure, format_err, Result}; use config::NodeConfig; -use config::CRATE_VERSION; +use config::G_CRATE_VERSION; use crypto::HashValue; use futures::FutureExt; use logger::prelude::*; @@ -215,7 +215,7 @@ impl BlockRelayer { if let Ok(Some((_, _, _, version))) = txpool.get_store().get_failed_block_by_id(block_id) { - if version == *CRATE_VERSION { + if version == *G_CRATE_VERSION { warn!("Block is failed block : {:?}", block_id); } } else { diff --git a/cmd/airdrop/src/main.rs b/cmd/airdrop/src/main.rs index 52a1ebcad1..f5a0523c4e 100644 --- a/cmd/airdrop/src/main.rs +++ b/cmd/airdrop/src/main.rs @@ -20,7 +20,7 @@ use starcoin_types::language_storage::ModuleId; use starcoin_types::transaction::authenticator::AccountPrivateKey; use starcoin_types::transaction::{RawUserTransaction, ScriptFunction}; use starcoin_vm_types::account_config::auto_accept_token::AutoAcceptToken; -use starcoin_vm_types::account_config::{stc_type_tag, BalanceResource, STC_TOKEN_CODE}; +use starcoin_vm_types::account_config::{stc_type_tag, BalanceResource, G_STC_TOKEN_CODE}; use starcoin_vm_types::language_storage::{StructTag, TypeTag}; use starcoin_vm_types::move_resource::MoveResource; use starcoin_vm_types::token::token_code::TokenCode; @@ -122,7 +122,7 @@ async fn main() -> Result<()> { let token_type: StructTag = options .token_code - .unwrap_or_else(|| STC_TOKEN_CODE.clone()) + .unwrap_or_else(|| G_STC_TOKEN_CODE.clone()) .try_into()?; let is_stc = stc_type_tag().eq(&TypeTag::Struct(token_type.clone())); diff --git a/cmd/faucet/src/web.rs b/cmd/faucet/src/web.rs index ed769b1f75..ba7c6be3f5 100644 --- a/cmd/faucet/src/web.rs +++ b/cmd/faucet/src/web.rs @@ -54,7 +54,7 @@ fn response(result: Result) -> Response> { } } -static CONTENT_TYPE: Lazy
= Lazy::new(|| Header { +static G_CONTENT_TYPE: Lazy
= Lazy::new(|| Header { field: "Content-Type".parse().unwrap(), value: AsciiString::from_ascii("text/html; charset=utf8").unwrap(), }); @@ -69,12 +69,13 @@ pub async fn run(server: Server, faucet: Faucet) { match url { "/" => { let response = - Response::from_string(index_html()).with_header(CONTENT_TYPE.clone()); + Response::from_string(index_html()).with_header(G_CONTENT_TYPE.clone()); let _err = request.respond(response); } "/api/fund" => { let resp = handle_fund(&faucet, &mut request).await; - if let Err(err) = request.respond(response(resp).with_header(CONTENT_TYPE.clone())) + if let Err(err) = + request.respond(response(resp).with_header(G_CONTENT_TYPE.clone())) { error!("response err: {}", err) } diff --git a/cmd/generator/src/gen_genesis.rs b/cmd/generator/src/gen_genesis.rs index b33d6a8b3d..da971417a6 100644 --- a/cmd/generator/src/gen_genesis.rs +++ b/cmd/generator/src/gen_genesis.rs @@ -52,7 +52,7 @@ impl CommandAction for GenGenesisCommand { init_or_load_data_dir(global_opt, opt.password.clone())?; Ok(GenGenesisResult { net: config.net().id().clone(), - config_path: config.data_dir().join(starcoin_config::CONFIG_FILE_PATH), + config_path: config.data_dir().join(starcoin_config::G_CONFIG_FILE_PATH), account_info: account, genesis: chain_info.genesis_hash(), }) diff --git a/cmd/generator/src/gen_genesis_config.rs b/cmd/generator/src/gen_genesis_config.rs index 543728f9cd..fb78a4907d 100644 --- a/cmd/generator/src/gen_genesis_config.rs +++ b/cmd/generator/src/gen_genesis_config.rs @@ -53,7 +53,7 @@ impl CommandAction for GenGenesisConfigCommand { let config_path = base .data_dir() - .join(starcoin_config::GENESIS_CONFIG_FILE_NAME); + .join(starcoin_config::G_GENESIS_CONFIG_FILE_NAME); // genesis config file auto generate in BaseConfig::default_with_opt ensure!( config_path.exists(), diff --git a/cmd/generator/src/main.rs b/cmd/generator/src/main.rs index 72f3a012c8..08d18eeb77 100644 --- a/cmd/generator/src/main.rs +++ b/cmd/generator/src/main.rs @@ -3,7 +3,7 @@ use anyhow::Result; use scmd::CmdContext; -use starcoin_config::{StarcoinOpt, APP_VERSION, CRATE_VERSION}; +use starcoin_config::{StarcoinOpt, G_APP_VERSION, G_CRATE_VERSION}; use starcoin_generator::cli_state::CliState; use starcoin_generator::gen_data::GenDataCommand; use starcoin_generator::gen_genesis::GenGenesisCommand; @@ -12,8 +12,8 @@ use starcoin_logger::prelude::*; fn run() -> Result<()> { let context = CmdContext::::with_state( - CRATE_VERSION, - Some(APP_VERSION.as_str()), + G_CRATE_VERSION, + Some(G_APP_VERSION.as_str()), CliState, ); context diff --git a/cmd/starcoin/src/account/transfer_cmd.rs b/cmd/starcoin/src/account/transfer_cmd.rs index 913b8f1f72..3ddf3ddf5a 100644 --- a/cmd/starcoin/src/account/transfer_cmd.rs +++ b/cmd/starcoin/src/account/transfer_cmd.rs @@ -8,7 +8,7 @@ use anyhow::Result; use clap::Parser; use scmd::{CommandAction, ExecContext}; use starcoin_types::account_address::AccountAddress; -use starcoin_vm_types::token::stc::STC_TOKEN_CODE; +use starcoin_vm_types::token::stc::G_STC_TOKEN_CODE; use starcoin_vm_types::token::token_code::TokenCode; use starcoin_vm_types::transaction::TransactionPayload; @@ -56,7 +56,7 @@ impl CommandAction for TransferCommand { let token_code = opt .token_code .clone() - .unwrap_or_else(|| STC_TOKEN_CODE.clone()); + .unwrap_or_else(|| G_STC_TOKEN_CODE.clone()); let script_function = starcoin_executor::encode_transfer_script_by_token_code( receiver_address, opt.amount, diff --git a/cmd/starcoin/src/cli_state.rs b/cmd/starcoin/src/cli_state.rs index f6ceba878e..addabe0811 100644 --- a/cmd/starcoin/src/cli_state.rs +++ b/cmd/starcoin/src/cli_state.rs @@ -25,7 +25,7 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; use std::time::Duration; -static HISTORY_FILE_NAME: &str = "history"; +static G_HISTORY_FILE_NAME: &str = "history"; pub struct CliState { net: ChainNetworkID, @@ -52,7 +52,7 @@ impl CliState { node_handle: Option, account_client: Box, ) -> CliState { - let data_dir = starcoin_config::DEFAULT_BASE_DATA_DIR + let data_dir = starcoin_config::G_DEFAULT_BASE_DATA_DIR .clone() .join("cli") .join(net.to_string()); @@ -99,7 +99,7 @@ impl CliState { } pub fn history_file(&self) -> PathBuf { - self.data_dir().join(HISTORY_FILE_NAME) + self.data_dir().join(G_HISTORY_FILE_NAME) } pub fn node_handle(&self) -> Option<&NodeHandle> { diff --git a/cmd/starcoin/src/dev/get_coin_cmd.rs b/cmd/starcoin/src/dev/get_coin_cmd.rs index 6147a80345..af037f98df 100644 --- a/cmd/starcoin/src/dev/get_coin_cmd.rs +++ b/cmd/starcoin/src/dev/get_coin_cmd.rs @@ -12,7 +12,7 @@ use starcoin_transaction_builder::encode_transfer_script_by_token_code; use starcoin_types::account_address::AccountAddress; use starcoin_types::account_config; use starcoin_types::account_config::STCUnit; -use starcoin_vm_types::account_config::STC_TOKEN_CODE; +use starcoin_vm_types::account_config::G_STC_TOKEN_CODE; use starcoin_vm_types::token::token_value::TokenValue; use starcoin_vm_types::transaction::TransactionPayload; use std::time::Duration; @@ -69,7 +69,7 @@ impl CommandAction for GetCoinCommand { TransactionPayload::ScriptFunction(encode_transfer_script_by_token_code( to.address, opt.amount.scaling(), - STC_TOKEN_CODE.clone(), + G_STC_TOKEN_CODE.clone(), )), )? .get_transaction_info() diff --git a/cmd/starcoin/src/dev/tests.rs b/cmd/starcoin/src/dev/tests.rs index d2b5c309f7..ed8b3afbab 100644 --- a/cmd/starcoin/src/dev/tests.rs +++ b/cmd/starcoin/src/dev/tests.rs @@ -17,7 +17,7 @@ use starcoin_vm_types::account_address::AccountAddress; use starcoin_vm_types::account_config::core_code_address; use starcoin_vm_types::identifier::Identifier; use starcoin_vm_types::language_storage::ModuleId; -use starcoin_vm_types::token::stc::STC_TOKEN_CODE; +use starcoin_vm_types::token::stc::G_STC_TOKEN_CODE; use starcoin_vm_types::transaction::{ RawUserTransaction, SignedUserTransaction, TransactionPayload, }; @@ -231,7 +231,7 @@ fn test_upgrade_module() { 2, dao_config.min_action_delay, false, - STC_TOKEN_CODE.clone(), + G_STC_TOKEN_CODE.clone(), config.net().stdlib_version(), ); @@ -274,7 +274,7 @@ fn test_upgrade_module() { let proposal_id = 0; let mut type_tags: Vec = Vec::new(); let module = parse_type_tag("0x1::UpgradeModuleDaoProposal::UpgradeModuleV2").unwrap(); - type_tags.push(STC_TOKEN_CODE.clone().try_into().unwrap()); + type_tags.push(G_STC_TOKEN_CODE.clone().try_into().unwrap()); type_tags.push(module); let mut args: Vec = Vec::new(); let arg_1 = parse_transaction_argument("0x0000000000000000000000000a550c18").unwrap(); @@ -329,7 +329,7 @@ fn test_upgrade_module() { let module_upgrade_queue = build_module_upgrade_queue( association_address(), proposal_id, - STC_TOKEN_CODE.clone(), + G_STC_TOKEN_CODE.clone(), config.net().stdlib_version(), ); let queue_txn = sign_txn_with_account_by_rpc_client( @@ -365,7 +365,7 @@ fn test_upgrade_module() { // 7. plan let module_upgrade_plan = - build_module_upgrade_plan(association_address(), proposal_id, STC_TOKEN_CODE.clone()); + build_module_upgrade_plan(association_address(), proposal_id, G_STC_TOKEN_CODE.clone()); let plan_txn = sign_txn_with_account_by_rpc_client( &cli_state, default_account.address, diff --git a/cmd/starcoin/src/main.rs b/cmd/starcoin/src/main.rs index 7d90854277..3b4e487d17 100644 --- a/cmd/starcoin/src/main.rs +++ b/cmd/starcoin/src/main.rs @@ -6,7 +6,7 @@ use scmd::CmdContext; use starcoin_account_provider::ProviderFactory; use starcoin_cmd::*; use starcoin_cmd::{CliState, StarcoinOpt}; -use starcoin_config::{Connect, APP_VERSION, CRATE_VERSION}; +use starcoin_config::{Connect, G_APP_VERSION, G_CRATE_VERSION}; use starcoin_logger::prelude::*; use starcoin_node_api::errors::NodeStartError; use starcoin_rpc_client::RpcClient; @@ -15,13 +15,13 @@ use std::time::Duration; /// This exit code means is that the node failed to start and required human intervention. /// Node start script can do auto task when meet this exist code. -static EXIT_CODE_NEED_HELP: i32 = 120; +static G_EXIT_CODE_NEED_HELP: i32 = 120; fn run() -> Result<()> { let logger_handle = starcoin_logger::init(); let context = CmdContext::::with_default_action( - CRATE_VERSION, - Some(APP_VERSION.as_str()), + G_CRATE_VERSION, + Some(G_APP_VERSION.as_str()), |opt| -> Result { info!("Starcoin opts: {}", opt); let connect = opt.connect.as_ref().unwrap_or(&Connect::IPC(None)); @@ -108,7 +108,7 @@ fn run() -> Result<()> { info!("Start console, disable stderr output."); logger_handle.disable_stderr(); print_logo(); - (*scmd::DEFAULT_CONSOLE_CONFIG, Some(state.history_file())) + (*scmd::G_DEFAULT_CONSOLE_CONFIG, Some(state.history_file())) }, |_, _, state| { let (_, _, handle) = state.into_inner(); @@ -125,34 +125,34 @@ fn run() -> Result<()> { #[rustfmt::skip] #[allow(clippy::print_literal)] fn print_logo(){ - println!("{}{}{}","\x1b[34;1m",r#" - (%&&&&(%&%( &# - ,#%%%&%%%#/ (%&&% - %#%#%%%%#&&% %& - / %%% #& - &#%%%#%%%%# *&% + println!("{}{}{}","\x1b[34;1m",r#" + (%&&&&(%&%( &# + ,#%%%&%%%#/ (%&&% + %#%#%%%%#&&% %& + / %%% #& + &#%%%#%%%%# *&% (#%%%#/ %%%%%%# #&% - #%#%%#&& #%%%%%%%( &%%& - (#%%## #%%%%%%%%%/ *%% - #%%%&#%%##&&&&%%%(%%%%%%%%%%%&&&&&&&& &% (&#/# - ((##%%%%%%%%%%%%%%%%%%%%%%%%&&&&&&&%% #### - ###%#(& &#%%%%%%%%%%%%%%%%%%%%%&&&&%##&(%&% - (#%## (#%%%%%%%%%%%%%%%%%%&%#(#%%# - (###(% &&#%%%%%%%%%%%%%%&%%#&& - #### %%%%%%%%%%%%( %% - /###/ #%%%%%%%%#%%# %%# - /###( (%%%%%%#%%%##%%%( *%%# - ###( (%%%%###&# %&#%%&(%%% - (##(& &#%#(# %%&&% - (###%# (%%%#((& &&%# + #%#%%#&& #%%%%%%%( &%%& + (#%%## #%%%%%%%%%/ *%% + #%%%&#%%##&&&&%%%(%%%%%%%%%%%&&&&&&&& &% (&#/# + ((##%%%%%%%%%%%%%%%%%%%%%%%%&&&&&&&%% #### + ###%#(& &#%%%%%%%%%%%%%%%%%%%%%&&&&%##&(%&% + (#%## (#%%%%%%%%%%%%%%%%%%&%#(#%%# + (###(% &&#%%%%%%%%%%%%%%&%%#&& + #### %%%%%%%%%%%%( %% + /###/ #%%%%%%%%#%%# %%# + /###( (%%%%%%#%%%##%%%( *%%# + ###( (%%%%###&# %&#%%&(%%% + (##(& &#%#(# %%&&% + (###%# (%%%#((& &&%# (#%%%%%%#( - + ██████╗████████╗ █████╗ ██████╗ █████╗ █████╗ ██╗███╗ ██╗ ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗██╔══██╗██╔══██╗██║████╗ ██║ ╚█████╗ ██║ ███████║██████╔╝██║ ╚═╝██║ ██║██║██╔██╗██║ ╚═══██╗ ██║ ██╔══██║██╔══██╗██║ ██╗██║ ██║██║██║╚████║ ██████╔╝ ██║ ██║ ██║██║ ██║╚█████╔╝╚█████╔╝██║██║ ╚███║ - ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚════╝ ╚════╝ ╚═╝╚═╝ ╚══╝ + ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚════╝ ╚════╝ ╚═╝╚═╝ ╚══╝ "#,"\x1b[0m"); } @@ -165,15 +165,15 @@ fn main() { //TODO not suggest clean data dir in main network. NodeStartError::LoadConfigError(e) => { error!("{:?}, please fix config.", e); - std::process::exit(EXIT_CODE_NEED_HELP); + std::process::exit(G_EXIT_CODE_NEED_HELP); } NodeStartError::StorageInitError(e) => { error!("{:?}, please clean your data dir.", e); - std::process::exit(EXIT_CODE_NEED_HELP); + std::process::exit(G_EXIT_CODE_NEED_HELP); } NodeStartError::GenesisError(e) => { error!("{:?}, please clean your data dir.", e); - std::process::exit(EXIT_CODE_NEED_HELP); + std::process::exit(G_EXIT_CODE_NEED_HELP); } NodeStartError::Other(e) => { error!("Node exit for an unexpected error: {:?}", e); diff --git a/commons/accumulator/src/node.rs b/commons/accumulator/src/node.rs index bba5ea550a..f3d05cd29c 100644 --- a/commons/accumulator/src/node.rs +++ b/commons/accumulator/src/node.rs @@ -1,7 +1,7 @@ // Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 -use crate::node_index::{NodeIndex, NODE_ERROR_INDEX}; +use crate::node_index::{NodeIndex, G_NODE_ERROR_INDEX}; use anyhow::Result; use serde::{Deserialize, Serialize}; use starcoin_crypto::{ @@ -48,7 +48,7 @@ impl AccumulatorNode { AccumulatorNode::Leaf(leaf) => leaf.index(), AccumulatorNode::Empty => { // bail!("error for get index"); - *NODE_ERROR_INDEX + *G_NODE_ERROR_INDEX } } } diff --git a/commons/accumulator/src/node_index.rs b/commons/accumulator/src/node_index.rs index 9ef589184f..53aae33c3e 100644 --- a/commons/accumulator/src/node_index.rs +++ b/commons/accumulator/src/node_index.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] pub struct NodeIndex(u64); pub const MAX_ACCUMULATOR_PROOF_DEPTH: usize = 63; -pub static NODE_ERROR_INDEX: Lazy = +pub static G_NODE_ERROR_INDEX: Lazy = Lazy::new(|| NodeIndex::from_inorder_index(u64::max_value())); #[derive(Debug, Eq, PartialEq)] diff --git a/commons/logger/src/lib.rs b/commons/logger/src/lib.rs index cefd48ad22..4ffb8e951b 100644 --- a/commons/logger/src/lib.rs +++ b/commons/logger/src/lib.rs @@ -94,7 +94,7 @@ impl std::fmt::Display for LogPattern { } /// set some third party module's default log level for reduce debug log. -static THIRD_PARTY_MODULES: Lazy> = Lazy::new(|| { +static G_THIRD_PARTY_MODULES: Lazy> = Lazy::new(|| { vec![ // ("tokio_reactor", LevelFilter::Info), // ("yamux", LevelFilter::Info), @@ -141,7 +141,7 @@ impl LoggerConfigArg { module_levels: Vec<(String, LevelFilter)>, pattern: Option, ) -> Self { - let mut default_module_levels = THIRD_PARTY_MODULES + let mut default_module_levels = G_THIRD_PARTY_MODULES .iter() .map(|(m, m_level)| { ( @@ -325,7 +325,7 @@ fn env_log_level(default_level: &str) -> (LevelFilter, Vec<(String, LevelFilter) (default_level, level_filters.module_levels) } -static LOGGER_HANDLE: Lazy>>> = Lazy::new(|| Mutex::new(None)); +static G_LOGGER_HANDLE: Lazy>>> = Lazy::new(|| Mutex::new(None)); pub fn init() -> Arc { init_with_default_level("info", None) @@ -336,7 +336,7 @@ pub fn init_with_default_level( pattern: Option, ) -> Arc { let (global_level, module_levels) = env_log_level(default_level); - LOG_INIT.call_once(|| { + G_LOG_INIT.call_once(|| { let arg = LoggerConfigArg::new(true, global_level, module_levels, pattern); let config = build_config(arg.clone()).expect("build log config fail."); let handle = match log4rs::init_config(config) { @@ -344,9 +344,9 @@ pub fn init_with_default_level( Err(e) => panic!("{}", e.to_string()), }; let logger_handle = LoggerHandle::new(arg, handle); - *LOGGER_HANDLE.lock() = Some(Arc::new(logger_handle)); + *G_LOGGER_HANDLE.lock() = Some(Arc::new(logger_handle)); }); - let logger_handle = LOGGER_HANDLE + let logger_handle = G_LOGGER_HANDLE .lock() .as_ref() .expect("logger handle must has been set.") @@ -357,7 +357,7 @@ pub fn init_with_default_level( logger_handle } -static LOG_INIT: Once = Once::new(); +static G_LOG_INIT: Once = Once::new(); pub fn init_for_test() -> Arc { init_with_default_level("debug", Some(LogPattern::WithLine)) diff --git a/commons/logger/src/structured_log.rs b/commons/logger/src/structured_log.rs index 4df611af79..72f9a362f4 100644 --- a/commons/logger/src/structured_log.rs +++ b/commons/logger/src/structured_log.rs @@ -15,9 +15,9 @@ const TIMESTAMP_FORMAT: &str = "%+"; // Defined global slog logger lazy_static! { - static ref GLOBAL_SLOG_LOGGER: ArcSwap = + static ref G_GLOBAL_SLOG_LOGGER: ArcSwap = ArcSwap::from(Arc::new(Logger::root(Discard, o!()))); - static ref SLOG_LEVEL: Arc> = Arc::new(Mutex::new(slog::Level::Info)); + static ref G_SLOG_LEVEL: Arc> = Arc::new(Mutex::new(slog::Level::Info)); } // A RuntimeLevelFilter will discard all log records whose log level is less than the level @@ -29,11 +29,11 @@ pub struct RuntimeLevelFilter { impl RuntimeLevelFilter { pub fn new(drain: D, level: slog::Level) -> Self { - let mut s = SLOG_LEVEL.lock().unwrap(); + let mut s = G_SLOG_LEVEL.lock().unwrap(); *s = level; RuntimeLevelFilter { drain, - level: SLOG_LEVEL.clone(), + level: G_SLOG_LEVEL.clone(), } } } @@ -91,20 +91,20 @@ fn create_default_root_logger( pub fn init_slog_logger(file: PathBuf, enable_stderr: bool) -> Result<()> { let logger = create_default_root_logger(file, slog::Level::Info, enable_stderr)?; - GLOBAL_SLOG_LOGGER.store(Arc::new(logger)); + G_GLOBAL_SLOG_LOGGER.store(Arc::new(logger)); Ok(()) } pub fn set_slog_level(level: &str) { let level = slog::Level::from_str(level).unwrap_or(slog::Level::Info); - let mut slog_level = SLOG_LEVEL.lock().unwrap(); + let mut slog_level = G_SLOG_LEVEL.lock().unwrap(); *slog_level = level; } pub fn disable_slog_stderr(log_path: PathBuf) { match create_default_root_logger(log_path, slog::Level::Info, false) { Ok(logger) => { - GLOBAL_SLOG_LOGGER.swap(Arc::new(logger)); + G_GLOBAL_SLOG_LOGGER.swap(Arc::new(logger)); } Err(e) => log::warn!("Failed to disable slog stderr:{}", e), }; @@ -114,5 +114,5 @@ pub fn with_logger(f: F) -> R where F: FnOnce(&Logger) -> R, { - f(&(*GLOBAL_SLOG_LOGGER.load())) + f(&(*G_GLOBAL_SLOG_LOGGER.load())) } diff --git a/commons/scmd/src/context.rs b/commons/scmd/src/context.rs index 839f0db6e9..9ecdf8a035 100644 --- a/commons/scmd/src/context.rs +++ b/commons/scmd/src/context.rs @@ -23,7 +23,7 @@ pub use rustyline::{ Editor, }; -pub static DEFAULT_CONSOLE_CONFIG: Lazy = Lazy::new(|| { +pub static G_DEFAULT_CONSOLE_CONFIG: Lazy = Lazy::new(|| { ConsoleConfig::builder() .max_history_size(1000) .history_ignore_space(true) @@ -35,7 +35,7 @@ pub static DEFAULT_CONSOLE_CONFIG: Lazy = Lazy::new(|| { .build() }); -static OUTPUT_FORMAT_ARG: &str = "output-format"; +static G_OUTPUT_FORMAT_ARG: &str = "output-format"; pub struct CmdContext where @@ -103,7 +103,7 @@ where .version(version) .long_version(long_version.unwrap_or(version)) .arg( - Arg::new(OUTPUT_FORMAT_ARG) + Arg::new(G_OUTPUT_FORMAT_ARG) .short('o') .help("set output-format, support [json|table]") .takes_value(true) @@ -120,7 +120,7 @@ where pub fn with_console_support_default(self) -> Self { self.with_console_support( - |_, _, _| -> (ConsoleConfig, Option) { (*DEFAULT_CONSOLE_CONFIG, None) }, + |_, _, _| -> (ConsoleConfig, Option) { (*G_DEFAULT_CONSOLE_CONFIG, None) }, |_, _, _| println!("Quit."), ) } @@ -203,7 +203,7 @@ where .try_get_matches_from_mut(iter) .map_err(CmdError::ClapError)?; let output_format = matches - .value_of(OUTPUT_FORMAT_ARG) + .value_of(G_OUTPUT_FORMAT_ARG) .expect("output-format arg must exist") .parse() .expect("parse output-format must success."); diff --git a/commons/utils/src/metrics.rs b/commons/utils/src/metrics.rs index 47ac3eb3fa..2ab95e0c61 100644 --- a/commons/utils/src/metrics.rs +++ b/commons/utils/src/metrics.rs @@ -27,17 +27,17 @@ use prometheus::{ use prometheus::{core::GenericCounterVec, Opts}; lazy_static! { - pub static ref TOKIO_THREADS_TOTAL: GenericCounter = + pub static ref G_TOKIO_THREADS_TOTAL: GenericCounter = GenericCounter::new("tokio_threads_total", "Total number of threads created") .expect("Creating of statics doesn't fail. qed"); - pub static ref TOKIO_THREADS_ALIVE: GenericGauge = + pub static ref G_TOKIO_THREADS_ALIVE: GenericGauge = GenericGauge::new("tokio_threads_alive", "Number of threads alive right now") .expect("Creating of statics doesn't fail. qed"); } #[cfg(feature = "metered")] lazy_static! { - pub static ref UNBOUNDED_CHANNELS_COUNTER : GenericCounterVec = GenericCounterVec::new( + pub static ref G_UNBOUNDED_CHANNELS_COUNTER : GenericCounterVec = GenericCounterVec::new( Opts::new("unbounded_channel_len", "Items in each mpsc::unbounded instance"), &["entity", "action"] // 'name of channel, send|received|dropped ).expect("Creating of statics doesn't fail. qed"); @@ -46,11 +46,11 @@ lazy_static! { /// Register the statics to report to registry pub fn register_globals(registry: &Registry) -> Result<(), PrometheusError> { - registry.register(Box::new(TOKIO_THREADS_ALIVE.clone()))?; - registry.register(Box::new(TOKIO_THREADS_TOTAL.clone()))?; + registry.register(Box::new(G_TOKIO_THREADS_ALIVE.clone()))?; + registry.register(Box::new(G_TOKIO_THREADS_TOTAL.clone()))?; #[cfg(feature = "metered")] - registry.register(Box::new(UNBOUNDED_CHANNELS_COUNTER.clone()))?; + registry.register(Box::new(G_UNBOUNDED_CHANNELS_COUNTER.clone()))?; Ok(()) } diff --git a/commons/utils/src/mpsc.rs b/commons/utils/src/mpsc.rs index 70792d6d40..ed8d7acfe9 100644 --- a/commons/utils/src/mpsc.rs +++ b/commons/utils/src/mpsc.rs @@ -35,7 +35,7 @@ mod inner { #[cfg(feature = "metered")] mod inner { //tracing implementation - use crate::metrics::UNBOUNDED_CHANNELS_COUNTER; + use crate::metrics::G_UNBOUNDED_CHANNELS_COUNTER; use futures::channel::mpsc::{ self, SendError, TryRecvError, TrySendError, UnboundedReceiver, UnboundedSender, }; @@ -105,7 +105,7 @@ mod inner { /// Proxy function to mpsc::UnboundedSender pub fn unbounded_send(&self, msg: T) -> Result<(), TrySendError> { self.1.unbounded_send(msg).map(|s| { - UNBOUNDED_CHANNELS_COUNTER + G_UNBOUNDED_CHANNELS_COUNTER .with_label_values(&[self.0, "send"]) .inc(); s @@ -134,7 +134,7 @@ mod inner { } // and discount the messages if count > 0 { - UNBOUNDED_CHANNELS_COUNTER + G_UNBOUNDED_CHANNELS_COUNTER .with_label_values(&[self.0, "dropped"]) .inc_by(count); } @@ -152,7 +152,7 @@ mod inner { pub fn try_next(&mut self) -> Result, TryRecvError> { self.1.try_next().map(|s| { if s.is_some() { - UNBOUNDED_CHANNELS_COUNTER + G_UNBOUNDED_CHANNELS_COUNTER .with_label_values(&[self.0, "received"]) .inc(); } @@ -177,7 +177,7 @@ mod inner { match Pin::new(&mut s.1).poll_next(cx) { Poll::Ready(msg) => { if msg.is_some() { - UNBOUNDED_CHANNELS_COUNTER + G_UNBOUNDED_CHANNELS_COUNTER .with_label_values(&[s.0, "received"]) .inc(); } diff --git a/commons/utils/src/stop_watch.rs b/commons/utils/src/stop_watch.rs index f9037b83a4..a896464e09 100644 --- a/commons/utils/src/stop_watch.rs +++ b/commons/utils/src/stop_watch.rs @@ -7,14 +7,14 @@ use simple_stopwatch::Stopwatch; use std::collections::HashMap; use std::sync::atomic::{AtomicBool, Ordering}; -static WATCH_STATUS: AtomicBool = AtomicBool::new(false); +static G_WATCH_STATUS: AtomicBool = AtomicBool::new(false); pub type WatchName = &'static str; pub const CHAIN_WATCH_NAME: WatchName = "chain"; -static DEFAULT_WATCH: Lazy> = Lazy::new(|| Mutex::new(Stopwatch::start_new())); -static WATCH_MAP: Lazy>> = Lazy::new(|| { +static G_DEFAULT_WATCH: Lazy> = Lazy::new(|| Mutex::new(Stopwatch::start_new())); +static G_WATCH_MAP: Lazy>> = Lazy::new(|| { let mut watch_map = HashMap::new(); watch_map.insert(CHAIN_WATCH_NAME, Mutex::new(Stopwatch::start_new())); watch_map @@ -22,10 +22,10 @@ static WATCH_MAP: Lazy>> = Lazy::new(|| { /// Watch some method handle time. pub fn watch(watch_name: &str, label: &str) { - if WATCH_STATUS.load(Ordering::SeqCst) { - let stop_watch = match WATCH_MAP.get(watch_name) { + if G_WATCH_STATUS.load(Ordering::SeqCst) { + let stop_watch = match G_WATCH_MAP.get(watch_name) { Some(stop_watch) => stop_watch, - None => &DEFAULT_WATCH, + None => &G_DEFAULT_WATCH, }; let mut watch = stop_watch.lock(); watch.restart(); @@ -35,14 +35,14 @@ pub fn watch(watch_name: &str, label: &str) { /// Start watching. pub fn start_watch() { - let _ = WATCH_STATUS + let _ = G_WATCH_STATUS .compare_exchange(false, true, Ordering::SeqCst, Ordering::Relaxed) .unwrap_or_else(|x| x); } /// Stop watching. pub fn stop_watch() { - let _ = WATCH_STATUS + let _ = G_WATCH_STATUS .compare_exchange(true, false, Ordering::SeqCst, Ordering::Relaxed) .unwrap_or_else(|x| x); } diff --git a/config/src/account_vault_config.rs b/config/src/account_vault_config.rs index d83f5a914d..c66e879632 100644 --- a/config/src/account_vault_config.rs +++ b/config/src/account_vault_config.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; use std::path::PathBuf; use std::sync::Arc; -static DEFAULT_DIR: Lazy = Lazy::new(|| PathBuf::from("account_vaults")); +static G_DEFAULT_DIR: Lazy = Lazy::new(|| PathBuf::from("account_vaults")); #[derive(Clone, Default, Debug, Deserialize, PartialEq, Serialize, Parser)] #[serde(deny_unknown_fields)] @@ -31,7 +31,7 @@ impl AccountVaultConfig { } pub fn dir(&self) -> PathBuf { - let path = self.dir.as_ref().unwrap_or(&DEFAULT_DIR); + let path = self.dir.as_ref().unwrap_or(&G_DEFAULT_DIR); if path.is_absolute() { path.clone() } else { diff --git a/config/src/available_port.rs b/config/src/available_port.rs index 603fb5d78f..588b28ad81 100644 --- a/config/src/available_port.rs +++ b/config/src/available_port.rs @@ -4,7 +4,7 @@ use once_cell::sync::Lazy; use parking_lot::Mutex; -static USED_PORTS: Lazy>> = Lazy::new(|| Mutex::new(vec![])); +static G_USED_PORTS: Lazy>> = Lazy::new(|| Mutex::new(vec![])); pub fn get_available_port_from(start_port: u16) -> u16 { for i in 0..100 { @@ -19,7 +19,7 @@ pub fn get_available_port_from(start_port: u16) -> u16 { /// check if `port` is available. fn check_port_in_use(port: u16) -> bool { - if USED_PORTS.lock().contains(&port) { + if G_USED_PORTS.lock().contains(&port) { return true; } use std::net::TcpStream; @@ -28,7 +28,7 @@ fn check_port_in_use(port: u16) -> bool { Err(_e) => false, }; if !in_use { - USED_PORTS.lock().push(port); + G_USED_PORTS.lock().push(port); }; in_use } diff --git a/config/src/genesis_config.rs b/config/src/genesis_config.rs index dbba07437a..fee32de189 100644 --- a/config/src/genesis_config.rs +++ b/config/src/genesis_config.rs @@ -24,7 +24,7 @@ use starcoin_vm_types::gas_schedule::{ use starcoin_vm_types::genesis_config::{ChainId, ConsensusStrategy, StdlibVersion}; use starcoin_vm_types::on_chain_config::{ instruction_table_v1, native_table_v1, native_table_v2, ConsensusConfig, DaoConfig, - TransactionPublishOption, VMConfig, Version, LATEST_INSTRUCTION_TABLE, LATEST_NATIVE_TABLE, + TransactionPublishOption, VMConfig, Version, G_LATEST_INSTRUCTION_TABLE, G_LATEST_NATIVE_TABLE, }; use starcoin_vm_types::on_chain_resource::Epoch; use starcoin_vm_types::time::{TimeService, TimeServiceType}; @@ -169,23 +169,23 @@ impl BuiltinNetworkID { pub fn genesis_config(self) -> &'static GenesisConfig { match self { - BuiltinNetworkID::Test => &TEST_CONFIG, - BuiltinNetworkID::Dev => &DEV_CONFIG, - BuiltinNetworkID::Halley => &HALLEY_CONFIG, - BuiltinNetworkID::Proxima => &PROXIMA_CONFIG, - BuiltinNetworkID::Barnard => &BARNARD_CONFIG, - BuiltinNetworkID::Main => &MAIN_CONFIG, + BuiltinNetworkID::Test => &G_TEST_CONFIG, + BuiltinNetworkID::Dev => &G_DEV_CONFIG, + BuiltinNetworkID::Halley => &G_HALLEY_CONFIG, + BuiltinNetworkID::Proxima => &G_PROXIMA_CONFIG, + BuiltinNetworkID::Barnard => &G_BARNARD_CONFIG, + BuiltinNetworkID::Main => &G_MAIN_CONFIG, } } pub fn boot_nodes(self) -> &'static [MultiaddrWithPeerId] { match self { - BuiltinNetworkID::Test => EMPTY_BOOT_NODES.as_slice(), - BuiltinNetworkID::Dev => EMPTY_BOOT_NODES.as_slice(), - BuiltinNetworkID::Halley => HALLEY_BOOT_NODES.as_slice(), - BuiltinNetworkID::Proxima => PROXIMA_BOOT_NODES.as_slice(), - BuiltinNetworkID::Barnard => BARNARD_BOOT_NODES.as_slice(), - BuiltinNetworkID::Main => MAIN_BOOT_NODES.as_slice(), + BuiltinNetworkID::Test => G_EMPTY_BOOT_NODES.as_slice(), + BuiltinNetworkID::Dev => G_EMPTY_BOOT_NODES.as_slice(), + BuiltinNetworkID::Halley => G_HALLEY_BOOT_NODES.as_slice(), + BuiltinNetworkID::Proxima => G_PROXIMA_BOOT_NODES.as_slice(), + BuiltinNetworkID::Barnard => G_BARNARD_BOOT_NODES.as_slice(), + BuiltinNetworkID::Main => G_MAIN_BOOT_NODES.as_slice(), } } @@ -685,126 +685,126 @@ impl GenesisConfig { } } -static UNCLE_RATE_TARGET: u64 = 240; -static DEFAULT_BASE_BLOCK_TIME_TARGET: u64 = 10000; -static DEFAULT_BASE_BLOCK_DIFF_WINDOW: u64 = 24; -static BASE_REWARD_PER_UNCLE_PERCENT: u64 = 10; -static MIN_BLOCK_TIME_TARGET: u64 = 5000; -static MAX_BLOCK_TIME_TARGET: u64 = 60000; -static BASE_MAX_UNCLES_PER_BLOCK: u64 = 2; +static G_UNCLE_RATE_TARGET: u64 = 240; +static G_DEFAULT_BASE_BLOCK_TIME_TARGET: u64 = 10000; +static G_DEFAULT_BASE_BLOCK_DIFF_WINDOW: u64 = 24; +static G_BASE_REWARD_PER_UNCLE_PERCENT: u64 = 10; +static G_MIN_BLOCK_TIME_TARGET: u64 = 5000; +static G_MAX_BLOCK_TIME_TARGET: u64 = 60000; +static G_BASE_MAX_UNCLES_PER_BLOCK: u64 = 2; -pub static TOTAL_STC_AMOUNT: Lazy> = +pub static G_TOTAL_STC_AMOUNT: Lazy> = Lazy::new(|| STCUnit::STC.value_of(3185136000)); //for Private funding -static DEFAULT_PRE_MINT_AMOUNT: Lazy> = +static G_DEFAULT_PRE_MINT_AMOUNT: Lazy> = Lazy::new(|| STCUnit::STC.value_of(159256800)); //for Starcoin Foundation + DevTeam time lock release. -static DEFAULT_TIME_LOCKED_AMOUNT: Lazy> = +static G_DEFAULT_TIME_LOCKED_AMOUNT: Lazy> = Lazy::new(|| STCUnit::STC.value_of(85043130 * 3 + 74213670 * 3)); //three years. -static DEFAULT_TIME_LOCKED_PERIOD: u64 = 3600 * 24 * 365 * 3; +static G_DEFAULT_TIME_LOCKED_PERIOD: u64 = 3600 * 24 * 365 * 3; -static DEFAULT_BASE_REWARD_PER_BLOCK: Lazy> = +static G_DEFAULT_BASE_REWARD_PER_BLOCK: Lazy> = Lazy::new(|| STCUnit::STC.value_of(10)); -pub static BASE_BLOCK_GAS_LIMIT: u64 = 50_000_000; //must big than maximum_number_of_gas_units +pub static G_BASE_BLOCK_GAS_LIMIT: u64 = 50_000_000; //must big than maximum_number_of_gas_units -static MAX_TRANSACTION_SIZE_IN_BYTES_V1: u64 = 4096 * 10; -static MAX_TRANSACTION_SIZE_IN_BYTES_V2: u64 = 60000; -static MAX_TRANSACTION_SIZE_IN_BYTES_V3: u64 = 128 * 1024; +static G_MAX_TRANSACTION_SIZE_IN_BYTES_V1: u64 = 4096 * 10; +static G_MAX_TRANSACTION_SIZE_IN_BYTES_V2: u64 = 60000; +static G_MAX_TRANSACTION_SIZE_IN_BYTES_V3: u64 = 128 * 1024; /// For V1 all accounts will be ~800 bytes -static DEFAULT_ACCOUNT_SIZE: Lazy> = +static G_DEFAULT_ACCOUNT_SIZE: Lazy> = Lazy::new(|| AbstractMemorySize::new(800)); /// Any transaction over this size will be charged `INTRINSIC_GAS_PER_BYTE` per byte -static LARGE_TRANSACTION_CUTOFF: Lazy> = +static G_LARGE_TRANSACTION_CUTOFF: Lazy> = Lazy::new(|| AbstractMemorySize::new(600)); -static GAS_CONSTANTS_V1: Lazy = Lazy::new(|| { +static G_GAS_CONSTANTS_V1: Lazy = Lazy::new(|| { GasConstants { global_memory_per_byte_cost: InternalGasUnits::new(4), global_memory_per_byte_write_cost: InternalGasUnits::new(9), min_transaction_gas_units: InternalGasUnits::new(600), - large_transaction_cutoff: *LARGE_TRANSACTION_CUTOFF, + large_transaction_cutoff: *G_LARGE_TRANSACTION_CUTOFF, intrinsic_gas_per_byte: InternalGasUnits::new(8), maximum_number_of_gas_units: GasUnits::new(40_000_000), //must less than base_block_gas_limit min_price_per_gas_unit: GasPrice::new(1), max_price_per_gas_unit: GasPrice::new(10_000), - max_transaction_size_in_bytes: MAX_TRANSACTION_SIZE_IN_BYTES_V1, // to pass stdlib_upgrade + max_transaction_size_in_bytes: G_MAX_TRANSACTION_SIZE_IN_BYTES_V1, // to pass stdlib_upgrade gas_unit_scaling_factor: 1, - default_account_size: *DEFAULT_ACCOUNT_SIZE, + default_account_size: *G_DEFAULT_ACCOUNT_SIZE, } }); -static GAS_CONSTANTS_V2: Lazy = Lazy::new(|| { +static G_GAS_CONSTANTS_V2: Lazy = Lazy::new(|| { GasConstants { global_memory_per_byte_cost: InternalGasUnits::new(4), global_memory_per_byte_write_cost: InternalGasUnits::new(9), min_transaction_gas_units: InternalGasUnits::new(600), - large_transaction_cutoff: *LARGE_TRANSACTION_CUTOFF, + large_transaction_cutoff: *G_LARGE_TRANSACTION_CUTOFF, intrinsic_gas_per_byte: InternalGasUnits::new(8), maximum_number_of_gas_units: GasUnits::new(40_000_000), //must less than base_block_gas_limit min_price_per_gas_unit: GasPrice::new(1), max_price_per_gas_unit: GasPrice::new(10_000), - max_transaction_size_in_bytes: MAX_TRANSACTION_SIZE_IN_BYTES_V2, // to pass stdlib_upgrade + max_transaction_size_in_bytes: G_MAX_TRANSACTION_SIZE_IN_BYTES_V2, // to pass stdlib_upgrade gas_unit_scaling_factor: 1, - default_account_size: *DEFAULT_ACCOUNT_SIZE, + default_account_size: *G_DEFAULT_ACCOUNT_SIZE, } }); -pub static GAS_CONSTANTS_V3: Lazy = Lazy::new(|| { +pub static G_GAS_CONSTANTS_V3: Lazy = Lazy::new(|| { GasConstants { global_memory_per_byte_cost: InternalGasUnits::new(4), global_memory_per_byte_write_cost: InternalGasUnits::new(9), min_transaction_gas_units: InternalGasUnits::new(600), - large_transaction_cutoff: *LARGE_TRANSACTION_CUTOFF, + large_transaction_cutoff: *G_LARGE_TRANSACTION_CUTOFF, intrinsic_gas_per_byte: InternalGasUnits::new(8), maximum_number_of_gas_units: GasUnits::new(40_000_000), //must less than base_block_gas_limit min_price_per_gas_unit: GasPrice::new(1), max_price_per_gas_unit: GasPrice::new(10_000), - max_transaction_size_in_bytes: MAX_TRANSACTION_SIZE_IN_BYTES_V3, + max_transaction_size_in_bytes: G_MAX_TRANSACTION_SIZE_IN_BYTES_V3, gas_unit_scaling_factor: 1, - default_account_size: *DEFAULT_ACCOUNT_SIZE, + default_account_size: *G_DEFAULT_ACCOUNT_SIZE, } }); -pub static TEST_GAS_CONSTANTS: Lazy = Lazy::new(|| { +pub static G_TEST_GAS_CONSTANTS: Lazy = Lazy::new(|| { GasConstants { global_memory_per_byte_cost: InternalGasUnits::new(4), global_memory_per_byte_write_cost: InternalGasUnits::new(9), min_transaction_gas_units: InternalGasUnits::new(600), - large_transaction_cutoff: *LARGE_TRANSACTION_CUTOFF, + large_transaction_cutoff: *G_LARGE_TRANSACTION_CUTOFF, intrinsic_gas_per_byte: InternalGasUnits::new(8), maximum_number_of_gas_units: GasUnits::new(40_000_000), //must less than base_block_gas_limit min_price_per_gas_unit: GasPrice::new(0), max_price_per_gas_unit: GasPrice::new(10_000), - max_transaction_size_in_bytes: MAX_TRANSACTION_SIZE_IN_BYTES_V3, + max_transaction_size_in_bytes: G_MAX_TRANSACTION_SIZE_IN_BYTES_V3, gas_unit_scaling_factor: 1, - default_account_size: *DEFAULT_ACCOUNT_SIZE, + default_account_size: *G_DEFAULT_ACCOUNT_SIZE, } }); -pub static LATEST_GAS_CONSTANTS: Lazy = Lazy::new(|| GAS_CONSTANTS_V3.clone()); +pub static G_LATEST_GAS_CONSTANTS: Lazy = Lazy::new(|| G_GAS_CONSTANTS_V3.clone()); pub fn latest_cost_table(gas_constants: GasConstants) -> CostTable { CostTable { - instruction_table: LATEST_INSTRUCTION_TABLE.clone(), - native_table: LATEST_NATIVE_TABLE.clone(), + instruction_table: G_LATEST_INSTRUCTION_TABLE.clone(), + native_table: G_LATEST_NATIVE_TABLE.clone(), gas_constants, } } /// only used in starcoin vm when init genesis -pub static LATEST_GAS_SCHEDULE: Lazy = - Lazy::new(|| latest_cost_table(LATEST_GAS_CONSTANTS.clone())); +pub static G_LATEST_GAS_SCHEDULE: Lazy = + Lazy::new(|| latest_cost_table(G_LATEST_GAS_CONSTANTS.clone())); -static EMPTY_BOOT_NODES: Lazy> = Lazy::new(Vec::new); +static G_EMPTY_BOOT_NODES: Lazy> = Lazy::new(Vec::new); const ONE_DAY: u64 = 86400; -pub static TEST_CONFIG: Lazy = Lazy::new(|| { +pub static G_TEST_CONFIG: Lazy = Lazy::new(|| { let (association_private_key, association_public_key) = genesis_multi_key_pair(); let (genesis_private_key, genesis_public_key) = genesis_key_pair(); @@ -817,24 +817,24 @@ pub static TEST_CONFIG: Lazy = Lazy::new(|| { }), version: Version { major: 1 }, reward_delay: 1, - pre_mine_amount: DEFAULT_PRE_MINT_AMOUNT.scaling(), - time_mint_amount: DEFAULT_TIME_LOCKED_AMOUNT.scaling(), - time_mint_period: DEFAULT_TIME_LOCKED_PERIOD, + pre_mine_amount: G_DEFAULT_PRE_MINT_AMOUNT.scaling(), + time_mint_amount: G_DEFAULT_TIME_LOCKED_AMOUNT.scaling(), + time_mint_period: G_DEFAULT_TIME_LOCKED_PERIOD, vm_config: VMConfig { - gas_schedule: latest_cost_table(TEST_GAS_CONSTANTS.clone()), + gas_schedule: latest_cost_table(G_TEST_GAS_CONSTANTS.clone()), }, publishing_option: TransactionPublishOption::open(), consensus_config: ConsensusConfig { - uncle_rate_target: UNCLE_RATE_TARGET, - base_block_time_target: DEFAULT_BASE_BLOCK_TIME_TARGET, - base_reward_per_block: DEFAULT_BASE_REWARD_PER_BLOCK.scaling(), - epoch_block_count: DEFAULT_BASE_BLOCK_DIFF_WINDOW * 2, - base_block_difficulty_window: DEFAULT_BASE_BLOCK_DIFF_WINDOW, - base_reward_per_uncle_percent: BASE_REWARD_PER_UNCLE_PERCENT, - min_block_time_target: MIN_BLOCK_TIME_TARGET, - max_block_time_target: MAX_BLOCK_TIME_TARGET, - base_max_uncles_per_block: BASE_MAX_UNCLES_PER_BLOCK, - base_block_gas_limit: BASE_BLOCK_GAS_LIMIT * 10, + uncle_rate_target: G_UNCLE_RATE_TARGET, + base_block_time_target: G_DEFAULT_BASE_BLOCK_TIME_TARGET, + base_reward_per_block: G_DEFAULT_BASE_REWARD_PER_BLOCK.scaling(), + epoch_block_count: G_DEFAULT_BASE_BLOCK_DIFF_WINDOW * 2, + base_block_difficulty_window: G_DEFAULT_BASE_BLOCK_DIFF_WINDOW, + base_reward_per_uncle_percent: G_BASE_REWARD_PER_UNCLE_PERCENT, + min_block_time_target: G_MIN_BLOCK_TIME_TARGET, + max_block_time_target: G_MAX_BLOCK_TIME_TARGET, + base_max_uncles_per_block: G_BASE_MAX_UNCLES_PER_BLOCK, + base_block_gas_limit: G_BASE_BLOCK_GAS_LIMIT * 10, strategy: ConsensusStrategy::Dummy.value(), }, association_key_pair: ( @@ -854,7 +854,7 @@ pub static TEST_CONFIG: Lazy = Lazy::new(|| { } }); -pub static DEV_CONFIG: Lazy = Lazy::new(|| { +pub static G_DEV_CONFIG: Lazy = Lazy::new(|| { let (association_private_key, association_public_key) = genesis_multi_key_pair(); let (genesis_private_key, genesis_public_key) = genesis_key_pair(); @@ -866,24 +866,24 @@ pub static DEV_CONFIG: Lazy = Lazy::new(|| { }), version: Version { major: 1 }, reward_delay: 1, - pre_mine_amount: DEFAULT_PRE_MINT_AMOUNT.scaling(), - time_mint_amount: DEFAULT_TIME_LOCKED_AMOUNT.scaling(), + pre_mine_amount: G_DEFAULT_PRE_MINT_AMOUNT.scaling(), + time_mint_amount: G_DEFAULT_TIME_LOCKED_AMOUNT.scaling(), time_mint_period: 3600 * 24, vm_config: VMConfig { - gas_schedule: latest_cost_table(TEST_GAS_CONSTANTS.clone()), + gas_schedule: latest_cost_table(G_TEST_GAS_CONSTANTS.clone()), }, publishing_option: TransactionPublishOption::open(), consensus_config: ConsensusConfig { - uncle_rate_target: UNCLE_RATE_TARGET, - base_block_time_target: DEFAULT_BASE_BLOCK_TIME_TARGET, - base_reward_per_block: DEFAULT_BASE_REWARD_PER_BLOCK.scaling(), - epoch_block_count: DEFAULT_BASE_BLOCK_DIFF_WINDOW * 2, - base_block_difficulty_window: DEFAULT_BASE_BLOCK_DIFF_WINDOW, - base_reward_per_uncle_percent: BASE_REWARD_PER_UNCLE_PERCENT, - min_block_time_target: MIN_BLOCK_TIME_TARGET, - max_block_time_target: MAX_BLOCK_TIME_TARGET, - base_max_uncles_per_block: BASE_MAX_UNCLES_PER_BLOCK, - base_block_gas_limit: BASE_BLOCK_GAS_LIMIT * 10, + uncle_rate_target: G_UNCLE_RATE_TARGET, + base_block_time_target: G_DEFAULT_BASE_BLOCK_TIME_TARGET, + base_reward_per_block: G_DEFAULT_BASE_REWARD_PER_BLOCK.scaling(), + epoch_block_count: G_DEFAULT_BASE_BLOCK_DIFF_WINDOW * 2, + base_block_difficulty_window: G_DEFAULT_BASE_BLOCK_DIFF_WINDOW, + base_reward_per_uncle_percent: G_BASE_REWARD_PER_UNCLE_PERCENT, + min_block_time_target: G_MIN_BLOCK_TIME_TARGET, + max_block_time_target: G_MAX_BLOCK_TIME_TARGET, + base_max_uncles_per_block: G_BASE_MAX_UNCLES_PER_BLOCK, + base_block_gas_limit: G_BASE_BLOCK_GAS_LIMIT * 10, strategy: ConsensusStrategy::Dummy.value(), }, association_key_pair: ( @@ -903,13 +903,13 @@ pub static DEV_CONFIG: Lazy = Lazy::new(|| { } }); -pub static HALLEY_BOOT_NODES: Lazy> = Lazy::new(|| { +pub static G_HALLEY_BOOT_NODES: Lazy> = Lazy::new(|| { vec!["/dns4/halley1.seed.starcoin.org/tcp/9840/p2p/12D3KooW9yQoKZrByqrUjmmPHXtR23qCXRQvF5KowYgoqypuhuCn".parse().expect("parse multi addr should be ok"), "/dns4/halley2.seed.starcoin.org/tcp/9840/p2p/12D3KooWCqWbB2Abp6co6vMGG7VcEC9yYJU3yB1VhVYvpRQAr3sv".parse().expect("parse multi addr should be ok"), "/dns4/halley3.seed.starcoin.org/tcp/9840/p2p/12D3KooWRiF6ZtUouCHgrgoCJ2jL4LCzzTEwopPbzVvTTRY3c2mf".parse().expect("parse multi addr should be ok"), ] }); -pub static HALLEY_CONFIG: Lazy = Lazy::new(|| { +pub static G_HALLEY_CONFIG: Lazy = Lazy::new(|| { let stdlib_version = StdlibVersion::Latest; let association_public_key = "068b8493d8c533fd08568429274e49639518a8517f6ab03a0f0cc37edcbdfdd0071855fd941dbcefeb9e4da9f417c7b0f39f73226c9310d39881ae13b45017fa67cc9cb01386e9f5e321b078d4d3a2925b520f955cf7dfd9f6891de366c186ce6ec4a3d5a1c6c795126e5ee1222e23f9a28266c07ecce3e2cd19c6e123b465c091bc45a1fa7f778c66c37af15f3e81ff511e69ff0481bcfaab7b4673f469a3d29760cacf5dd0105a541b5f50720b9577a4c3ff7475554afedbf6a884777f9db4c461fe9aca18df90ed31ee967fe49ed47756311eaa2a6042b7aff1422e48643dc7a0004e0ca3e6b8e548c80d76eeb88e84a82f6b863a1346eabadfe4d5d9be86f98fa72c63f1e1a3f193d4ff71e10dbf364200b221e1a7f71cfab55cc7f7ad2a05"; @@ -921,24 +921,24 @@ pub static HALLEY_CONFIG: Lazy = Lazy::new(|| { }), version: Version { major: 1 }, reward_delay: 3, - pre_mine_amount: DEFAULT_PRE_MINT_AMOUNT.scaling(), - time_mint_amount: DEFAULT_TIME_LOCKED_AMOUNT.scaling(), + pre_mine_amount: G_DEFAULT_PRE_MINT_AMOUNT.scaling(), + time_mint_amount: G_DEFAULT_TIME_LOCKED_AMOUNT.scaling(), time_mint_period: 3600 * 24 * 31, vm_config: VMConfig { - gas_schedule: LATEST_GAS_SCHEDULE.clone(), + gas_schedule: G_LATEST_GAS_SCHEDULE.clone(), }, publishing_option: TransactionPublishOption::open(), consensus_config: ConsensusConfig { - uncle_rate_target: UNCLE_RATE_TARGET, - base_block_time_target: DEFAULT_BASE_BLOCK_TIME_TARGET, - base_reward_per_block: DEFAULT_BASE_REWARD_PER_BLOCK.scaling(), - epoch_block_count: DEFAULT_BASE_BLOCK_DIFF_WINDOW * 10, - base_block_difficulty_window: DEFAULT_BASE_BLOCK_DIFF_WINDOW, - base_reward_per_uncle_percent: BASE_REWARD_PER_UNCLE_PERCENT, - min_block_time_target: MIN_BLOCK_TIME_TARGET, - max_block_time_target: MAX_BLOCK_TIME_TARGET, - base_max_uncles_per_block: BASE_MAX_UNCLES_PER_BLOCK, - base_block_gas_limit: BASE_BLOCK_GAS_LIMIT * 10, + uncle_rate_target: G_UNCLE_RATE_TARGET, + base_block_time_target: G_DEFAULT_BASE_BLOCK_TIME_TARGET, + base_reward_per_block: G_DEFAULT_BASE_REWARD_PER_BLOCK.scaling(), + epoch_block_count: G_DEFAULT_BASE_BLOCK_DIFF_WINDOW * 10, + base_block_difficulty_window: G_DEFAULT_BASE_BLOCK_DIFF_WINDOW, + base_reward_per_uncle_percent: G_BASE_REWARD_PER_UNCLE_PERCENT, + min_block_time_target: G_MIN_BLOCK_TIME_TARGET, + max_block_time_target: G_MAX_BLOCK_TIME_TARGET, + base_max_uncles_per_block: G_BASE_MAX_UNCLES_PER_BLOCK, + base_block_gas_limit: G_BASE_BLOCK_GAS_LIMIT * 10, strategy: ConsensusStrategy::CryptoNight.value(), }, association_key_pair: ( @@ -959,14 +959,14 @@ pub static HALLEY_CONFIG: Lazy = Lazy::new(|| { } }); -pub static PROXIMA_BOOT_NODES: Lazy> = Lazy::new(|| { +pub static G_PROXIMA_BOOT_NODES: Lazy> = Lazy::new(|| { vec!["/dns4/proxima1.seed.starcoin.org/tcp/9840/p2p/12D3KooWFvCKQ1n2JkSQpn8drqGwU27vTPkKx264zD4CFbgaKDJU".parse().expect("parse multi addr should be ok"), "/dns4/proxima2.seed.starcoin.org/tcp/9840/p2p/12D3KooWAua4KokJMiCodGPEF2n4yN42B2Q26KgwrQTntnrCDRHd".parse().expect("parse multi addr should be ok"), "/dns4/proxima3.seed.starcoin.org/tcp/9840/p2p/12D3KooW9vHQJk9o69tZPMM2viQ3eWpgp6veDBRz8tTvDFDBejwk".parse().expect("parse multi addr should be ok"), ] }); -pub static PROXIMA_CONFIG: Lazy = Lazy::new(|| { +pub static G_PROXIMA_CONFIG: Lazy = Lazy::new(|| { let stdlib_version = StdlibVersion::Version(10); let association_public_key = "068b8493d8c533fd08568429274e49639518a8517f6ab03a0f0cc37edcbdfdd0071855fd941dbcefeb9e4da9f417c7b0f39f73226c9310d39881ae13b45017fa67cc9cb01386e9f5e321b078d4d3a2925b520f955cf7dfd9f6891de366c186ce6ec4a3d5a1c6c795126e5ee1222e23f9a28266c07ecce3e2cd19c6e123b465c091bc45a1fa7f778c66c37af15f3e81ff511e69ff0481bcfaab7b4673f469a3d29760cacf5dd0105a541b5f50720b9577a4c3ff7475554afedbf6a884777f9db4c461fe9aca18df90ed31ee967fe49ed47756311eaa2a6042b7aff1422e48643dc7a0004e0ca3e6b8e548c80d76eeb88e84a82f6b863a1346eabadfe4d5d9be86f98fa72c63f1e1a3f193d4ff71e10dbf364200b221e1a7f71cfab55cc7f7ad2a05"; GenesisConfig { @@ -977,28 +977,28 @@ pub static PROXIMA_CONFIG: Lazy = Lazy::new(|| { }), version: Version { major: 1 }, reward_delay: 7, - pre_mine_amount: DEFAULT_PRE_MINT_AMOUNT.scaling(), - time_mint_amount: DEFAULT_TIME_LOCKED_AMOUNT.scaling(), - time_mint_period: DEFAULT_TIME_LOCKED_PERIOD / 12, + pre_mine_amount: G_DEFAULT_PRE_MINT_AMOUNT.scaling(), + time_mint_amount: G_DEFAULT_TIME_LOCKED_AMOUNT.scaling(), + time_mint_period: G_DEFAULT_TIME_LOCKED_PERIOD / 12, vm_config: VMConfig { gas_schedule: CostTable { instruction_table: instruction_table_v1(), native_table: native_table_v2(), - gas_constants: GAS_CONSTANTS_V3.clone(), + gas_constants: G_GAS_CONSTANTS_V3.clone(), }, }, publishing_option: TransactionPublishOption::open(), consensus_config: ConsensusConfig { - uncle_rate_target: UNCLE_RATE_TARGET, - base_block_time_target: DEFAULT_BASE_BLOCK_TIME_TARGET, - base_reward_per_block: DEFAULT_BASE_REWARD_PER_BLOCK.scaling(), - epoch_block_count: DEFAULT_BASE_BLOCK_DIFF_WINDOW * 10, - base_block_difficulty_window: DEFAULT_BASE_BLOCK_DIFF_WINDOW, - base_reward_per_uncle_percent: BASE_REWARD_PER_UNCLE_PERCENT, - min_block_time_target: MIN_BLOCK_TIME_TARGET, - max_block_time_target: MAX_BLOCK_TIME_TARGET, - base_max_uncles_per_block: BASE_MAX_UNCLES_PER_BLOCK, - base_block_gas_limit: BASE_BLOCK_GAS_LIMIT, + uncle_rate_target: G_UNCLE_RATE_TARGET, + base_block_time_target: G_DEFAULT_BASE_BLOCK_TIME_TARGET, + base_reward_per_block: G_DEFAULT_BASE_REWARD_PER_BLOCK.scaling(), + epoch_block_count: G_DEFAULT_BASE_BLOCK_DIFF_WINDOW * 10, + base_block_difficulty_window: G_DEFAULT_BASE_BLOCK_DIFF_WINDOW, + base_reward_per_uncle_percent: G_BASE_REWARD_PER_UNCLE_PERCENT, + min_block_time_target: G_MIN_BLOCK_TIME_TARGET, + max_block_time_target: G_MAX_BLOCK_TIME_TARGET, + base_max_uncles_per_block: G_BASE_MAX_UNCLES_PER_BLOCK, + base_block_gas_limit: G_BASE_BLOCK_GAS_LIMIT, strategy: ConsensusStrategy::CryptoNight.value(), }, association_key_pair: ( @@ -1019,7 +1019,7 @@ pub static PROXIMA_CONFIG: Lazy = Lazy::new(|| { } }); -pub static BARNARD_BOOT_NODES: Lazy> = Lazy::new(|| { +pub static G_BARNARD_BOOT_NODES: Lazy> = Lazy::new(|| { vec![ "/dns4/barnard1.seed.starcoin.org/tcp/9840/p2p/12D3KooWJcsd9JQngZFsHgYgkHymk7anN8fKqBtD1x8jEbq64QET".parse().expect("parse multi addr should be ok"), "/dns4/barnard2.seed.starcoin.org/tcp/9840/p2p/12D3KooWMKgVbWRQain4Sbw4DUnAJMykjdFanAcePn5xsTZihGTo".parse().expect("parse multi addr should be ok"), @@ -1030,7 +1030,7 @@ pub static BARNARD_BOOT_NODES: Lazy> = Lazy::new(|| { ] }); -pub static BARNARD_CONFIG: Lazy = Lazy::new(|| { +pub static G_BARNARD_CONFIG: Lazy = Lazy::new(|| { // This is a test config, GenesisConfig { genesis_block_parameter: GenesisBlockParameterConfig::Static(GenesisBlockParameter{ @@ -1042,26 +1042,26 @@ pub static BARNARD_CONFIG: Lazy = Lazy::new(|| { reward_delay: 7, pre_mine_amount: STCUnit::STC.value_of(15925680).scaling(), time_mint_amount: STCUnit::STC.value_of(47777040).scaling(), - time_mint_period: DEFAULT_TIME_LOCKED_PERIOD, + time_mint_period: G_DEFAULT_TIME_LOCKED_PERIOD, vm_config: VMConfig { gas_schedule: CostTable { instruction_table: instruction_table_v1(), native_table: native_table_v1(), - gas_constants: GAS_CONSTANTS_V1.clone(), + gas_constants: G_GAS_CONSTANTS_V1.clone(), }, }, publishing_option: TransactionPublishOption::locked(), consensus_config: ConsensusConfig { uncle_rate_target: 500, - base_block_time_target: DEFAULT_BASE_BLOCK_TIME_TARGET, + base_block_time_target: G_DEFAULT_BASE_BLOCK_TIME_TARGET, base_reward_per_block: STCUnit::STC.value_of(1).scaling(), - epoch_block_count: DEFAULT_BASE_BLOCK_DIFF_WINDOW * 10, - base_block_difficulty_window: DEFAULT_BASE_BLOCK_DIFF_WINDOW, - base_reward_per_uncle_percent: BASE_REWARD_PER_UNCLE_PERCENT, - min_block_time_target: MIN_BLOCK_TIME_TARGET, - max_block_time_target: MAX_BLOCK_TIME_TARGET, - base_max_uncles_per_block: BASE_MAX_UNCLES_PER_BLOCK, - base_block_gas_limit: BASE_BLOCK_GAS_LIMIT, + epoch_block_count: G_DEFAULT_BASE_BLOCK_DIFF_WINDOW * 10, + base_block_difficulty_window: G_DEFAULT_BASE_BLOCK_DIFF_WINDOW, + base_reward_per_uncle_percent: G_BASE_REWARD_PER_UNCLE_PERCENT, + min_block_time_target: G_MIN_BLOCK_TIME_TARGET, + max_block_time_target: G_MAX_BLOCK_TIME_TARGET, + base_max_uncles_per_block: G_BASE_MAX_UNCLES_PER_BLOCK, + base_block_gas_limit: G_BASE_BLOCK_GAS_LIMIT, strategy: ConsensusStrategy::CryptoNight.value(), }, association_key_pair: (None, MultiEd25519PublicKey::from_encoded_string("3e6c08fb7f265a35ffd121c809bfa233041d92165c2fdd13f8b85be0814243ba2d616c5105dc8baa39ff764bbcd072e44fcb8bfe5a2f773636285c40d1af15087b00e16ec03438e99858127374c3c148b57a5e10068ca956eff06240c8199f46e4746a6fac58d7d65cfd3ccad4331d071a9ff1a0a29c3bc3896b86c0a7f4ce79e75fbc8422501f5a6bb50ae39e7656949f76d24ce4b677ea224254d8661e509d839e3222ea576580b965d94920765aa1ec62047b7536b0ae57fbdffef968f09e3a5847fb627a9a7909961b21c50c868e26797e2a406879f5cf1d80f4035a448a32fa70d239907d561e116d03dfd9fcba8ab1095117b36b188bf277cc977fc4af87c071e8106a551f0bfe57e9aa2b03d037afd3aaab5c8f0eb56d725f598deada04") @@ -1079,7 +1079,7 @@ pub static BARNARD_CONFIG: Lazy = Lazy::new(|| { } }); -pub static MAIN_BOOT_NODES: Lazy> = Lazy::new(|| { +pub static G_MAIN_BOOT_NODES: Lazy> = Lazy::new(|| { vec![ "/dns4/main1.seed.starcoin.org/tcp/9840/p2p/12D3KooWSW8t32L6VyjPZxxe3VSD7H6Ffgh69eCaDnDyab2M6tfK".parse().expect("parse multi addr should be ok"), "/dns4/main2.seed.starcoin.org/tcp/9840/p2p/12D3KooWBWsibdKdogDpFUfSVejPdK6t4s1eEvcqjuPVJ3gSpypx".parse().expect("parse multi addr should be ok"), @@ -1093,7 +1093,7 @@ pub static MAIN_BOOT_NODES: Lazy> = Lazy::new(|| { ] }); -pub static MAIN_CONFIG: Lazy = Lazy::new(|| { +pub static G_MAIN_CONFIG: Lazy = Lazy::new(|| { let stdlib_version = StdlibVersion::Version(4); let publishing_option = TransactionPublishOption::locked(); GenesisConfig { @@ -1104,28 +1104,28 @@ pub static MAIN_CONFIG: Lazy = Lazy::new(|| { }), version: Version { major: 1 }, reward_delay: 7, - pre_mine_amount: DEFAULT_PRE_MINT_AMOUNT.scaling(), - time_mint_amount: DEFAULT_TIME_LOCKED_AMOUNT.scaling(), - time_mint_period: DEFAULT_TIME_LOCKED_PERIOD, + pre_mine_amount: G_DEFAULT_PRE_MINT_AMOUNT.scaling(), + time_mint_amount: G_DEFAULT_TIME_LOCKED_AMOUNT.scaling(), + time_mint_period: G_DEFAULT_TIME_LOCKED_PERIOD, vm_config: VMConfig { gas_schedule: CostTable { instruction_table: instruction_table_v1(), native_table: native_table_v2(), - gas_constants: GAS_CONSTANTS_V2.clone(), + gas_constants: G_GAS_CONSTANTS_V2.clone(), }, }, publishing_option, consensus_config: ConsensusConfig { - uncle_rate_target: UNCLE_RATE_TARGET, - base_block_time_target: DEFAULT_BASE_BLOCK_TIME_TARGET, - base_reward_per_block: DEFAULT_BASE_REWARD_PER_BLOCK.scaling(), - epoch_block_count: DEFAULT_BASE_BLOCK_DIFF_WINDOW * 10, - base_block_difficulty_window: DEFAULT_BASE_BLOCK_DIFF_WINDOW, - base_reward_per_uncle_percent: BASE_REWARD_PER_UNCLE_PERCENT, - min_block_time_target: MIN_BLOCK_TIME_TARGET, - max_block_time_target: MAX_BLOCK_TIME_TARGET, - base_max_uncles_per_block: BASE_MAX_UNCLES_PER_BLOCK, - base_block_gas_limit: BASE_BLOCK_GAS_LIMIT, + uncle_rate_target: G_UNCLE_RATE_TARGET, + base_block_time_target: G_DEFAULT_BASE_BLOCK_TIME_TARGET, + base_reward_per_block: G_DEFAULT_BASE_REWARD_PER_BLOCK.scaling(), + epoch_block_count: G_DEFAULT_BASE_BLOCK_DIFF_WINDOW * 10, + base_block_difficulty_window: G_DEFAULT_BASE_BLOCK_DIFF_WINDOW, + base_reward_per_uncle_percent: G_BASE_REWARD_PER_UNCLE_PERCENT, + min_block_time_target: G_MIN_BLOCK_TIME_TARGET, + max_block_time_target: G_MAX_BLOCK_TIME_TARGET, + base_max_uncles_per_block: G_BASE_MAX_UNCLES_PER_BLOCK, + base_block_gas_limit: G_BASE_BLOCK_GAS_LIMIT, strategy: ConsensusStrategy::CryptoNight.value(), }, association_key_pair: (None, MultiEd25519PublicKey::from_encoded_string("810a82a896a4f8fd065bcab8b06588fe1afdbb3d3830693c65a73d31ee1e482d85a40286b624b8481b05d9ed748e7c051b63ed36ce952cbc48bb0de4bfc6ec5888feded087075af9585a83c777ba52da1ab3aef139764a0de5fbc2d8aa8d380b02") diff --git a/config/src/lib.rs b/config/src/lib.rs index d07a0b83ad..b85d789b59 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -55,8 +55,8 @@ pub use available_port::{ pub use genesis_config::{ BuiltinNetworkID, ChainNetwork, ChainNetworkID, FutureBlockParameter, FutureBlockParameterResolver, GenesisBlockParameter, GenesisBlockParameterConfig, - GenesisConfig, DEV_CONFIG, HALLEY_CONFIG, LATEST_GAS_SCHEDULE, MAIN_CONFIG, PROXIMA_CONFIG, - TEST_CONFIG, + GenesisConfig, G_DEV_CONFIG, G_HALLEY_CONFIG, G_LATEST_GAS_SCHEDULE, G_MAIN_CONFIG, + G_PROXIMA_CONFIG, G_TEST_CONFIG, }; pub use logger_config::LoggerConfig; pub use metrics_config::MetricsConfig; @@ -71,32 +71,32 @@ pub use starcoin_vm_types::time::{MockTimeService, RealTimeService, TimeService} pub use storage_config::{RocksdbConfig, StorageConfig, DEFAULT_CACHE_SIZE}; pub use txpool_config::TxPoolConfig; -pub static CRATE_VERSION: &str = clap::crate_version!(); -pub static GIT_VERSION: &str = git_version!( +pub static G_CRATE_VERSION: &str = clap::crate_version!(); +pub static G_GIT_VERSION: &str = git_version!( args = ["--tags", "--dirty", "--always"], fallback = "unknown" ); -pub static APP_NAME: &str = "starcoin"; -pub static APP_VERSION: Lazy = Lazy::new(|| { - if GIT_VERSION != "unknown" { - format!("{} (build:{})", CRATE_VERSION, GIT_VERSION) +pub static G_APP_NAME: &str = "starcoin"; +pub static G_APP_VERSION: Lazy = Lazy::new(|| { + if G_GIT_VERSION != "unknown" { + format!("{} (build:{})", G_CRATE_VERSION, G_GIT_VERSION) } else { - CRATE_VERSION.to_string() + G_CRATE_VERSION.to_string() } }); -pub static APP_NAME_WITH_VERSION: Lazy = - Lazy::new(|| format!("{}/{}", APP_NAME, APP_VERSION.clone())); +pub static G_APP_NAME_WITH_VERSION: Lazy = + Lazy::new(|| format!("{}/{}", G_APP_NAME, G_APP_VERSION.clone())); /// Default data dir -pub static DEFAULT_BASE_DATA_DIR: Lazy = Lazy::new(|| { +pub static G_DEFAULT_BASE_DATA_DIR: Lazy = Lazy::new(|| { dirs_next::home_dir() .expect("read home dir should ok") .join(".starcoin") }); -pub static CONFIG_FILE_PATH: &str = "config.toml"; -pub static GENESIS_CONFIG_FILE_NAME: &str = "genesis_config.json"; +pub static G_CONFIG_FILE_PATH: &str = "config.toml"; +pub static G_GENESIS_CONFIG_FILE_NAME: &str = "genesis_config.json"; pub fn load_config_with_opt(opt: &StarcoinOpt) -> Result { NodeConfig::load_with_opt(opt) @@ -165,11 +165,11 @@ impl FromStr for Connect { } } -static OPT_NET_HELP: &str = r#"Chain Network +static G_OPT_NET_HELP: &str = r#"Chain Network Builtin network: test,dev,halley,proxima,barnard,main Custom network format: chain_name:chain_id - Such as: - my_chain:123 will init a new chain with id `123`. + Such as: + my_chain:123 will init a new chain with id `123`. Custom network first start should also set the `genesis-config` option. Use starcoin_generator command to generate a genesis config."#; @@ -187,7 +187,7 @@ pub struct StarcoinOpt { pub base_data_dir: Option, #[serde(skip_serializing_if = "Option::is_none")] - #[clap(long, short = 'n', help = OPT_NET_HELP)] + #[clap(long, short = 'n', help = G_OPT_NET_HELP)] pub net: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -274,7 +274,7 @@ impl AsRef for DataDirPath { impl Default for DataDirPath { fn default() -> Self { - DataDirPath::PathBuf(DEFAULT_BASE_DATA_DIR.to_path_buf()) + DataDirPath::PathBuf(G_DEFAULT_BASE_DATA_DIR.to_path_buf()) } } @@ -295,7 +295,7 @@ impl BaseConfig { if id.is_dev() || id.is_test() { temp_dir() } else { - DataDirPath::PathBuf(DEFAULT_BASE_DATA_DIR.to_path_buf()) + DataDirPath::PathBuf(G_DEFAULT_BASE_DATA_DIR.to_path_buf()) } } }; @@ -321,7 +321,7 @@ impl BaseConfig { data_dir: &Path, genesis_config_name: Option, ) -> Result { - let config_path = data_dir.join(GENESIS_CONFIG_FILE_NAME); + let config_path = data_dir.join(G_GENESIS_CONFIG_FILE_NAME); let config_in_file = if config_path.exists() { Some(GenesisConfig::load(config_path.as_path())?) } else { @@ -378,7 +378,7 @@ impl BaseConfig { } fn genesis_config_path(&self) -> PathBuf { - self.data_dir.join(GENESIS_CONFIG_FILE_NAME) + self.data_dir.join(G_GENESIS_CONFIG_FILE_NAME) } pub fn net(&self) -> &ChainNetwork { @@ -396,7 +396,7 @@ impl BaseConfig { let data_dir = base.data_dir(); ensure!(data_dir.is_dir(), "please pass in a dir as data_dir"); - let config_file_path = data_dir.join(CONFIG_FILE_PATH); + let config_file_path = data_dir.join(G_CONFIG_FILE_PATH); let config = if !config_file_path.exists() { info!( "Config file not exist, generate default config to: {:?}", @@ -483,7 +483,7 @@ impl NodeConfig { } pub fn config_path(&self) -> PathBuf { - self.base().data_dir().join(CONFIG_FILE_PATH) + self.base().data_dir().join(G_CONFIG_FILE_PATH) } pub fn load_with_opt(opt: &StarcoinOpt) -> Result { diff --git a/config/src/logger_config.rs b/config/src/logger_config.rs index f406a85a4c..99b7dd4c9c 100644 --- a/config/src/logger_config.rs +++ b/config/src/logger_config.rs @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; use std::path::PathBuf; use std::sync::Arc; -static LOGGER_FILE_NAME: &str = "starcoin.log"; +static G_LOGGER_FILE_NAME: &str = "starcoin.log"; const DEFAULT_MAX_FILE_SIZE: u64 = 1024 * 1024 * 1024; const MAX_FILE_SIZE_FOR_TEST: u64 = 10 * 1024 * 1024; @@ -47,7 +47,7 @@ impl LoggerConfig { if self.disable_file() { return None; } - let log_path = self.base().data_dir.join(LOGGER_FILE_NAME); + let log_path = self.base().data_dir.join(G_LOGGER_FILE_NAME); Some(log_path) } diff --git a/config/src/metrics_config.rs b/config/src/metrics_config.rs index b83b80cd11..c149f3e3f6 100644 --- a/config/src/metrics_config.rs +++ b/config/src/metrics_config.rs @@ -11,11 +11,11 @@ use starcoin_metrics::{get_metric_from_registry, Registry}; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::sync::Arc; -pub static DEFAULT_METRIC_SERVER_ADDRESS: IpAddr = IpAddr::V4(Ipv4Addr::UNSPECIFIED); -pub static DEFAULT_METRIC_SERVER_PORT: u16 = 9101; -pub static DEFAULT_METRIC_PUSH_AUTH_PASSWORD: &str = ""; +pub static G_DEFAULT_METRIC_SERVER_ADDRESS: IpAddr = IpAddr::V4(Ipv4Addr::UNSPECIFIED); +pub static G_DEFAULT_METRIC_SERVER_PORT: u16 = 9101; +pub static G_DEFAULT_METRIC_PUSH_AUTH_PASSWORD: &str = ""; -pub static DEFAULT_METRIC_NAMESPACE: &str = "starcoin"; +pub static G_DEFAULT_METRIC_NAMESPACE: &str = "starcoin"; #[derive(Clone, Default, Debug, Deserialize, PartialEq, Serialize, Parser)] #[serde(deny_unknown_fields)] @@ -51,7 +51,7 @@ impl PushParameterConfig { pub fn auth_password(&self) -> String { self.auth_password .clone() - .unwrap_or_else(|| DEFAULT_METRIC_PUSH_AUTH_PASSWORD.to_owned()) + .unwrap_or_else(|| G_DEFAULT_METRIC_PUSH_AUTH_PASSWORD.to_owned()) } } @@ -123,15 +123,15 @@ impl MetricsConfig { fn generate_address(&mut self) { if !self.disable_metrics() { self.metrics_address = Some(SocketAddr::new( - self.address.unwrap_or(DEFAULT_METRIC_SERVER_ADDRESS), + self.address.unwrap_or(G_DEFAULT_METRIC_SERVER_ADDRESS), self.port.unwrap_or_else(|| { let base = self.base(); if base.net.is_test() { get_random_available_port() } else if base.net.is_dev() { - get_available_port_from(DEFAULT_METRIC_SERVER_PORT) + get_available_port_from(G_DEFAULT_METRIC_SERVER_PORT) } else { - DEFAULT_METRIC_SERVER_PORT + G_DEFAULT_METRIC_SERVER_PORT } }), )); @@ -149,10 +149,10 @@ impl MetricsConfig { label: Option<(&str, &str)>, ) -> Option> { //auto add namespace - let metric_name = if name.starts_with(DEFAULT_METRIC_NAMESPACE) { + let metric_name = if name.starts_with(G_DEFAULT_METRIC_NAMESPACE) { name.to_string() } else { - format!("{}_{}", DEFAULT_METRIC_NAMESPACE, name) + format!("{}_{}", G_DEFAULT_METRIC_NAMESPACE, name) }; self.registry .as_ref() @@ -179,7 +179,8 @@ impl ConfigModule for MetricsConfig { self.generate_address(); if !self.disable_metrics() { - let registry = Registry::new_custom(Some(DEFAULT_METRIC_NAMESPACE.to_string()), None)?; + let registry = + Registry::new_custom(Some(G_DEFAULT_METRIC_NAMESPACE.to_string()), None)?; self.registry = Some(registry); } diff --git a/config/src/network_config.rs b/config/src/network_config.rs index 8398777e5e..bf97afc082 100644 --- a/config/src/network_config.rs +++ b/config/src/network_config.rs @@ -29,8 +29,8 @@ use std::path::PathBuf; use std::str::FromStr; use std::sync::Arc; -pub static DEFAULT_NETWORK_PORT: u16 = 9840; -static NETWORK_KEY_FILE: Lazy = Lazy::new(|| PathBuf::from("network_key")); +pub static G_DEFAULT_NETWORK_PORT: u16 = 9840; +static G_NETWORK_KEY_FILE: Lazy = Lazy::new(|| PathBuf::from("network_key")); #[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize, Parser)] pub struct NetworkRpcQuotaConfiguration { @@ -327,7 +327,7 @@ impl NetworkConfig { } fn node_key_file(&self) -> PathBuf { - let path = self.node_key_file.as_ref().unwrap_or(&NETWORK_KEY_FILE); + let path = self.node_key_file.as_ref().unwrap_or(&G_NETWORK_KEY_FILE); if path.is_absolute() { path.clone() } else { @@ -365,9 +365,9 @@ impl NetworkConfig { let port = if base.net().is_test() { get_random_available_port() } else if base.net().is_dev() { - get_available_port_from(DEFAULT_NETWORK_PORT) + get_available_port_from(G_DEFAULT_NETWORK_PORT) } else { - DEFAULT_NETWORK_PORT + G_DEFAULT_NETWORK_PORT }; //test env use in memory transport. diff --git a/config/src/storage_config.rs b/config/src/storage_config.rs index 16e4712c54..fc9fbe2538 100644 --- a/config/src/storage_config.rs +++ b/config/src/storage_config.rs @@ -65,7 +65,7 @@ impl Default for RocksdbConfig { } } -static DEFAULT_DB_DIR: Lazy = Lazy::new(|| PathBuf::from("starcoindb/db")); +static G_DEFAULT_DB_DIR: Lazy = Lazy::new(|| PathBuf::from("starcoindb/db")); pub const DEFAULT_CACHE_SIZE: usize = 20000; #[derive(Clone, Default, Debug, Deserialize, PartialEq, Serialize, Parser)] @@ -110,7 +110,7 @@ impl StorageConfig { } pub fn dir(&self) -> PathBuf { - self.base().data_dir().join(DEFAULT_DB_DIR.as_path()) + self.base().data_dir().join(G_DEFAULT_DB_DIR.as_path()) } pub fn rocksdb_config(&self) -> RocksdbConfig { diff --git a/config/src/tests.rs b/config/src/tests.rs index a09f37a262..fe48e8eeb9 100644 --- a/config/src/tests.rs +++ b/config/src/tests.rs @@ -49,7 +49,7 @@ fn test_genesis_config_save_and_load() -> Result<()> { let mut genesis_config = BuiltinNetworkID::Test.genesis_config().clone(); genesis_config.consensus_config.base_block_time_target = 10000000; let temp_path = temp_dir(); - let file_path = temp_path.path().join(GENESIS_CONFIG_FILE_NAME); + let file_path = temp_path.path().join(G_GENESIS_CONFIG_FILE_NAME); genesis_config.save(file_path.as_path())?; let genesis_config2 = GenesisConfig::load(file_path.as_path())?; assert_eq!(genesis_config, genesis_config2); diff --git a/consensus/src/consensus_test.rs b/consensus/src/consensus_test.rs index 2eb5d675e5..8f4200f25f 100644 --- a/consensus/src/consensus_test.rs +++ b/consensus/src/consensus_test.rs @@ -5,7 +5,7 @@ use crate::consensus::Consensus; use crate::difficulty::{get_next_target_helper, BlockDiffInfo}; -use crate::{difficult_to_target, target_to_difficulty, CRYPTONIGHT}; +use crate::{difficult_to_target, target_to_difficulty, G_CRYPTONIGHT}; use starcoin_crypto::hash::PlainCryptoHash; use starcoin_types::block::{BlockHeader, BlockHeaderBuilder, RawBlockHeader}; use starcoin_types::U256; @@ -36,13 +36,13 @@ fn verify_header_test() { .build(); let raw_header: RawBlockHeader = header.clone().into(); let time_service = TimeServiceType::RealTimeService.new_time_service(); - let nonce = CRYPTONIGHT.solve_consensus_nonce( + let nonce = G_CRYPTONIGHT.solve_consensus_nonce( &header.as_pow_header_blob(), raw_header.difficulty, time_service.as_ref(), ); let header = header.as_builder().with_nonce(nonce).build(); - CRYPTONIGHT + G_CRYPTONIGHT .verify_header_difficulty(header.difficulty(), &header) .unwrap() } diff --git a/consensus/src/lib.rs b/consensus/src/lib.rs index cf21bae41c..6aafead4da 100644 --- a/consensus/src/lib.rs +++ b/consensus/src/lib.rs @@ -49,18 +49,18 @@ pub fn set_header_nonce(header: &[u8], nonce: u32, extra: &BlockHeaderExtra) -> header } -static DUMMY: Lazy = Lazy::new(DummyConsensus::new); -static ARGON: Lazy = Lazy::new(ArgonConsensus::new); -static KECCAK: Lazy = Lazy::new(KeccakConsensus::new); -pub static CRYPTONIGHT: Lazy = Lazy::new(CryptoNightConsensus::new); +static G_DUMMY: Lazy = Lazy::new(DummyConsensus::new); +static G_ARGON: Lazy = Lazy::new(ArgonConsensus::new); +static G_KECCAK: Lazy = Lazy::new(KeccakConsensus::new); +pub static G_CRYPTONIGHT: Lazy = Lazy::new(CryptoNightConsensus::new); impl Consensus for ConsensusStrategy { fn calculate_next_difficulty(&self, reader: &dyn ChainReader) -> Result { match self { - ConsensusStrategy::Dummy => DUMMY.calculate_next_difficulty(reader), - ConsensusStrategy::Argon => ARGON.calculate_next_difficulty(reader), - ConsensusStrategy::Keccak => KECCAK.calculate_next_difficulty(reader), - ConsensusStrategy::CryptoNight => CRYPTONIGHT.calculate_next_difficulty(reader), + ConsensusStrategy::Dummy => G_DUMMY.calculate_next_difficulty(reader), + ConsensusStrategy::Argon => G_ARGON.calculate_next_difficulty(reader), + ConsensusStrategy::Keccak => G_KECCAK.calculate_next_difficulty(reader), + ConsensusStrategy::CryptoNight => G_CRYPTONIGHT.calculate_next_difficulty(reader), } } @@ -72,26 +72,26 @@ impl Consensus for ConsensusStrategy { ) -> u32 { match self { ConsensusStrategy::Dummy => { - DUMMY.solve_consensus_nonce(mining_hash, difficulty, time_service) + G_DUMMY.solve_consensus_nonce(mining_hash, difficulty, time_service) } ConsensusStrategy::Argon => { - ARGON.solve_consensus_nonce(mining_hash, difficulty, time_service) + G_ARGON.solve_consensus_nonce(mining_hash, difficulty, time_service) } ConsensusStrategy::Keccak => { - KECCAK.solve_consensus_nonce(mining_hash, difficulty, time_service) + G_KECCAK.solve_consensus_nonce(mining_hash, difficulty, time_service) } ConsensusStrategy::CryptoNight => { - CRYPTONIGHT.solve_consensus_nonce(mining_hash, difficulty, time_service) + G_CRYPTONIGHT.solve_consensus_nonce(mining_hash, difficulty, time_service) } } } fn verify(&self, reader: &dyn ChainReader, header: &BlockHeader) -> Result<()> { match self { - ConsensusStrategy::Dummy => DUMMY.verify(reader, header), - ConsensusStrategy::Argon => ARGON.verify(reader, header), - ConsensusStrategy::Keccak => KECCAK.verify(reader, header), - ConsensusStrategy::CryptoNight => CRYPTONIGHT.verify(reader, header), + ConsensusStrategy::Dummy => G_DUMMY.verify(reader, header), + ConsensusStrategy::Argon => G_ARGON.verify(reader, header), + ConsensusStrategy::Keccak => G_KECCAK.verify(reader, header), + ConsensusStrategy::CryptoNight => G_CRYPTONIGHT.verify(reader, header), } } @@ -102,11 +102,11 @@ impl Consensus for ConsensusStrategy { extra: &BlockHeaderExtra, ) -> Result { match self { - ConsensusStrategy::Dummy => DUMMY.calculate_pow_hash(mining_hash, nonce, extra), - ConsensusStrategy::Argon => ARGON.calculate_pow_hash(mining_hash, nonce, extra), - ConsensusStrategy::Keccak => KECCAK.calculate_pow_hash(mining_hash, nonce, extra), + ConsensusStrategy::Dummy => G_DUMMY.calculate_pow_hash(mining_hash, nonce, extra), + ConsensusStrategy::Argon => G_ARGON.calculate_pow_hash(mining_hash, nonce, extra), + ConsensusStrategy::Keccak => G_KECCAK.calculate_pow_hash(mining_hash, nonce, extra), ConsensusStrategy::CryptoNight => { - CRYPTONIGHT.calculate_pow_hash(mining_hash, nonce, extra) + G_CRYPTONIGHT.calculate_pow_hash(mining_hash, nonce, extra) } } } diff --git a/executor/src/error_code_test.rs b/executor/src/error_code_test.rs index 67242ad55a..8991e34ba3 100644 --- a/executor/src/error_code_test.rs +++ b/executor/src/error_code_test.rs @@ -18,7 +18,7 @@ use starcoin_vm_types::account_address::AccountAddress; use starcoin_vm_types::account_config::core_code_address; use starcoin_vm_types::account_config::{genesis_address, stc_type_tag}; use starcoin_vm_types::genesis_config::ChainId; -use starcoin_vm_types::token::stc::STC_TOKEN_CODE; +use starcoin_vm_types::token::stc::G_STC_TOKEN_CODE; use starcoin_vm_types::token::token_code::TokenCode; use starcoin_vm_types::transaction::Package; use starcoin_vm_types::transaction::RawUserTransaction; @@ -31,11 +31,11 @@ use test_helper::executor::{ association_execute, execute_and_apply, move_abort_code, prepare_genesis, }; -pub static WRONG_TOKEN_CODE_FOR_TEST: Lazy = Lazy::new(|| { +pub static G_WRONG_TOKEN_CODE_FOR_TEST: Lazy = Lazy::new(|| { TokenCode::from_str("0x1::ABC::ABC").expect("Parse wrong token code should success.") }); -pub static DUMMY_TOKEN_CODE: Lazy = Lazy::new(|| { +pub static G_DUMMY_TOKEN_CODE: Lazy = Lazy::new(|| { TokenCode::from_str("0x1::DummyToken::DummyToken") .expect("Parse dummy token code should success.") }); @@ -139,7 +139,7 @@ fn test_execute_transfer_txn_with_wrong_token_code() -> Result<()> { 1000, 1, DEFAULT_MAX_GAS_AMOUNT, - WRONG_TOKEN_CODE_FOR_TEST.clone(), + G_WRONG_TOKEN_CODE_FOR_TEST.clone(), net.time_service().now_secs() + DEFAULT_EXPIRATION_TIME, net.chain_id(), ); @@ -174,7 +174,7 @@ fn test_execute_transfer_txn_with_dummy_gas_token_code() -> Result<()> { 1000, 1, DEFAULT_MAX_GAS_AMOUNT, - DUMMY_TOKEN_CODE.clone(), + G_DUMMY_TOKEN_CODE.clone(), net.time_service().now_secs() + DEFAULT_EXPIRATION_TIME, net.chain_id(), ); @@ -206,7 +206,7 @@ pub fn raw_peer_to_peer_txn_with_non_default_gas_token( TransactionPayload::ScriptFunction(encode_transfer_script_by_token_code( receiver, transfer_amount, - STC_TOKEN_CODE.clone(), + G_STC_TOKEN_CODE.clone(), )), max_gas, gas_price, diff --git a/executor/tests/executor_test.rs b/executor/tests/executor_test.rs index 9603b1453e..9b64afa88d 100644 --- a/executor/tests/executor_test.rs +++ b/executor/tests/executor_test.rs @@ -38,7 +38,7 @@ use test_helper::executor::{ }; // use test_helper::Account; use starcoin_state_api::StateReaderExt; -use starcoin_types::account_config::STC_TOKEN_CODE; +use starcoin_types::account_config::G_STC_TOKEN_CODE; use starcoin_vm_types::account_config::core_code_address; use vm_runtime::starcoin_vm::StarcoinVM; @@ -750,7 +750,7 @@ fn test_execute_transfer_txn() -> Result<()> { 0, 1, DEFAULT_MAX_GAS_AMOUNT, - STC_TOKEN_CODE.clone(), + G_STC_TOKEN_CODE.clone(), net.time_service().now_secs() + DEFAULT_EXPIRATION_TIME, net.chain_id(), ); @@ -775,7 +775,7 @@ fn test_execute_transfer_txn() -> Result<()> { 0, 1, DEFAULT_MAX_GAS_AMOUNT, - STC_TOKEN_CODE.clone(), + G_STC_TOKEN_CODE.clone(), net.time_service().now_secs() + DEFAULT_EXPIRATION_TIME, net.chain_id(), ); diff --git a/executor/tests/module_upgrade_test.rs b/executor/tests/module_upgrade_test.rs index 588f5a3dfe..cc0bb9a5f6 100644 --- a/executor/tests/module_upgrade_test.rs +++ b/executor/tests/module_upgrade_test.rs @@ -1,6 +1,6 @@ use anyhow::Result; use logger::prelude::*; -use starcoin_config::genesis_config::TOTAL_STC_AMOUNT; +use starcoin_config::genesis_config::G_TOTAL_STC_AMOUNT; use starcoin_config::{BuiltinNetworkID, ChainNetwork}; use starcoin_crypto::hash::PlainCryptoHash; use starcoin_executor::execute_readonly_function; @@ -20,13 +20,13 @@ use starcoin_vm_types::genesis_config::{ChainId, StdlibVersion}; use starcoin_vm_types::move_resource::MoveResource; use starcoin_vm_types::on_chain_config::{MoveLanguageVersion, TransactionPublishOption, Version}; use starcoin_vm_types::on_chain_resource::LinearWithdrawCapability; -use starcoin_vm_types::token::stc::STC_TOKEN_CODE; +use starcoin_vm_types::token::stc::G_STC_TOKEN_CODE; use starcoin_vm_types::transaction::{Package, TransactionPayload}; use statedb::ChainStateDB; use std::convert::TryInto; use std::fs::File; use std::io::Read; -use stdlib::{load_upgrade_package, StdlibCompat, STDLIB_VERSIONS}; +use stdlib::{load_upgrade_package, StdlibCompat, G_STDLIB_VERSIONS}; use test_helper::dao::{ dao_vote_test, execute_script_on_chain_config, on_chain_config_type_tag, vote_language_version, }; @@ -348,7 +348,7 @@ fn test_upgrade_stdlib_with_incremental_package() -> Result<()> { #[stest::test(timeout = 300)] fn test_stdlib_upgrade() -> Result<()> { let mut genesis_config = BuiltinNetworkID::Test.genesis_config().clone(); - let stdlib_versions = STDLIB_VERSIONS.clone(); + let stdlib_versions = G_STDLIB_VERSIONS.clone(); let mut current_version = stdlib_versions[0]; genesis_config.stdlib_version = current_version; let net = ChainNetwork::new_custom( @@ -550,13 +550,13 @@ where ); assert_eq!( chain_state.get_stc_info().unwrap().unwrap().total_value, - TOTAL_STC_AMOUNT.scaling() + G_TOTAL_STC_AMOUNT.scaling() ); let withdraw_cap = chain_state .get_resource_by_access_path::( LinearWithdrawCapability::resource_path_for( association_address(), - STC_TOKEN_CODE.clone().try_into()?, + G_STC_TOKEN_CODE.clone().try_into()?, ), )?; assert!( diff --git a/executor/tests/on_chain_config_test.rs b/executor/tests/on_chain_config_test.rs index b0958ecde4..df76f9d712 100644 --- a/executor/tests/on_chain_config_test.rs +++ b/executor/tests/on_chain_config_test.rs @@ -14,7 +14,7 @@ use starcoin_vm_types::account_config::genesis_address; use starcoin_vm_types::gas_schedule::{GasAlgebra, InternalGasUnits}; use starcoin_vm_types::on_chain_config::{ consensus_config_type_tag, vm_config_type_tag, ConsensusConfig, OnChainConfig, VMConfig, - CONSENSUS_CONFIG_IDENTIFIER, + G_CONSENSUS_CONFIG_IDENTIFIER, }; use starcoin_vm_types::transaction::Transaction; use starcoin_vm_types::value::{serialize_values, MoveValue}; @@ -49,7 +49,7 @@ fn test_modify_on_chain_consensus_config() -> Result<()> { //get consensus config let config = { - let module_id = ModuleId::new(genesis_address(), CONSENSUS_CONFIG_IDENTIFIER.clone()); + let module_id = ModuleId::new(genesis_address(), G_CONSENSUS_CONFIG_IDENTIFIER.clone()); let mut rets = starcoin_dev::playground::call_contract( &chain_state, module_id, diff --git a/executor/tests/sip_flag_test.rs b/executor/tests/sip_flag_test.rs index 68d6deb858..34f2797752 100644 --- a/executor/tests/sip_flag_test.rs +++ b/executor/tests/sip_flag_test.rs @@ -8,7 +8,7 @@ use starcoin_types::language_storage::{ModuleId, StructTag, TypeTag}; use starcoin_types::transaction::ScriptFunction; use starcoin_vm_types::account_config::core_code_address; use starcoin_vm_types::account_config::{genesis_address, stc_type_tag}; -use starcoin_vm_types::sips::{SIP, SIPS}; +use starcoin_vm_types::sips::{G_SIPS, SIP}; use starcoin_vm_types::transaction::{Package, TransactionPayload}; use test_helper::dao::dao_vote_test; use test_helper::executor::*; @@ -23,7 +23,7 @@ pub const TEST_SIP_10000: &str = r#" fn test_sip_flags() -> Result<()> { let alice = Account::new(); let (chain_state, net) = prepare_genesis(); - for sip in SIPS.iter() { + for sip in G_SIPS.iter() { assert!(chain_state.is_activated(*sip)?); } diff --git a/executor/tests/treasury_withdraw_test.rs b/executor/tests/treasury_withdraw_test.rs index 62b1c24387..21585433a6 100644 --- a/executor/tests/treasury_withdraw_test.rs +++ b/executor/tests/treasury_withdraw_test.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use anyhow::Result; -use starcoin_config::genesis_config::TOTAL_STC_AMOUNT; +use starcoin_config::genesis_config::G_TOTAL_STC_AMOUNT; use starcoin_executor::account::create_account_txn_sent_as_association; use starcoin_state_api::StateReaderExt; use starcoin_transaction_builder::DEFAULT_MAX_GAS_AMOUNT; @@ -13,7 +13,7 @@ use starcoin_vm_types::account_config::core_code_address; use starcoin_vm_types::move_resource::MoveResource; use starcoin_vm_types::on_chain_resource::dao::WithdrawToken; use starcoin_vm_types::on_chain_resource::LinearWithdrawCapability; -use starcoin_vm_types::token::stc::{STCUnit, STC_TOKEN_CODE, STC_TOKEN_CODE_STR}; +use starcoin_vm_types::token::stc::{STCUnit, G_STC_TOKEN_CODE, STC_TOKEN_CODE_STR}; use starcoin_vm_types::transaction::{ RawUserTransaction, ScriptFunction, Transaction, TransactionPayload, }; @@ -74,7 +74,7 @@ fn test_treasury_withdraw() -> Result<()> { let cap = chain_state.get_resource_by_access_path::( LinearWithdrawCapability::resource_path_for( *alice.address(), - STC_TOKEN_CODE.clone().try_into()?, + G_STC_TOKEN_CODE.clone().try_into()?, ), )?; assert!(cap.is_some(), "expect LinearWithdrawCapability exist."); @@ -99,7 +99,7 @@ fn test_treasury_withdraw_too_many() -> Result<()> { let output1 = execute_and_apply(&chain_state, txn1); assert_eq!(KeptVMStatus::Executed, output1.status().status().unwrap()); - let withdraw_amount = TOTAL_STC_AMOUNT.scaling() / 2; + let withdraw_amount = G_TOTAL_STC_AMOUNT.scaling() / 2; let period = 1000u64; let vote_script_function = ScriptFunction::new( diff --git a/genesis/src/lib.rs b/genesis/src/lib.rs index 441806ec6a..e5db8f01ef 100644 --- a/genesis/src/lib.rs +++ b/genesis/src/lib.rs @@ -35,7 +35,7 @@ use std::sync::Arc; mod errors; pub use errors::GenesisError; -pub static GENESIS_GENERATED_DIR: &str = "generated"; +pub static G_GENESIS_GENERATED_DIR: &str = "generated"; pub const GENESIS_DIR: Dir = include_dir!("generated"); #[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)] diff --git a/genesis/src/main.rs b/genesis/src/main.rs index f5e43b5d5c..bc9c1ce9cb 100644 --- a/genesis/src/main.rs +++ b/genesis/src/main.rs @@ -4,7 +4,7 @@ use clap::Parser; use starcoin_config::BuiltinNetworkID; use starcoin_config::ChainNetwork; -use starcoin_genesis::{Genesis, GENESIS_GENERATED_DIR}; +use starcoin_genesis::{Genesis, G_GENESIS_GENERATED_DIR}; use starcoin_logger::prelude::*; use std::path::Path; @@ -66,7 +66,7 @@ fn main() { } }; if regenerate { - let path = Path::new(GENESIS_GENERATED_DIR).join(net.to_string()); + let path = Path::new(G_GENESIS_GENERATED_DIR).join(net.to_string()); new_genesis.save(path.as_path()).expect("save genesis fail"); } else { info!( diff --git a/network-p2p/src/service_test.rs b/network-p2p/src/service_test.rs index 9f6689bc93..b3fba2db08 100644 --- a/network-p2p/src/service_test.rs +++ b/network-p2p/src/service_test.rs @@ -22,7 +22,7 @@ use std::thread; use std::{sync::Arc, time::Duration}; use Event::NotificationStreamOpened; -static TEST_CHAIN_INFO: Lazy = +static G_TEST_CHAIN_INFO: Lazy = Lazy::new(|| ChainInfo::new(ChainId::new(0), HashValue::zero(), ChainStatus::random())); /// Builds a full node to be used for testing. Returns the node service and its associated events @@ -36,7 +36,7 @@ fn build_test_full_node( let worker = NetworkWorker::new(config::Params { network_config: config, protocol_id: config::ProtocolId::from("/test-protocol-name"), - chain_info: TEST_CHAIN_INFO.clone(), + chain_info: G_TEST_CHAIN_INFO.clone(), metrics_registry: None, }) .unwrap(); diff --git a/network-rpc/api/src/lib.rs b/network-rpc/api/src/lib.rs index fc6a877569..1553fff473 100644 --- a/network-rpc/api/src/lib.rs +++ b/network-rpc/api/src/lib.rs @@ -32,7 +32,7 @@ pub const MAX_TXN_REQUEST_SIZE: u64 = 1000; pub const MAX_BLOCK_INFO_REQUEST_SIZE: u64 = 1000; pub const MAX_BLOCK_IDS_REQUEST_SIZE: u64 = 10000; -pub static RPC_INFO: Lazy = Lazy::new(|| RpcInfo::new(gen_client::get_rpc_info())); +pub static G_RPC_INFO: Lazy = Lazy::new(|| RpcInfo::new(gen_client::get_rpc_info())); pub trait RpcRequest { fn verify(&self) -> Result<()> { diff --git a/network/src/worker.rs b/network/src/worker.rs index 15ca46ce47..18fb038bbd 100644 --- a/network/src/worker.rs +++ b/network/src/worker.rs @@ -101,7 +101,7 @@ pub fn build_network_worker( request_response_protocols: rpc_protocols, transport: transport_config, node_name, - client_version: starcoin_config::APP_NAME_WITH_VERSION.clone(), + client_version: starcoin_config::G_APP_NAME_WITH_VERSION.clone(), allow_non_globals_in_dht, ..NetworkConfiguration::default() }; diff --git a/node/src/network_service_factory.rs b/node/src/network_service_factory.rs index 146e3a4244..173ee9295b 100644 --- a/node/src/network_service_factory.rs +++ b/node/src/network_service_factory.rs @@ -19,7 +19,7 @@ impl ServiceFactory for NetworkServiceFactory { fn create(ctx: &mut ServiceContext) -> Result { let config = ctx.get_shared::>()?; let storage = ctx.get_shared::>()?; - let rpc_info = starcoin_network_rpc_api::RPC_INFO.clone(); + let rpc_info = starcoin_network_rpc_api::G_RPC_INFO.clone(); let txpool_service = ctx.service_ref::()?.clone(); let block_relayer = ctx.service_ref::()?.clone(); let network_rpc_service = ctx.service_ref::()?.clone(); diff --git a/rpc/server/src/module/txfactory_rpc.rs b/rpc/server/src/module/txfactory_rpc.rs index ac4dcf2810..ae91937f63 100644 --- a/rpc/server/src/module/txfactory_rpc.rs +++ b/rpc/server/src/module/txfactory_rpc.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; use starcoin_rpc_api::types::FactoryAction; use std::sync::atomic::{AtomicBool, Ordering}; -static FACTORY_STATUS: AtomicBool = AtomicBool::new(true); +static G_FACTORY_STATUS: AtomicBool = AtomicBool::new(true); #[derive(Debug, Serialize, Deserialize)] pub struct TxFactoryStatusHandle {} @@ -13,14 +13,14 @@ pub struct TxFactoryStatusHandle {} impl TxFactoryStatusHandle { pub fn handle_action(action: FactoryAction) -> bool { let _result = match action { - FactoryAction::Stop => FACTORY_STATUS + FactoryAction::Stop => G_FACTORY_STATUS .compare_exchange(true, false, Ordering::SeqCst, Ordering::Relaxed) .unwrap_or_else(|x| x), - FactoryAction::Start => FACTORY_STATUS + FactoryAction::Start => G_FACTORY_STATUS .compare_exchange(false, true, Ordering::SeqCst, Ordering::Relaxed) .unwrap_or_else(|x| x), _ => true, }; - FACTORY_STATUS.load(Ordering::SeqCst) + G_FACTORY_STATUS.load(Ordering::SeqCst) } } diff --git a/state/api/src/chain_state.rs b/state/api/src/chain_state.rs index 89de917a73..9e5c23a73b 100644 --- a/state/api/src/chain_state.rs +++ b/state/api/src/chain_state.rs @@ -17,7 +17,7 @@ use starcoin_types::{ account_state::AccountState, state_set::ChainStateSet, }; -use starcoin_vm_types::account_config::{genesis_address, STC_TOKEN_CODE}; +use starcoin_vm_types::account_config::{genesis_address, G_STC_TOKEN_CODE}; use starcoin_vm_types::genesis_config::ChainId; use starcoin_vm_types::language_storage::ModuleId; use starcoin_vm_types::on_chain_resource::dao::{Proposal, ProposalAction}; @@ -264,7 +264,7 @@ pub trait StateReaderExt: StateView { } fn get_balance(&self, address: AccountAddress) -> Result> { - self.get_balance_by_token_code(address, STC_TOKEN_CODE.clone()) + self.get_balance_by_token_code(address, G_STC_TOKEN_CODE.clone()) } /// Get balance by address and coin type @@ -338,7 +338,7 @@ pub trait StateReaderExt: StateView { } fn get_stc_info(&self) -> Result> { - self.get_token_info(STC_TOKEN_CODE.clone()) + self.get_token_info(G_STC_TOKEN_CODE.clone()) } fn get_treasury(&self, token_code: TokenCode) -> Result> { @@ -347,7 +347,7 @@ pub trait StateReaderExt: StateView { } fn get_stc_treasury(&self) -> Result> { - self.get_treasury(STC_TOKEN_CODE.clone()) + self.get_treasury(G_STC_TOKEN_CODE.clone()) } fn get_proposal(&self, token_code: TokenCode) -> Result>> @@ -362,7 +362,7 @@ pub trait StateReaderExt: StateView { where A: ProposalAction + DeserializeOwned, { - self.get_proposal(STC_TOKEN_CODE.clone()) + self.get_proposal(G_STC_TOKEN_CODE.clone()) } } diff --git a/state/statedb/src/lib.rs b/state/statedb/src/lib.rs index fc40d0aaf6..430e83e2a5 100644 --- a/state/statedb/src/lib.rs +++ b/state/statedb/src/lib.rs @@ -215,7 +215,7 @@ pub struct ChainStateDB { updates: RwLock>, } -static DEFAULT_CACHE_SIZE: usize = 10240; +static G_DEFAULT_CACHE_SIZE: usize = 10240; impl ChainStateDB { pub fn mock() -> Self { @@ -226,7 +226,7 @@ impl ChainStateDB { Self { store: store.clone(), state_tree: StateTree::new(store, root_hash), - cache: Mutex::new(LruCache::new(DEFAULT_CACHE_SIZE)), + cache: Mutex::new(LruCache::new(G_DEFAULT_CACHE_SIZE)), updates: RwLock::new(HashSet::new()), } } @@ -241,7 +241,7 @@ impl ChainStateDB { Self { store: self.store.clone(), state_tree: StateTree::new(self.store.clone(), Some(state_root)), - cache: Mutex::new(LruCache::new(DEFAULT_CACHE_SIZE)), + cache: Mutex::new(LruCache::new(G_DEFAULT_CACHE_SIZE)), updates: RwLock::new(HashSet::new()), } } diff --git a/sync/src/block_connector/block_connector_service.rs b/sync/src/block_connector/block_connector_service.rs index 6ed01ae70a..31bf6f75a4 100644 --- a/sync/src/block_connector/block_connector_service.rs +++ b/sync/src/block_connector/block_connector_service.rs @@ -5,7 +5,7 @@ use crate::block_connector::{ExecuteRequest, ResetRequest, WriteBlockChainServic use crate::sync::{CheckSyncEvent, SyncService}; use crate::tasks::BlockConnectedEvent; use anyhow::{format_err, Result}; -use config::{NodeConfig, CRATE_VERSION}; +use config::{NodeConfig, G_CRATE_VERSION}; use executor::VMMetrics; use logger::prelude::*; use network::NetworkServiceRef; @@ -146,7 +146,7 @@ impl EventHandler for BlockConnectorService { msg.get_block().clone(), Some(peer_id.clone()), format!("{:?}", e), - CRATE_VERSION.to_string(), + G_CRATE_VERSION.to_string(), ) { warn!( diff --git a/sync/src/block_connector/test_illegal_block.rs b/sync/src/block_connector/test_illegal_block.rs index 1efc5c3549..88be5c52ba 100644 --- a/sync/src/block_connector/test_illegal_block.rs +++ b/sync/src/block_connector/test_illegal_block.rs @@ -7,7 +7,7 @@ use crate::block_connector::{ use anyhow::Result; use config::{ BuiltinNetworkID, ChainNetwork, GenesisBlockParameter, GenesisBlockParameterConfig, NodeConfig, - TEST_CONFIG, + G_TEST_CONFIG, }; use consensus::Consensus; use logger::prelude::*; @@ -690,9 +690,9 @@ async fn test_verify_uncles_in_old_epoch(begin_epoch: bool) -> Result { uncle_block_and_writeable_block_chain(count, count - 2).await; let end_number = if begin_epoch { - TEST_CONFIG.consensus_config.epoch_block_count - 1 + G_TEST_CONFIG.consensus_config.epoch_block_count - 1 } else { - TEST_CONFIG.consensus_config.epoch_block_count + 1 + G_TEST_CONFIG.consensus_config.epoch_block_count + 1 }; let old_epoch_num = writeable_block_chain_service.get_main().epoch().number(); // create block loop @@ -862,7 +862,7 @@ async fn test_verify_uncle_and_parent_number_failed() { #[stest::test] async fn test_verify_uncle_which_parent_is_end_block_in_last_epoch() { - let count = TEST_CONFIG.consensus_config.epoch_block_count; + let count = G_TEST_CONFIG.consensus_config.epoch_block_count; let (uncle_header, mut writeable_block_chain_service, node_config, storage) = uncle_block_and_writeable_block_chain(count, count - 1).await; diff --git a/sync/src/tasks/block_sync_task.rs b/sync/src/tasks/block_sync_task.rs index a7be76abed..8968824524 100644 --- a/sync/src/tasks/block_sync_task.rs +++ b/sync/src/tasks/block_sync_task.rs @@ -4,7 +4,7 @@ use crate::tasks::{BlockConnectedEvent, BlockConnectedEventHandle, BlockFetcher, BlockLocalStore}; use crate::verified_rpc_client::RpcVerifyError; use anyhow::{format_err, Result}; -use config::CRATE_VERSION; +use config::G_CRATE_VERSION; use futures::future::BoxFuture; use futures::FutureExt; use logger::prelude::*; @@ -223,7 +223,7 @@ where .get_storage() .get_failed_block_by_id(block.id())? { - if version == *CRATE_VERSION { + if version == *G_CRATE_VERSION { warn!( "[sync] apply a previous failed block: {}, previous_peer_id:{:?}, err: {}", block.id(), @@ -260,7 +260,7 @@ where block, peer_id.clone(), error_msg, - CRATE_VERSION.to_string(), + G_CRATE_VERSION.to_string(), )?; if let Some(peer) = peer_id { self.peer_provider.report_peer(peer, e.reputation()); diff --git a/sync/src/tasks/mock.rs b/sync/src/tasks/mock.rs index db7a27313d..f8d567ab5c 100644 --- a/sync/src/tasks/mock.rs +++ b/sync/src/tasks/mock.rs @@ -20,7 +20,7 @@ use starcoin_chain::BlockChain; use starcoin_chain_api::ChainReader; use starcoin_chain_mock::MockChain; use starcoin_crypto::HashValue; -use starcoin_network_rpc_api::RPC_INFO; +use starcoin_network_rpc_api::G_RPC_INFO; use starcoin_sync_api::SyncTarget; use starcoin_types::block::{Block, BlockIdAndNumber, BlockInfo, BlockNumber}; use starcoin_types::peer_info::PeerId; @@ -150,7 +150,7 @@ impl SyncNodeMocker { peer_id.clone(), chain.chain_info(), NotificationMessage::protocols(), - RPC_INFO.clone().into_protocols(), + G_RPC_INFO.clone().into_protocols(), ); let peer_selector = PeerSelector::new(vec![peer_info], PeerStrategy::default(), None); Ok(Self::new_inner( diff --git a/sync/src/verified_rpc_client.rs b/sync/src/verified_rpc_client.rs index 4e768c98a5..7b84febc34 100644 --- a/sync/src/verified_rpc_client.rs +++ b/sync/src/verified_rpc_client.rs @@ -87,16 +87,16 @@ where } } -static BLOCK_NUMBER_VERIFIER: fn(&BlockNumber, &BlockHeader) -> bool = +static G_BLOCK_NUMBER_VERIFIER: fn(&BlockNumber, &BlockHeader) -> bool = |block_number, block_header| -> bool { *block_number == block_header.number() }; -static BLOCK_ID_VERIFIER: fn(&HashValue, &BlockHeader) -> bool = +static G_BLOCK_ID_VERIFIER: fn(&HashValue, &BlockHeader) -> bool = |block_hash, block_header| -> bool { *block_hash == block_header.id() }; -static BLOCK_BODY_VERIFIER: fn(&HashValue, &BlockBody) -> bool = +static G_BLOCK_BODY_VERIFIER: fn(&HashValue, &BlockBody) -> bool = |body_hash, block_body| -> bool { *body_hash == block_body.hash() }; -static BLOCK_INFO_VERIFIER: fn(&HashValue, &BlockInfo) -> bool = +static G_BLOCK_INFO_VERIFIER: fn(&HashValue, &BlockInfo) -> bool = |block_id, block_info| -> bool { *block_id == block_info.block_id }; /// Enhancement RpcClient, for verify rpc response by request and auto select peer. @@ -258,7 +258,7 @@ impl VerifiedRpcClient { .client .get_headers_by_number(peer_id.clone(), req.clone()) .await?; - let resp = BLOCK_NUMBER_VERIFIER.verify(peer_id, req, resp)?; + let resp = G_BLOCK_NUMBER_VERIFIER.verify(peer_id, req, resp)?; Ok(resp) } @@ -271,7 +271,7 @@ impl VerifiedRpcClient { .client .get_headers_by_hash(peer_id.clone(), req.clone()) .await?; - let resp = BLOCK_ID_VERIFIER.verify(peer_id, req, resp)?; + let resp = G_BLOCK_ID_VERIFIER.verify(peer_id, req, resp)?; Ok(resp) } @@ -285,7 +285,7 @@ impl VerifiedRpcClient { .client .get_bodies_by_hash(peer_id.clone(), req.clone()) .await?; - let resp = BLOCK_BODY_VERIFIER.verify(peer_id.clone(), req, resp)?; + let resp = G_BLOCK_BODY_VERIFIER.verify(peer_id.clone(), req, resp)?; Ok((resp, peer_id)) } @@ -306,7 +306,7 @@ impl VerifiedRpcClient { .client .get_block_infos(peer_id.clone(), req.clone()) .await?; - let resp = BLOCK_INFO_VERIFIER.verify(peer_id, req, resp)?; + let resp = G_BLOCK_INFO_VERIFIER.verify(peer_id, req, resp)?; Ok(resp) } diff --git a/testsuite/tests/steps/cmd.rs b/testsuite/tests/steps/cmd.rs index 7f5b47946a..eccc7d7a78 100644 --- a/testsuite/tests/steps/cmd.rs +++ b/testsuite/tests/steps/cmd.rs @@ -12,16 +12,16 @@ use starcoin_account_provider::ProviderFactory; use starcoin_cmd::add_command; use starcoin_cmd::{CliState, StarcoinOpt}; use starcoin_config::account_provider_config::AccountProviderConfig; -use starcoin_config::{APP_VERSION, CRATE_VERSION}; +use starcoin_config::{G_APP_VERSION, G_CRATE_VERSION}; use starcoin_logger::prelude::*; use std::collections::{HashMap, HashSet}; use std::time::Duration; lazy_static! { - static ref SELECTOR_REGEX: Regex = Regex::new(r"@(?P[^@\s]+)@").unwrap(); + static ref G_SELECTOR_REGEX: Regex = Regex::new(r"@(?P[^@\s]+)@").unwrap(); } fn extract_selector_str(input: &str) -> HashSet<&str> { - SELECTOR_REGEX + G_SELECTOR_REGEX .captures_iter(input) .filter_map(|cap| cap.name("value").map(|find| find.as_str())) .collect() @@ -48,8 +48,8 @@ pub fn steps() -> Steps { account_client, ); let context = CmdContext::::with_state( - CRATE_VERSION, - Some(APP_VERSION.as_str()), + G_CRATE_VERSION, + Some(G_APP_VERSION.as_str()), state, ); // get last cmd result as current parameter diff --git a/vm/compiler/src/lib.rs b/vm/compiler/src/lib.rs index 2d6da3130c..2cd9407899 100644 --- a/vm/compiler/src/lib.rs +++ b/vm/compiler/src/lib.rs @@ -71,15 +71,17 @@ fn substitute_variable( text: &str, vars: HashMap<&str, String, S>, ) -> String { - static PAT: Lazy = Lazy::new(|| Regex::new(r"\{\{([A-Za-z][A-Za-z0-9]*)\}\}").unwrap()); - PAT.replace_all(text, |caps: &Captures| { - let name = &caps[1]; - vars.get(name) - .map(|s| s.to_string()) - //if name not found, replace with origin place holder {{name}}, '{{' in format represent '{' - .unwrap_or_else(|| format!("{{{{{}}}}}", name)) - }) - .to_string() + static G_PAT: Lazy = + Lazy::new(|| Regex::new(r"\{\{([A-Za-z][A-Za-z0-9]*)\}\}").unwrap()); + G_PAT + .replace_all(text, |caps: &Captures| { + let name = &caps[1]; + vars.get(name) + .map(|s| s.to_string()) + //if name not found, replace with origin place holder {{name}}, '{{' in format represent '{' + .unwrap_or_else(|| format!("{{{{{}}}}}", name)) + }) + .to_string() } /// perform Windows style line ending (CRLF) to Unix stype (LF) conversion in given file @@ -304,14 +306,14 @@ mod tests { struct M{ value: u64, } - + struct M2{ value: u128, } public fun hello(){ } - + public fun hello2(){ } } diff --git a/vm/move-package-manager/src/lib.rs b/vm/move-package-manager/src/lib.rs index d2a9ab250e..f550451491 100644 --- a/vm/move-package-manager/src/lib.rs +++ b/vm/move-package-manager/src/lib.rs @@ -104,7 +104,8 @@ pub struct IntegrationTestCommand { /// update test baseline. update_baseline: bool, } -static PRE_COMPILED_LIB: Lazy>> = Lazy::new(|| Mutex::new(None)); +static G_PRE_COMPILED_LIB: Lazy>> = + Lazy::new(|| Mutex::new(None)); pub fn run_integration_test(move_arg: Move, cmd: IntegrationTestCommand) -> Result<()> { let rerooted_path = { let path = &move_arg.package_path; @@ -223,7 +224,7 @@ pub fn run_integration_test(move_arg: Move, cmd: IntegrationTestCommand) -> Resu { // update the global - *PRE_COMPILED_LIB.lock().unwrap() = Some(pre_compiled_lib); + *G_PRE_COMPILED_LIB.lock().unwrap() = Some(pre_compiled_lib); } let spectests_dir = rerooted_path.join("spectests"); @@ -249,7 +250,7 @@ pub fn run_integration_test(move_arg: Move, cmd: IntegrationTestCommand) -> Resu move |path| { starcoin_transactional_test_harness::run_test_impl( path, - PRE_COMPILED_LIB.lock().unwrap().as_ref(), + G_PRE_COMPILED_LIB.lock().unwrap().as_ref(), ) }, "integration-test".to_string(), diff --git a/vm/move-package-manager/src/main.rs b/vm/move-package-manager/src/main.rs index 45d4a4950a..6ca72e020b 100644 --- a/vm/move-package-manager/src/main.rs +++ b/vm/move-package-manager/src/main.rs @@ -81,7 +81,7 @@ fn main() -> Result<()> { ), Commands::Sandbox { storage_dir, cmd } => cmd.handle_command( natives, - &genesis_config::LATEST_GAS_SCHEDULE, + &genesis_config::G_LATEST_GAS_SCHEDULE, &error_descriptions, move_args, &storage_dir, diff --git a/vm/move-prover/tests/testsuite.rs b/vm/move-prover/tests/testsuite.rs index 6b40733549..58c2240bb1 100644 --- a/vm/move-prover/tests/testsuite.rs +++ b/vm/move-prover/tests/testsuite.rs @@ -22,7 +22,7 @@ const ENV_TEST_FEATURE: &str = "MVP_TEST_FEATURE"; const ENV_TEST_ON_CI: &str = "MVP_TEST_ON_CI"; const REGULAR_TEST_FLAGS: &[&str] = &["--dependency=../stdlib/sources"]; -static NOT_CONFIGURED_WARNED: AtomicBool = AtomicBool::new(false); +static G_NOT_CONFIGURED_WARNED: AtomicBool = AtomicBool::new(false); /// A struct to describe a feature to test. struct Feature { @@ -59,8 +59,8 @@ enum InclusionMode { } fn get_features() -> &'static [Feature] { - static TESTED_FEATURES: OnceCell> = OnceCell::new(); - TESTED_FEATURES.get_or_init(|| { + static G_TESTED_FEATURES: OnceCell> = OnceCell::new(); + G_TESTED_FEATURES.get_or_init(|| { vec![ // Tests the default configuration. Feature { @@ -171,7 +171,7 @@ fn test_runner_for_feature(path: &Path, feature: &Feature) -> datatest_stable::R if no_tools { options.prover.generate_only = true; - if NOT_CONFIGURED_WARNED + if G_NOT_CONFIGURED_WARNED .compare_exchange(false, true, Ordering::Relaxed, Ordering::Relaxed) .is_ok() { diff --git a/vm/starcoin-transactional-test-harness/src/lib.rs b/vm/starcoin-transactional-test-harness/src/lib.rs index c7dceafcc7..e16d4e824b 100644 --- a/vm/starcoin-transactional-test-harness/src/lib.rs +++ b/vm/starcoin-transactional-test-harness/src/lib.rs @@ -66,7 +66,7 @@ use starcoin_vm_types::{ }; use std::convert::TryFrom; use std::{collections::BTreeMap, convert::TryInto, path::Path, str::FromStr}; -use stdlib::{starcoin_framework_named_addresses, PRECOMPILED_STARCOIN_FRAMEWORK}; +use stdlib::{starcoin_framework_named_addresses, G_PRECOMPILED_STARCOIN_FRAMEWORK}; mod in_memory_state_cache; pub mod remote_state; @@ -1019,7 +1019,7 @@ impl<'a> MoveTestAdapter<'a> for StarcoinTestAdapter<'a> { /// Run the Starcoin transactional test flow, using the given file as input. pub fn run_test(path: &Path) -> Result<(), Box> { - run_test_impl(path, Some(&*PRECOMPILED_STARCOIN_FRAMEWORK)) + run_test_impl(path, Some(&*G_PRECOMPILED_STARCOIN_FRAMEWORK)) } pub fn run_test_impl( diff --git a/vm/stdlib/src/lib.rs b/vm/stdlib/src/lib.rs index 9fa554186e..1cb55fa1f3 100644 --- a/vm/stdlib/src/lib.rs +++ b/vm/stdlib/src/lib.rs @@ -63,7 +63,7 @@ pub const STDLIB_DIR: Dir = starcoin_framework::SOURCES_DIR; // The current stdlib that is freshly built. This will never be used in deployment so we don't need // to pull the same trick here in order to include this in the Rust binary. -static FRESH_MOVELANG_STDLIB: Lazy>> = Lazy::new(|| { +static G_FRESH_MOVELANG_STDLIB: Lazy>> = Lazy::new(|| { build_stdlib(STARCOIN_FRAMEWORK_SOURCES.files.as_slice()) .values() .map(|m| { @@ -81,7 +81,7 @@ pub const COMPILED_MOVE_CODE_DIR: Dir = include_dir!("compiled"); pub const LATEST_VERSION: &str = "latest"; -pub static STDLIB_VERSIONS: Lazy> = Lazy::new(|| { +pub static G_STDLIB_VERSIONS: Lazy> = Lazy::new(|| { let mut versions = COMPILED_MOVE_CODE_DIR .dirs() .iter() @@ -93,9 +93,9 @@ pub static STDLIB_VERSIONS: Lazy> = Lazy::new(|| { versions }); -static COMPILED_STDLIB: Lazy>>> = Lazy::new(|| { +static G_COMPILED_STDLIB: Lazy>>> = Lazy::new(|| { let mut map = HashMap::new(); - for version in &*STDLIB_VERSIONS { + for version in &*G_STDLIB_VERSIONS { let modules = read_compiled_modules(*version); verify_compiled_modules(&modules); map.insert(*version, modules); @@ -105,7 +105,7 @@ static COMPILED_STDLIB: Lazy>>> = Lazy::new(| pub const SCRIPT_HASH_LENGTH: usize = HashValue::LENGTH; -pub static PRECOMPILED_STARCOIN_FRAMEWORK: Lazy = Lazy::new(|| { +pub static G_PRECOMPILED_STARCOIN_FRAMEWORK: Lazy = Lazy::new(|| { let sources = stdlib_files(); let compiler = Compiler::new(&sources, &[]) .set_flags(Flags::empty().set_sources_shadow_deps(false)) @@ -136,12 +136,12 @@ pub use starcoin_framework::STARCOIN_FRAMEWORK_SOURCES; /// Return all versions of stdlib, include latest. pub fn stdlib_versions() -> Vec { - STDLIB_VERSIONS.clone() + G_STDLIB_VERSIONS.clone() } /// Return the latest stable version of stdlib. pub fn stdlib_latest_stable_version() -> Option { - STDLIB_VERSIONS + G_STDLIB_VERSIONS .iter() .filter(|version| !version.is_latest()) .last() @@ -161,8 +161,8 @@ pub enum StdLibOptions { /// will be used. pub fn stdlib_modules(option: StdLibOptions) -> &'static [Vec] { match option { - StdLibOptions::Fresh => &*FRESH_MOVELANG_STDLIB, - StdLibOptions::Compiled(version) => &*COMPILED_STDLIB + StdLibOptions::Fresh => &*G_FRESH_MOVELANG_STDLIB, + StdLibOptions::Compiled(version) => &*G_COMPILED_STDLIB .get(&version) .unwrap_or_else(|| panic!("Stdlib version {:?} not exist.", version)), } diff --git a/vm/transaction-builder-generator/src/rust.rs b/vm/transaction-builder-generator/src/rust.rs index 86a3cba99f..d24685d391 100644 --- a/vm/transaction-builder-generator/src/rust.rs +++ b/vm/transaction-builder-generator/src/rust.rs @@ -306,7 +306,7 @@ pub fn encode(self) -> TransactionPayload {{"# r#" /// Try to recognize a Diem `Script` and convert it into a structured object `ScriptCall`. pub fn decode(script: &Script) -> Option {{ - match TRANSACTION_SCRIPT_DECODER_MAP.get({}) {{ + match G_TRANSACTION_SCRIPT_DECODER_MAP.get({}) {{ Some(decoder) => decoder(script), None => None, }} @@ -326,7 +326,7 @@ pub fn decode(script: &Script) -> Option {{ /// Try to recognize a Diem `TransactionPayload` and convert it into a structured object `ScriptFunctionCall`. pub fn decode(payload: &TransactionPayload) -> Option {{ if let TransactionPayload::ScriptFunction(script) = payload {{ - match SCRIPT_FUNCTION_DECODER_MAP.get(&format!("{{}}{{}}", {}, {})) {{ + match G_SCRIPT_FUNCTION_DECODER_MAP.get(&format!("{{}}{{}}", {}, {})) {{ Some(decoder) => decoder(payload), None => None, }} @@ -579,7 +579,7 @@ TransactionPayload::ScriptFunction(ScriptFunction {{ r#" type TransactionScriptDecoderMap = std::collections::HashMap, Box Option + std::marker::Sync + std::marker::Send>>; -static TRANSACTION_SCRIPT_DECODER_MAP: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| {{"# +static G_TRANSACTION_SCRIPT_DECODER_MAP: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| {{"# )?; self.out.indent(); writeln!( @@ -605,7 +605,7 @@ static TRANSACTION_SCRIPT_DECODER_MAP: once_cell::sync::Lazy Option + std::marker::Sync + std::marker::Send>>; -static SCRIPT_FUNCTION_DECODER_MAP: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| {{"# +static G_SCRIPT_FUNCTION_DECODER_MAP: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| {{"# )?; self.out.indent(); writeln!( diff --git a/vm/transaction-builder/src/lib.rs b/vm/transaction-builder/src/lib.rs index ed8320f7a0..8f093e589e 100644 --- a/vm/transaction-builder/src/lib.rs +++ b/vm/transaction-builder/src/lib.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use anyhow::Result; -use starcoin_config::{genesis_config::TOTAL_STC_AMOUNT, ChainNetwork}; +use starcoin_config::{genesis_config::G_TOTAL_STC_AMOUNT, ChainNetwork}; use starcoin_crypto::hash::PlainCryptoHash; use starcoin_crypto::HashValue; use starcoin_vm_types::access::ModuleAccess; @@ -17,7 +17,7 @@ use starcoin_vm_types::language_storage::ModuleId; use starcoin_vm_types::language_storage::{StructTag, TypeTag}; use starcoin_vm_types::on_chain_config::VMConfig; use starcoin_vm_types::on_chain_resource::nft::NFTUUID; -use starcoin_vm_types::token::stc::{stc_type_tag, STC_TOKEN_CODE}; +use starcoin_vm_types::token::stc::{stc_type_tag, G_STC_TOKEN_CODE}; use starcoin_vm_types::token::token_code::TokenCode; use starcoin_vm_types::transaction::authenticator::{AccountPrivateKey, AuthenticationKey}; use starcoin_vm_types::transaction::{ @@ -65,7 +65,7 @@ pub fn build_transfer_txn( amount, gas_price, max_gas, - STC_TOKEN_CODE.clone(), + G_STC_TOKEN_CODE.clone(), expiration_timestamp_secs, chain_id, ) @@ -241,7 +241,7 @@ pub fn encode_create_account_script_function( } pub fn encode_transfer_script_function(recipient: AccountAddress, amount: u128) -> ScriptFunction { - encode_transfer_script_by_token_code(recipient, amount, STC_TOKEN_CODE.clone()) + encode_transfer_script_by_token_code(recipient, amount, G_STC_TOKEN_CODE.clone()) } pub fn encode_transfer_script_by_token_code( @@ -525,7 +525,7 @@ pub fn build_init_script_v2(net: &ChainNetwork) -> ScriptFunction { vec![ bcs_ext::to_bytes(&net.genesis_config().stdlib_version.version()).unwrap(), bcs_ext::to_bytes(&genesis_config.reward_delay).unwrap(), - bcs_ext::to_bytes(&TOTAL_STC_AMOUNT.scaling()).unwrap(), + bcs_ext::to_bytes(&G_TOTAL_STC_AMOUNT.scaling()).unwrap(), bcs_ext::to_bytes(&genesis_config.pre_mine_amount).unwrap(), bcs_ext::to_bytes(&genesis_config.time_mint_amount).unwrap(), bcs_ext::to_bytes(&genesis_config.time_mint_period).unwrap(), diff --git a/vm/types/src/account_config/constants/account.rs b/vm/types/src/account_config/constants/account.rs index fe9023bb18..5c9307a443 100644 --- a/vm/types/src/account_config/constants/account.rs +++ b/vm/types/src/account_config/constants/account.rs @@ -11,25 +11,25 @@ use once_cell::sync::Lazy; pub const ACCOUNT_MODULE_NAME: &str = "Account"; // Account -static ACCOUNT_MODULE_IDENTIFIER: Lazy = +static G_ACCOUNT_MODULE_IDENTIFIER: Lazy = Lazy::new(|| Identifier::new("Account").unwrap()); -static ACCOUNT_STRUCT_NAME: Lazy = Lazy::new(|| Identifier::new("Account").unwrap()); -static ACCOUNT_BALANCE_STRUCT_NAME: Lazy = +static G_ACCOUNT_STRUCT_NAME: Lazy = Lazy::new(|| Identifier::new("Account").unwrap()); +static G_ACCOUNT_BALANCE_STRUCT_NAME: Lazy = Lazy::new(|| Identifier::new("Balance").unwrap()); /// The ModuleId for the Account module. -pub static ACCOUNT_MODULE: Lazy = - Lazy::new(|| ModuleId::new(CORE_CODE_ADDRESS, ACCOUNT_MODULE_IDENTIFIER.clone())); +pub static G_ACCOUNT_MODULE: Lazy = + Lazy::new(|| ModuleId::new(CORE_CODE_ADDRESS, G_ACCOUNT_MODULE_IDENTIFIER.clone())); pub fn account_balance_struct_name() -> &'static IdentStr { - &*ACCOUNT_BALANCE_STRUCT_NAME + &*G_ACCOUNT_BALANCE_STRUCT_NAME } pub fn account_struct_tag() -> StructTag { StructTag { address: CORE_CODE_ADDRESS, - module: ACCOUNT_MODULE_IDENTIFIER.clone(), - name: ACCOUNT_STRUCT_NAME.to_owned(), + module: G_ACCOUNT_MODULE_IDENTIFIER.clone(), + name: G_ACCOUNT_STRUCT_NAME.to_owned(), type_params: vec![], } } diff --git a/vm/types/src/account_config/constants/chain.rs b/vm/types/src/account_config/constants/chain.rs index 526c34e48e..fe0442c13d 100644 --- a/vm/types/src/account_config/constants/chain.rs +++ b/vm/types/src/account_config/constants/chain.rs @@ -8,35 +8,35 @@ use crate::{ use once_cell::sync::Lazy; /// The ModuleId for the TransactionTimeout module -pub static TRANSACTION_TIMEOUT_MODULE: Lazy = Lazy::new(|| { +pub static G_TRANSACTION_TIMEOUT_MODULE: Lazy = Lazy::new(|| { ModuleId::new( CORE_CODE_ADDRESS, Identifier::new("TransactionTimeout").unwrap(), ) }); -pub static BLOCK_MODULE_NAME: &str = "Block"; -pub static TRANSACTION_MANAGER_MODULE_NAME: &str = "TransactionManager"; +pub static G_BLOCK_MODULE_NAME: &str = "Block"; +pub static G_TRANSACTION_MANAGER_MODULE_NAME: &str = "TransactionManager"; /// The ModuleId for block module -pub static BLOCK_MODULE: Lazy = Lazy::new(|| { +pub static G_BLOCK_MODULE: Lazy = Lazy::new(|| { ModuleId::new( CORE_CODE_ADDRESS, - Identifier::new(BLOCK_MODULE_NAME).unwrap(), + Identifier::new(G_BLOCK_MODULE_NAME).unwrap(), ) }); /// The ModuleId for transaction manager module -pub static TRANSACTION_MANAGER_MODULE: Lazy = Lazy::new(|| { +pub static G_TRANSACTION_MANAGER_MODULE: Lazy = Lazy::new(|| { ModuleId::new( CORE_CODE_ADDRESS, - Identifier::new(TRANSACTION_MANAGER_MODULE_NAME).unwrap(), + Identifier::new(G_TRANSACTION_MANAGER_MODULE_NAME).unwrap(), ) }); -pub static PROLOGUE_NAME: Lazy = Lazy::new(|| Identifier::new("prologue").unwrap()); -pub static BLOCK_PROLOGUE_NAME: Lazy = +pub static G_PROLOGUE_NAME: Lazy = Lazy::new(|| Identifier::new("prologue").unwrap()); +pub static G_BLOCK_PROLOGUE_NAME: Lazy = Lazy::new(|| Identifier::new("block_prologue").unwrap()); -pub static EPILOGUE_NAME: Lazy = Lazy::new(|| Identifier::new("epilogue").unwrap()); -pub static EPILOGUE_V2_NAME: Lazy = +pub static G_EPILOGUE_NAME: Lazy = Lazy::new(|| Identifier::new("epilogue").unwrap()); +pub static G_EPILOGUE_V2_NAME: Lazy = Lazy::new(|| Identifier::new("epilogue_v2").unwrap()); diff --git a/vm/types/src/account_config/constants/event.rs b/vm/types/src/account_config/constants/event.rs index b70315f7de..1c1a11f0ee 100644 --- a/vm/types/src/account_config/constants/event.rs +++ b/vm/types/src/account_config/constants/event.rs @@ -11,25 +11,25 @@ use move_core_types::{ }; use once_cell::sync::Lazy; -static EVENT_MODULE_NAME: Lazy = Lazy::new(|| Identifier::new("Event").unwrap()); +static G_EVENT_MODULE_NAME: Lazy = Lazy::new(|| Identifier::new("Event").unwrap()); pub static EVENT_MODULE: Lazy = - Lazy::new(|| ModuleId::new(CORE_CODE_ADDRESS, EVENT_MODULE_NAME.clone())); + Lazy::new(|| ModuleId::new(CORE_CODE_ADDRESS, G_EVENT_MODULE_NAME.clone())); -static EVENT_HANDLE_STRUCT_NAME: Lazy = +static G_EVENT_HANDLE_STRUCT_NAME: Lazy = Lazy::new(|| Identifier::new("EventHandle").unwrap()); -static EVENT_HANDLE_GENERATOR_STRUCT_NAME: Lazy = +static G_EVENT_HANDLE_GENERATOR_STRUCT_NAME: Lazy = Lazy::new(|| Identifier::new("EventHandleGenerator").unwrap()); pub fn event_module_name() -> &'static IdentStr { - &*EVENT_MODULE_NAME + &*G_EVENT_MODULE_NAME } pub fn event_handle_generator_struct_name() -> &'static IdentStr { - &*EVENT_HANDLE_GENERATOR_STRUCT_NAME + &*G_EVENT_HANDLE_GENERATOR_STRUCT_NAME } pub fn event_handle_struct_name() -> &'static IdentStr { - &*EVENT_HANDLE_STRUCT_NAME + &*G_EVENT_HANDLE_STRUCT_NAME } pub fn event_handle_generator_struct_tag() -> StructTag { diff --git a/vm/types/src/on_chain_config/consensus_config.rs b/vm/types/src/on_chain_config/consensus_config.rs index bd1e26fba2..ad1f7403dc 100644 --- a/vm/types/src/on_chain_config/consensus_config.rs +++ b/vm/types/src/on_chain_config/consensus_config.rs @@ -10,7 +10,7 @@ use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; const CONSENSUS_CONFIG_MODULE_NAME: &str = "ConsensusConfig"; -pub static CONSENSUS_CONFIG_IDENTIFIER: Lazy = +pub static G_CONSENSUS_CONFIG_IDENTIFIER: Lazy = Lazy::new(|| Identifier::new(CONSENSUS_CONFIG_MODULE_NAME).unwrap()); /// The Consensus on chain. @@ -38,8 +38,8 @@ impl ConsensusConfig { pub fn type_tag() -> TypeTag { TypeTag::Struct(StructTag { address: CORE_CODE_ADDRESS, - module: CONSENSUS_CONFIG_IDENTIFIER.clone(), - name: CONSENSUS_CONFIG_IDENTIFIER.clone(), + module: G_CONSENSUS_CONFIG_IDENTIFIER.clone(), + name: G_CONSENSUS_CONFIG_IDENTIFIER.clone(), type_params: vec![], }) } diff --git a/vm/types/src/on_chain_config/genesis_gas_schedule.rs b/vm/types/src/on_chain_config/genesis_gas_schedule.rs index 231738a2e9..c5d501c315 100644 --- a/vm/types/src/on_chain_config/genesis_gas_schedule.rs +++ b/vm/types/src/on_chain_config/genesis_gas_schedule.rs @@ -260,7 +260,7 @@ pub fn instruction_table_v2() -> Vec { } /// return latest instruction table, as `initial_instruction_table` function should not be modified. -pub static LATEST_INSTRUCTION_TABLE: Lazy> = Lazy::new(|| { +pub static G_LATEST_INSTRUCTION_TABLE: Lazy> = Lazy::new(|| { let latest_ins = instruction_table_v2(); debug_assert!( latest_ins.len() == Bytecode::VARIANT_COUNT, @@ -373,7 +373,7 @@ pub fn v3_native_table() -> Vec { .collect::>() } -pub static LATEST_NATIVE_TABLE: Lazy> = Lazy::new(|| { +pub static G_LATEST_NATIVE_TABLE: Lazy> = Lazy::new(|| { let native_table = v3_native_table(); debug_assert!( diff --git a/vm/types/src/on_chain_config/mod.rs b/vm/types/src/on_chain_config/mod.rs index 9f3dad10ef..2e2086f209 100644 --- a/vm/types/src/on_chain_config/mod.rs +++ b/vm/types/src/on_chain_config/mod.rs @@ -23,11 +23,11 @@ mod move_lang_version; mod version; mod vm_config; pub use self::{ - consensus_config::{consensus_config_type_tag, ConsensusConfig, CONSENSUS_CONFIG_IDENTIFIER}, + consensus_config::{consensus_config_type_tag, ConsensusConfig, G_CONSENSUS_CONFIG_IDENTIFIER}, dao_config::DaoConfig, genesis_gas_schedule::*, move_lang_version::MoveLanguageVersion, - version::{version_config_type_tag, Version, VERSION_CONFIG_IDENTIFIER}, + version::{version_config_type_tag, Version, G_VERSION_CONFIG_IDENTIFIER}, vm_config::*, }; pub use crate::on_chain_resource::GlobalTimeOnChain; @@ -60,7 +60,7 @@ impl ConfigID { } } -pub static ON_CHAIN_CONFIG_REGISTRY: Lazy> = Lazy::new(|| { +pub static G_ON_CHAIN_CONFIG_REGISTRY: Lazy> = Lazy::new(|| { vec![ Version::config_id(), ConsensusConfig::config_id(), diff --git a/vm/types/src/on_chain_config/version.rs b/vm/types/src/on_chain_config/version.rs index 0ea598dbd6..958a509bc5 100644 --- a/vm/types/src/on_chain_config/version.rs +++ b/vm/types/src/on_chain_config/version.rs @@ -10,7 +10,7 @@ use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; const VERSION_CONFIG_MODULE_NAME: &str = "Version"; -pub static VERSION_CONFIG_IDENTIFIER: Lazy = +pub static G_VERSION_CONFIG_IDENTIFIER: Lazy = Lazy::new(|| Identifier::new(VERSION_CONFIG_MODULE_NAME).unwrap()); /// Defines the version of Starcoin software. @@ -40,8 +40,8 @@ impl MoveResource for Version { pub fn version_config_type_tag() -> TypeTag { TypeTag::Struct(StructTag { address: CORE_CODE_ADDRESS, - module: VERSION_CONFIG_IDENTIFIER.clone(), - name: VERSION_CONFIG_IDENTIFIER.clone(), + module: G_VERSION_CONFIG_IDENTIFIER.clone(), + name: G_VERSION_CONFIG_IDENTIFIER.clone(), type_params: vec![], }) } diff --git a/vm/types/src/on_chain_config/vm_config.rs b/vm/types/src/on_chain_config/vm_config.rs index 5e0b2a28fe..54b6755641 100644 --- a/vm/types/src/on_chain_config/vm_config.rs +++ b/vm/types/src/on_chain_config/vm_config.rs @@ -14,13 +14,13 @@ use starcoin_crypto::HashValue; pub const SCRIPT_HASH_LENGTH: usize = HashValue::LENGTH; const VM_CONFIG_MODULE_NAME: &str = "VMConfig"; -pub static VM_CONFIG_IDENTIFIER: Lazy = +pub static G_VM_CONFIG_IDENTIFIER: Lazy = Lazy::new(|| Identifier::new(VM_CONFIG_MODULE_NAME).unwrap()); -pub static INSTRUCTION_SCHEDULE_IDENTIFIER: Lazy = +pub static G_INSTRUCTION_SCHEDULE_IDENTIFIER: Lazy = Lazy::new(|| Identifier::new("instruction_schedule").unwrap()); -pub static NATIVE_SCHEDULE_IDENTIFIER: Lazy = +pub static G_NATIVE_SCHEDULE_IDENTIFIER: Lazy = Lazy::new(|| Identifier::new("native_schedule").unwrap()); -pub static GAS_CONSTANTS_IDENTIFIER: Lazy = +pub static G_GAS_CONSTANTS_IDENTIFIER: Lazy = Lazy::new(|| Identifier::new("gas_constants").unwrap()); /// Defines and holds the publishing policies for the VM. There are three possible configurations: @@ -133,8 +133,8 @@ impl OnChainConfig for VMConfig { pub fn vm_config_type_tag() -> TypeTag { TypeTag::Struct(StructTag { address: CORE_CODE_ADDRESS, - module: VM_CONFIG_IDENTIFIER.clone(), - name: VM_CONFIG_IDENTIFIER.clone(), + module: G_VM_CONFIG_IDENTIFIER.clone(), + name: G_VM_CONFIG_IDENTIFIER.clone(), type_params: vec![], }) } diff --git a/vm/types/src/sips.rs b/vm/types/src/sips.rs index c32067d986..1ec1312883 100644 --- a/vm/types/src/sips.rs +++ b/vm/types/src/sips.rs @@ -25,16 +25,16 @@ impl SIP { } } -pub static SIP_2: SIP = SIP { +pub static G_SIP_2: SIP = SIP { id: 2, module_name: "SIP_2", url: "https://github.com/starcoinorg/SIPs/tree/master/sip-1", }; -pub static SIP_3: SIP = SIP { +pub static G_SIP_3: SIP = SIP { id: 3, module_name: "SIP_3", url: "https://github.com/starcoinorg/SIPs/tree/master/sip-1", }; -pub static SIPS: Lazy> = Lazy::new(|| vec![SIP_2, SIP_3]); +pub static G_SIPS: Lazy> = Lazy::new(|| vec![G_SIP_2, G_SIP_3]); diff --git a/vm/types/src/token/stc.rs b/vm/types/src/token/stc.rs index 3f2c42ac7e..67a291ba3b 100644 --- a/vm/types/src/token/stc.rs +++ b/vm/types/src/token/stc.rs @@ -15,17 +15,17 @@ use std::str::FromStr; pub const STC_NAME: &str = "STC"; pub const STC_TOKEN_CODE_STR: &str = "0x1::STC::STC"; -pub static STC_TOKEN_CODE: Lazy = Lazy::new(|| { +pub static G_STC_TOKEN_CODE: Lazy = Lazy::new(|| { TokenCode::from_str(STC_TOKEN_CODE_STR).expect("Parse STC token code should success.") }); -static STC_IDENTIFIER: Lazy = Lazy::new(|| Identifier::new(STC_NAME).unwrap()); +static G_STC_IDENTIFIER: Lazy = Lazy::new(|| Identifier::new(STC_NAME).unwrap()); pub fn stc_type_tag() -> TypeTag { TypeTag::Struct(StructTag { address: CORE_CODE_ADDRESS, - module: STC_IDENTIFIER.clone(), - name: STC_IDENTIFIER.clone(), + module: G_STC_IDENTIFIER.clone(), + name: G_STC_IDENTIFIER.clone(), type_params: vec![], }) } @@ -40,10 +40,10 @@ pub const SYMBOL_MICROSTC_LOWER: &str = "microstc"; pub const SYMBOL_MILLISTC_LOWER: &str = "millistc"; pub const SYMBOL_STC_LOWER: &str = "stc"; -pub static SCALE_NANOSTC: u32 = 0; -pub static SCALE_MICROSTC: u32 = 3; -pub static SCALE_MILLISTC: u32 = 6; -pub static SCALE_STC: u32 = 9; +pub static G_SCALE_NANOSTC: u32 = 0; +pub static G_SCALE_MICROSTC: u32 = 3; +pub static G_SCALE_MILLISTC: u32 = 6; +pub static G_SCALE_STC: u32 = 9; #[derive(Clone, Copy, Debug)] #[allow(clippy::upper_case_acronyms)] @@ -110,10 +110,10 @@ impl TokenUnit for STCUnit { fn scale(&self) -> u32 { match self { - Self::NanoSTC => SCALE_NANOSTC, - Self::MicroSTC => SCALE_MICROSTC, - Self::MilliSTC => SCALE_MILLISTC, - Self::STC => SCALE_STC, + Self::NanoSTC => G_SCALE_NANOSTC, + Self::MicroSTC => G_SCALE_MICROSTC, + Self::MilliSTC => G_SCALE_MILLISTC, + Self::STC => G_SCALE_STC, } } } diff --git a/vm/types/src/token/token_code.rs b/vm/types/src/token/token_code.rs index b9cb98eebe..5a7dd248c2 100644 --- a/vm/types/src/token/token_code.rs +++ b/vm/types/src/token/token_code.rs @@ -147,7 +147,7 @@ impl Serialize for TokenCode { mod test { use crate::language_storage::{StructTag, TypeTag}; use crate::parser::parse_type_tag; - use crate::token::stc::STC_TOKEN_CODE; + use crate::token::stc::G_STC_TOKEN_CODE; use crate::token::token_code::TokenCode; use serde::{Deserialize, Serialize}; use std::convert::TryInto; @@ -174,7 +174,7 @@ mod test { #[test] fn test_token_serialize() { let setting = Setting { - default_token: STC_TOKEN_CODE.clone(), + default_token: G_STC_TOKEN_CODE.clone(), }; let json = serde_json::to_string(&setting).unwrap(); let setting2: Setting = serde_json::from_str(json.as_str()).unwrap(); diff --git a/vm/vm-runtime/src/errors.rs b/vm/vm-runtime/src/errors.rs index 42a28d6cb7..34937d01ba 100644 --- a/vm/vm-runtime/src/errors.rs +++ b/vm/vm-runtime/src/errors.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use starcoin_logger::prelude::*; -use starcoin_vm_types::account_config::ACCOUNT_MODULE; +use starcoin_vm_types::account_config::G_ACCOUNT_MODULE; use starcoin_vm_types::errors::VMError; use starcoin_vm_types::vm_status::{AbortLocation, StatusCode, VMStatus}; @@ -136,5 +136,5 @@ pub fn convert_normal_success_epilogue_error(error: VMError) -> Result<(), VMSta } fn account_module_abort() -> AbortLocation { - AbortLocation::Module(ACCOUNT_MODULE.clone()) + AbortLocation::Module(G_ACCOUNT_MODULE.clone()) } diff --git a/vm/vm-runtime/src/starcoin_vm.rs b/vm/vm-runtime/src/starcoin_vm.rs index 33f21d2be3..9e30e3f979 100644 --- a/vm/vm-runtime/src/starcoin_vm.rs +++ b/vm/vm-runtime/src/starcoin_vm.rs @@ -14,7 +14,7 @@ use move_vm_runtime::move_vm::MoveVM; use move_vm_runtime::move_vm_adapter::{PublishModuleBundleOption, SessionAdapter}; use move_vm_runtime::session::Session; use once_cell::sync::Lazy; -use starcoin_config::LATEST_GAS_SCHEDULE; +use starcoin_config::G_LATEST_GAS_SCHEDULE; use starcoin_logger::prelude::*; use starcoin_types::account_config::config_change::ConfigChangeEvent; use starcoin_types::account_config::{ @@ -34,7 +34,7 @@ use starcoin_vm_types::account_address::AccountAddress; use starcoin_vm_types::account_config::upgrade::UpgradeEvent; use starcoin_vm_types::account_config::{ core_code_address, genesis_address, ModuleUpgradeStrategy, TwoPhaseUpgradeV2Resource, - EPILOGUE_NAME, EPILOGUE_V2_NAME, PROLOGUE_NAME, + G_EPILOGUE_NAME, G_EPILOGUE_V2_NAME, G_PROLOGUE_NAME, }; use starcoin_vm_types::contract_event::ContractEvent; use starcoin_vm_types::file_format::{CompiledModule, CompiledScript}; @@ -44,8 +44,8 @@ use starcoin_vm_types::genesis_config::StdlibVersion; use starcoin_vm_types::identifier::IdentStr; use starcoin_vm_types::language_storage::ModuleId; use starcoin_vm_types::on_chain_config::{ - MoveLanguageVersion, GAS_CONSTANTS_IDENTIFIER, INSTRUCTION_SCHEDULE_IDENTIFIER, - NATIVE_SCHEDULE_IDENTIFIER, VM_CONFIG_IDENTIFIER, + MoveLanguageVersion, G_GAS_CONSTANTS_IDENTIFIER, G_INSTRUCTION_SCHEDULE_IDENTIFIER, + G_NATIVE_SCHEDULE_IDENTIFIER, G_VM_CONFIG_IDENTIFIER, }; use starcoin_vm_types::transaction::{DryRunTransaction, Package, TransactionPayloadType}; use starcoin_vm_types::transaction_metadata::TransactionPayloadMetadata; @@ -67,7 +67,7 @@ use starcoin_vm_types::{ use std::convert::{TryFrom, TryInto}; use std::sync::Arc; -static ZERO_COST_SCHEDULE: Lazy = +static G_ZERO_COST_SCHEDULE: Lazy = Lazy::new(|| zero_cost_schedule(NativeCostIndex::NUMBER_OF_NATIVE_FUNCTIONS)); #[derive(Clone)] @@ -100,7 +100,7 @@ impl StarcoinVM { pub fn load_configs(&mut self, state: &dyn StateView) -> Result<(), Error> { if state.is_genesis() { self.vm_config = Some(VMConfig { - gas_schedule: LATEST_GAS_SCHEDULE.clone(), + gas_schedule: G_LATEST_GAS_SCHEDULE.clone(), }); self.version = Some(Version { major: 1 }); Ok(()) @@ -140,8 +140,8 @@ impl StarcoinVM { let data = self .execute_readonly_function( state, - &ModuleId::new(core_code_address(), VM_CONFIG_IDENTIFIER.to_owned()), - INSTRUCTION_SCHEDULE_IDENTIFIER.as_ident_str(), + &ModuleId::new(core_code_address(), G_VM_CONFIG_IDENTIFIER.to_owned()), + G_INSTRUCTION_SCHEDULE_IDENTIFIER.as_ident_str(), vec![], vec![], )? @@ -157,8 +157,8 @@ impl StarcoinVM { let data = self .execute_readonly_function( state, - &ModuleId::new(core_code_address(), VM_CONFIG_IDENTIFIER.to_owned()), - NATIVE_SCHEDULE_IDENTIFIER.as_ident_str(), + &ModuleId::new(core_code_address(), G_VM_CONFIG_IDENTIFIER.to_owned()), + G_NATIVE_SCHEDULE_IDENTIFIER.as_ident_str(), vec![], vec![], )? @@ -172,8 +172,8 @@ impl StarcoinVM { let data = self .execute_readonly_function( state, - &ModuleId::new(core_code_address(), VM_CONFIG_IDENTIFIER.to_owned()), - GAS_CONSTANTS_IDENTIFIER.as_ident_str(), + &ModuleId::new(core_code_address(), G_VM_CONFIG_IDENTIFIER.to_owned()), + G_GAS_CONSTANTS_IDENTIFIER.as_ident_str(), vec![], vec![], )? @@ -649,8 +649,8 @@ impl StarcoinVM { session .as_mut() .execute_function( - &account_config::TRANSACTION_MANAGER_MODULE, - &PROLOGUE_NAME, + &account_config::G_TRANSACTION_MANAGER_MODULE, + &G_PROLOGUE_NAME, vec![gas_token_ty], serialize_values(&vec![ MoveValue::Signer(genesis_address), @@ -710,7 +710,7 @@ impl StarcoinVM { // From stdlib v5, the epilogue function add `txn_authentication_key_preimage` argument, change to epilogue_v2 let (function_name, args) = if stdlib_version > StdlibVersion::Version(4) { ( - &EPILOGUE_V2_NAME, + &G_EPILOGUE_V2_NAME, serialize_values(&vec![ MoveValue::Signer(genesis_address), MoveValue::Address(txn_data.sender), @@ -727,7 +727,7 @@ impl StarcoinVM { ) } else { ( - &EPILOGUE_NAME, + &G_EPILOGUE_NAME, serialize_values(&vec![ MoveValue::Signer(genesis_address), MoveValue::Address(txn_data.sender), @@ -745,7 +745,7 @@ impl StarcoinVM { session .as_mut() .execute_function( - &account_config::TRANSACTION_MANAGER_MODULE, + &account_config::G_TRANSACTION_MANAGER_MODULE, function_name, vec![gas_token_ty], args, @@ -763,7 +763,7 @@ impl StarcoinVM { let txn_sender = account_config::genesis_address(); // always use 0 gas for system. let max_gas_amount = GasUnits::new(0); - let cost_table = &ZERO_COST_SCHEDULE; + let cost_table = &G_ZERO_COST_SCHEDULE; let mut gas_status = { let mut gas_status = GasStatus::new(cost_table, max_gas_amount); gas_status.set_metering(false); @@ -798,8 +798,8 @@ impl StarcoinVM { session .as_mut() .execute_function( - &account_config::TRANSACTION_MANAGER_MODULE, - &account_config::BLOCK_PROLOGUE_NAME, + &account_config::G_TRANSACTION_MANAGER_MODULE, + &account_config::G_BLOCK_PROLOGUE_NAME, vec![], args, &mut gas_status, @@ -824,7 +824,7 @@ impl StarcoinVM { Ok(gas_schedule) => gas_schedule, Err(e) => { if remote_cache.is_genesis() { - &LATEST_GAS_SCHEDULE + &G_LATEST_GAS_SCHEDULE } else { return discard_error_vm_status(e); } @@ -914,7 +914,7 @@ impl StarcoinVM { Ok(gas_schedule) => gas_schedule, Err(e) => { if remote_cache.is_genesis() { - &LATEST_GAS_SCHEDULE + &G_LATEST_GAS_SCHEDULE } else { return Ok(discard_error_vm_status(e)); } @@ -1104,7 +1104,7 @@ impl StarcoinVM { }); let data_cache = StateViewCache::new(state_view); - let cost_table = &ZERO_COST_SCHEDULE; + let cost_table = &G_ZERO_COST_SCHEDULE; let mut gas_status = { let mut gas_status = GasStatus::new(cost_table, GasUnits::new(0)); gas_status.set_metering(false);