Skip to content

Commit

Permalink
update snapshots and serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
emmazzz committed Jan 4, 2023
1 parent 37260eb commit 8e70238
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 75 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,14 @@ validators:
value: 0
delegation_token_supply:
value: 0
pending_delegations: []
pending_withdraws: []
pending_delegations:
contents:
id: "0xd5d9aa879b78dc1f516d71ab979189086eff752f"
size: 0
pending_withdraws:
contents:
id: "0xab8235dace3d68c7fb48110d63cbf4d6fd81ce10"
size: 0
commission_rate: 0
pending_validators: []
pending_removals: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ expression: common_costs_estimate
---
{
"MergeCoin": {
"computation_cost": 6679,
"storage_cost": 9567,
"computation_cost": 6814,
"storage_cost": 9768,
"storage_rebate": 0
},
"Publish": {
"computation_cost": 7484,
"storage_cost": 10690,
"computation_cost": 7619,
"storage_cost": 10891,
"storage_rebate": 0
},
"SharedCounterAssertValue": {
Expand All @@ -29,8 +29,8 @@ expression: common_costs_estimate
"storage_rebate": 0
},
"SplitCoin": {
"computation_cost": 6657,
"storage_cost": 9535,
"computation_cost": 6792,
"storage_cost": 9736,
"storage_rebate": 0
},
"TransferPortionSuiCoin": {
Expand Down
1 change: 1 addition & 0 deletions crates/sui-framework/docs/table_vec.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ Return the length of the TableVec.

## Function `is_empty`

Return if the TableVec is empty or not.


<pre><code><b>public</b> <b>fun</b> <a href="table_vec.md#0x2_table_vec_is_empty">is_empty</a>&lt;Element: store&gt;(t: &<a href="table_vec.md#0x2_table_vec_TableVec">table_vec::TableVec</a>&lt;Element&gt;): bool
Expand Down
97 changes: 37 additions & 60 deletions crates/sui-open-rpc/spec/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3004,7 +3004,7 @@
}
}
},
"Entry_for_ValidatorPair_and_Array_of_PendingWithdrawEntry": {
"Entry_for_ValidatorPair_and_TableVec": {
"description": "Rust version of the Move sui::vec_map::Entry type",
"type": "object",
"required": [
Expand All @@ -3016,10 +3016,7 @@
"$ref": "#/components/schemas/ValidatorPair"
},
"value": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PendingWithdrawEntry"
}
"$ref": "#/components/schemas/TableVec"
}
}
},
Expand Down Expand Up @@ -4548,50 +4545,6 @@
}
}
},
"PendingDelegationEntry": {
"description": "Rust version of the Move sui::staking_pool::PendingDelegationEntry type.",
"type": "object",
"required": [
"delegator",
"staked_sui_id",
"sui_amount"
],
"properties": {
"delegator": {
"$ref": "#/components/schemas/SuiAddress"
},
"staked_sui_id": {
"$ref": "#/components/schemas/ObjectID"
},
"sui_amount": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
}
},
"PendingWithdrawEntry": {
"description": "Rust version of the Move sui::staking_pool::PendingWithdrawEntry type.",
"type": "object",
"required": [
"delegator",
"principal_withdraw_amount",
"withdrawn_pool_tokens"
],
"properties": {
"delegator": {
"$ref": "#/components/schemas/SuiAddress"
},
"principal_withdraw_amount": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"withdrawn_pool_tokens": {
"$ref": "#/components/schemas/Balance"
}
}
},
"RPCTransactionRequestParams": {
"oneOf": [
{
Expand Down Expand Up @@ -4761,16 +4714,10 @@
"$ref": "#/components/schemas/Supply"
},
"pending_delegations": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PendingDelegationEntry"
}
"$ref": "#/components/schemas/TableVec"
},
"pending_withdraws": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PendingWithdrawEntry"
}
"$ref": "#/components/schemas/TableVec"
},
"rewards_pool": {
"$ref": "#/components/schemas/Balance"
Expand Down Expand Up @@ -5521,6 +5468,36 @@
}
}
},
"Table": {
"description": "Rust version of the Move sui::table::Table type. Putting it here since we only use it in sui_system in the framework.",
"type": "object",
"required": [
"id",
"size"
],
"properties": {
"id": {
"$ref": "#/components/schemas/ObjectID"
},
"size": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
}
},
"TableVec": {
"description": "Rust version of the Move sui::table::Table type. Putting it here since we only use it in sui_system in the framework.",
"type": "object",
"required": [
"contents"
],
"properties": {
"contents": {
"$ref": "#/components/schemas/Table"
}
}
},
"TransactionBytes": {
"type": "object",
"required": [
Expand Down Expand Up @@ -6136,7 +6113,7 @@
}
},
"pending_delegation_switches": {
"$ref": "#/components/schemas/VecMap_for_ValidatorPair_and_Array_of_PendingWithdrawEntry"
"$ref": "#/components/schemas/VecMap_for_ValidatorPair_and_TableVec"
},
"pending_removals": {
"type": "array",
Expand Down Expand Up @@ -6179,7 +6156,7 @@
}
}
},
"VecMap_for_ValidatorPair_and_Array_of_PendingWithdrawEntry": {
"VecMap_for_ValidatorPair_and_TableVec": {
"description": "Rust version of the Move sui::vec_map::VecMap type",
"type": "object",
"required": [
Expand All @@ -6189,7 +6166,7 @@
"contents": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Entry_for_ValidatorPair_and_Array_of_PendingWithdrawEntry"
"$ref": "#/components/schemas/Entry_for_ValidatorPair_and_TableVec"
}
}
}
Expand Down
32 changes: 29 additions & 3 deletions crates/sui-types/src/sui_system_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,32 @@ pub struct PendingWithdrawEntry {
withdrawn_pool_tokens: Balance,
}

