Skip to content

Commit

Permalink
feat: added IotaSystemAdminCap (#3923)
Browse files Browse the repository at this point in the history
* feat: add `IotaSystemAdminCap`

* feat(iota-framework-snapshot): update the snapshots

* fix(iota-e2e-tests): update the mock framework

* fix(iota-types): license header

* fix(iota-types): add `dummy_field` to the `IotaSystemAdminCap` struct

* feat: update snapshots

* feat(iota-graphql-e2e-tests): update tests

* refactor: change the `dummy_field` type to bool

* fix(iota-types): added missed import

* fix(iota-json-rpc-tests): fix the `get_normalized_move_modules_by_package` test

* fix(iota-e2e-tests): update snapshot for test_full_node_load_migration_data

* fix(iota-e2e-tests): fix the `basic_read_cmd_snapshot_tests` test

* fix(iota-framework): added more info about `IotaSystemAdminCap`

* refactor(iota-json-rpc): cleanup

---------

Co-authored-by: miker83z <[email protected]>
Co-authored-by: Mirko Zichichi <[email protected]>
  • Loading branch information
3 people authored Nov 7, 2024
1 parent 0d967e5 commit 8b277f0
Show file tree
Hide file tree
Showing 113 changed files with 2,976 additions and 3,136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -67,7 +67,7 @@ module iota_system::genesis {
genesis_validators: vector<GenesisValidatorMetadata>,
_token_distribution_schedule: TokenDistributionSchedule,
_timelock_genesis_label: Option<String>,
system_timelock_cap: SystemTimelockCap,
iota_system_admin_cap: IotaSystemAdminCap,
ctx: &mut TxContext,
) {
assert!(tx_context::epoch(ctx) == 0, 0);
Expand Down Expand Up @@ -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,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8> = b"sys_timelock_cap";

public struct IotaSystemState has key {
id: UID,
version: u64,
Expand All @@ -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(
Expand All @@ -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();
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,6 +51,7 @@ module iota_system::iota_system_state_inner {
validators: ValidatorSetV1,
storage_fund: Balance<IOTA>,
parameters: SystemParametersV1,
iota_system_admin_cap: IotaSystemAdminCap,
reference_gas_price: u64,
safe_mode: bool,
epoch_start_timestamp_ms: u64,
Expand All @@ -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);
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -67,7 +67,7 @@ module iota_system::genesis {
genesis_validators: vector<GenesisValidatorMetadata>,
_token_distribution_schedule: TokenDistributionSchedule,
_timelock_genesis_label: Option<String>,
system_timelock_cap: SystemTimelockCap,
iota_system_admin_cap: IotaSystemAdminCap,
ctx: &mut TxContext,
) {
assert!(tx_context::epoch(ctx) == 0, 0);
Expand Down Expand Up @@ -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,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8> = b"sys_timelock_cap";

public struct IotaSystemState has key {
id: UID,
version: u64,
Expand All @@ -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(
Expand All @@ -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();
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -58,6 +59,7 @@ module iota_system::iota_system_state_inner {
validators: ValidatorSetV1,
storage_fund: Balance<IOTA>,
parameters: SystemParametersV1,
iota_system_admin_cap: IotaSystemAdminCap,
reference_gas_price: u64,
safe_mode: bool,
epoch_start_timestamp_ms: u64,
Expand All @@ -73,6 +75,7 @@ module iota_system::iota_system_state_inner {
validators: ValidatorSetV2,
storage_fund: Balance<IOTA>,
parameters: SystemParametersV1,
iota_system_admin_cap: IotaSystemAdminCap,
reference_gas_price: u64,
safe_mode: bool,
epoch_start_timestamp_ms: u64,
Expand All @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -67,7 +67,7 @@ module iota_system::genesis {
genesis_validators: vector<GenesisValidatorMetadata>,
_token_distribution_schedule: TokenDistributionSchedule,
_timelock_genesis_label: Option<String>,
system_timelock_cap: SystemTimelockCap,
iota_system_admin_cap: IotaSystemAdminCap,
ctx: &mut TxContext,
) {
assert!(tx_context::epoch(ctx) == 0, 0);
Expand Down Expand Up @@ -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,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8> = b"sys_timelock_cap";

public struct IotaSystemState has key {
id: UID,
version: u64,
Expand All @@ -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(
Expand All @@ -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();
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -48,6 +49,7 @@ module iota_system::iota_system_state_inner {
validators: ValidatorSetV1,
storage_fund: Balance<IOTA>,
parameters: SystemParametersV1,
iota_system_admin_cap: IotaSystemAdminCap,
reference_gas_price: u64,
safe_mode: bool,
epoch_start_timestamp_ms: u64,
Expand All @@ -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 {
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -67,7 +67,7 @@ module iota_system::genesis {
genesis_validators: vector<GenesisValidatorMetadata>,
_token_distribution_schedule: TokenDistributionSchedule,
_timelock_genesis_label: Option<String>,
system_timelock_cap: SystemTimelockCap,
iota_system_admin_cap: IotaSystemAdminCap,
ctx: &mut TxContext,
) {
assert!(tx_context::epoch(ctx) == 0, 0);
Expand Down Expand Up @@ -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,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8> = b"sys_timelock_cap";

public struct IotaSystemState has key {
id: UID,
version: u64,
Expand All @@ -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(
Expand All @@ -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();
Expand All @@ -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);
}

Expand Down
Loading

0 comments on commit 8b277f0

Please sign in to comment.