diff --git a/.github/workflows/axon-start-with-short-genesis.yml b/.github/workflows/axon-start-with-short-genesis.yml index c966eae64..e160b59af 100644 --- a/.github/workflows/axon-start-with-short-genesis.yml +++ b/.github/workflows/axon-start-with-short-genesis.yml @@ -42,7 +42,6 @@ jobs: target/debug/axon init \ --config devtools/chain/config.toml \ --chain-spec devtools/chain/specs/single_node/chain-spec.toml \ - --key-file devtools/chain/debug.key \ | tee -a ${{ env.LOG_FILE }} target/debug/axon run \ --config devtools/chain/config.toml \ @@ -74,7 +73,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - + - name: Cache of Cargo uses: actions/cache@v3 with: @@ -102,7 +101,6 @@ jobs: target/debug/axon init \ --config devtools/chain/nodes/node_${id}.toml \ --chain-spec devtools/chain/specs/multi_nodes_short_epoch_len/chain-spec.toml \ - --key-file devtools/chain/debug.key \ > ${{ env.LOG_PATH }}/node_${id}.log done diff --git a/.github/workflows/openzeppelin_test_11.yml b/.github/workflows/openzeppelin_test_11.yml index 0cc5af716..8bc5b712d 100644 --- a/.github/workflows/openzeppelin_test_11.yml +++ b/.github/workflows/openzeppelin_test_11.yml @@ -113,7 +113,6 @@ jobs: ./target/debug/axon init \ --config devtools/chain/config.toml \ --chain-spec devtools/chain/specs/single_node/chain-spec.toml \ - --key-file devtools/chain/debug.key \ > /tmp/log 2>&1 ./target/debug/axon run \ --config devtools/chain/config.toml \ diff --git a/.github/workflows/openzeppelin_test_16_19.yml b/.github/workflows/openzeppelin_test_16_19.yml index f41132037..684795f3b 100644 --- a/.github/workflows/openzeppelin_test_16_19.yml +++ b/.github/workflows/openzeppelin_test_16_19.yml @@ -113,7 +113,6 @@ jobs: ./target/debug/axon init \ --config devtools/chain/config.toml \ --chain-spec devtools/chain/specs/single_node/chain-spec.toml \ - --key-file devtools/chain/debug.key \ > /tmp/log 2>&1 ./target/debug/axon run \ --config devtools/chain/config.toml \ diff --git a/.github/workflows/openzeppelin_test_1_5_and_12_15.yml b/.github/workflows/openzeppelin_test_1_5_and_12_15.yml index 90a75db73..87a0276d8 100644 --- a/.github/workflows/openzeppelin_test_1_5_and_12_15.yml +++ b/.github/workflows/openzeppelin_test_1_5_and_12_15.yml @@ -114,7 +114,6 @@ jobs: ./target/debug/axon init \ --config devtools/chain/config.toml \ --chain-spec devtools/chain/specs/single_node/chain-spec.toml \ - --key-file devtools/chain/debug.key \ > /tmp/log 2>&1 ./target/debug/axon run \ --config devtools/chain/config.toml \ diff --git a/.github/workflows/openzeppelin_test_6_10.yml b/.github/workflows/openzeppelin_test_6_10.yml index eeef0a230..7b0a8bba2 100644 --- a/.github/workflows/openzeppelin_test_6_10.yml +++ b/.github/workflows/openzeppelin_test_6_10.yml @@ -113,7 +113,6 @@ jobs: ./target/debug/axon init \ --config devtools/chain/config.toml \ --chain-spec devtools/chain/specs/single_node/chain-spec.toml \ - --key-file devtools/chain/debug.key \ > /tmp/log 2>&1 ./target/debug/axon run \ --config devtools/chain/config.toml \ diff --git a/.github/workflows/somking_test.yml b/.github/workflows/somking_test.yml index fae437e19..0fded8fa7 100644 --- a/.github/workflows/somking_test.yml +++ b/.github/workflows/somking_test.yml @@ -26,7 +26,6 @@ jobs: ./axon init \ --config ${{ github.workspace }}/axon/config.toml \ --chain-spec ${{ github.workspace }}/axon/specs/single_node/chain-spec.toml \ - --key-file ${{ github.workspace }}/axon/debug.key \ > /tmp/log 2>&1 ./axon run \ --config ${{ github.workspace }}/axon/config.toml \ diff --git a/.github/workflows/v3_core_test.yml b/.github/workflows/v3_core_test.yml index 83e685003..1ad9ef8d7 100644 --- a/.github/workflows/v3_core_test.yml +++ b/.github/workflows/v3_core_test.yml @@ -101,7 +101,6 @@ jobs: ./target/debug/axon init \ --config devtools/chain/config.toml \ --chain-spec devtools/chain/specs/single_node/chain-spec.toml \ - --key-file devtools/chain/debug.key \ > /tmp/log 2>&1 ./target/debug/axon run \ --config devtools/chain/config.toml \ diff --git a/.github/workflows/web3_compatible.yml b/.github/workflows/web3_compatible.yml index b7395954f..8def0ce84 100644 --- a/.github/workflows/web3_compatible.yml +++ b/.github/workflows/web3_compatible.yml @@ -71,7 +71,6 @@ jobs: ./target/debug/axon init \ --config devtools/chain/config.toml \ --chain-spec devtools/chain/specs/single_node/chain-spec.toml \ - --key-file devtools/chain/debug.key \ > /tmp/log 2>&1 ./target/debug/axon run \ --config devtools/chain/config.toml \ diff --git a/Makefile b/Makefile index 0e68ea634..dffc707e7 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,6 @@ e2e-test: ./target/debug/axon init \ --config devtools/chain/config.toml \ --chain-spec devtools/chain/specs/single_node/chain-spec.toml \ - --key-file devtools/chain/debug.key \ > /tmp/log 2>&1 ./target/debug/axon run \ --config devtools/chain/config.toml \ diff --git a/README.md b/README.md index d4d873e5c..53805237f 100644 --- a/README.md +++ b/README.md @@ -59,8 +59,7 @@ cargo build --release # Initialize the chain target/release/axon init \ --config devtools/chain/config.toml \ - --chain-spec devtools/chain/specs/single_node/chain-spec.toml \ - --key-file devtools/chain/debug.key + --chain-spec devtools/chain/specs/single_node/chain-spec.toml # Start a single Axon node target/release/axon run --config devtools/chain/config.toml ``` diff --git a/core/cli/src/args/init.rs b/core/cli/src/args/init.rs index e8a822175..39e4b964a 100644 --- a/core/cli/src/args/init.rs +++ b/core/cli/src/args/init.rs @@ -1,9 +1,6 @@ use clap::Parser; -use common_config_parser::types::{ - spec::{ChainSpec, PrivateKey}, - Config, -}; +use common_config_parser::types::{spec::ChainSpec, Config}; use common_version::Version; use crate::{ @@ -28,16 +25,11 @@ pub struct InitArgs { help = "File path of chain spec." )] pub spec: ChainSpec, - - #[command(flatten)] - pub key: PrivateKey, } impl InitArgs { pub(crate) fn execute(self, kernel_version: Version) -> Result<()> { - let Self { config, spec, key } = self; - - let key_data = key.data().map_err(Error::Internal)?; + let Self { config, spec } = self; utils::check_version( &config.data_path_for_version(), @@ -46,6 +38,6 @@ impl InitArgs { )?; utils::register_log(&config); - core_run::init(config, spec, key_data).map_err(Error::Running) + core_run::init(config, spec).map_err(Error::Running) } } diff --git a/core/run/src/components/chain_spec.rs b/core/run/src/components/chain_spec.rs index bf91c578f..0d0bf34b5 100644 --- a/core/run/src/components/chain_spec.rs +++ b/core/run/src/components/chain_spec.rs @@ -1,5 +1,4 @@ use common_config_parser::types::spec::ChainSpec; -use common_crypto::Secp256k1RecoverablePrivateKey; use protocol::types::{ Block, Eip1559Transaction, RichBlock, TransactionAction, UnsignedTransaction, BASE_FEE_PER_GAS, @@ -7,11 +6,11 @@ use protocol::types::{ pub(crate) trait ChainSpecExt { //! Generate the genesis block. - fn generate_genesis_block(&self, genesis_key: Secp256k1RecoverablePrivateKey) -> RichBlock; + fn generate_genesis_block(&self) -> RichBlock; } impl ChainSpecExt for ChainSpec { - fn generate_genesis_block(&self, _genesis_key: Secp256k1RecoverablePrivateKey) -> RichBlock { + fn generate_genesis_block(&self) -> RichBlock { let txs = vec![]; let block = Block { header: self.genesis.build_header(), diff --git a/core/run/src/lib.rs b/core/run/src/lib.rs index 99381440e..068548781 100644 --- a/core/run/src/lib.rs +++ b/core/run/src/lib.rs @@ -3,10 +3,7 @@ use std::{collections::HashMap, sync::Arc, time::Duration}; use common_apm::metrics::mempool::{MEMPOOL_CO_QUEUE_LEN, MEMPOOL_LEN_GAUGE}; use common_config_parser::types::spec::{ChainSpec, InitialAccount}; use common_config_parser::types::{Config, ConfigMempool}; -use common_crypto::{ - BlsPrivateKey, BlsPublicKey, Secp256k1, Secp256k1PrivateKey, Secp256k1RecoverablePrivateKey, - ToPublicKey, -}; +use common_crypto::{BlsPrivateKey, BlsPublicKey, Secp256k1, Secp256k1PrivateKey, ToPublicKey}; use protocol::tokio::{ self, runtime::Builder as RuntimeBuilder, sync::Mutex as AsyncMutex, time::sleep, @@ -50,12 +47,8 @@ use components::{ pub use error::MainError; use key_provider::KeyP; -pub fn init( - config: Config, - spec: ChainSpec, - key: Secp256k1RecoverablePrivateKey, -) -> ProtocolResult<()> { - let genesis = spec.generate_genesis_block(key); +pub fn init(config: Config, spec: ChainSpec) -> ProtocolResult<()> { + let genesis = spec.generate_genesis_block(); let path_rocksdb = config.data_path_for_rocksdb(); if path_rocksdb.exists() { diff --git a/core/run/src/tests.rs b/core/run/src/tests.rs index 746b158e5..f22a9081a 100644 --- a/core/run/src/tests.rs +++ b/core/run/src/tests.rs @@ -12,10 +12,9 @@ use clap::{builder::TypedValueParser as _, Command}; use hasher::HasherKeccak; use common_config_parser::types::{ - spec::{ChainSpec, ChainSpecValueParser, PrivateKeyFileValueParser}, + spec::{ChainSpec, ChainSpecValueParser}, Config, ConfigValueParser, }; -use common_crypto::Secp256k1RecoverablePrivateKey; use core_executor::{ system_contract::metadata::{segment::EpochSegment, EPOCH_SEGMENT_KEY}, AxonExecutorApplyAdapter, MetadataHandle, @@ -37,7 +36,6 @@ struct TestCase<'a> { chain_name: &'a str, config_file: &'a str, chain_spec_file: &'a str, - key_file: &'a str, input_genesis_hash: &'a str, genesis_state_root: &'a str, } @@ -47,7 +45,6 @@ const TESTCASES: &[TestCase] = &[ chain_name: "single_node", config_file: "config.toml", chain_spec_file: "specs/single_node/chain-spec.toml", - key_file: "debug.key", input_genesis_hash: "0xe3a40f0115fbf101520ceea1ce7103a73cb46554187ac7ed67f3522103e06d99", genesis_state_root: "0x2f1e8e50d5ab97af96fdb5d6de8e691e5bb80f46f2c98c4133d265bd8b60de61", }, @@ -55,7 +52,6 @@ const TESTCASES: &[TestCase] = &[ chain_name: "multi_nodes", config_file: "nodes/node_1.toml", chain_spec_file: "specs/multi_nodes/chain-spec.toml", - key_file: "debug.key", input_genesis_hash: "0x1b4cf78373961dabcba5d4a9402c924fc4fecdd9ce367239f02c8971a052f3b5", genesis_state_root: "0xf684cbec490eb5b8a07b80f369f3bf87f05ec73494b869111010a6ad6fa89894", }, @@ -63,7 +59,6 @@ const TESTCASES: &[TestCase] = &[ chain_name: "multi_nodes_short_epoch_len", config_file: "nodes/node_1.toml", chain_spec_file: "specs/multi_nodes_short_epoch_len/chain-spec.toml", - key_file: "debug.key", input_genesis_hash: "0xd930632a7565acfc149c1d896d79910608768de5b936fdb34cc47c9b2296dd2a", genesis_state_root: "0xa5e1e7ac3e03f7dc26cc93ab69c0ec49e591cbdaa7694c75682745c40bfca468", }, @@ -113,13 +108,6 @@ async fn check_genesis_data<'a>(case: &TestCase<'a>) { .parse_ref(&command, None, chain_spec_path.as_os_str()) .expect("parse chain-spec file") }; - let key: Secp256k1RecoverablePrivateKey = { - let key_file_path = tmp_dir_path.join(case.key_file); - let key_data = PrivateKeyFileValueParser - .parse_ref(&command, None, key_file_path.as_os_str()) - .expect("parse key file"); - Secp256k1RecoverablePrivateKey::try_from(key_data.as_ref()).expect("load key data") - }; let path_block = tmp_dir.path().join("block"); let db_group = DatabaseGroup::new( @@ -130,7 +118,7 @@ async fn check_genesis_data<'a>(case: &TestCase<'a>) { ) .expect("initialize databases"); - let partial_genesis = chain_spec.generate_genesis_block(key); + let partial_genesis = chain_spec.generate_genesis_block(); let genesis = execute_genesis(partial_genesis, &chain_spec, &db_group) .await .expect("complete genesis block"); diff --git a/devtools/chain/debug.key b/devtools/chain/debug.key deleted file mode 100644 index 5a5922e28..000000000 --- a/devtools/chain/debug.key +++ /dev/null @@ -1,2 +0,0 @@ -7ª‰=‘JMï`À©„ÓaFϲi$קÊn ¹• -- \ No newline at end of file diff --git a/devtools/docker/docker-entrypoint.sh b/devtools/docker/docker-entrypoint.sh index 3c5fae44c..4748e546d 100755 --- a/devtools/docker/docker-entrypoint.sh +++ b/devtools/docker/docker-entrypoint.sh @@ -4,9 +4,8 @@ BASE_DIR="/app/devtools/chain" DATA_DIR="${BASE_DIR}/data" CONFIG_FILE="${BASE_DIR}/config.toml" CHAIN_SPEC_FILE="${BASE_DIR}/specs/single_node/chain-spec.toml" -KEY_FILE="${BASE_DIR}/debug.key" if [ ! -e "${DATA_DIR}" ]; then - /app/axon init --config "${CONFIG_FILE}" --chain-spec "${CHAIN_SPEC_FILE}" --key-file "${KEY_FILE}" + /app/axon init --config "${CONFIG_FILE}" --chain-spec "${CHAIN_SPEC_FILE}" fi /app/axon run --config "${CONFIG_FILE}"