Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: get_node_info rpc for more useful configs #674

Merged
merged 5 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/block-producer/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,8 @@ pub async fn run(config: Config, skip_config_check: bool) -> Result<()> {
generator,
tests_rpc_impl: test_mode_control.map(Box::new),
rollup_config,
chain_config: config.chain.to_owned(),
consensus_config: config.consensus.to_owned(),
mem_pool_config: config.mem_pool.clone(),
node_mode: config.node_mode,
rpc_client: rpc_client.clone(),
Expand Down
103 changes: 102 additions & 1 deletion crates/jsonrpc-types/src/godwoken.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1176,9 +1176,27 @@ impl From<offchain::RunResult> for RunResult {
#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Default)]
#[serde(rename_all = "snake_case")]
pub struct NodeInfo {
// godwoken current version
pub mode: NodeMode,
pub version: String,
pub backends: Vec<BackendInfo>,
pub eoa_scripts: Vec<EoaScript>,
pub gw_scripts: Vec<GwScript>,
pub rollup_cell: RollupCell,
pub rollup_config: NodeRollupConfig,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug)]
#[serde(rename_all = "lowercase")]
pub enum NodeMode {
FullNode,
Test,
ReadOnly,
}

impl Default for NodeMode {
fn default() -> Self {
NodeMode::ReadOnly
}
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Default)]
Expand All @@ -1187,8 +1205,91 @@ pub struct BackendInfo {
pub validator_code_hash: H256,
pub generator_code_hash: H256,
pub validator_script_type_hash: H256,
pub backend_type: BackendType,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug)]
#[serde(rename_all = "snake_case")]
pub enum BackendType {
Unknown,
Meta,
Sudt,
Polyjuice,
EthAddrReg,
}

impl Default for BackendType {
fn default() -> Self {
BackendType::Unknown
}
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Default)]
#[serde(rename_all = "snake_case")]
pub struct GwScript {
pub type_hash: H256,
pub script: Script,
pub script_type: GwScriptType,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug)]
#[serde(rename_all = "snake_case")]
pub enum GwScriptType {
Unknown,
Deposit,
Withdraw,
StateValidator,
StakeLock,
CustodianLock,
ChallengeLock,
L1Sudt,
L2Sudt,
OmniLock,
}

impl Default for GwScriptType {
fn default() -> Self {
GwScriptType::Unknown
}
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Default)]
#[serde(rename_all = "snake_case")]
pub struct RollupCell {
RetricSu marked this conversation as resolved.
Show resolved Hide resolved
pub type_hash: H256,
pub script: Script,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Default)]
#[serde(rename_all = "snake_case")]
pub struct NodeRollupConfig {
pub required_staking_capacity: Uint64,
pub challenge_maturity_blocks: Uint64,
pub finality_blocks: Uint64,
pub reward_burn_rate: Uint32,
pub chain_id: Uint64,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Default)]
#[serde(rename_all = "snake_case")]
pub struct EoaScript {
pub type_hash: H256,
RetricSu marked this conversation as resolved.
Show resolved Hide resolved
pub script: Script,
pub eoa_type: EoaScriptType,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug)]
#[serde(rename_all = "snake_case")]
pub enum EoaScriptType {
Unknown,
Eth,
}

impl Default for EoaScriptType {
fn default() -> Self {
EoaScriptType::Unknown
}
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Default)]
#[serde(rename_all = "snake_case")]
pub struct ErrorTxReceipt {
Expand Down
Loading