Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions crates/iota-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ use iota_types::{
TransactionEvents, VerifiedCertifiedTransactionEffects, VerifiedSignedTransactionEffects,
},
error::{ExecutionError, IotaError, IotaResult, UserInputError},
event::{Event, EventID, SystemEpochInfoEvent, SystemEpochInfoEventV1, SystemEpochInfoEventV2},
event::{Event, EventID, SystemEpochInfoEvent},
executable_transaction::VerifiedExecutableTransaction,
execution_config_utils::to_binary_config,
execution_status::ExecutionStatus,
Expand Down Expand Up @@ -4714,9 +4714,9 @@ impl AuthorityState {
let system_epoch_info_event = temporary_store
.events
.data
.iter()
.into_iter()
.find(|event| event.is_system_epoch_info_event())
.map(|event| SystemEpochInfoEvent::from(event));
.map(SystemEpochInfoEvent::from);
// 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());
Expand Down
9 changes: 6 additions & 3 deletions crates/iota-core/src/authority/authority_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ use iota_types::{
error::UserInputError,
execution::TypeLayoutStore,
fp_bail, fp_ensure,
iota_system_state::get_iota_system_state,
iota_system_state::{
get_iota_system_state, iota_system_state_summary::IotaSystemStateSummaryV2,
},
message_envelope::Message,
storage::{
BackingPackageStore, MarkerValue, ObjectKey, ObjectOrTombstone, ObjectStore, get_module,
Expand Down Expand Up @@ -1592,10 +1594,11 @@ impl AuthorityStore {

// It is safe to call this function because we are in the middle of
// reconfiguration.
let system_state = self
let system_state: IotaSystemStateSummaryV2 = self
.get_iota_system_state_object_unsafe()
.expect("Reading iota system state object cannot fail")
.into_iota_system_state_summary();
.into_iota_system_state_summary()
.try_into()?;
let storage_fund_balance = system_state.storage_fund_total_object_storage_rebates;
info!(
"Total IOTA amount in the network: {}, storage fund balance: {}, total storage rebate: {} at beginning of epoch {}",
Expand Down
49 changes: 47 additions & 2 deletions crates/iota-json-rpc-types/src/iota_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ use iota_types::{
signature::GenericSignature,
storage::{DeleteKind, WriteKind},
transaction::{
Argument, CallArg, ChangeEpoch, Command, EndOfEpochTransactionKind, GenesisObject,
InputObjectKind, ObjectArg, ProgrammableMoveCall, ProgrammableTransaction,
Argument, CallArg, ChangeEpoch, ChangeEpochV2, Command, EndOfEpochTransactionKind,
GenesisObject, InputObjectKind, ObjectArg, ProgrammableMoveCall, ProgrammableTransaction,
SenderSignedData, TransactionData, TransactionDataAPI, TransactionKind,
},
};
Expand Down Expand Up @@ -517,6 +517,9 @@ impl IotaTransactionBlockKind {
EndOfEpochTransactionKind::ChangeEpoch(e) => {
IotaEndOfEpochTransactionKind::ChangeEpoch(e.into())
}
EndOfEpochTransactionKind::ChangeEpochV2(e) => {
IotaEndOfEpochTransactionKind::ChangeEpochV2(e.into())
}
EndOfEpochTransactionKind::AuthenticatorStateCreate => {
IotaEndOfEpochTransactionKind::AuthenticatorStateCreate
}
Expand Down Expand Up @@ -603,6 +606,9 @@ impl IotaTransactionBlockKind {
EndOfEpochTransactionKind::ChangeEpoch(e) => {
IotaEndOfEpochTransactionKind::ChangeEpoch(e.into())
}
EndOfEpochTransactionKind::ChangeEpochV2(e) => {
IotaEndOfEpochTransactionKind::ChangeEpochV2(e.into())
}
EndOfEpochTransactionKind::AuthenticatorStateCreate => {
IotaEndOfEpochTransactionKind::AuthenticatorStateCreate
}
Expand Down Expand Up @@ -679,6 +685,42 @@ impl From<ChangeEpoch> for IotaChangeEpoch {
}
}

#[serde_as]
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
pub struct IotaChangeEpochV2 {
#[schemars(with = "BigInt<u64>")]
#[serde_as(as = "BigInt<u64>")]
pub epoch: EpochId,
#[schemars(with = "BigInt<u64>")]
#[serde_as(as = "BigInt<u64>")]
pub storage_charge: u64,
#[schemars(with = "BigInt<u64>")]
#[serde_as(as = "BigInt<u64>")]
pub computation_charge: u64,
#[schemars(with = "BigInt<u64>")]
#[serde_as(as = "BigInt<u64>")]
pub computation_charge_burned: u64,
#[schemars(with = "BigInt<u64>")]
#[serde_as(as = "BigInt<u64>")]
pub storage_rebate: u64,
#[schemars(with = "BigInt<u64>")]
#[serde_as(as = "BigInt<u64>")]
pub epoch_start_timestamp_ms: u64,
}

impl From<ChangeEpochV2> for IotaChangeEpochV2 {
fn from(e: ChangeEpochV2) -> Self {
Self {
epoch: e.epoch,
storage_charge: e.storage_charge,
computation_charge: e.computation_charge,
computation_charge_burned: e.computation_charge_burned,
storage_rebate: e.storage_rebate,
epoch_start_timestamp_ms: e.epoch_start_timestamp_ms,
}
}
}

#[derive(Debug, Deserialize, Serialize, JsonSchema, Clone, PartialEq, Eq)]
#[enum_dispatch(IotaTransactionBlockEffectsAPI)]
#[serde(
Expand Down Expand Up @@ -1035,10 +1077,12 @@ impl Display for IotaTransactionBlockEffects {
"Gas Cost Summary:\n \
Storage Cost: {} NANOS\n \
Computation Cost: {} NANOS\n \
Computation Cost Burned: {} NANOS\n \
Storage Rebate: {} NANOS\n \
Non-refundable Storage Fee: {} NANOS",
gas_cost_summary.storage_cost,
gas_cost_summary.computation_cost,
gas_cost_summary.computation_cost_burned,
gas_cost_summary.storage_rebate,
gas_cost_summary.non_refundable_storage_fee,
)]);
Expand Down Expand Up @@ -1622,6 +1666,7 @@ pub struct IotaEndOfEpochTransaction {
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
pub enum IotaEndOfEpochTransactionKind {
ChangeEpoch(IotaChangeEpoch),
ChangeEpochV2(IotaChangeEpochV2),
AuthenticatorStateCreate,
AuthenticatorStateExpire(IotaAuthenticatorStateExpire),
BridgeStateCreate(CheckpointDigest),
Expand Down
14 changes: 7 additions & 7 deletions crates/iota-json-rpc/src/coin_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1287,9 +1287,8 @@ mod tests {
id::UID,
iota_system_state::{
IotaSystemState,
iota_system_state_inner_v1::{
IotaSystemStateV1, StorageFundV1, SystemParametersV1, ValidatorSetV1,
},
iota_system_state_inner_v1::{StorageFundV1, SystemParametersV1, ValidatorSetV1},
iota_system_state_inner_v2::IotaSystemStateV2,
},
};
use mockall::predicate;
Expand All @@ -1305,7 +1304,7 @@ mod tests {
let mut state = default_system_state();
state.iota_treasury_cap.inner.total_supply.value = 42;

Ok(IotaSystemState::V1(state))
Ok(IotaSystemState::V2(state))
});

let coin_read_api = CoinReadApi::new_for_tests(Arc::new(mock_state), None);
Expand Down Expand Up @@ -1415,8 +1414,8 @@ mod tests {
expected.assert_eq(error_result.message());
}

fn default_system_state() -> IotaSystemStateV1 {
IotaSystemStateV1 {
fn default_system_state() -> IotaSystemStateV2 {
IotaSystemStateV2 {
epoch: Default::default(),
protocol_version: Default::default(),
system_state_version: Default::default(),
Expand Down Expand Up @@ -1464,7 +1463,8 @@ mod tests {
},
safe_mode: Default::default(),
safe_mode_storage_charges: iota_types::balance::Balance::new(Default::default()),
safe_mode_computation_rewards: iota_types::balance::Balance::new(Default::default()),
safe_mode_computation_charges: iota_types::balance::Balance::new(Default::default()),
safe_mode_computation_charges_burned: Default::default(),
safe_mode_storage_rebates: Default::default(),
safe_mode_non_refundable_storage_fee: Default::default(),
epoch_start_timestamp_ms: Default::default(),
Expand Down
58 changes: 56 additions & 2 deletions crates/iota-open-rpc/spec/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,7 @@
"hardened_otw_check": true,
"no_extraneous_module_bytes": true,
"passkey_auth": true,
"protocol_defined_base_fee": false,
"relocate_event_module": false,
"rethrow_serialization_type_layout_errors": true,
"zklogin_auth": false
Expand All @@ -1327,6 +1328,7 @@
"address_to_u256_cost_base": {
"u64": "52"
},
"base_gas_price": null,
"base_tx_cost_fixed": {
"u64": "1000"
},
Expand Down Expand Up @@ -7582,6 +7584,37 @@
}
}
},
"IotaChangeEpochV2": {
"type": "object",
"required": [
"computation_charge",
"computation_charge_burned",
"epoch",
"epoch_start_timestamp_ms",
"storage_charge",
"storage_rebate"
],
"properties": {
"computation_charge": {
"$ref": "#/components/schemas/BigInt_for_uint64"
},
"computation_charge_burned": {
"$ref": "#/components/schemas/BigInt_for_uint64"
},
"epoch": {
"$ref": "#/components/schemas/BigInt_for_uint64"
},
"epoch_start_timestamp_ms": {
"$ref": "#/components/schemas/BigInt_for_uint64"
},
"storage_charge": {
"$ref": "#/components/schemas/BigInt_for_uint64"
},
"storage_rebate": {
"$ref": "#/components/schemas/BigInt_for_uint64"
}
}
},
"IotaCoinMetadata": {
"type": "object",
"required": [
Expand Down Expand Up @@ -7649,6 +7682,18 @@
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"ChangeEpochV2"
],
"properties": {
"ChangeEpochV2": {
"$ref": "#/components/schemas/IotaChangeEpochV2"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
Expand Down Expand Up @@ -8317,7 +8362,8 @@
"protocolVersion",
"referenceGasPrice",
"safeMode",
"safeModeComputationRewards",
"safeModeComputationCharges",
"safeModeComputationChargesBurned",
"safeModeNonRefundableStorageFee",
"safeModeStorageCharges",
"safeModeStorageRebates",
Expand Down Expand Up @@ -8482,14 +8528,22 @@
"description": "Whether the system is running in a downgraded safe mode due to a non-recoverable bug. This is set whenever we failed to execute advance_epoch, and ended up executing advance_epoch_safe_mode. It can be reset once we are able to successfully execute advance_epoch.",
"type": "boolean"
},
"safeModeComputationRewards": {
"safeModeComputationCharges": {
"description": "Amount of computation rewards accumulated (and not yet distributed) during safe mode.",
"allOf": [
{
"$ref": "#/components/schemas/BigInt_for_uint64"
}
]
},
"safeModeComputationChargesBurned": {
"description": "Amount of burned computation rewards accumulated during safe mode.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"description": "Amount of burned computation rewards accumulated during safe mode.",
"description": "Amount of burned computation charges accumulated during safe mode.",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This suggestion will be outdated due to 3d65d4a and 3f59333

IotaSystemStateSummaryV1 will now be kept unchanged with field safe_mode_computation_rewards and IotaSystemStateSummaryV2 introduced with renamed and additional fields.

"allOf": [
{
"$ref": "#/components/schemas/BigInt_for_uint64"
}
]
},
"safeModeNonRefundableStorageFee": {
"description": "Amount of non-refundable storage fee accumulated during safe mode.",
"allOf": [
Expand Down
Loading
Loading