/// Rust version of the Move sui::table::Table type. Putting it here since
/// we only use it in sui_system in the framework.
#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq, JsonSchema)]
pub struct TableVec {
pub contents: Table,
}

impl Default for TableVec {
fn default() -> Self {
TableVec {
contents: Table {
id: ObjectID::from(SuiAddress::ZERO),
size: 0,
},
}
}
}

/// Rust version of the Move sui::table::Table type. Putting it here since
/// we only use it in sui_system in the framework.
#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq, JsonSchema)]
pub struct Table {
pub id: ObjectID,
pub size: u64,
}

/// Rust version of the Move sui::staking_pool::StakingPool type
#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq, JsonSchema)]
pub struct StakingPool {
Expand All @@ -116,8 +142,8 @@ pub struct StakingPool {
pub sui_balance: u64,
pub rewards_pool: Balance,
pub delegation_token_supply: Supply,
pub pending_delegations: Vec<PendingDelegationEntry>,
pub pending_withdraws: Vec<PendingWithdrawEntry>,
pub pending_delegations: TableVec,
pub pending_withdraws: TableVec,
}

/// Rust version of the Move sui::validator_set::ValidatorPair type
Expand All @@ -137,7 +163,7 @@ pub struct ValidatorSet {
pub pending_validators: Vec<Validator>,
pub pending_removals: Vec<u64>,
pub next_epoch_validators: Vec<ValidatorMetadata>,
pub pending_delegation_switches: VecMap<ValidatorPair, Vec<PendingWithdrawEntry>>,
pub pending_delegation_switches: VecMap<ValidatorPair, TableVec>,
}

/// Rust version of the Move sui::sui_system::SuiSystemState type
Expand Down
6 changes: 3 additions & 3 deletions crates/test-utils/src/sui_system_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use sui_types::crypto::{
use sui_types::id::UID;
use sui_types::sui_system_state::SystemParameters;
use sui_types::sui_system_state::{
StakeSubsidy, StakingPool, SuiSystemState, Validator, ValidatorMetadata, ValidatorSet,
StakeSubsidy, StakingPool, SuiSystemState, TableVec, Validator, ValidatorMetadata, ValidatorSet,
};
use sui_types::SUI_SYSTEM_STATE_OBJECT_ID;

Expand Down Expand Up @@ -47,8 +47,8 @@ pub fn test_staking_pool(sui_address: SuiAddress, sui_balance: u64) -> StakingPo
sui_balance,
rewards_pool: Balance::new(0),
delegation_token_supply: Supply { value: 0 },
pending_delegations: vec![],
pending_withdraws: vec![],
pending_delegations: TableVec::default(),
pending_withdraws: TableVec::default(),
}
}

Expand Down

0 comments on commit 8e70238

Please sign in to comment.