Skip to content

Commit

Permalink
GasTokenOracle && Easygas support
Browse files Browse the repository at this point in the history
  • Loading branch information
sanlee42 committed Sep 19, 2022
1 parent f1363a3 commit 14a6415
Show file tree
Hide file tree
Showing 21 changed files with 365 additions and 182 deletions.
8 changes: 7 additions & 1 deletion build/StarcoinFramework/BuildInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: FixedPoint32
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: GasTokenOracleProposalPlugin
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: Genesis
: StarcoinFramework
Expand Down Expand Up @@ -225,6 +228,9 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: STC
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: STCTokenOracle
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: STCUSDOracle
: StarcoinFramework
Expand Down Expand Up @@ -318,7 +324,7 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: YieldFarmingV2
: StarcoinFramework
source_digest: 5E08A2774FAADBD05F5E98290A4B05E6D4D5AA4DB5123B79F6015AC8574B75F8
source_digest: 48AF77686B3041A6808EDF955FF489408428E6D7475609F2F498B619C0D98A01
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/PriceOracle.mv
Binary file not shown.
Binary file modified build/StarcoinFramework/bytecode_modules/TransactionManager.mv
Binary file not shown.
175 changes: 118 additions & 57 deletions build/StarcoinFramework/docs/Account.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions build/StarcoinFramework/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ This is the root document for the Move StarcoinFramework module documentation. T
- [`0x1::Errors`](Errors.md#0x1_Errors)
- [`0x1::Event`](Event.md#0x1_Event)
- [`0x1::FixedPoint32`](FixedPoint32.md#0x1_FixedPoint32)
- [`0x1::GasTokenOracleProposalPlugin`](GasTokenOracleProposalPlugin.md#0x1_GasTokenOracleProposalPlugin)
- [`0x1::Genesis`](Genesis.md#0x1_Genesis)
- [`0x1::GenesisNFT`](GenesisNFT.md#0x1_GenesisNFT)
- [`0x1::GenesisNFTScripts`](GenesisNFT.md#0x1_GenesisNFTScripts)
Expand Down Expand Up @@ -85,6 +86,7 @@ This is the root document for the Move StarcoinFramework module documentation. T
- [`0x1::SIP_2`](SIPs.md#0x1_SIP_2)
- [`0x1::SIP_3`](SIPs.md#0x1_SIP_3)
- [`0x1::STC`](STC.md#0x1_STC)
- [`0x1::STCTokenOracle`](Oracle.md#0x1_STCTokenOracle)
- [`0x1::STCUSDOracle`](Oracle.md#0x1_STCUSDOracle)
- [`0x1::SharedEd25519PublicKey`](SharedEd25519PublicKey.md#0x1_SharedEd25519PublicKey)
- [`0x1::Signature`](Signature.md#0x1_Signature)
Expand Down
19 changes: 17 additions & 2 deletions build/StarcoinFramework/docs/TransactionManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@
<b>use</b> <a href="BlockReward.md#0x1_BlockReward">0x1::BlockReward</a>;
<b>use</b> <a href="ChainId.md#0x1_ChainId">0x1::ChainId</a>;
<b>use</b> <a href="CoreAddresses.md#0x1_CoreAddresses">0x1::CoreAddresses</a>;
<b>use</b> <a href="DAOSpace.md#0x1_DAOSpace">0x1::DAOSpace</a>;
<b>use</b> <a href="Epoch.md#0x1_Epoch">0x1::Epoch</a>;
<b>use</b> <a href="Errors.md#0x1_Errors">0x1::Errors</a>;
<b>use</b> <a href="GasTokenOracleProposalPlugin.md#0x1_GasTokenOracleProposalPlugin">0x1::GasTokenOracleProposalPlugin</a>;
<b>use</b> <a href="PackageTxnManager.md#0x1_PackageTxnManager">0x1::PackageTxnManager</a>;
<b>use</b> <a href="STC.md#0x1_STC">0x1::STC</a>;
<b>use</b> <a href="Oracle.md#0x1_STCTokenOracle">0x1::STCTokenOracle</a>;
<b>use</b> <a href="Signer.md#0x1_Signer">0x1::Signer</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="TransactionFee.md#0x1_TransactionFee">0x1::TransactionFee</a>;
Expand Down Expand Up @@ -162,6 +166,12 @@ It verifies:
txn_gas_price,
txn_max_gas_units,
);
<b>let</b> stc_price= <b>if</b> (!<a href="STC.md#0x1_STC_is_stc">STC::is_stc</a>&lt;TokenType&gt;()){
<a href="DAOSpace.md#0x1_DAOSpace_gas_token_oracle_read">DAOSpace::gas_token_oracle_read</a>&lt;<a href="StarcoinDAO.md#0x1_StarcoinDAO">StarcoinDAO</a>,OracleProposalPlugin, STCToken&lt;TokenType&gt;&gt;()
}<b>else</b>{
1
};
<a href="Account.md#0x1_Account_txn_gas_check">Account::txn_gas_check</a>&lt;TokenType&gt;(txn_sender, txn_gas_price, txn_max_gas_units, stc_price);
<b>assert</b>!(
<a href="TransactionTimeout.md#0x1_TransactionTimeout_is_valid_transaction_timestamp">TransactionTimeout::is_valid_transaction_timestamp</a>(txn_expiration_time),
<a href="Errors.md#0x1_Errors_invalid_argument">Errors::invalid_argument</a>(<a href="TransactionManager.md#0x1_TransactionManager_EPROLOGUE_TRANSACTION_EXPIRED">EPROLOGUE_TRANSACTION_EXPIRED</a>),
Expand Down Expand Up @@ -210,8 +220,6 @@ It verifies:
<b>include</b> <a href="Timestamp.md#0x1_Timestamp_AbortsIfTimestampNotExists">Timestamp::AbortsIfTimestampNotExists</a>;
<b>include</b> <a href="Block.md#0x1_Block_AbortsIfBlockMetadataNotExist">Block::AbortsIfBlockMetadataNotExist</a>;
<b>aborts_if</b> txn_gas_price * txn_max_gas_units &gt; 0 && !<b>exists</b>&lt;<a href="Account.md#0x1_Account_Balance">Account::Balance</a>&lt;TokenType&gt;&gt;(txn_sender);
<b>aborts_if</b> txn_gas_price * txn_max_gas_units &gt; 0 && StarcoinFramework::Token::spec_token_code&lt;TokenType&gt;() != StarcoinFramework::Token::spec_token_code&lt;<a href="STC.md#0x1_STC">STC</a>&gt;();
<b>aborts_if</b> txn_gas_price * txn_max_gas_units &gt; 0 && <b>global</b>&lt;<a href="Account.md#0x1_Account_Balance">Account::Balance</a>&lt;TokenType&gt;&gt;(txn_sender).token.value &lt; txn_gas_price * txn_max_gas_units;
<b>aborts_if</b> txn_gas_price * txn_max_gas_units &gt; 0 && txn_sequence_number &gt;= max_u64();
<b>aborts_if</b> txn_sequence_number &lt; <b>global</b>&lt;<a href="Account.md#0x1_Account_Account">Account::Account</a>&gt;(txn_sender).sequence_number;
<b>aborts_if</b> txn_sequence_number != <b>global</b>&lt;<a href="Account.md#0x1_Account_Account">Account::Account</a>&gt;(txn_sender).sequence_number;
Expand Down Expand Up @@ -323,6 +331,13 @@ It collects gas and bumps the sequence number
success: bool,
) {
<a href="CoreAddresses.md#0x1_CoreAddresses_assert_genesis_address">CoreAddresses::assert_genesis_address</a>(&account);
<b>let</b> stc_price =
<b>if</b> (!<a href="STC.md#0x1_STC_is_stc">STC::is_stc</a>&lt;TokenType&gt;()){
<a href="DAOSpace.md#0x1_DAOSpace_gas_token_oracle_read">DAOSpace::gas_token_oracle_read</a>&lt;<a href="StarcoinDAO.md#0x1_StarcoinDAO">StarcoinDAO</a>, OracleProposalPlugin, TokenType&gt;()
}<b>else</b>{
1
};
<a href="Account.md#0x1_Account_txn_gas_process">Account::txn_gas_process</a>&lt;TokenType&gt;(&account, txn_sender, txn_gas_price, txn_max_gas_units, gas_units_remaining, stc_price);
<a href="Account.md#0x1_Account_txn_epilogue_v2">Account::txn_epilogue_v2</a>&lt;TokenType&gt;(
&account,
txn_sender,
Expand Down
Binary file modified build/StarcoinFramework/source_maps/Account.mvsm
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/Oracle.mvsm
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/PriceOracle.mvsm
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/PriceOracleAggregator.mvsm
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/PriceOracleScripts.mvsm
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/STCUSDOracle.mvsm
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/TransactionManager.mvsm
Binary file not shown.
59 changes: 17 additions & 42 deletions integration-tests/account/txn_prologue_and_epilogue.exp
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,13 @@ task 4 'run'. lines 27-59:
}
}

task 5 'run'. lines 63-90:
task 5 'run'. lines 63-89:
{
"gas_used": 329083,
"status": {
"MoveAbort": {
"location": {
"Module": {
"address": "0x00000000000000000000000000000001",
"name": "Account"
}
},
"abort_code": "1031"
}
}
"gas_used": 304567,
"status": "Executed"
}

task 6 'run'. lines 94-122:
task 6 'run'. lines 93-121:
{
"gas_used": 300870,
"status": {
Expand All @@ -54,9 +44,9 @@ task 6 'run'. lines 94-122:
}
}

task 7 'run'. lines 126-156:
task 7 'run'. lines 125-155:
{
"gas_used": 335601,
"gas_used": 309389,
"status": {
"MoveAbort": {
"location": {
Expand All @@ -70,15 +60,15 @@ task 7 'run'. lines 126-156:
}
}

task 8 'run'. lines 160-205:
task 8 'run'. lines 159-204:
{
"gas_used": 403810,
"gas_used": 357188,
"status": "Executed"
}

task 9 'run'. lines 209-239:
task 9 'run'. lines 208-238:
{
"gas_used": 335471,
"gas_used": 309259,
"status": {
"MoveAbort": {
"location": {
Expand All @@ -92,34 +82,19 @@ task 9 'run'. lines 209-239:
}
}

task 10 'run'. lines 243-274:
task 10 'run'. lines 242-273:
{
"gas_used": 180123,
"status": {
"MoveAbort": {
"location": {
"Module": {
"address": "0x00000000000000000000000000000001",
"name": "Account"
}
},
"abort_code": "2568"
}
}
"gas_used": 191825,
"status": "Executed"
}

task 11 'run'. lines 278-309:
task 11 'run'. lines 277-308:
{
"gas_used": 174016,
"gas_used": 144115,
"status": {
"MoveAbort": {
"location": {
"Module": {
"address": "0x00000000000000000000000000000001",
"name": "CoreAddresses"
}
},
"abort_code": "2818"
"location": "Script",
"abort_code": "1007"
}
}
}
1 change: 0 additions & 1 deletion integration-tests/account/txn_prologue_and_epilogue.move
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ script {
let txn_sequence_number = 0;
let txn_gas_price = 1;
let txn_max_gas_units = 10000; //EPROLOGUE_CANT_PAY_GAS_DEPOSIT

Account::txn_prologue<STC>(
&account,
txn_sender,
Expand Down
Loading

0 comments on commit 14a6415

Please sign in to comment.