From cff774d4cbbefcd56472b973971e8f3e94e0eca1 Mon Sep 17 00:00:00 2001 From: Valerii Reutov Date: Tue, 5 Nov 2024 15:37:57 +0200 Subject: [PATCH] feat: add and integrate `IotaSystemAdminCap` rust module --- .../base/sources/genesis.move | 6 ++-- .../base/sources/iota_system.move | 8 ++--- .../base/sources/iota_system_state_inner.move | 4 +++ .../deep_upgrade/sources/genesis.move | 6 ++-- .../deep_upgrade/sources/iota_system.move | 8 ++--- .../sources/iota_system_state_inner.move | 7 ++++ .../safe_mode/sources/genesis.move | 6 ++-- .../safe_mode/sources/iota_system.move | 8 ++--- .../sources/iota_system_state_inner.move | 4 +++ .../shallow_upgrade/sources/genesis.move | 6 ++-- .../shallow_upgrade/sources/iota_system.move | 8 ++--- .../sources/iota_system_state_inner.move | 7 ++++ crates/iota-genesis-builder/src/lib.rs | 11 +++--- crates/iota-json-rpc/src/coin_api.rs | 2 ++ .../iota_system_state_inner_v1.rs | 3 ++ .../simtest_iota_system_state_inner.rs | 3 ++ crates/iota-types/src/lib.rs | 1 + crates/iota-types/src/system_admin_cap.rs | 34 +++++++++++++++++++ 18 files changed, 95 insertions(+), 37 deletions(-) create mode 100644 crates/iota-types/src/system_admin_cap.rs diff --git a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/base/sources/genesis.move b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/base/sources/genesis.move index f4d69976b8b..c5a91d91351 100644 --- a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/base/sources/genesis.move +++ b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/base/sources/genesis.move @@ -7,7 +7,7 @@ module iota_system::genesis { use iota::balance; use iota::iota::IotaTreasuryCap; - use iota::timelock::SystemTimelockCap; + use iota::system_admin_cap::IotaSystemAdminCap; use iota_system::iota_system; use iota_system::validator; @@ -67,7 +67,7 @@ module iota_system::genesis { genesis_validators: vector, _token_distribution_schedule: TokenDistributionSchedule, _timelock_genesis_label: Option, - system_timelock_cap: SystemTimelockCap, + iota_system_admin_cap: IotaSystemAdminCap, ctx: &mut TxContext, ) { assert!(tx_context::epoch(ctx) == 0, 0); @@ -118,7 +118,7 @@ module iota_system::genesis { genesis_chain_parameters.protocol_version, genesis_chain_parameters.chain_start_timestamp_ms, genesis_chain_parameters.epoch_duration_ms, - system_timelock_cap, + iota_system_admin_cap, ctx, ); } diff --git a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/base/sources/iota_system.move b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/base/sources/iota_system.move index 9054f11b4a6..b615e565ac1 100644 --- a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/base/sources/iota_system.move +++ b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/base/sources/iota_system.move @@ -7,13 +7,11 @@ module iota_system::iota_system { use iota::dynamic_field; use iota::iota::IOTA; use iota::iota::IotaTreasuryCap; - use iota::timelock::SystemTimelockCap; + use iota::system_admin_cap::IotaSystemAdminCap; use iota_system::validator::ValidatorV1; use iota_system::iota_system_state_inner::{Self, IotaSystemStateV1}; - const SYSTEM_TIMELOCK_CAP_DF_KEY: vector = b"sys_timelock_cap"; - public struct IotaSystemState has key { id: UID, version: u64, @@ -27,7 +25,7 @@ module iota_system::iota_system { protocol_version: u64, epoch_start_timestamp_ms: u64, epoch_duration_ms: u64, - system_timelock_cap: SystemTimelockCap, + iota_system_admin_cap: IotaSystemAdminCap, ctx: &mut TxContext, ) { let system_state = iota_system_state_inner::create( @@ -37,6 +35,7 @@ module iota_system::iota_system { protocol_version, epoch_start_timestamp_ms, epoch_duration_ms, + iota_system_admin_cap, ctx, ); let version = iota_system_state_inner::genesis_system_state_version(); @@ -45,7 +44,6 @@ 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); } diff --git a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/base/sources/iota_system_state_inner.move b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/base/sources/iota_system_state_inner.move index e3abf0b3c56..14f0d9e0186 100644 --- a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/base/sources/iota_system_state_inner.move +++ b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/base/sources/iota_system_state_inner.move @@ -8,6 +8,7 @@ module iota_system::iota_system_state_inner { use iota::event; use iota::iota::IOTA; use iota::iota::IotaTreasuryCap; + use iota::system_admin_cap::IotaSystemAdminCap; use iota::table::{Self, Table}; use iota_system::validator::ValidatorV1; @@ -50,6 +51,7 @@ module iota_system::iota_system_state_inner { validators: ValidatorSetV1, storage_fund: Balance, parameters: SystemParametersV1, + iota_system_admin_cap: IotaSystemAdminCap, reference_gas_price: u64, safe_mode: bool, epoch_start_timestamp_ms: u64, @@ -63,6 +65,7 @@ module iota_system::iota_system_state_inner { protocol_version: u64, epoch_start_timestamp_ms: u64, epoch_duration_ms: u64, + iota_system_admin_cap: IotaSystemAdminCap, ctx: &mut TxContext, ): IotaSystemStateV1 { let validators = new_validator_set(validators, ctx); @@ -77,6 +80,7 @@ module iota_system::iota_system_state_inner { epoch_duration_ms, extra_fields: bag::new(ctx), }, + iota_system_admin_cap, reference_gas_price: 1, safe_mode: false, epoch_start_timestamp_ms, diff --git a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/deep_upgrade/sources/genesis.move b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/deep_upgrade/sources/genesis.move index f4d69976b8b..c5a91d91351 100644 --- a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/deep_upgrade/sources/genesis.move +++ b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/deep_upgrade/sources/genesis.move @@ -7,7 +7,7 @@ module iota_system::genesis { use iota::balance; use iota::iota::IotaTreasuryCap; - use iota::timelock::SystemTimelockCap; + use iota::system_admin_cap::IotaSystemAdminCap; use iota_system::iota_system; use iota_system::validator; @@ -67,7 +67,7 @@ module iota_system::genesis { genesis_validators: vector, _token_distribution_schedule: TokenDistributionSchedule, _timelock_genesis_label: Option, - system_timelock_cap: SystemTimelockCap, + iota_system_admin_cap: IotaSystemAdminCap, ctx: &mut TxContext, ) { assert!(tx_context::epoch(ctx) == 0, 0); @@ -118,7 +118,7 @@ module iota_system::genesis { genesis_chain_parameters.protocol_version, genesis_chain_parameters.chain_start_timestamp_ms, genesis_chain_parameters.epoch_duration_ms, - system_timelock_cap, + iota_system_admin_cap, ctx, ); } diff --git a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/deep_upgrade/sources/iota_system.move b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/deep_upgrade/sources/iota_system.move index 549ba9c21a3..2d34ba2c6be 100644 --- a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/deep_upgrade/sources/iota_system.move +++ b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/deep_upgrade/sources/iota_system.move @@ -7,13 +7,11 @@ module iota_system::iota_system { use iota::dynamic_field; use iota::iota::IOTA; use iota::iota::IotaTreasuryCap; - use iota::timelock::SystemTimelockCap; + use iota::system_admin_cap::IotaSystemAdminCap; use iota_system::validator::ValidatorV1; use iota_system::iota_system_state_inner::{Self, IotaSystemStateV1, IotaSystemStateV2}; - const SYSTEM_TIMELOCK_CAP_DF_KEY: vector = b"sys_timelock_cap"; - public struct IotaSystemState has key { id: UID, version: u64, @@ -27,7 +25,7 @@ module iota_system::iota_system { protocol_version: u64, epoch_start_timestamp_ms: u64, epoch_duration_ms: u64, - system_timelock_cap: SystemTimelockCap, + iota_system_admin_cap: IotaSystemAdminCap, ctx: &mut TxContext, ) { let system_state = iota_system_state_inner::create( @@ -37,6 +35,7 @@ module iota_system::iota_system { protocol_version, epoch_start_timestamp_ms, epoch_duration_ms, + iota_system_admin_cap, ctx, ); let version = iota_system_state_inner::genesis_system_state_version(); @@ -45,7 +44,6 @@ 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); } diff --git a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/deep_upgrade/sources/iota_system_state_inner.move b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/deep_upgrade/sources/iota_system_state_inner.move index a1f64c1602d..f7d69dd771f 100644 --- a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/deep_upgrade/sources/iota_system_state_inner.move +++ b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/deep_upgrade/sources/iota_system_state_inner.move @@ -8,6 +8,7 @@ module iota_system::iota_system_state_inner { use iota::event; use iota::iota::IOTA; use iota::iota::IotaTreasuryCap; + use iota::system_admin_cap::IotaSystemAdminCap; use iota::table::{Self, Table}; use iota_system::validator::{ValidatorV1, ValidatorV2}; @@ -58,6 +59,7 @@ module iota_system::iota_system_state_inner { validators: ValidatorSetV1, storage_fund: Balance, parameters: SystemParametersV1, + iota_system_admin_cap: IotaSystemAdminCap, reference_gas_price: u64, safe_mode: bool, epoch_start_timestamp_ms: u64, @@ -73,6 +75,7 @@ module iota_system::iota_system_state_inner { validators: ValidatorSetV2, storage_fund: Balance, parameters: SystemParametersV1, + iota_system_admin_cap: IotaSystemAdminCap, reference_gas_price: u64, safe_mode: bool, epoch_start_timestamp_ms: u64, @@ -86,6 +89,7 @@ module iota_system::iota_system_state_inner { protocol_version: u64, epoch_start_timestamp_ms: u64, epoch_duration_ms: u64, + iota_system_admin_cap: IotaSystemAdminCap, ctx: &mut TxContext, ): IotaSystemStateV1 { let validators = new_validator_set(validators, ctx); @@ -100,6 +104,7 @@ module iota_system::iota_system_state_inner { epoch_duration_ms, extra_fields: bag::new(ctx), }, + iota_system_admin_cap, reference_gas_price: 1, safe_mode: false, epoch_start_timestamp_ms, @@ -178,6 +183,7 @@ module iota_system::iota_system_state_inner { validators, storage_fund, parameters, + iota_system_admin_cap, reference_gas_price, safe_mode, epoch_start_timestamp_ms, @@ -194,6 +200,7 @@ module iota_system::iota_system_state_inner { validators: new_validator_set, storage_fund, parameters, + iota_system_admin_cap, reference_gas_price, safe_mode, epoch_start_timestamp_ms, diff --git a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/safe_mode/sources/genesis.move b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/safe_mode/sources/genesis.move index f4d69976b8b..c5a91d91351 100644 --- a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/safe_mode/sources/genesis.move +++ b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/safe_mode/sources/genesis.move @@ -7,7 +7,7 @@ module iota_system::genesis { use iota::balance; use iota::iota::IotaTreasuryCap; - use iota::timelock::SystemTimelockCap; + use iota::system_admin_cap::IotaSystemAdminCap; use iota_system::iota_system; use iota_system::validator; @@ -67,7 +67,7 @@ module iota_system::genesis { genesis_validators: vector, _token_distribution_schedule: TokenDistributionSchedule, _timelock_genesis_label: Option, - system_timelock_cap: SystemTimelockCap, + iota_system_admin_cap: IotaSystemAdminCap, ctx: &mut TxContext, ) { assert!(tx_context::epoch(ctx) == 0, 0); @@ -118,7 +118,7 @@ module iota_system::genesis { genesis_chain_parameters.protocol_version, genesis_chain_parameters.chain_start_timestamp_ms, genesis_chain_parameters.epoch_duration_ms, - system_timelock_cap, + iota_system_admin_cap, ctx, ); } diff --git a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/safe_mode/sources/iota_system.move b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/safe_mode/sources/iota_system.move index 113afd557ce..701a2597b6d 100644 --- a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/safe_mode/sources/iota_system.move +++ b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/safe_mode/sources/iota_system.move @@ -7,13 +7,11 @@ module iota_system::iota_system { use iota::dynamic_field; use iota::iota::IOTA; use iota::iota::IotaTreasuryCap; - use iota::timelock::SystemTimelockCap; + use iota::system_admin_cap::IotaSystemAdminCap; use iota_system::validator::ValidatorV1; use iota_system::iota_system_state_inner::{Self, IotaSystemStateV1}; - const SYSTEM_TIMELOCK_CAP_DF_KEY: vector = b"sys_timelock_cap"; - public struct IotaSystemState has key { id: UID, version: u64, @@ -27,7 +25,7 @@ module iota_system::iota_system { protocol_version: u64, epoch_start_timestamp_ms: u64, epoch_duration_ms: u64, - system_timelock_cap: SystemTimelockCap, + iota_system_admin_cap: IotaSystemAdminCap, ctx: &mut TxContext, ) { let system_state = iota_system_state_inner::create( @@ -37,6 +35,7 @@ module iota_system::iota_system { protocol_version, epoch_start_timestamp_ms, epoch_duration_ms, + iota_system_admin_cap, ctx, ); let version = iota_system_state_inner::genesis_system_state_version(); @@ -45,7 +44,6 @@ 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); } diff --git a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/safe_mode/sources/iota_system_state_inner.move b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/safe_mode/sources/iota_system_state_inner.move index a2ea7aa1f8d..df1cc71f995 100644 --- a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/safe_mode/sources/iota_system_state_inner.move +++ b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/safe_mode/sources/iota_system_state_inner.move @@ -8,6 +8,7 @@ module iota_system::iota_system_state_inner { use iota::event; use iota::iota::IOTA; use iota::iota::IotaTreasuryCap; + use iota::system_admin_cap::IotaSystemAdminCap; use iota::table::{Self, Table}; use iota_system::validator::ValidatorV1; @@ -47,6 +48,7 @@ module iota_system::iota_system_state_inner { iota_treasury_cap: IotaTreasuryCap, validators: ValidatorSetV1, storage_fund: Balance, + iota_system_admin_cap: IotaSystemAdminCap, parameters: SystemParametersV1, reference_gas_price: u64, safe_mode: bool, @@ -61,6 +63,7 @@ module iota_system::iota_system_state_inner { protocol_version: u64, epoch_start_timestamp_ms: u64, epoch_duration_ms: u64, + iota_system_admin_cap: IotaSystemAdminCap, ctx: &mut TxContext, ): IotaSystemStateV1 { let system_state = IotaSystemStateV1 { @@ -78,6 +81,7 @@ module iota_system::iota_system_state_inner { epoch_duration_ms, extra_fields: bag::new(ctx), }, + iota_system_admin_cap, reference_gas_price: 1, safe_mode: false, epoch_start_timestamp_ms, diff --git a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/shallow_upgrade/sources/genesis.move b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/shallow_upgrade/sources/genesis.move index f4d69976b8b..c5a91d91351 100644 --- a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/shallow_upgrade/sources/genesis.move +++ b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/shallow_upgrade/sources/genesis.move @@ -7,7 +7,7 @@ module iota_system::genesis { use iota::balance; use iota::iota::IotaTreasuryCap; - use iota::timelock::SystemTimelockCap; + use iota::system_admin_cap::IotaSystemAdminCap; use iota_system::iota_system; use iota_system::validator; @@ -67,7 +67,7 @@ module iota_system::genesis { genesis_validators: vector, _token_distribution_schedule: TokenDistributionSchedule, _timelock_genesis_label: Option, - system_timelock_cap: SystemTimelockCap, + iota_system_admin_cap: IotaSystemAdminCap, ctx: &mut TxContext, ) { assert!(tx_context::epoch(ctx) == 0, 0); @@ -118,7 +118,7 @@ module iota_system::genesis { genesis_chain_parameters.protocol_version, genesis_chain_parameters.chain_start_timestamp_ms, genesis_chain_parameters.epoch_duration_ms, - system_timelock_cap, + iota_system_admin_cap, ctx, ); } diff --git a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/shallow_upgrade/sources/iota_system.move b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/shallow_upgrade/sources/iota_system.move index 549ba9c21a3..2d34ba2c6be 100644 --- a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/shallow_upgrade/sources/iota_system.move +++ b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/shallow_upgrade/sources/iota_system.move @@ -7,13 +7,11 @@ module iota_system::iota_system { use iota::dynamic_field; use iota::iota::IOTA; use iota::iota::IotaTreasuryCap; - use iota::timelock::SystemTimelockCap; + use iota::system_admin_cap::IotaSystemAdminCap; use iota_system::validator::ValidatorV1; use iota_system::iota_system_state_inner::{Self, IotaSystemStateV1, IotaSystemStateV2}; - const SYSTEM_TIMELOCK_CAP_DF_KEY: vector = b"sys_timelock_cap"; - public struct IotaSystemState has key { id: UID, version: u64, @@ -27,7 +25,7 @@ module iota_system::iota_system { protocol_version: u64, epoch_start_timestamp_ms: u64, epoch_duration_ms: u64, - system_timelock_cap: SystemTimelockCap, + iota_system_admin_cap: IotaSystemAdminCap, ctx: &mut TxContext, ) { let system_state = iota_system_state_inner::create( @@ -37,6 +35,7 @@ module iota_system::iota_system { protocol_version, epoch_start_timestamp_ms, epoch_duration_ms, + iota_system_admin_cap, ctx, ); let version = iota_system_state_inner::genesis_system_state_version(); @@ -45,7 +44,6 @@ 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); } diff --git a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/shallow_upgrade/sources/iota_system_state_inner.move b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/shallow_upgrade/sources/iota_system_state_inner.move index 18c0632784c..21473700282 100644 --- a/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/shallow_upgrade/sources/iota_system_state_inner.move +++ b/crates/iota-e2e-tests/tests/framework_upgrades/mock_iota_systems/shallow_upgrade/sources/iota_system_state_inner.move @@ -8,6 +8,7 @@ module iota_system::iota_system_state_inner { use iota::event; use iota::iota::IOTA; use iota::iota::IotaTreasuryCap; + use iota::system_admin_cap::IotaSystemAdminCap; use iota::table::{Self, Table}; use iota_system::validator::ValidatorV1; @@ -49,6 +50,7 @@ module iota_system::iota_system_state_inner { validators: ValidatorSetV1, storage_fund: Balance, parameters: SystemParametersV1, + iota_system_admin_cap: IotaSystemAdminCap, reference_gas_price: u64, safe_mode: bool, epoch_start_timestamp_ms: u64, @@ -64,6 +66,7 @@ module iota_system::iota_system_state_inner { validators: ValidatorSetV1, storage_fund: Balance, parameters: SystemParametersV1, + iota_system_admin_cap: IotaSystemAdminCap, reference_gas_price: u64, safe_mode: bool, epoch_start_timestamp_ms: u64, @@ -77,6 +80,7 @@ module iota_system::iota_system_state_inner { protocol_version: u64, epoch_start_timestamp_ms: u64, epoch_duration_ms: u64, + iota_system_admin_cap: IotaSystemAdminCap, ctx: &mut TxContext, ): IotaSystemStateV1 { let validators = new_validator_set(validators, ctx); @@ -91,6 +95,7 @@ module iota_system::iota_system_state_inner { epoch_duration_ms, extra_fields: bag::new(ctx), }, + iota_system_admin_cap, reference_gas_price: 1, safe_mode: false, epoch_start_timestamp_ms, @@ -167,6 +172,7 @@ module iota_system::iota_system_state_inner { validators, storage_fund, parameters, + iota_system_admin_cap, reference_gas_price, safe_mode, epoch_start_timestamp_ms, @@ -182,6 +188,7 @@ module iota_system::iota_system_state_inner { validators, storage_fund, parameters, + iota_system_admin_cap, reference_gas_price, safe_mode, epoch_start_timestamp_ms, diff --git a/crates/iota-genesis-builder/src/lib.rs b/crates/iota-genesis-builder/src/lib.rs index 27f77ebf443..a4d0f17607c 100644 --- a/crates/iota-genesis-builder/src/lib.rs +++ b/crates/iota-genesis-builder/src/lib.rs @@ -64,6 +64,7 @@ use iota_types::{ programmable_transaction_builder::ProgrammableTransactionBuilder, randomness_state::{RANDOMNESS_MODULE_NAME, RANDOMNESS_STATE_CREATE_FUNCTION_NAME}, stardust::stardust_to_iota_address, + system_admin_cap::IOTA_SYSTEM_ADMIN_CAP_MODULE_NAME, timelock::{ stardust_upgrade_label::STARDUST_UPGRADE_LABEL_VALUE, timelocked_staked_iota::TimelockedStakedIota, @@ -1470,11 +1471,11 @@ pub fn generate_genesis_system_object( vec![pre_minted_supply], ); - // Step 5: Create System Timelock Cap. - let system_timelock_cap = builder.programmable_move_call( + // Step 5: Create System Admin Cap. + let system_admin_cap = builder.programmable_move_call( IOTA_FRAMEWORK_PACKAGE_ID, - ident_str!("timelock").to_owned(), - ident_str!("new_system_timelock_cap").to_owned(), + IOTA_SYSTEM_ADMIN_CAP_MODULE_NAME.to_owned(), + ident_str!("new_system_admin_cap").to_owned(), vec![], vec![], ); @@ -1493,7 +1494,7 @@ pub fn generate_genesis_system_object( .map(|a| builder.input(a)) .collect::>()?; arguments.append(&mut call_arg_arguments); - arguments.push(system_timelock_cap); + arguments.push(system_admin_cap); builder.programmable_move_call( IOTA_SYSTEM_ADDRESS.into(), ident_str!("genesis").to_owned(), diff --git a/crates/iota-json-rpc/src/coin_api.rs b/crates/iota-json-rpc/src/coin_api.rs index 0acf253cbd1..226c0ba2935 100644 --- a/crates/iota-json-rpc/src/coin_api.rs +++ b/crates/iota-json-rpc/src/coin_api.rs @@ -1261,6 +1261,7 @@ mod tests { IotaSystemStateV1, StorageFundV1, SystemParametersV1, ValidatorSetV1, }, }, + system_admin_cap::IotaSystemAdminCap, }; use mockall::predicate; @@ -1427,6 +1428,7 @@ mod tests { validator_low_stake_grace_period: Default::default(), extra_fields: Default::default(), }, + iota_system_admin_cap: IotaSystemAdminCap {}, reference_gas_price: Default::default(), validator_report_records: VecMap { contents: Default::default(), diff --git a/crates/iota-types/src/iota_system_state/iota_system_state_inner_v1.rs b/crates/iota-types/src/iota_system_state/iota_system_state_inner_v1.rs index cd5f6ba87ef..f4797f3f4e2 100644 --- a/crates/iota-types/src/iota_system_state/iota_system_state_inner_v1.rs +++ b/crates/iota-types/src/iota_system_state/iota_system_state_inner_v1.rs @@ -28,6 +28,7 @@ use crate::{ iota_system_state::epoch_start_iota_system_state::EpochStartSystemState, multiaddr::Multiaddr, storage::ObjectStore, + system_admin_cap::IotaSystemAdminCap, }; const E_METADATA_INVALID_POP: u64 = 0; @@ -444,6 +445,7 @@ pub struct IotaSystemStateV1 { pub validators: ValidatorSetV1, pub storage_fund: StorageFundV1, pub parameters: SystemParametersV1, + pub iota_system_admin_cap: IotaSystemAdminCap, pub reference_gas_price: u64, pub validator_report_records: VecMap>, pub safe_mode: bool, @@ -617,6 +619,7 @@ impl IotaSystemStateTrait for IotaSystemStateV1 { validator_low_stake_grace_period, extra_fields: _, }, + iota_system_admin_cap: _, reference_gas_price, validator_report_records: VecMap { diff --git a/crates/iota-types/src/iota_system_state/simtest_iota_system_state_inner.rs b/crates/iota-types/src/iota_system_state/simtest_iota_system_state_inner.rs index e5b5a5376f8..3f88e8be2b4 100644 --- a/crates/iota-types/src/iota_system_state/simtest_iota_system_state_inner.rs +++ b/crates/iota-types/src/iota_system_state/simtest_iota_system_state_inner.rs @@ -32,6 +32,7 @@ pub struct SimTestIotaSystemStateV1 { pub validators: SimTestValidatorSetV1, pub storage_fund: Balance, pub parameters: SimTestSystemParametersV1, + pub iota_system_admin_cap: IotaSystemAdminCap, pub reference_gas_price: u64, pub safe_mode: bool, pub epoch_start_timestamp_ms: u64, @@ -231,6 +232,7 @@ pub struct SimTestIotaSystemStateShallowV1 { pub validators: SimTestValidatorSetV1, pub storage_fund: Balance, pub parameters: SimTestSystemParametersV1, + pub iota_system_admin_cap: IotaSystemAdminCap, pub reference_gas_price: u64, pub safe_mode: bool, pub epoch_start_timestamp_ms: u64, @@ -373,6 +375,7 @@ pub struct SimTestIotaSystemStateDeepV1 { pub validators: SimTestValidatorSetDeepV1, pub storage_fund: Balance, pub parameters: SimTestSystemParametersV1, + pub iota_system_admin_cap: IotaSystemAdminCap, pub reference_gas_price: u64, pub safe_mode: bool, pub epoch_start_timestamp_ms: u64, diff --git a/crates/iota-types/src/lib.rs b/crates/iota-types/src/lib.rs index 985c0f23a4f..962434c3c2b 100644 --- a/crates/iota-types/src/lib.rs +++ b/crates/iota-types/src/lib.rs @@ -85,6 +85,7 @@ pub mod signature_verification; pub mod stardust; pub mod storage; pub mod supported_protocol_versions; +pub mod system_admin_cap; pub mod timelock; pub mod traffic_control; pub mod transaction; diff --git a/crates/iota-types/src/system_admin_cap.rs b/crates/iota-types/src/system_admin_cap.rs new file mode 100644 index 00000000000..0d68982a0f7 --- /dev/null +++ b/crates/iota-types/src/system_admin_cap.rs @@ -0,0 +1,34 @@ +// Copyright (c) 2024 IOTA Stiftung +// Modifications Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use move_core_types::{ident_str, identifier::IdentStr}; + +pub const IOTA_SYSTEM_ADMIN_CAP_MODULE_NAME: &IdentStr = ident_str!("system_admin_cap"); +pub const IOTA_SYSTEM_ADMIN_CAP_STRUCT_NAME: &IdentStr = ident_str!("IotaSystemAdminCap"); + +pub use checked::*; + +#[iota_macros::with_checked_arithmetic] +mod checked { + use move_core_types::language_storage::StructTag; + use serde::{Deserialize, Serialize}; + + use super::*; + use crate::IOTA_FRAMEWORK_ADDRESS; + + // Rust version of the IotaSystemAdminCap type + #[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)] + pub struct IotaSystemAdminCap {} + + impl IotaSystemAdminCap { + pub fn type_() -> StructTag { + StructTag { + address: IOTA_FRAMEWORK_ADDRESS, + module: IOTA_SYSTEM_ADMIN_CAP_MODULE_NAME.to_owned(), + name: IOTA_SYSTEM_ADMIN_CAP_STRUCT_NAME.to_owned(), + type_params: Vec::new(), + } + } + } +}