Closed Flouse closed 1 year ago
use ckb_fixed_hash::{H160, H256}; use gw_jsonrpc_types::{ blockchain::{CellDep, Script}, ckb_jsonrpc_types::JsonBytes, godwoken::{ChallengeTargetType, L2BlockCommittedInfo, RollupConfig}, }; use serde::{Deserialize, Serialize}; use std::{ cmp::min, collections::{HashMap, HashSet}, path::PathBuf, };
pub enum Trace { Jaeger, TokioConsole, }
pub struct Config {
pub node_mode: NodeMode,
#[serde(default)]
pub contract_log_config: ContractLogConfig,
pub backend_switches: Vec
pub enum RPCMethods { PProf, Test, }
pub struct RPCServerConfig {
pub listen: String,
#[serde(default)]
pub enable_methods: HashSet
pub struct RPCClientConfig { pub indexer_url: String, pub ckb_url: String, }
pub struct RPCConfig {
pub allowed_sudt_proxy_creator_account_id: Vec
pub struct RPCRateLimit { pub seconds: u64, pub lru_size: usize, }
/// Onchain rollup cell config
pub struct ChainConfig {
/// Ignore invalid state caused by blocks
#[serde(default)]
pub skipped_invalid_block_list: Vec
/// Genesis config
pub struct GenesisConfig { pub timestamp: u64, pub rollup_type_hash: H256, pub meta_contract_validator_type_hash: H256, pub eth_registry_validator_type_hash: H256, pub rollup_config: RollupConfig, // For load secp data and use in challenge transaction pub secp_data_dep: CellDep, }
pub struct WalletConfig { pub privkey_path: PathBuf, pub lock: Script, }
// NOTE: Rewards receiver lock must be different than lock in WalletConfig, // since stake_capacity(minus burnt) + challenge_capacity - tx_fee will never // bigger or equal than stake_capacity(minus burnt) + challenge_capacity. // TODO: Support sudt stake ?
pub struct ChallengerConfig { pub rewards_receiver_lock: Script, pub burn_lock: Script, }
pub struct ContractTypeScriptConfig { pub state_validator: Script, pub deposit_lock: Script, pub stake_lock: Script, pub custodian_lock: Script, pub withdrawal_lock: Script, pub challenge_lock: Script, pub l1_sudt: Script, pub omni_lock: Script, pub allowed_eoa_scripts: HashMap<H256, Script>, pub allowed_contract_scripts: HashMap<H256, Script>, }
pub struct ContractsCellDep { pub rollup_cell_type: CellDep, pub deposit_cell_lock: CellDep, pub stake_cell_lock: CellDep, pub custodian_cell_lock: CellDep, pub withdrawal_cell_lock: CellDep, pub challenge_cell_lock: CellDep, pub l1_sudt_type: CellDep, pub omni_lock: CellDep, pub allowed_eoa_locks: HashMap<H256, CellDep>, pub allowed_contract_types: HashMap<H256, CellDep>, }
pub struct ConsensusConfig { pub contract_type_scripts: ContractTypeScriptConfig, }
pub struct RegistryAddressConfig { pub registry_id: u32, pub address: JsonBytes, }
pub struct BlockProducerConfig {
#[serde(default = "default_check_mem_block_before_submit")]
pub check_mem_block_before_submit: bool,
pub block_producer: RegistryAddressConfig,
pub rollup_config_cell_dep: CellDep,
pub challenger_config: ChallengerConfig,
#[serde(default = "default_block_producer_wallet")]
pub wallet_config: Option
const fn default_check_mem_block_before_submit() -> bool { false }
const fn default_withdrawal_unlocker_wallet() -> Option
const fn default_block_producer_wallet() -> Option
pub enum BackendType { Meta, Sudt, Polyjuice, EthAddrReg, Unknown, }
impl Default for BackendType { fn default() -> Self { BackendType::Unknown } }
pub struct BackendSwitchConfig {
pub switch_height: u64,
pub backends: Vec
pub struct BackendConfig { pub validator_path: PathBuf, pub generator_path: PathBuf, pub validator_script_type_hash: H256, pub backend_type: BackendType, }
pub struct DebugConfig { pub output_l1_tx_cycles: bool, pub expected_l1_tx_upper_bound_cycles: u64, /// Directory to save debugging info of l1 transactions pub debug_tx_dump_path: PathBuf, #[serde(default = "default_enable_debug_rpc")] pub enable_debug_rpc: bool, }
// Field default value for backward config file compitability fn default_enable_debug_rpc() -> bool { false }
impl Default for DebugConfig { fn default() -> Self { const EXPECTED_TX_UPPER_BOUND_CYCLES: u64 = 350000000u64; const DEFAULT_DEBUG_TX_DUMP_PATH: &str = "debug-tx-dump";
Self { debug_tx_dump_path: DEFAULT_DEBUG_TX_DUMP_PATH.into(), output_l1_tx_cycles: true, expected_l1_tx_upper_bound_cycles: EXPECTED_TX_UPPER_BOUND_CYCLES, enable_debug_rpc: false, } } }
pub struct OffChainValidatorConfig { pub verify_withdrawal_signature: bool, pub verify_tx_signature: bool, pub verify_tx_execution: bool, pub verify_max_cycles: u64, pub dump_tx_on_failure: bool, }
impl Default for OffChainValidatorConfig { fn default() -> Self { Self { verify_withdrawal_signature: true, verify_tx_signature: true, verify_tx_execution: true, verify_max_cycles: 70_000_000, dump_tx_on_failure: true, } } }
pub struct P2PNetworkConfig {
/// Multiaddr listen address, e.g. /ip4/1.2.3.4/tcp/443
#[serde(default)]
pub listen: Option
pub struct PublishMemPoolConfig {
pub hosts: Vec
pub struct SubscribeMemPoolConfig {
pub hosts: Vec
pub struct MemPoolConfig {
pub execute_l2tx_max_cycles: u64,
#[serde(default = "default_restore_path")]
pub restore_path: PathBuf,
pub publish: Option
pub struct MemBlockConfig { pub max_deposits: usize, pub max_withdrawals: usize, pub max_txs: usize, #[serde( default = "default_max_block_cycles_limit", with = "toml_u64_serde_workaround" )] pub max_cycles_limit: u64, #[serde(default = "default_syscall_cycles")] pub syscall_cycles: SyscallCyclesConfig, }
const fn default_max_block_cycles_limit() -> u64 { u64::MAX }
fn default_syscall_cycles() -> SyscallCyclesConfig { SyscallCyclesConfig::all_zero() }
// Workaround: https://github.com/alexcrichton/toml-rs/issues/256 // Serialize to string instead mod toml_u64_serde_workaround { use serde::{Deserialize, Deserializer, Serializer};
pub fn serialize<S: Serializer>(val: &u64, s: S) -> Result<S::Ok, S::Error> { s.serialize_str(&val.to_string()) }
pub fn deserialize<'de, D>(deserializer: D) -> Result<u64, D::Error>
where
D: Deserializer<'de>,
{
let s: &str = Deserialize::deserialize(deserializer)?;
s.parse::
// Field default value for backward config file compitability fn default_restore_path() -> PathBuf { const DEFAULT_RESTORE_PATH: &str = "mem_block";
DEFAULT_RESTORE_PATH.into() }
impl Default for MemPoolConfig { fn default() -> Self { Self { execute_l2tx_max_cycles: 100_000_000, restore_path: default_restore_path(), publish: None, subscribe: None, mem_block: MemBlockConfig::default(), } } }
impl Default for MemBlockConfig { fn default() -> Self { Self { max_deposits: 100, max_withdrawals: 100, max_txs: 1000, max_cycles_limit: default_max_block_cycles_limit(), syscall_cycles: SyscallCyclesConfig::all_zero(), } } }
pub enum NodeMode { FullNode, Test, ReadOnly, }
impl Default for NodeMode { fn default() -> Self { NodeMode::ReadOnly } }
pub struct DBBlockValidatorConfig { pub verify_max_cycles: u64, pub parallel_verify_blocks: bool, pub replace_scripts: Option<HashMap<H256, PathBuf>>, pub skip_targets: Option<HashSet<(u64, ChallengeTargetType, u32)>>, }
impl Default for DBBlockValidatorConfig { fn default() -> Self { Self { verify_max_cycles: 7000_0000, replace_scripts: None, skip_targets: None, parallel_verify_blocks: true, } } }
pub struct StoreConfig {
#[serde(default)]
pub path: PathBuf,
#[serde(default)]
pub cache_size: Option
pub struct FeeConfig { // fee_rate: fee / cycles limit pub meta_cycles_limit: u64, // fee_rate: fee / cycles limit pub sudt_cycles_limit: u64, // fee_rate: fee / cycles_limit pub eth_addr_reg_cycles_limit: u64, // fee_rate: fee / cycles limit pub withdraw_cycles_limit: u64, }
impl FeeConfig { pub fn minimal_tx_cycles_limit(&self) -> u64 { min( min(self.meta_cycles_limit, self.sudt_cycles_limit), self.eth_addr_reg_cycles_limit, ) } }
impl Default for FeeConfig { fn default() -> Self { // CKB default weight is 1000 / 1000 Self { // 20K cycles unified for simple Godwoken native contracts meta_cycles_limit: 20000, sudt_cycles_limit: 20000, withdraw_cycles_limit: 20000, eth_addr_reg_cycles_limit: 20000, // 1176198 cycles used } } }
pub struct GithubConfigUrl { pub org: String, pub repo: String, pub branch: String, pub path: String, pub token: String, }
// Configs in DynamicConfig can be hot reloaded from remote. But GithubConfigUrl must be setup.
pub struct DynamicConfig { pub fee_config: FeeConfig, pub rpc_config: RPCConfig, }
pub enum ContractLogConfig { Verbose, Error, }
impl Default for ContractLogConfig { fn default() -> Self { ContractLogConfig::Verbose } }
// Cycles config for all db related syscalls
pub struct SyscallCyclesConfig { pub sys_store_cycles: u64, pub sys_load_cycles: u64, pub sys_create_cycles: u64, pub sys_load_account_script_cycles: u64, pub sys_store_data_cycles: u64, pub sys_load_data_cycles: u64, pub sys_get_block_hash_cycles: u64, pub sys_recover_account_cycles: u64, pub sys_log_cycles: u64, }
impl SyscallCyclesConfig { pub fn all_zero() -> Self { SyscallCyclesConfig { sys_store_cycles: 0, sys_load_cycles: 0, sys_create_cycles: 0, sys_load_account_script_cycles: 0, sys_store_data_cycles: 0, sys_load_data_cycles: 0, sys_get_block_hash_cycles: 0, sys_recover_account_cycles: 0, sys_log_cycles: 0, } } }
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
Let's write down the comment/description of every config.