From 9087dd14c047d2523725ef5d20cf4e24371adcad Mon Sep 17 00:00:00 2001 From: iosh Date: Mon, 2 Dec 2024 21:42:47 +0800 Subject: [PATCH] chore: add config to enable internal contracts --- __test__/genesis.test.ts | 6 +++--- conflux.d.ts | 16 ++++++++++++++-- src/config.rs | 14 +++++++++++++- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/__test__/genesis.test.ts b/__test__/genesis.test.ts index 34786be..d6bb1ab 100644 --- a/__test__/genesis.test.ts +++ b/__test__/genesis.test.ts @@ -1,9 +1,9 @@ import { http, createPublicClient, parseCFX } from "cive"; -import { describe, expect, test } from "vitest"; -import { createServer } from "../index"; -import { getFreePorts, TEST_NETWORK_ID, TEST_PK } from "./help"; import { privateKeyToAccount } from "cive/accounts"; import { base32AddressToHex } from "cive/utils"; +import { describe, expect, test } from "vitest"; +import { createServer } from "../index"; +import { TEST_NETWORK_ID, TEST_PK, getFreePorts } from "./help"; describe("genesis", () => { test("default", async () => { diff --git a/conflux.d.ts b/conflux.d.ts index 3cea494..8025321 100644 --- a/conflux.d.ts +++ b/conflux.d.ts @@ -26,9 +26,11 @@ export interface ConfluxConfig { */ stratumListenAddress?: string /** - * Port for stratum. - * @default 32525 + * `mining_type` is the type of mining. + * stratum | cpu | disable */ + miningType?: string + /** Port for stratum. */ stratumPort?: number /** log_conf` the path of the log4rs configuration file. The configuration in the file will overwrite the value set by `log_level`. */ logConf?: string @@ -100,6 +102,16 @@ export interface ConfluxConfig { defaultTransitionTime?: number /** @default:3 */ cip1559TransitionHeight?: number + /** + * Enable CIP43A, CIP64, CIP71, CIP78A, CIP92 after hydra_transition_number + * @default:1 + */ + hydraTransitionNumber?: number + /** + * Enable cip76, cip86 after hydra_transition_height + * @default:1 + */ + hydraTransitionHeight?: number /** @default: temp dir */ confluxDataDir?: string /** pos config path */ diff --git a/src/config.rs b/src/config.rs index dbbf4ea..f810004 100644 --- a/src/config.rs +++ b/src/config.rs @@ -26,8 +26,10 @@ pub struct ConfluxConfig { /// Listen address for stratum /// @default "127.0.0.1" pub stratum_listen_address: Option, + /// `mining_type` is the type of mining. + /// stratum | cpu | disable + pub mining_type: Option, /// Port for stratum. - /// @default 32525 pub stratum_port: Option, /// log_conf` the path of the log4rs configuration file. The configuration in the file will overwrite the value set by `log_level`. pub log_conf: Option, @@ -79,6 +81,12 @@ pub struct ConfluxConfig { pub default_transition_time: Option, /// @default:3 pub cip1559_transition_height: Option, + /// Enable CIP43A, CIP64, CIP71, CIP78A, CIP92 after hydra_transition_number + /// @default:1 + pub hydra_transition_number: Option, + /// Enable cip76, cip86 after hydra_transition_height + /// @default:1 + pub hydra_transition_height: Option, /// @default: temp dir pub conflux_data_dir: Option, /// pos config path @@ -205,6 +213,9 @@ pub fn convert_config(js_config: ConfluxConfig, temp_dir_path: &Path) -> Configu conf.raw_conf.cip1559_transition_height = Some(js_config.cip1559_transition_height.unwrap_or(2) as u64); + conf.raw_conf.hydra_transition_number = + Some(js_config.hydra_transition_number.unwrap_or(1) as u64); + conf.raw_conf.hydra_transition_height = Some(js_config.hydra_transition_height.unwrap_or(1) as u64); conf.raw_conf.poll_lifetime_in_seconds = js_config.poll_lifetime_in_seconds; @@ -238,6 +249,7 @@ pub fn convert_config(js_config: ConfluxConfig, temp_dir_path: &Path) -> Configu .unwrap_or("127.0.0.1".to_string()); conf.raw_conf.jsonrpc_ws_port = js_config.jsonrpc_ws_port; + conf.raw_conf.mining_type = js_config.mining_type; conf.raw_conf.jsonrpc_http_port = js_config.jsonrpc_http_port; conf.raw_conf.stratum_port = js_config.stratum_port.unwrap_or(32525);