Skip to content

Commit

Permalink
[compiler-v2] Fixed features for unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
welbon committed Dec 19, 2024
1 parent e8c0de9 commit 3695306
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 5 deletions.
100 changes: 100 additions & 0 deletions vm/framework/starcoin-framework/doc/stc_genesis.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -406,6 +407,105 @@ Overall governance allocation strategy:



</details>

<a id="0x1_stc_genesis_initialize_for_unit_tests"></a>

## Function `initialize_for_unit_tests`



<pre><code><b>public</b> <b>fun</b> <a href="stc_genesis.md#0x1_stc_genesis_initialize_for_unit_tests">initialize_for_unit_tests</a>()
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="stc_genesis.md#0x1_stc_genesis_initialize_for_unit_tests">initialize_for_unit_tests</a>() {
<b>let</b> stdlib_version: u64 = 6;
<b>let</b> reward_delay: u64 = 7;
<b>let</b> total_stc_amount: u128 = 3185136000000000000u128;
<b>let</b> pre_mine_stc_amount: u128 = 159256800000000000u128;
<b>let</b> time_mint_stc_amount: u128 = (85043130u128 * 3u128 + 74213670u128 * 3u128) * 1000000000u128;
<b>let</b> time_mint_stc_period: u64 = 1000000000;

<b>let</b> parent_hash: <a href="../../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt; = x"0000000000000000000000000000000000000000000000000000000000000000";
<b>let</b> association_auth_key: <a href="../../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt; = x"0000000000000000000000000000000000000000000000000000000000000000";
<b>let</b> genesis_auth_key: <a href="../../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt; = x"0000000000000000000000000000000000000000000000000000000000000000";
<b>let</b> <a href="chain_id.md#0x1_chain_id">chain_id</a>: u8 = 255;
<b>let</b> genesis_timestamp: u64 = 0;

//consensus config
<b>let</b> uncle_rate_target: u64 = 80;
<b>let</b> epoch_block_count: u64 = 240;
<b>let</b> base_block_time_target: u64 = 10000;
<b>let</b> base_block_difficulty_window: u64 = 24;
<b>let</b> base_reward_per_block: u128 = 1000000000;
<b>let</b> base_reward_per_uncle_percent: u64 = 10;
<b>let</b> min_block_time_target: u64 = 1000;
<b>let</b> max_block_time_target: u64 = 20000;
<b>let</b> base_max_uncles_per_block: u64 = 2;
<b>let</b> base_block_gas_limit: u64 = 500000000;
<b>let</b> strategy: u8 = 0;

//vm config
<b>let</b> script_allowed: bool = <b>true</b>;
<b>let</b> module_publishing_allowed: bool = <b>true</b>;

// todo: initialize gas_schedule_blob properly
<b>let</b> gas_schedule_blob: <a href="../../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt; = <a href="../../move-stdlib/doc/vector.md#0x1_vector_empty">vector::empty</a>&lt;u8&gt;();

// <a href="dao.md#0x1_dao">dao</a> config
<b>let</b> voting_delay: u64 = 1000;
<b>let</b> voting_period: u64 = 6000;
<b>let</b> voting_quorum_rate: u8 = 4;
<b>let</b> min_action_delay: u64 = 1000;

// transaction timeout config
<b>let</b> transaction_timeout: u64 = 10000;

<a href="stc_genesis.md#0x1_stc_genesis_initialize">Self::initialize</a>(
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,
<a href="chain_id.md#0x1_chain_id">chain_id</a>,
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,
<a href="../../move-stdlib/doc/vector.md#0x1_vector_empty">vector::empty</a>(),
);
}
</code></pre>



</details>

<a id="@Specification_0"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ module starcoin_framework::stc_genesis {
dao_treasury_withdraw_proposal::plugin<STC>(starcoin_framework, treasury_withdraw_cap);
}

#[test]
// #[test]
public fun initialize_for_unit_tests() {
let stdlib_version: u64 = 6;
let reward_delay: u64 = 7;
Expand Down
17 changes: 13 additions & 4 deletions vm/types/src/on_chain_config/starcoin_features.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 3695306

Please sign in to comment.