Skip to content

Commit

Permalink
Merge pull request #50 from MangoNet-Labs/devnet
Browse files Browse the repository at this point in the history
Devnet
  • Loading branch information
MangoNetworkOs authored Feb 12, 2025
2 parents d439ec2 + 5d62da9 commit 2264bd5
Show file tree
Hide file tree
Showing 68 changed files with 398 additions and 362 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ members = [

[workspace.package]
# This version string will be inherited by mgo-core, mgo-faucet, mgo-node, mgo-tools, mgo-sdk, mgo-move-build, and mgo crates.
version = "1.0.0"
version = "1.0.1"

[profile.release]
# debug = 1 means line charts only, which is minimum needed for good stack traces
Expand Down
6 changes: 3 additions & 3 deletions crates/mgo-benchmark/src/benchmark_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use mgo_types::base_types::ConciseableName;
use mgo_types::base_types::ObjectID;
use mgo_types::base_types::MgoAddress;
use mgo_types::crypto::{deterministic_random_account_key, AccountKeyPair};
use mgo_types::gas_coin::TOTAL_SUPPLY_MIST;
use mgo_types::gas_coin::TOTAL_SUPPLY_MANGO;
use mgo_types::object::Owner;
use test_cluster::TestClusterBuilder;
use tokio::runtime::Builder;
Expand Down Expand Up @@ -100,8 +100,8 @@ impl Env {
let cluster = TestClusterBuilder::new()
.with_accounts(vec![AccountConfig {
address: Some(primary_gas_owner),
// We can't use TOTAL_SUPPLY_MIST because we need to account for validator stakes in genesis allocation.
gas_amounts: vec![TOTAL_SUPPLY_MIST / 2],
// We can't use TOTAL_SUPPLY_MANGO because we need to account for validator stakes in genesis allocation.
gas_amounts: vec![TOTAL_SUPPLY_MANGO / 2],
}])
.with_num_validators(committee_size)
.build()
Expand Down
4 changes: 2 additions & 2 deletions crates/mgo-benchmark/src/drivers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ impl BenchmarkStats {
"latency (min)",
"latency (p50)",
"latency (p99)",
"gas used (MIST total)",
"gas used/hr (MIST approx.)",
"gas used (MANGO total)",
"gas used/hr (MANGO approx.)",
]);
let mut row = Row::new();
row.add_cell(Cell::new(self.duration.as_secs()));
Expand Down
8 changes: 4 additions & 4 deletions crates/mgo-benchmark/src/workloads/batch_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::sync::Arc;
use mgo_core::test_utils::make_pay_mgo_transaction;
use mgo_types::base_types::{ObjectID, SequenceNumber};
use mgo_types::digests::ObjectDigest;
use mgo_types::gas_coin::MIST_PER_MGO;
use mgo_types::gas_coin::MANGO_PER_MGO;
use mgo_types::object::Owner;
use mgo_types::{
base_types::{ObjectRef, MgoAddress},
Expand All @@ -24,12 +24,12 @@ use mgo_types::{
};
use tracing::{debug, error};

/// Value of each address's "primary coin" in mist. The first transaction gives
/// Value of each address's "primary coin" in mango. The first transaction gives
/// each address a coin worth PRIMARY_COIN_VALUE, and all subsequent transfers
/// send TRANSFER_AMOUNT coins each time
const PRIMARY_COIN_VALUE: u64 = 100 * MIST_PER_MGO;
const PRIMARY_COIN_VALUE: u64 = 100 * MANGO_PER_MGO;

/// Number of mist sent to each address on each batch transfer
/// Number of mango sent to each address on each batch transfer
const BATCH_TRANSFER_AMOUNT: u64 = 1;

const DUMMY_GAS: ObjectRef = (ObjectID::ZERO, SequenceNumber::MIN, ObjectDigest::MIN);
Expand Down
4 changes: 2 additions & 2 deletions crates/mgo-benchmark/src/workloads/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use mgo_core::test_utils::make_transfer_mgo_transaction;
use mgo_test_transaction_builder::TestTransactionBuilder;
use mgo_types::base_types::{ObjectRef, MgoAddress};
use mgo_types::crypto::{get_key_pair, AccountKeyPair};
use mgo_types::gas_coin::MIST_PER_MGO;
use mgo_types::gas_coin::MANGO_PER_MGO;
use mgo_types::transaction::Transaction;
use tracing::error;

Expand Down Expand Up @@ -70,7 +70,7 @@ impl Payload for DelegationTestPayload {
None => make_transfer_mgo_transaction(
self.gas,
self.sender,
Some(MIST_PER_MGO),
Some(MANGO_PER_MGO),
self.sender,
&self.keypair,
self.system_state_observer
Expand Down
2 changes: 1 addition & 1 deletion crates/mgo-benchmark/src/workloads/transfer_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use mgo_types::{
};

/// TODO: This should be the amount that is being transferred instead of MAX_GAS.
/// Number of mist sent to each address on each batch transfer
/// Number of mango sent to each address on each batch transfer
const _TRANSFER_AMOUNT: u64 = 1;

#[derive(Debug)]
Expand Down
6 changes: 3 additions & 3 deletions crates/mgo-benchmark/src/workloads/workload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ use crate::workloads::{Gas, GasCoinConfig};
use crate::ValidatorProxy;
use async_trait::async_trait;
use std::sync::Arc;
use mgo_types::gas_coin::MIST_PER_MGO;
use mgo_types::gas_coin::MANGO_PER_MGO;

// This is the maximum gas we will transfer from primary coin into any gas coin
// for running the benchmark
pub const MAX_GAS_FOR_TESTING: u64 = 1_000 * MIST_PER_MGO;
pub const MAX_GAS_FOR_TESTING: u64 = 1_000 * MANGO_PER_MGO;

// TODO: get this information from protocol config
// This is the maximum budget that can be set for a transaction. 50 MGO.
pub const MAX_BUDGET: u64 = 50 * MIST_PER_MGO;
pub const MAX_BUDGET: u64 = 50 * MANGO_PER_MGO;
// (COIN_BYTES_SIZE * STORAGE_PRICE * STORAGE_UNITS_PER_BYTE)
pub const STORAGE_COST_PER_COIN: u64 = 130 * 76 * 100;
// (COUNTER_BYTES_SIZE * STORAGE_PRICE * STORAGE_UNITS_PER_BYTE)
Expand Down
52 changes: 26 additions & 26 deletions crates/mgo-config/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use mgo_types::committee::CommitteeWithNetworkMetadata;
use mgo_types::crypto::DefaultHash;
use mgo_types::deny_list::{get_coin_deny_list, PerTypeDenyList};
use mgo_types::effects::{TransactionEffects, TransactionEvents};
use mgo_types::gas_coin::TOTAL_SUPPLY_MIST;
use mgo_types::gas_coin::TOTAL_SUPPLY_MANGO;
use mgo_types::messages_checkpoint::{
CertifiedCheckpointSummary, CheckpointContents, CheckpointSummary, VerifiedCheckpoint,
};
Expand Down Expand Up @@ -431,7 +431,7 @@ impl GenesisCeremonyParameters {

fn default_initial_stake_subsidy_distribution_amount() -> u64 {
// 1M Mgo
1_000_000 * mgo_types::gas_coin::MIST_PER_MGO
1_000_000 * mgo_types::gas_coin::MANGO_PER_MGO
}

fn default_stake_subsidy_period_length() -> u64 {
Expand All @@ -455,11 +455,11 @@ impl GenesisCeremonyParameters {
stake_subsidy_period_length: self.stake_subsidy_period_length,
stake_subsidy_decrease_rate: self.stake_subsidy_decrease_rate,
max_validator_count: mgo_types::governance::MAX_VALIDATOR_COUNT,
min_validator_joining_stake: mgo_types::governance::MIN_VALIDATOR_JOINING_STAKE_MIST,
min_validator_joining_stake: mgo_types::governance::MIN_VALIDATOR_JOINING_STAKE_MANGO,
validator_low_stake_threshold:
mgo_types::governance::VALIDATOR_LOW_STAKE_THRESHOLD_MIST,
mgo_types::governance::VALIDATOR_LOW_STAKE_THRESHOLD_MANGO,
validator_very_low_stake_threshold:
mgo_types::governance::VALIDATOR_VERY_LOW_STAKE_THRESHOLD_MIST,
mgo_types::governance::VALIDATOR_VERY_LOW_STAKE_THRESHOLD_MANGO,
validator_low_stake_grace_period:
mgo_types::governance::VALIDATOR_LOW_STAKE_GRACE_PERIOD,
}
Expand All @@ -475,20 +475,20 @@ impl Default for GenesisCeremonyParameters {
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct TokenDistributionSchedule {
pub stake_subsidy_fund_mist: u64,
pub stake_subsidy_fund_mango: u64,
pub allocations: Vec<TokenAllocation>,
}

impl TokenDistributionSchedule {
pub fn validate(&self) {
let mut total_mist = self.stake_subsidy_fund_mist;
let mut total_mango = self.stake_subsidy_fund_mango;

for allocation in &self.allocations {
total_mist += allocation.amount_mist;
total_mango += allocation.amount_mango;
}

if total_mist != TOTAL_SUPPLY_MIST {
panic!("TokenDistributionSchedule adds up to {total_mist} and not expected {TOTAL_SUPPLY_MIST}");
if total_mango != TOTAL_SUPPLY_MANGO {
panic!("TokenDistributionSchedule adds up to {total_mango} and not expected {TOTAL_SUPPLY_MANGO}");
}
}

Expand All @@ -510,13 +510,13 @@ impl TokenDistributionSchedule {
*validators
.get_mut(staked_with_validator)
.expect("allocation must be staked with valid validator") +=
allocation.amount_mist;
allocation.amount_mango;
}
}

// Check that all validators have sufficient stake allocated to ensure they meet the
// minimum stake threshold
let minimum_required_stake = mgo_types::governance::VALIDATOR_LOW_STAKE_THRESHOLD_MIST;
let minimum_required_stake = mgo_types::governance::VALIDATOR_LOW_STAKE_THRESHOLD_MANGO;
for (validator, stake) in validators {
if stake < minimum_required_stake {
panic!("validator {validator} has '{stake}' stake and does not meet the minimum required stake threshold of '{minimum_required_stake}'");
Expand All @@ -527,23 +527,23 @@ impl TokenDistributionSchedule {
pub fn new_for_validators_with_default_allocation<I: IntoIterator<Item = MgoAddress>>(
validators: I,
) -> Self {
let mut supply = TOTAL_SUPPLY_MIST;
let default_allocation = mgo_types::governance::VALIDATOR_LOW_STAKE_THRESHOLD_MIST;
let mut supply = TOTAL_SUPPLY_MANGO;
let default_allocation = mgo_types::governance::VALIDATOR_LOW_STAKE_THRESHOLD_MANGO;

let allocations = validators
.into_iter()
.map(|a| {
supply -= default_allocation;
TokenAllocation {
recipient_address: a,
amount_mist: default_allocation,
amount_mango: default_allocation,
staked_with_validator: Some(a),
}
})
.collect();

let schedule = Self {
stake_subsidy_fund_mist: supply,
stake_subsidy_fund_mango: supply,
allocations,
};

Expand All @@ -563,8 +563,8 @@ impl TokenDistributionSchedule {
let mut allocations: Vec<TokenAllocation> =
reader.deserialize().collect::<Result<_, _>>()?;
assert_eq!(
TOTAL_SUPPLY_MIST,
allocations.iter().map(|a| a.amount_mist).sum::<u64>(),
TOTAL_SUPPLY_MANGO,
allocations.iter().map(|a| a.amount_mango).sum::<u64>(),
"Token Distribution Schedule must add up to 10B Mgo",
);
let stake_subsidy_fund_allocation = allocations.pop().unwrap();
Expand All @@ -581,7 +581,7 @@ impl TokenDistributionSchedule {
);

let schedule = Self {
stake_subsidy_fund_mist: stake_subsidy_fund_allocation.amount_mist,
stake_subsidy_fund_mango: stake_subsidy_fund_allocation.amount_mango,
allocations,
};

Expand All @@ -598,7 +598,7 @@ impl TokenDistributionSchedule {

writer.serialize(TokenAllocation {
recipient_address: MgoAddress::default(),
amount_mist: self.stake_subsidy_fund_mist,
amount_mango: self.stake_subsidy_fund_mango,
staked_with_validator: None,
})?;

Expand All @@ -610,7 +610,7 @@ impl TokenDistributionSchedule {
#[serde(rename_all = "kebab-case")]
pub struct TokenAllocation {
pub recipient_address: MgoAddress,
pub amount_mist: u64,
pub amount_mango: u64,

/// Indicates if this allocation should be staked at genesis and with which validator
pub staked_with_validator: Option<MgoAddress>,
Expand All @@ -626,7 +626,7 @@ impl TokenDistributionScheduleBuilder {
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
Self {
pool: TOTAL_SUPPLY_MIST,
pool: TOTAL_SUPPLY_MANGO,
allocations: vec![],
}
}
Expand All @@ -635,25 +635,25 @@ impl TokenDistributionScheduleBuilder {
&mut self,
validators: I,
) {
let default_allocation = mgo_types::governance::VALIDATOR_LOW_STAKE_THRESHOLD_MIST;
let default_allocation = mgo_types::governance::VALIDATOR_LOW_STAKE_THRESHOLD_MANGO;

for validator in validators {
self.add_allocation(TokenAllocation {
recipient_address: validator,
amount_mist: default_allocation,
amount_mango: default_allocation,
staked_with_validator: Some(validator),
});
}
}

pub fn add_allocation(&mut self, allocation: TokenAllocation) {
self.pool = self.pool.checked_sub(allocation.amount_mist).unwrap();
self.pool = self.pool.checked_sub(allocation.amount_mango).unwrap();
self.allocations.push(allocation);
}

pub fn build(&self) -> TokenDistributionSchedule {
let schedule = TokenDistributionSchedule {
stake_subsidy_fund_mist: self.pool,
stake_subsidy_fund_mango: self.pool,
allocations: self.allocations.clone(),
};

Expand Down
2 changes: 1 addition & 1 deletion crates/mgo-config/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use tracing::info;
// Default max number of concurrent requests served
pub const DEFAULT_GRPC_CONCURRENCY_LIMIT: usize = 20000000000;

/// Default gas price of 100 Mist
/// Default gas price of 100 Mango
pub const DEFAULT_VALIDATOR_GAS_PRICE: u64 = mgo_types::transaction::DEFAULT_VALIDATOR_GAS_PRICE;

/// Default commission rate of 2%
Expand Down
4 changes: 2 additions & 2 deletions crates/mgo-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1531,9 +1531,9 @@ impl AuthorityState {
let ((gas_status, checked_input_objects), mock_gas) = if transaction.gas().is_empty() {
let sender = transaction.sender();
// use a 1B mgo coin
const MIST_TO_MGO: u64 = 1_000_000_000;
const MANGO_TO_MGO: u64 = 1_000_000_000;
const DRY_RUN_MGO: u64 = 1_000_000_000;
let max_coin_value = MIST_TO_MGO * DRY_RUN_MGO;
let max_coin_value = MANGO_TO_MGO * DRY_RUN_MGO;
let gas_object_id = ObjectID::random();
let gas_object = Object::new_move(
MoveObject::new_gas_coin(OBJECT_START_VERSION, gas_object_id, max_coin_value),
Expand Down
4 changes: 2 additions & 2 deletions crates/mgo-core/src/authority/authority_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use super::authority_store_tables::LiveObject;
use super::{authority_store_tables::AuthorityPerpetualTables, *};
use mango_common::sync::notify_read::NotifyRead;
use mgo_types::effects::{TransactionEffects, TransactionEvents};
use mgo_types::gas_coin::TOTAL_SUPPLY_MIST;
use mgo_types::gas_coin::TOTAL_SUPPLY_MANGO;
use typed_store::rocks::util::is_ref_count_value;

const NUM_SHARDS: usize = 4096;
Expand Down Expand Up @@ -1549,7 +1549,7 @@ impl AuthorityStore {
.set(imbalance);
self.metrics
.mgo_conservation_imbalance
.set((total_mgo as i128 - TOTAL_SUPPLY_MIST as i128) as i64);
.set((total_mgo as i128 - TOTAL_SUPPLY_MANGO as i128) as i64);

if let Some(expected_imbalance) = self
.perpetual_tables
Expand Down
2 changes: 1 addition & 1 deletion crates/mgo-core/src/unit_tests/gas_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async fn test_tx_more_than_maximum_gas_budget() {
// - computation ok, OOG for storage, OOG for minimal storage (e.g. computation is entire budget)
//
// With multiple gas coins is practically impossible to fail storage cost because we
// get a significant among of MIST back from smashing. So we try:
// get a significant among of MANGO back from smashing. So we try:
// - OOG computation, storage ok
//
// impossible scenarios:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ module mgo_system::genesis {
}

struct TokenDistributionSchedule has drop {
stake_subsidy_fund_mist: u64,
stake_subsidy_fund_mango: u64,
allocations: vector<TokenAllocation>,
}

struct TokenAllocation has drop {
recipient_address: address,
amount_mist: u64,
amount_mango: u64,
staked_with_validator: Option<address>,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ module mgo_system::genesis {
}

struct TokenDistributionSchedule has drop {
stake_subsidy_fund_mist: u64,
stake_subsidy_fund_mango: u64,
allocations: vector<TokenAllocation>,
}

struct TokenAllocation has drop {
recipient_address: address,
amount_mist: u64,
amount_mango: u64,
staked_with_validator: Option<address>,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ module mgo_system::genesis {
}

struct TokenDistributionSchedule has drop {
stake_subsidy_fund_mist: u64,
stake_subsidy_fund_mango: u64,
allocations: vector<TokenAllocation>,
}

struct TokenAllocation has drop {
recipient_address: address,
amount_mist: u64,
amount_mango: u64,
staked_with_validator: Option<address>,
}

Expand Down
Loading

0 comments on commit 2264bd5

Please sign in to comment.