From 11897a4b747ea02b32eabda1487c201a3835e3f0 Mon Sep 17 00:00:00 2001 From: Saurabh Joshi Date: Thu, 16 May 2024 12:19:18 +0530 Subject: [PATCH] finite supply supra_coin e2e move tests passing --- .config/nextest.toml | 2 ++ .../src/aptos_test_harness.rs | 2 +- aptos-move/e2e-testsuite/src/tests/mint.rs | 2 +- aptos-move/framework/supra-framework/doc/supra_coin.md | 4 ++-- .../framework/supra-framework/sources/supra_coin.move | 6 +++--- aptos-move/vm-genesis/src/lib.rs | 8 ++++---- crates/aptos-faucet/core/src/funder/mint.rs | 4 ++-- crates/indexer/src/models/coin_models/coin_activities.rs | 2 +- crates/indexer/src/processors/coin_processor.rs | 2 +- .../transaction-emitter-lib/src/emitter/account_minter.rs | 2 +- sdk/src/transaction_builder.rs | 2 +- 11 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index df06faf996ef1..0ef256116f3ad 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -14,3 +14,5 @@ retries = 3 status-level = "skip" failure-output = "immediate-final" junit = { path = "junit.xml" } + + diff --git a/aptos-move/aptos-transactional-test-harness/src/aptos_test_harness.rs b/aptos-move/aptos-transactional-test-harness/src/aptos_test_harness.rs index cfcedc563db01..32c1261d1acdb 100644 --- a/aptos-move/aptos-transactional-test-harness/src/aptos_test_harness.rs +++ b/aptos-move/aptos-transactional-test-harness/src/aptos_test_harness.rs @@ -532,7 +532,7 @@ impl<'a> AptosTestAdapter<'a> { let txn = RawTransaction::new( aptos_test_root_address(), parameters.sequence_number + 1, - aptos_cached_packages::aptos_stdlib::aptos_coin_mint(account_addr, amount), + aptos_cached_packages::aptos_stdlib::supra_coin_mint(account_addr, amount), parameters.max_gas_amount, parameters.gas_unit_price, parameters.expiration_timestamp_secs, diff --git a/aptos-move/e2e-testsuite/src/tests/mint.rs b/aptos-move/e2e-testsuite/src/tests/mint.rs index e5c74bc1f6cae..c23798b911cf1 100644 --- a/aptos-move/e2e-testsuite/src/tests/mint.rs +++ b/aptos-move/e2e-testsuite/src/tests/mint.rs @@ -22,7 +22,7 @@ fn mint_to_new_account() { let mint_amount = 1_000_000; let txn = root .transaction() - .payload(aptos_stdlib::aptos_coin_mint( + .payload(aptos_stdlib::supra_coin_mint( *new_account.address(), mint_amount, )) diff --git a/aptos-move/framework/supra-framework/doc/supra_coin.md b/aptos-move/framework/supra-framework/doc/supra_coin.md index 0b6804f590164..1b377bb48ed3c 100644 --- a/aptos-move/framework/supra-framework/doc/supra_coin.md +++ b/aptos-move/framework/supra-framework/doc/supra_coin.md @@ -191,7 +191,7 @@ Account does not have mint capability Max supply of Supra Coin to be 100 billion with 8 decimal places fraction -
const MAX_SUPRA_COIN_SUPPLY: u128 = 340282366920938463463374607431768211455;
+
const MAX_SUPRA_COIN_SUPPLY: u128 = 10000000000000000000;
 
@@ -316,7 +316,7 @@ accounts. // Mint the core resource account SupraCoin for gas so it can execute system transactions. coin::register<SupraCoin>(core_resources); let coins = coin::mint<SupraCoin>( - 18446744073709551615, + ((MAX_SUPRA_COIN_SUPPLY)/10 as u64), &mint_cap, ); coin::deposit<SupraCoin>(signer::address_of(core_resources), coins); diff --git a/aptos-move/framework/supra-framework/sources/supra_coin.move b/aptos-move/framework/supra-framework/sources/supra_coin.move index fea31113a58fa..9a0eda4bc2c3f 100644 --- a/aptos-move/framework/supra-framework/sources/supra_coin.move +++ b/aptos-move/framework/supra-framework/sources/supra_coin.move @@ -15,8 +15,8 @@ module supra_framework::supra_coin { /// Max supply of Supra Coin to be 100 billion with 8 decimal places fraction - //const MAX_SUPRA_COIN_SUPPLY: u128 = 100_000_000_000_00_000_000u128; - const MAX_SUPRA_COIN_SUPPLY: u128 = 340282366920938463463374607431768211455u128; + const MAX_SUPRA_COIN_SUPPLY: u128 = 100_000_000_000_00_000_000u128; + //const MAX_SUPRA_COIN_SUPPLY: u128 = 340282366920938463463374607431768211455u128; /// Account does not have mint capability const ENO_CAPABILITIES: u64 = 1; /// Mint capability has already been delegated to this specified address @@ -85,7 +85,7 @@ module supra_framework::supra_coin { // Mint the core resource account SupraCoin for gas so it can execute system transactions. coin::register(core_resources); let coins = coin::mint( - 18446744073709551615, + ((MAX_SUPRA_COIN_SUPPLY)/10 as u64), &mint_cap, ); coin::deposit(signer::address_of(core_resources), coins); diff --git a/aptos-move/vm-genesis/src/lib.rs b/aptos-move/vm-genesis/src/lib.rs index 7771f667cdc7f..16cd6a22ad59e 100644 --- a/aptos-move/vm-genesis/src/lib.rs +++ b/aptos-move/vm-genesis/src/lib.rs @@ -136,7 +136,7 @@ pub fn encode_aptos_mainnet_genesis_transaction( &gas_schedule, ); initialize_features(&mut session); - initialize_aptos_coin(&mut session); + initialize_supra_coin(&mut session); initialize_on_chain_governance(&mut session, genesis_config); create_accounts(&mut session, accounts); create_employee_validators(&mut session, employees, genesis_config); @@ -248,7 +248,7 @@ pub fn encode_genesis_change_set( if genesis_config.is_test { initialize_core_resources_and_supra_coin(&mut session, core_resources_key); } else { - initialize_aptos_coin(&mut session); + initialize_supra_coin(&mut session); } initialize_on_chain_governance(&mut session, genesis_config); create_and_initialize_validators(&mut session, validators); @@ -482,11 +482,11 @@ fn initialize_features(session: &mut SessionExt) { ); } -fn initialize_aptos_coin(session: &mut SessionExt) { +fn initialize_supra_coin(session: &mut SessionExt) { exec_function( session, GENESIS_MODULE_NAME, - "initialize_aptos_coin", + "initialize_supra_coin", vec![], serialize_values(&vec![MoveValue::Signer(CORE_CODE_ADDRESS)]), ); diff --git a/crates/aptos-faucet/core/src/funder/mint.rs b/crates/aptos-faucet/core/src/funder/mint.rs index d6974a45b1b85..1f7a76f71eb77 100644 --- a/crates/aptos-faucet/core/src/funder/mint.rs +++ b/crates/aptos-faucet/core/src/funder/mint.rs @@ -173,7 +173,7 @@ impl MintFunder { let faucet_account = self.faucet_account.write().await; client .submit_and_wait(&faucet_account.sign_with_transaction_builder( - transaction_factory.payload(aptos_stdlib::aptos_coin_delegate_mint_capability( + transaction_factory.payload(aptos_stdlib::supra_coin_delegate_mint_capability( delegated_account.address(), )), )) @@ -184,7 +184,7 @@ impl MintFunder { // Claim the capability! client .submit_and_wait(&delegated_account.sign_with_transaction_builder( - transaction_factory.payload(aptos_stdlib::aptos_coin_claim_mint_capability()), + transaction_factory.payload(aptos_stdlib::supra_coin_claim_mint_capability()), )) .await .context("Failed to claim the minting capability")?; diff --git a/crates/indexer/src/models/coin_models/coin_activities.rs b/crates/indexer/src/models/coin_models/coin_activities.rs index a5f03c59dcf6b..a8100d05bb3b2 100644 --- a/crates/indexer/src/models/coin_models/coin_activities.rs +++ b/crates/indexer/src/models/coin_models/coin_activities.rs @@ -19,7 +19,7 @@ use aptos_api_types::{ Event as APIEvent, Transaction as APITransaction, TransactionInfo as APITransactionInfo, TransactionPayload, UserTransactionRequest, WriteSetChange as APIWriteSetChange, }; -use aptos_types::APTOS_COIN_TYPE; +use aptos_types::SUPRA_COIN_TYPE; use bigdecimal::BigDecimal; use field_count::FieldCount; use serde::{Deserialize, Serialize}; diff --git a/crates/indexer/src/processors/coin_processor.rs b/crates/indexer/src/processors/coin_processor.rs index 9c65d42271388..d2b02b77de770 100644 --- a/crates/indexer/src/processors/coin_processor.rs +++ b/crates/indexer/src/processors/coin_processor.rs @@ -19,7 +19,7 @@ use crate::{ schema, }; use aptos_api_types::Transaction as APITransaction; -use aptos_types::APTOS_COIN_TYPE; +use aptos_types::SUPRA_COIN_TYPE; use async_trait::async_trait; use diesel::{pg::upsert::excluded, result::Error, ExpressionMethods, PgConnection}; use field_count::FieldCount; diff --git a/crates/transaction-emitter-lib/src/emitter/account_minter.rs b/crates/transaction-emitter-lib/src/emitter/account_minter.rs index 61bdab69db175..b31c11e819133 100644 --- a/crates/transaction-emitter-lib/src/emitter/account_minter.rs +++ b/crates/transaction-emitter-lib/src/emitter/account_minter.rs @@ -288,7 +288,7 @@ impl<'t> AccountMinter<'t> { let txn = self .source_account .sign_with_transaction_builder(self.txn_factory.payload( - aptos_stdlib::aptos_coin_mint(self.source_account.address(), amount), + aptos_stdlib::supra_coin_mint(self.source_account.address(), amount), )); if let Err(e) = txn_executor.execute_transactions(&[txn]).await { diff --git a/sdk/src/transaction_builder.rs b/sdk/src/transaction_builder.rs index bb28f20c1c95e..6a22f5bd7dece 100644 --- a/sdk/src/transaction_builder.rs +++ b/sdk/src/transaction_builder.rs @@ -228,7 +228,7 @@ impl TransactionFactory { } pub fn mint(&self, to: AccountAddress, amount: u64) -> TransactionBuilder { - self.payload(aptos_stdlib::aptos_coin_mint(to, amount)) + self.payload(aptos_stdlib::supra_coin_mint(to, amount)) } //