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

Add upgrade plugin And add StarcoinDAO #94

Merged
merged 12 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion build/StarcoinFramework/BuildInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: StakeToSBTPlugin
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: StarcoinDAO
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: StarcoinVerifier
: StarcoinFramework
Expand Down Expand Up @@ -291,6 +294,9 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: UpgradeModuleDaoProposal
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: UpgradeModulePlugin
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: VMConfig
: StarcoinFramework
Expand All @@ -306,7 +312,7 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: YieldFarmingV2
: StarcoinFramework
source_digest: A710EE5A9CB99AFE86615AD5840E39342DB78E8FB0F5F9509550D55526BF054D
source_digest: 5F36AADE9312D2934E215C4971621A24AF18EA5B56A52D2BE1D8E173174D0F3C
build_flags:
dev_mode: false
test_mode: false
Expand Down
Binary file modified build/StarcoinFramework/bytecode_modules/Account.mv
Binary file not shown.
Binary file modified build/StarcoinFramework/bytecode_modules/Genesis.mv
Binary file not shown.
Binary file not shown.
Binary file modified build/StarcoinFramework/bytecode_modules/OnChainConfigDao.mv
Binary file not shown.
Binary file modified build/StarcoinFramework/bytecode_modules/StdlibUpgradeScripts.mv
Binary file not shown.
Binary file not shown.
26 changes: 26 additions & 0 deletions build/StarcoinFramework/docs/Account.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The module for the account resource that governs every account
- [Resource `EventStore`](#0x1_Account_EventStore)
- [Constants](#@Constants_0)
- [Function `remove_signer_capability`](#0x1_Account_remove_signer_capability)
- [Function `get_genesis_capability`](#0x1_Account_get_genesis_capability)
- [Function `create_signer_with_cap`](#0x1_Account_create_signer_with_cap)
- [Function `destroy_signer_cap`](#0x1_Account_destroy_signer_cap)
- [Function `signer_address`](#0x1_Account_signer_address)
Expand Down Expand Up @@ -830,6 +831,31 @@ This function can only called once by signer.



</details>

<a name="0x1_Account_get_genesis_capability"></a>

## Function `get_genesis_capability`



<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="Account.md#0x1_Account_get_genesis_capability">get_genesis_capability</a>(): <a href="Account.md#0x1_Account_SignerCapability">Account::SignerCapability</a>
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> (<b>friend</b>) <b>fun</b> <a href="Account.md#0x1_Account_get_genesis_capability">get_genesis_capability</a>():<a href="Account.md#0x1_Account_SignerCapability">SignerCapability</a>{
<b>let</b> signer_cap = <a href="Account.md#0x1_Account_SignerCapability">SignerCapability</a> {addr: <a href="Token.md#0x1_Token_token_address">Token::token_address</a>&lt;<a href="STC.md#0x1_STC">STC</a>&gt;() };
signer_cap
}
</code></pre>



</details>

<a name="0x1_Account_create_signer_with_cap"></a>
Expand Down
1 change: 1 addition & 0 deletions build/StarcoinFramework/docs/Genesis.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ The module for init Genesis

};
<a href="StdlibUpgradeScripts.md#0x1_StdlibUpgradeScripts_do_upgrade_from_v11_to_v12">StdlibUpgradeScripts::do_upgrade_from_v11_to_v12</a>();
<a href="StdlibUpgradeScripts.md#0x1_StdlibUpgradeScripts_do_upgrade_from_v12_to_v12_1">StdlibUpgradeScripts::do_upgrade_from_v12_to_v12_1</a>();
//Start time, <a href="Timestamp.md#0x1_Timestamp_is_genesis">Timestamp::is_genesis</a>() will <b>return</b> <b>false</b>. this call should at the end of genesis init.
<a href="Timestamp.md#0x1_Timestamp_set_time_has_started">Timestamp::set_time_has_started</a>(&genesis_account);
<a href="Account.md#0x1_Account_release_genesis_signer">Account::release_genesis_signer</a>(genesis_account);
Expand Down
27 changes: 27 additions & 0 deletions build/StarcoinFramework/docs/OnChainConfigDao.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ OnChainConfigDao is a DAO proposal for modify onchain configuration.
- [Function `plugin`](#0x1_OnChainConfigDao_plugin)
- [Function `propose_update`](#0x1_OnChainConfigDao_propose_update)
- [Function `execute`](#0x1_OnChainConfigDao_execute)
- [Function `config_cap`](#0x1_OnChainConfigDao_config_cap)
- [Module Specification](#@Module_Specification_1)


<pre><code><b>use</b> <a href="Config.md#0x1_Config">0x1::Config</a>;
<b>use</b> <a href="CoreAddresses.md#0x1_CoreAddresses">0x1::CoreAddresses</a>;
<b>use</b> <a href="Dao.md#0x1_Dao">0x1::Dao</a>;
<b>use</b> <a href="Errors.md#0x1_Errors">0x1::Errors</a>;
<b>use</b> <a href="Signer.md#0x1_Signer">0x1::Signer</a>;
Expand Down Expand Up @@ -243,6 +245,31 @@ the kind of this proposal module.



</details>

<a name="0x1_OnChainConfigDao_config_cap"></a>

## Function `config_cap`



<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="OnChainConfigDao.md#0x1_OnChainConfigDao_config_cap">config_cap</a>&lt;TokenT: store, ConfigT: <b>copy</b>, drop, store&gt;(): <a href="Config.md#0x1_Config_ModifyConfigCapability">Config::ModifyConfigCapability</a>&lt;ConfigT&gt;
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> (<b>friend</b>) <b>fun</b> <a href="OnChainConfigDao.md#0x1_OnChainConfigDao_config_cap">config_cap</a>&lt;TokenT: store, ConfigT: <b>copy</b> + drop + store&gt;():<a href="Config.md#0x1_Config_ModifyConfigCapability">Config::ModifyConfigCapability</a>&lt;ConfigT&gt;<b>acquires</b> <a href="OnChainConfigDao.md#0x1_OnChainConfigDao_WrappedConfigModifyCapability">WrappedConfigModifyCapability</a>{
<b>let</b> <a href="OnChainConfigDao.md#0x1_OnChainConfigDao_WrappedConfigModifyCapability">WrappedConfigModifyCapability</a> &lt;TokenT, ConfigT&gt;{cap} = <b>move_from</b>&lt;<a href="OnChainConfigDao.md#0x1_OnChainConfigDao_WrappedConfigModifyCapability">WrappedConfigModifyCapability</a>&lt;TokenT, ConfigT&gt;&gt;(<a href="CoreAddresses.md#0x1_CoreAddresses_GENESIS_ADDRESS">CoreAddresses::GENESIS_ADDRESS</a>());
cap
}
</code></pre>



</details>

<a name="@Module_Specification_1"></a>
Expand Down
2 changes: 2 additions & 0 deletions build/StarcoinFramework/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ This is the root document for the Move StarcoinFramework module documentation. T
- [`0x1::Signer`](Signer.md#0x1_Signer)
- [`0x1::SnapshotUtil`](SnapshotUtil.md#0x1_SnapshotUtil)
- [`0x1::StakeToSBTPlugin`](StakeToSBTPlugin.md#0x1_StakeToSBTPlugin)
- [`0x1::StarcoinDAO`](StarcoinDAO.md#0x1_StarcoinDAO)
- [`0x1::StarcoinVerifier`](StarcoinVerifier.md#0x1_StarcoinVerifier)
- [`0x1::StdlibUpgradeScripts`](StdlibUpgradeScripts.md#0x1_StdlibUpgradeScripts)
- [`0x1::StructuredHash`](StarcoinVerifier.md#0x1_StructuredHash)
Expand All @@ -107,6 +108,7 @@ This is the root document for the Move StarcoinFramework module documentation. T
- [`0x1::TypeInfo`](TypeInfo.md#0x1_TypeInfo)
- [`0x1::U256`](U256.md#0x1_U256)
- [`0x1::UpgradeModuleDaoProposal`](UpgradeModuleDaoProposal.md#0x1_UpgradeModuleDaoProposal)
- [`0x1::UpgradeModulePlugin`](UpgradeModulePlugin.md#0x1_UpgradeModulePlugin)
- [`0x1::VMConfig`](VMConfig.md#0x1_VMConfig)
- [`0x1::Vector`](Vector.md#0x1_Vector)
- [`0x1::Version`](Version.md#0x1_Version)
Expand Down
51 changes: 51 additions & 0 deletions build/StarcoinFramework/docs/StdlibUpgradeScripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ The module for StdlibUpgrade init scripts
- [Function `do_upgrade_from_v7_to_v8`](#0x1_StdlibUpgradeScripts_do_upgrade_from_v7_to_v8)
- [Function `upgrade_from_v11_to_v12`](#0x1_StdlibUpgradeScripts_upgrade_from_v11_to_v12)
- [Function `do_upgrade_from_v11_to_v12`](#0x1_StdlibUpgradeScripts_do_upgrade_from_v11_to_v12)
- [Function `upgrade_from_v12_to_v12_1`](#0x1_StdlibUpgradeScripts_upgrade_from_v12_to_v12_1)
- [Function `do_upgrade_from_v12_to_v12_1`](#0x1_StdlibUpgradeScripts_do_upgrade_from_v12_to_v12_1)
- [Module Specification](#@Module_Specification_0)


Expand All @@ -35,6 +37,7 @@ The module for StdlibUpgrade init scripts
<b>use</b> <a href="Oracle.md#0x1_Oracle">0x1::Oracle</a>;
<b>use</b> <a href="STC.md#0x1_STC">0x1::STC</a>;
<b>use</b> <a href="Oracle.md#0x1_STCUSDOracle">0x1::STCUSDOracle</a>;
<b>use</b> <a href="StarcoinDAO.md#0x1_StarcoinDAO">0x1::StarcoinDAO</a>;
<b>use</b> <a href="Timestamp.md#0x1_Timestamp">0x1::Timestamp</a>;
<b>use</b> <a href="Token.md#0x1_Token">0x1::Token</a>;
<b>use</b> <a href="Treasury.md#0x1_Treasury">0x1::Treasury</a>;
Expand Down Expand Up @@ -346,6 +349,54 @@ deprecated, use <code>do_upgrade_from_v6_to_v7_with_language_version</code>.



</details>

<a name="0x1_StdlibUpgradeScripts_upgrade_from_v12_to_v12_1"></a>

## Function `upgrade_from_v12_to_v12_1`



<pre><code><b>public</b>(<b>script</b>) <b>fun</b> <a href="StdlibUpgradeScripts.md#0x1_StdlibUpgradeScripts_upgrade_from_v12_to_v12_1">upgrade_from_v12_to_v12_1</a>()
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b>(<b>script</b>) <b>fun</b> <a href="StdlibUpgradeScripts.md#0x1_StdlibUpgradeScripts_upgrade_from_v12_to_v12_1">upgrade_from_v12_to_v12_1</a>() {
<a href="StdlibUpgradeScripts.md#0x1_StdlibUpgradeScripts_do_upgrade_from_v12_to_v12_1">do_upgrade_from_v12_to_v12_1</a>();
}
</code></pre>



</details>

<a name="0x1_StdlibUpgradeScripts_do_upgrade_from_v12_to_v12_1"></a>

## Function `do_upgrade_from_v12_to_v12_1`



<pre><code><b>public</b> <b>fun</b> <a href="StdlibUpgradeScripts.md#0x1_StdlibUpgradeScripts_do_upgrade_from_v12_to_v12_1">do_upgrade_from_v12_to_v12_1</a>()
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="StdlibUpgradeScripts.md#0x1_StdlibUpgradeScripts_do_upgrade_from_v12_to_v12_1">do_upgrade_from_v12_to_v12_1</a>() {
<a href="StarcoinDAO.md#0x1_StarcoinDAO_create_dao">StarcoinDAO::create_dao</a>( 60000, 120000, 10, 10000, 0);
}
</code></pre>



</details>

<a name="@Module_Specification_0"></a>
Expand Down
27 changes: 20 additions & 7 deletions build/StarcoinFramework/docs/UpgradeModuleDaoProposal.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ UpgradeModuleDaoProposal is a proposal moudle used to upgrade contract codes und
- [Struct `UpgradeModuleV2`](#0x1_UpgradeModuleDaoProposal_UpgradeModuleV2)
- [Constants](#@Constants_0)
- [Function `plugin`](#0x1_UpgradeModuleDaoProposal_plugin)
- [Function `get_genesis_upgrade_cap`](#0x1_UpgradeModuleDaoProposal_get_genesis_upgrade_cap)
- [Function `propose_module_upgrade_v2`](#0x1_UpgradeModuleDaoProposal_propose_module_upgrade_v2)
- [Function `submit_module_upgrade_plan`](#0x1_UpgradeModuleDaoProposal_submit_module_upgrade_plan)
- [Module Specification](#@Module_Specification_1)
Expand Down Expand Up @@ -213,16 +214,28 @@ If this goverment can upgrade module, call this to register capability.



</details>

<a name="0x1_UpgradeModuleDaoProposal_get_genesis_upgrade_cap"></a>

## Function `get_genesis_upgrade_cap`

<a name="0x1_UpgradeModuleDaoProposal_AbortIfUnableUpgrade"></a>


<pre><code><b>schema</b> <a href="UpgradeModuleDaoProposal.md#0x1_UpgradeModuleDaoProposal_AbortIfUnableUpgrade">AbortIfUnableUpgrade</a>&lt;TokenT&gt; {
module_address: <b>address</b>;
<b>let</b> token_issuer = <a href="Token.md#0x1_Token_SPEC_TOKEN_TEST_ADDRESS">Token::SPEC_TOKEN_TEST_ADDRESS</a>();
<b>aborts_if</b> !<b>exists</b>&lt;<a href="UpgradeModuleDaoProposal.md#0x1_UpgradeModuleDaoProposal_UpgradeModuleCapability">UpgradeModuleCapability</a>&lt;TokenT&gt;&gt;(token_issuer);
<b>let</b> cap = <b>global</b>&lt;<a href="UpgradeModuleDaoProposal.md#0x1_UpgradeModuleDaoProposal_UpgradeModuleCapability">UpgradeModuleCapability</a>&lt;TokenT&gt;&gt;(token_issuer).cap;
<b>aborts_if</b> <a href="PackageTxnManager.md#0x1_PackageTxnManager_account_address">PackageTxnManager::account_address</a>(cap) != module_address;
<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="UpgradeModuleDaoProposal.md#0x1_UpgradeModuleDaoProposal_get_genesis_upgrade_cap">get_genesis_upgrade_cap</a>&lt;TokenT: store&gt;(): <a href="PackageTxnManager.md#0x1_PackageTxnManager_UpgradePlanCapability">PackageTxnManager::UpgradePlanCapability</a>
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> (<b>friend</b>) <b>fun</b> <a href="UpgradeModuleDaoProposal.md#0x1_UpgradeModuleDaoProposal_get_genesis_upgrade_cap">get_genesis_upgrade_cap</a>&lt;TokenT:store&gt;():<a href="PackageTxnManager.md#0x1_PackageTxnManager_UpgradePlanCapability">PackageTxnManager::UpgradePlanCapability</a> <b>acquires</b> <a href="UpgradeModuleDaoProposal.md#0x1_UpgradeModuleDaoProposal_UpgradeModuleCapability">UpgradeModuleCapability</a>{
<b>let</b> <a href="UpgradeModuleDaoProposal.md#0x1_UpgradeModuleDaoProposal_UpgradeModuleCapability">UpgradeModuleCapability</a>&lt;TokenT&gt;{
cap
} = <b>move_from</b>(<a href="Token.md#0x1_Token_token_address">Token::token_address</a>&lt;TokenT&gt;());
cap
}
</code></pre>

Expand Down
Binary file modified build/StarcoinFramework/source_maps/Account.mvsm
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/Genesis.mvsm
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/GenesisSignerCapability.mvsm
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/OnChainConfigDao.mvsm
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/StdlibUpgradeScripts.mvsm
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/UpgradeModuleDaoProposal.mvsm
Binary file not shown.
6 changes: 3 additions & 3 deletions integration-tests/daospace/dao_account.exp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ processed 6 tasks

task 2 'run'. lines 6-23:
{
"gas_used": 837509,
"gas_used": 858490,
"status": "Executed"
}

Expand All @@ -14,7 +14,7 @@ task 3 'run'. lines 28-40:

task 4 'run'. lines 42-51:
{
"gas_used": 712879,
"gas_used": 733860,
"status": {
"MoveAbort": {
"location": {
Expand All @@ -30,7 +30,7 @@ task 4 'run'. lines 42-51:

task 5 'run'. lines 53-61:
{
"gas_used": 711648,
"gas_used": 732629,
"status": {
"MoveAbort": {
"location": {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospace/dao_ext.exp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ processed 9 tasks

task 6 'run'. lines 56-65:
{
"gas_used": 917082,
"gas_used": 938063,
"status": "Executed"
}

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospace/dao_grant.exp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ task 5 'run'. lines 13-21:

task 8 'run'. lines 100-109:
{
"gas_used": 1174718,
"gas_used": 1195699,
"status": "Executed"
}

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospace/dao_proposal.exp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ processed 42 tasks

task 7 'run'. lines 150-159:
{
"gas_used": 1171921,
"gas_used": 1192902,
"status": "Executed"
}

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospace/dao_upgrade.exp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ task 8 'run'. lines 87-101:

task 9 'run'. lines 102-111:
{
"gas_used": 991772,
"gas_used": 1012753,
"status": "Executed"
}

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospace/stake_to_sbt_plugin.exp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ task 4 'run'. lines 9-17:

task 6 'run'. lines 61-69:
{
"gas_used": 1267818,
"gas_used": 1288799,
"status": "Executed"
}

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospace/xdao.exp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ processed 4 tasks

task 3 'run'. lines 54-61:
{
"gas_used": 1053290,
"gas_used": 1074271,
"status": "Executed"
}
2 changes: 1 addition & 1 deletion integration-tests/daospaceplugin/mint_proposal_plugin.exp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ task 8 'run'. lines 71-85:

task 9 'run'. lines 87-96:
{
"gas_used": 1106537,
"gas_used": 1127518,
"status": "Executed"
}

Expand Down
7 changes: 7 additions & 0 deletions integration-tests/starcoin_dao/starcoin_dao.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
processed 4 tasks

task 3 'run'. lines 8-16:
{
"gas_used": 1405560,
"status": "Executed"
}
16 changes: 16 additions & 0 deletions integration-tests/starcoin_dao/starcoin_dao.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//# init -n test

//# faucet --addr creator --amount 100000000000

//# faucet --addr alice --amount 10000000000


//# run --signers creator
script{
use StarcoinFramework::StdlibUpgradeScripts;

fun main(){
StdlibUpgradeScripts::upgrade_from_v12_to_v12_1();
}
}
// check: EXECUTED
8 changes: 8 additions & 0 deletions sources/Account.move
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ module Account {
use StarcoinFramework::STC::{Self, STC};
use StarcoinFramework::BCS;

friend StarcoinFramework::StarcoinDAO;

spec module {
pragma verify = false;
pragma aborts_if_is_strict = true;
Expand Down Expand Up @@ -191,6 +193,12 @@ module Account {
signer_cap
}

//TODO: Create StarcoinDAO , need modify or remove get_genesis_capability soon
public (friend) fun get_genesis_capability():SignerCapability{
WGB5445 marked this conversation as resolved.
Show resolved Hide resolved
let signer_cap = SignerCapability {addr: Token::token_address<STC>() };
signer_cap
}

public fun create_signer_with_cap(cap: &SignerCapability): signer {
create_signer(cap.addr)
}
Expand Down
1 change: 1 addition & 0 deletions sources/Genesis.move
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ module Genesis {

};
StdlibUpgradeScripts::do_upgrade_from_v11_to_v12();
StdlibUpgradeScripts::do_upgrade_from_v12_to_v12_1();
//Start time, Timestamp::is_genesis() will return false. this call should at the end of genesis init.
Timestamp::set_time_has_started(&genesis_account);
Account::release_genesis_signer(genesis_account);
Expand Down
Loading