diff --git a/vm/framework/starcoin-framework/doc/stc_genesis.md b/vm/framework/starcoin-framework/doc/stc_genesis.md index b3f87021fe..84c6362784 100644 --- a/vm/framework/starcoin-framework/doc/stc_genesis.md +++ b/vm/framework/starcoin-framework/doc/stc_genesis.md @@ -10,6 +10,7 @@ The module for init Genesis - [Function `initialize_versions`](#0x1_stc_genesis_initialize_versions) - [Function `initialize_stc`](#0x1_stc_genesis_initialize_stc) - [Function `initialize_stc_governance_allocation`](#0x1_stc_genesis_initialize_stc_governance_allocation) +- [Function `initialize_for_unit_tests`](#0x1_stc_genesis_initialize_for_unit_tests) - [Specification](#@Specification_0) @@ -406,6 +407,105 @@ Overall governance allocation strategy: + + + + +## Function `initialize_for_unit_tests` + + + +
public fun initialize_for_unit_tests()
+
+ + + +
+Implementation + + +
public fun initialize_for_unit_tests() {
+    let stdlib_version: u64 = 6;
+    let reward_delay: u64 = 7;
+    let total_stc_amount: u128 = 3185136000000000000u128;
+    let pre_mine_stc_amount: u128 = 159256800000000000u128;
+    let time_mint_stc_amount: u128 = (85043130u128 * 3u128 + 74213670u128 * 3u128) * 1000000000u128;
+    let time_mint_stc_period: u64 = 1000000000;
+
+    let parent_hash: vector<u8> = x"0000000000000000000000000000000000000000000000000000000000000000";
+    let association_auth_key: vector<u8> = x"0000000000000000000000000000000000000000000000000000000000000000";
+    let genesis_auth_key: vector<u8> = x"0000000000000000000000000000000000000000000000000000000000000000";
+    let chain_id: u8 = 255;
+    let genesis_timestamp: u64 = 0;
+
+    //consensus config
+    let uncle_rate_target: u64 = 80;
+    let epoch_block_count: u64 = 240;
+    let base_block_time_target: u64 = 10000;
+    let base_block_difficulty_window: u64 = 24;
+    let base_reward_per_block: u128 = 1000000000;
+    let base_reward_per_uncle_percent: u64 = 10;
+    let min_block_time_target: u64 = 1000;
+    let max_block_time_target: u64 = 20000;
+    let base_max_uncles_per_block: u64 = 2;
+    let base_block_gas_limit: u64 = 500000000;
+    let strategy: u8 = 0;
+
+    //vm config
+    let script_allowed: bool = true;
+    let module_publishing_allowed: bool = true;
+
+    // todo: initialize gas_schedule_blob properly
+    let gas_schedule_blob: vector<u8> = vector::empty<u8>();
+
+    // dao config
+    let voting_delay: u64 = 1000;
+    let voting_period: u64 = 6000;
+    let voting_quorum_rate: u8 = 4;
+    let min_action_delay: u64 = 1000;
+
+    // transaction timeout config
+    let transaction_timeout: u64 = 10000;
+
+    Self::initialize(
+        stdlib_version,
+        reward_delay,
+        total_stc_amount,
+        pre_mine_stc_amount,
+        time_mint_stc_amount,
+        time_mint_stc_period,
+        parent_hash,
+        association_auth_key,
+        genesis_auth_key,
+        chain_id,
+        genesis_timestamp,
+        uncle_rate_target,
+        epoch_block_count,
+        base_block_time_target,
+        base_block_difficulty_window,
+        base_reward_per_block,
+        base_reward_per_uncle_percent,
+        min_block_time_target,
+        max_block_time_target,
+        base_max_uncles_per_block,
+        base_block_gas_limit,
+        strategy,
+        script_allowed,
+        module_publishing_allowed,
+        gas_schedule_blob,
+        voting_delay,
+        voting_period,
+        voting_quorum_rate,
+        min_action_delay,
+        transaction_timeout,
+        0,
+        vector::empty(),
+    );
+}
+
+ + +
diff --git a/vm/framework/starcoin-framework/sources/stc/stc_genesis.move b/vm/framework/starcoin-framework/sources/stc/stc_genesis.move index c50abc6422..aa5ff13a22 100644 --- a/vm/framework/starcoin-framework/sources/stc/stc_genesis.move +++ b/vm/framework/starcoin-framework/sources/stc/stc_genesis.move @@ -320,7 +320,7 @@ module starcoin_framework::stc_genesis { dao_treasury_withdraw_proposal::plugin(starcoin_framework, treasury_withdraw_cap); } - #[test] + // #[test] public fun initialize_for_unit_tests() { let stdlib_version: u64 = 6; let reward_delay: u64 = 7; diff --git a/vm/types/src/on_chain_config/starcoin_features.rs b/vm/types/src/on_chain_config/starcoin_features.rs index 481743d0a1..86a02a0f3d 100644 --- a/vm/types/src/on_chain_config/starcoin_features.rs +++ b/vm/types/src/on_chain_config/starcoin_features.rs @@ -1,8 +1,12 @@ // Copyright (c) The Starcoin Contributors // SPDX-License-Identifier: Apache-2.0 -use move_core_types::effects::{ChangeSet, Op}; -use move_core_types::language_storage::CORE_CODE_ADDRESS; +use move_core_types::{ + account_address::AccountAddress, + effects::{ChangeSet, Op}, + identifier::Identifier, + language_storage::{CORE_CODE_ADDRESS, StructTag}, +}; use serde::{Deserialize, Serialize}; use crate::on_chain_config::OnChainConfig; @@ -230,11 +234,16 @@ pub fn starcoin_test_feature_flags_genesis() -> ChangeSet { change_set .add_resource_op( CORE_CODE_ADDRESS, - Features::struct_tag(), + //Features::struct_tag(), + StructTag { + address: AccountAddress::ONE, + module: Identifier::new("features").unwrap(), + name: Identifier::new("Features").unwrap(), + type_args: vec![], + }, Op::New(features_value.into()), ) .expect("adding genesis Feature resource must succeed"); - change_set }