Skip to content

Commit

Permalink
Merge branch 'develop' into tooling-dashboard/style-my-coins
Browse files Browse the repository at this point in the history
  • Loading branch information
evavirseda authored Oct 30, 2024
2 parents db68f79 + e13b151 commit 7b93192
Show file tree
Hide file tree
Showing 53 changed files with 566 additions and 430 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/_vercel_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,63 +36,63 @@ jobs:
explorer-preview:
name: Vercel Explorer Preview
if: inputs.shouldDeployPreview && inputs.isExplorer
uses: ./.github/workflows/apps-explorer.deploy.yml
uses: ./.github/workflows/apps_explorer_deploy.yml
secrets: inherit
with:
isProd: false

explorer-prod:
name: Vercel Explorer Production
if: inputs.isDevelop
uses: ./.github/workflows/apps-explorer.deploy.yml
uses: ./.github/workflows/apps_explorer_deploy.yml
secrets: inherit
with:
isProd: true

ui-kit-preview:
name: Vercel UI Kit Preview
if: inputs.shouldDeployPreview && inputs.isAppsUiKit
uses: ./.github/workflows/apps-ui-kit.deploy.yml
uses: ./.github/workflows/apps_ui_kit_deploy.yml
secrets: inherit
with:
isProd: false

ui-kit-prod:
name: Vercel UI Kit Production
if: inputs.isDevelop
uses: ./.github/workflows/apps-ui-kit.deploy.yml
uses: ./.github/workflows/apps_ui_kit_deploy.yml
secrets: inherit
with:
isProd: true

wallet-dashboard-preview:
name: Vercel Wallet Dashboard Preview
if: inputs.shouldDeployPreview && inputs.isWalletDashboard
uses: ./.github/workflows/apps-wallet-dashboard.deploy.yml
uses: ./.github/workflows/apps_wallet_dashboard_deploy.yml
secrets: inherit
with:
isProd: false

wallet-dashboard-prod:
name: Vercel Wallet Dashboard Production
if: inputs.isDevelop
uses: ./.github/workflows/apps-wallet-dashboard.deploy.yml
uses: ./.github/workflows/apps_wallet_dashboard_deploy.yml
secrets: inherit
with:
isProd: true

apps-backend-preview:
name: Vercel apps-backend Preview
if: inputs.shouldDeployPreview && inputs.isAppsBackend
uses: ./.github/workflows/apps-backend.deploy.yml
uses: ./.github/workflows/apps_backend_deploy.yml
secrets: inherit
with:
isProd: false

apps-backend-prod:
name: Vercel apps-backend Production
if: inputs.isDevelop
uses: ./.github/workflows/apps-backend.deploy.yml
uses: ./.github/workflows/apps_backend_deploy.yml
secrets: inherit
with:
isProd: true
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 12 additions & 6 deletions crates/iota-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4514,7 +4514,11 @@ impl AuthorityState {
gas_cost_summary: &GasCostSummary,
checkpoint: CheckpointSequenceNumber,
epoch_start_timestamp_ms: CheckpointTimestamp,
) -> anyhow::Result<(IotaSystemState, SystemEpochInfoEventV1, TransactionEffects)> {
) -> anyhow::Result<(
IotaSystemState,
Option<SystemEpochInfoEventV1>,
TransactionEffects,
)> {
let mut txns = Vec::new();

if let Some(tx) = self.create_authenticator_state_tx(epoch_store) {
Expand Down Expand Up @@ -4644,11 +4648,13 @@ impl AuthorityState {
.data
.iter()
.find(|event| event.is_system_epoch_info_event())
.expect("end of epoch tx must emit system epoch info event");
let system_epoch_info_event = bcs::from_bytes::<SystemEpochInfoEventV1>(
&system_epoch_info_event.contents,
)
.expect("deserialization should succeed since we asserted that the event is of this type");
.map(|event| {
bcs::from_bytes::<SystemEpochInfoEventV1>(&event.contents)
.expect("event deserialization should succeed as type was pre-validated")
});
// The system epoch info event can be `None` in case if the `advance_epoch`
// Move function call failed and was executed in the safe mode.
assert!(system_epoch_info_event.is_some() || system_obj.safe_mode());

// We must write tx and effects to the state sync tables so that state sync is
// able to deliver to the transaction to CheckpointExecutor after it is
Expand Down
11 changes: 8 additions & 3 deletions crates/iota-core/src/checkpoints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1445,11 +1445,16 @@ impl CheckpointBuilder {
)
.await?;

// The system epoch info event can be `None` in case if the `advance_epoch`
// Move function call failed and was executed in the safe mode.
// In this case, the tokens supply should be unchanged.
//
// SAFETY: The number of minted and burnt tokens easily fit into an i64 and due
// to those small numbers, no overflows will occur during conversion or
// subtraction.
let epoch_supply_change = system_epoch_info_event.minted_tokens_amount as i64
- system_epoch_info_event.burnt_tokens_amount as i64;
let epoch_supply_change = system_epoch_info_event.map_or(0, |event| {
event.minted_tokens_amount as i64 - event.burnt_tokens_amount as i64
});

let committee = system_state_obj
.get_current_epoch_committee()
Expand Down Expand Up @@ -1574,7 +1579,7 @@ impl CheckpointBuilder {
checkpoint_effects: &mut Vec<TransactionEffects>,
signatures: &mut Vec<Vec<GenericSignature>>,
checkpoint: CheckpointSequenceNumber,
) -> anyhow::Result<(IotaSystemState, SystemEpochInfoEventV1)> {
) -> anyhow::Result<(IotaSystemState, Option<SystemEpochInfoEventV1>)> {
let (system_state, system_epoch_info_event, effects) = self
.state
.create_and_execute_advance_epoch_tx(
Expand Down
15 changes: 3 additions & 12 deletions crates/iota-core/src/epoch/randomness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,19 @@ pub const SINGLETON_KEY: u64 = 0;
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[allow(clippy::large_enum_variant)]
pub enum VersionedProcessedMessage {
V0(), // deprecated
V1(dkg_v1::ProcessedMessage<PkG, EncG>),
}

impl VersionedProcessedMessage {
pub fn sender(&self) -> PartyId {
match self {
VersionedProcessedMessage::V0() => {
panic!("BUG: invalid VersionedProcessedMessage version V0")
}
VersionedProcessedMessage::V1(msg) => msg.message.sender,
}
}

pub fn unwrap_v1(self) -> dkg_v1::ProcessedMessage<PkG, EncG> {
if let VersionedProcessedMessage::V1(msg) = self {
msg
} else {
panic!("BUG: expected message version is 1")
match self {
VersionedProcessedMessage::V1(msg) => msg,
}
}

Expand Down Expand Up @@ -110,7 +104,6 @@ impl VersionedProcessedMessage {

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum VersionedUsedProcessedMessages {
V0(), // deprecated
V1(dkg_v1::UsedProcessedMessages<PkG, EncG>),
}

Expand All @@ -123,9 +116,7 @@ impl VersionedUsedProcessedMessages {
// All inputs are verified in add_confirmation, so we can assume they are of the
// correct version.
let rng = &mut StdRng::from_rng(OsRng).expect("RNG construction should not fail");
let VersionedUsedProcessedMessages::V1(msg) = self else {
panic!("BUG: invalid VersionedUsedProcessedMessages version")
};
let VersionedUsedProcessedMessages::V1(msg) = self;
party.complete_v1(
msg,
&confirmations
Expand Down
2 changes: 1 addition & 1 deletion crates/iota-core/src/state_accumulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ impl StateAccumulatorV1 {
epoch_store: Arc<AuthorityPerEpochStore>,
last_checkpoint_of_epoch: CheckpointSequenceNumber,
) -> IotaResult<Accumulator> {
let _scope = monitored_scope("AccumulateEpochV2");
let _scope = monitored_scope("AccumulateEpoch");
let running_root = epoch_store
.get_running_root_accumulator(&last_checkpoint_of_epoch)?
.expect("Expected running root accumulator to exist up to last checkpoint of epoch");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
// SPDX-License-Identifier: Apache-2.0

module iota_system::genesis {
use std::vector;
use iota::balance::{Self, Balance};
use iota::object::UID;
use iota::iota::IOTA;
use iota::tx_context::{Self, TxContext};
use std::option::Option;
use std::string::String;

use iota::balance;
use iota::iota::IotaTreasuryCap;
use iota::timelock::SystemTimelockCap;

use iota_system::iota_system;
use iota_system::validator;
Expand Down Expand Up @@ -55,15 +54,20 @@ module iota_system::genesis {
public struct TokenAllocation has drop {
recipient_address: address,
amount_nanos: u64,

staked_with_validator: Option<address>,
staked_with_timelock_expiration: Option<u64>,
}

#[allow(unused_function)]
fun create(
iota_system_state_id: UID,
mut iota_supply: Balance<IOTA>,
mut iota_treasury_cap: IotaTreasuryCap,
genesis_chain_parameters: GenesisChainParameters,
genesis_validators: vector<GenesisValidatorMetadata>,
_token_distribution_schedule: TokenDistributionSchedule,
_timelock_genesis_label: Option<String>,
system_timelock_cap: SystemTimelockCap,
ctx: &mut TxContext,
) {
assert!(tx_context::epoch(ctx) == 0, 0);
Expand Down Expand Up @@ -97,7 +101,7 @@ module iota_system::genesis {
network_address,
p2p_address,
primary_address,
balance::split(&mut iota_supply, 2500),
iota_treasury_cap.mint_balance(2500, ctx),
ctx
);

Expand All @@ -108,11 +112,13 @@ module iota_system::genesis {

iota_system::create(
iota_system_state_id,
iota_treasury_cap,
validators,
iota_supply, // storage_fund
balance::zero(),
genesis_chain_parameters.protocol_version,
genesis_chain_parameters.chain_start_timestamp_ms,
genesis_chain_parameters.epoch_duration_ms,
system_timelock_cap,
ctx,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
// SPDX-License-Identifier: Apache-2.0

module iota_system::iota_system {
use std::vector;

use iota::balance::Balance;
use iota::object::UID;
use iota::iota::IOTA;
use iota::transfer;
use iota::tx_context::{Self, TxContext};
use iota::dynamic_field;
use iota::iota::IOTA;
use iota::iota::IotaTreasuryCap;
use iota::timelock::SystemTimelockCap;

use iota_system::validator::Validator;
use iota_system::iota_system_state_inner::IotaSystemStateInner;
use iota_system::iota_system_state_inner;
use iota_system::validator::ValidatorV1;
use iota_system::iota_system_state_inner::{Self, IotaSystemStateV1};

const SYSTEM_TIMELOCK_CAP_DF_KEY: vector<u8> = b"sys_timelock_cap";

public struct IotaSystemState has key {
id: UID,
Expand All @@ -23,14 +21,17 @@ module iota_system::iota_system {

public(package) fun create(
id: UID,
validators: vector<Validator>,
iota_treasury_cap: IotaTreasuryCap,
validators: vector<ValidatorV1>,
storage_fund: Balance<IOTA>,
protocol_version: u64,
epoch_start_timestamp_ms: u64,
epoch_duration_ms: u64,
system_timelock_cap: SystemTimelockCap,
ctx: &mut TxContext,
) {
let system_state = iota_system_state_inner::create(
iota_treasury_cap,
validators,
storage_fund,
protocol_version,
Expand All @@ -44,21 +45,22 @@ module iota_system::iota_system {
version,
};
dynamic_field::add(&mut self.id, version, system_state);
dynamic_field::add(&mut self.id, SYSTEM_TIMELOCK_CAP_DF_KEY, system_timelock_cap);
transfer::share_object(self);
}

#[allow(unused_function)]
fun advance_epoch(
validator_target_reward: u64,
storage_charge: Balance<IOTA>,
computation_reward: Balance<IOTA>,
wrapper: &mut IotaSystemState,
new_epoch: u64,
next_protocol_version: u64,
storage_rebate: u64,
_non_refundable_storage_fee: u64,
_storage_fund_reinvest_rate: u64, // share of storage fund's rewards that's reinvested
// into storage fund, in basis point.
_reward_slashing_rate: u64, // how much rewards are slashed to punish a validator, in bps.
epoch_start_timestamp_ms: u64, // Timestamp of the epoch start
non_refundable_storage_fee: u64,
reward_slashing_rate: u64,
epoch_start_timestamp_ms: u64,
ctx: &mut TxContext,
) : Balance<IOTA> {
let self = load_system_state_mut(wrapper);
Expand All @@ -67,28 +69,32 @@ module iota_system::iota_system {
self,
new_epoch,
next_protocol_version,
validator_target_reward,
storage_charge,
computation_reward,
storage_rebate,
non_refundable_storage_fee,
reward_slashing_rate,
epoch_start_timestamp_ms,
ctx
);

storage_rebate
}

public fun active_validator_addresses(wrapper: &mut IotaSystemState): vector<address> {
public fun active_validator_addresses(_wrapper: &mut IotaSystemState): vector<address> {
vector::empty()
}

fun load_system_state_mut(self: &mut IotaSystemState): &mut IotaSystemStateInner {
fun load_system_state_mut(self: &mut IotaSystemState): &mut IotaSystemStateV1 {
load_inner_maybe_upgrade(self)
}

fun load_inner_maybe_upgrade(self: &mut IotaSystemState): &mut IotaSystemStateInner {
fun load_inner_maybe_upgrade(self: &mut IotaSystemState): &mut IotaSystemStateV1 {
let version = self.version;
// TODO: This is where we check the version and perform upgrade if necessary.

let inner: &mut IotaSystemStateInner = dynamic_field::borrow_mut(&mut self.id, version);
let inner: &mut IotaSystemStateV1 = dynamic_field::borrow_mut(&mut self.id, version);
assert!(iota_system_state_inner::system_state_version(inner) == version, 0);
inner
}
Expand Down
Loading

0 comments on commit 7b93192

Please sign in to comment.