Module sui_system::validator
- Struct
ValidatorMetadata
- Struct
Validator
- Struct
StakingRequestEvent
- Struct
UnstakingRequestEvent
- Struct
ConvertingToFungibleStakedSuiEvent
- Struct
RedeemingFungibleStakedSuiEvent
- Constants
- Function
new_metadata
- Function
new
- Function
deactivate
- Function
activate
- Function
adjust_stake_and_gas_price
- Function
request_add_stake
- Function
convert_to_fungible_staked_sui
- Function
redeem_fungible_staked_sui
- Function
request_add_stake_at_genesis
- Function
request_withdraw_stake
- Function
request_set_gas_price
- Function
set_candidate_gas_price
- Function
request_set_commission_rate
- Function
set_candidate_commission_rate
- Function
deposit_stake_rewards
- Function
process_pending_stakes_and_withdraws
- Function
is_preactive
- Function
metadata
- Function
sui_address
- Function
name
- Function
description
- Function
image_url
- Function
project_url
- Function
network_address
- Function
p2p_address
- Function
primary_address
- Function
worker_address
- Function
protocol_pubkey_bytes
- Function
proof_of_possession
- Function
network_pubkey_bytes
- Function
worker_pubkey_bytes
- Function
next_epoch_network_address
- Function
next_epoch_p2p_address
- Function
next_epoch_primary_address
- Function
next_epoch_worker_address
- Function
next_epoch_protocol_pubkey_bytes
- Function
next_epoch_proof_of_possession
- Function
next_epoch_network_pubkey_bytes
- Function
next_epoch_worker_pubkey_bytes
- Function
operation_cap_id
- Function
next_epoch_gas_price
- Function
total_stake_amount
- Function
stake_amount
- Function
total_stake
- Function
voting_power
- Function
set_voting_power
- Function
pending_stake_amount
- Function
pending_stake_withdraw_amount
- Function
gas_price
- Function
commission_rate
- Function
pool_token_exchange_rate_at_epoch
- Function
staking_pool_id
- Function
is_duplicate
- Function
is_equal_some_and_value
- Function
is_equal_some
- Function
new_unverified_validator_operation_cap_and_transfer
- Function
update_name
- Function
update_description
- Function
update_image_url
- Function
update_project_url
- Function
update_next_epoch_network_address
- Function
update_candidate_network_address
- Function
update_next_epoch_p2p_address
- Function
update_candidate_p2p_address
- Function
update_next_epoch_primary_address
- Function
update_candidate_primary_address
- Function
update_next_epoch_worker_address
- Function
update_candidate_worker_address
- Function
update_next_epoch_protocol_pubkey
- Function
update_candidate_protocol_pubkey
- Function
update_next_epoch_network_pubkey
- Function
update_candidate_network_pubkey
- Function
update_next_epoch_worker_pubkey
- Function
update_candidate_worker_pubkey
- Function
effectuate_staged_metadata
- Function
validate_metadata
- Function
validate_metadata_bcs
- Function
get_staking_pool_ref
- Function
new_from_metadata
use std::address;
use std::ascii;
use std::bcs;
use std::option;
use std::string;
use std::type_name;
use std::u64;
use std::vector;
use sui::address;
use sui::bag;
use sui::balance;
use sui::coin;
use sui::config;
use sui::deny_list;
use sui::dynamic_field;
use sui::dynamic_object_field;
use sui::event;
use sui::hex;
use sui::object;
use sui::sui;
use sui::table;
use sui::transfer;
use sui::tx_context;
use sui::types;
use sui::url;
use sui::vec_set;
use sui_system::staking_pool;
use sui_system::validator_cap;
Struct ValidatorMetadata
public struct ValidatorMetadata has store
Fields
Struct Validator
public struct Validator has store
Fields
Struct StakingRequestEvent
Event emitted when a new stake request is received.
public struct StakingRequestEvent has copy, drop
Fields
Struct UnstakingRequestEvent
Event emitted when a new unstake request is received.
public struct UnstakingRequestEvent has copy, drop
Fields
Struct ConvertingToFungibleStakedSuiEvent
Event emitted when a staked SUI is converted to a fungible staked SUI.
public struct ConvertingToFungibleStakedSuiEvent has copy, drop
Fields
Struct RedeemingFungibleStakedSuiEvent
Event emitted when a fungible staked SUI is redeemed.
public struct RedeemingFungibleStakedSuiEvent has copy, drop
Fields
Constants
Function called during non-genesis times.
const ECalledDuringNonGenesis: u64 = 12;
Commission rate set by the validator is higher than the threshold
const ECommissionRateTooHigh: u64 = 8;
Validator trying to set gas price higher than threshold.
const EGasPriceHigherThanThreshold: u64 = 102;
Capability code is not valid
const EInvalidCap: u64 = 101;
Invalid proof_of_possession field in ValidatorMetadata
const EInvalidProofOfPossession: u64 = 0;
Stake amount is invalid or wrong.
const EInvalidStakeAmount: u64 = 11;
Invalid net_address field in ValidatorMetadata
const EMetadataInvalidNetAddr: u64 = 4;
Invalid network_pubkey_bytes field in ValidatorMetadata
const EMetadataInvalidNetPubkey: u64 = 2;
Invalid p2p_address field in ValidatorMetadata
const EMetadataInvalidP2pAddr: u64 = 5;
Invalid primary_address field in ValidatorMetadata
const EMetadataInvalidPrimaryAddr: u64 = 6;
Invalid pubkey_bytes field in ValidatorMetadata
const EMetadataInvalidPubkey: u64 = 1;
Invalidworker_address field in ValidatorMetadata
const EMetadataInvalidWorkerAddr: u64 = 7;
Invalid worker_pubkey_bytes field in ValidatorMetadata
const EMetadataInvalidWorkerPubkey: u64 = 3;
New Capability is not created by the validator itself
const ENewCapNotCreatedByValidatorItself: u64 = 100;
Intended validator is not a candidate one.
const ENotValidatorCandidate: u64 = 10;
Validator Metadata is too long
const EValidatorMetadataExceedingLengthLimit: u64 = 9;
const MAX_COMMISSION_RATE: u64 = 2000;
Max gas price a validator can set is 100K MIST.
const MAX_VALIDATOR_GAS_PRICE: u64 = 100000;
const MAX_VALIDATOR_METADATA_LENGTH: u64 = 256;
Function new_metadata
public(package) fun new_metadata(sui_address: address, protocol_pubkey_bytes: vector<u8>, network_pubkey_bytes: vector<u8>, worker_pubkey_bytes: vector<u8>, proof_of_possession: vector<u8>, name: std::string::String, description: std::string::String, image_url: sui::url::Url, project_url: sui::url::Url, net_address: std::string::String, p2p_address: std::string::String, primary_address: std::string::String, worker_address: std::string::String, extra_fields: sui::bag::Bag): sui_system::validator::ValidatorMetadata
Implementation
Function new
public(package) fun new(sui_address: address, protocol_pubkey_bytes: vector<u8>, network_pubkey_bytes: vector<u8>, worker_pubkey_bytes: vector<u8>, proof_of_possession: vector<u8>, name: vector<u8>, description: vector<u8>, image_url: vector<u8>, project_url: vector<u8>, net_address: vector<u8>, p2p_address: vector<u8>, primary_address: vector<u8>, worker_address: vector<u8>, gas_price: u64, commission_rate: u64, ctx: &mut sui::tx_context::TxContext): sui_system::validator::Validator
Implementation
Function deactivate
Deactivate this validator's staking pool
public(package) fun deactivate(self: &mut sui_system::validator::Validator, deactivation_epoch: u64)
Implementation
Function activate
public(package) fun activate(self: &mut sui_system::validator::Validator, activation_epoch: u64)
Implementation
Function adjust_stake_and_gas_price
Process pending stake and pending withdraws, and update the gas price.
public(package) fun adjust_stake_and_gas_price(self: &mut sui_system::validator::Validator)
Implementation
Function request_add_stake
Request to add stake to the validator's staking pool, processed at the end of the epoch.
public(package) fun request_add_stake(self: &mut sui_system::validator::Validator, stake: sui::balance::Balance<sui::sui::SUI>, staker_address: address, ctx: &mut sui::tx_context::TxContext): sui_system::staking_pool::StakedSui
Implementation
Function convert_to_fungible_staked_sui
public(package) fun convert_to_fungible_staked_sui(self: &mut sui_system::validator::Validator, staked_sui: sui_system::staking_pool::StakedSui, ctx: &mut sui::tx_context::TxContext): sui_system::staking_pool::FungibleStakedSui
Implementation
Function redeem_fungible_staked_sui
public(package) fun redeem_fungible_staked_sui(self: &mut sui_system::validator::Validator, fungible_staked_sui: sui_system::staking_pool::FungibleStakedSui, ctx: &sui::tx_context::TxContext): sui::balance::Balance<sui::sui::SUI>
Implementation
Function request_add_stake_at_genesis
Request to add stake to the validator's staking pool at genesis
public(package) fun request_add_stake_at_genesis(self: &mut sui_system::validator::Validator, stake: sui::balance::Balance<sui::sui::SUI>, staker_address: address, ctx: &mut sui::tx_context::TxContext)
Implementation
Function request_withdraw_stake
Request to withdraw stake from the validator's staking pool, processed at the end of the epoch.
public(package) fun request_withdraw_stake(self: &mut sui_system::validator::Validator, staked_sui: sui_system::staking_pool::StakedSui, ctx: &sui::tx_context::TxContext): sui::balance::Balance<sui::sui::SUI>
Implementation
Function request_set_gas_price
Request to set new gas price for the next epoch. Need to present a ValidatorOperationCap.
public(package) fun request_set_gas_price(self: &mut sui_system::validator::Validator, verified_cap: sui_system::validator_cap::ValidatorOperationCap, new_price: u64)
Implementation
Function set_candidate_gas_price
Set new gas price for the candidate validator.
public(package) fun set_candidate_gas_price(self: &mut sui_system::validator::Validator, verified_cap: sui_system::validator_cap::ValidatorOperationCap, new_price: u64)
Implementation
Function request_set_commission_rate
Request to set new commission rate for the next epoch.
public(package) fun request_set_commission_rate(self: &mut sui_system::validator::Validator, new_commission_rate: u64)
Implementation
Function set_candidate_commission_rate
Set new commission rate for the candidate validator.
public(package) fun set_candidate_commission_rate(self: &mut sui_system::validator::Validator, new_commission_rate: u64)
Implementation
Function deposit_stake_rewards
Deposit stakes rewards into the validator's staking pool, called at the end of the epoch.
public(package) fun deposit_stake_rewards(self: &mut sui_system::validator::Validator, reward: sui::balance::Balance<sui::sui::SUI>)
Implementation
Function process_pending_stakes_and_withdraws
Process pending stakes and withdraws, called at the end of the epoch.
public(package) fun process_pending_stakes_and_withdraws(self: &mut sui_system::validator::Validator, ctx: &sui::tx_context::TxContext)
Implementation
Function is_preactive
Returns true if the validator is preactive.
public fun is_preactive(self: &sui_system::validator::Validator): bool
Implementation
Function metadata
public fun metadata(self: &sui_system::validator::Validator): &sui_system::validator::ValidatorMetadata
Implementation
Function sui_address
public fun sui_address(self: &sui_system::validator::Validator): address
Implementation
Function name
public fun name(self: &sui_system::validator::Validator): &std::string::String
Implementation
Function description
public fun description(self: &sui_system::validator::Validator): &std::string::String
Implementation
Function image_url
public fun image_url(self: &sui_system::validator::Validator): &sui::url::Url
Implementation
Function project_url
public fun project_url(self: &sui_system::validator::Validator): &sui::url::Url
Implementation
Function network_address
public fun network_address(self: &sui_system::validator::Validator): &std::string::String
Implementation
Function p2p_address
public fun p2p_address(self: &sui_system::validator::Validator): &std::string::String
Implementation
Function primary_address
public fun primary_address(self: &sui_system::validator::Validator): &std::string::String
Implementation
Function worker_address
public fun worker_address(self: &sui_system::validator::Validator): &std::string::String
Implementation
Function protocol_pubkey_bytes
public fun protocol_pubkey_bytes(self: &sui_system::validator::Validator): &vector<u8>
Implementation
Function proof_of_possession
public fun proof_of_possession(self: &sui_system::validator::Validator): &vector<u8>
Implementation
Function network_pubkey_bytes
public fun network_pubkey_bytes(self: &sui_system::validator::Validator): &vector<u8>
Implementation
Function worker_pubkey_bytes
public fun worker_pubkey_bytes(self: &sui_system::validator::Validator): &vector<u8>
Implementation
Function next_epoch_network_address
public fun next_epoch_network_address(self: &sui_system::validator::Validator): &std::option::Option<std::string::String>
Implementation
Function next_epoch_p2p_address
public fun next_epoch_p2p_address(self: &sui_system::validator::Validator): &std::option::Option<std::string::String>
Implementation
Function next_epoch_primary_address
public fun next_epoch_primary_address(self: &sui_system::validator::Validator): &std::option::Option<std::string::String>
Implementation
Function next_epoch_worker_address
public fun next_epoch_worker_address(self: &sui_system::validator::Validator): &std::option::Option<std::string::String>
Implementation
Function next_epoch_protocol_pubkey_bytes
public fun next_epoch_protocol_pubkey_bytes(self: &sui_system::validator::Validator): &std::option::Option<vector<u8>>
Implementation
Function next_epoch_proof_of_possession
public fun next_epoch_proof_of_possession(self: &sui_system::validator::Validator): &std::option::Option<vector<u8>>
Implementation
Function next_epoch_network_pubkey_bytes
public fun next_epoch_network_pubkey_bytes(self: &sui_system::validator::Validator): &std::option::Option<vector<u8>>
Implementation
Function next_epoch_worker_pubkey_bytes
public fun next_epoch_worker_pubkey_bytes(self: &sui_system::validator::Validator): &std::option::Option<vector<u8>>
Implementation
Function operation_cap_id
public fun operation_cap_id(self: &sui_system::validator::Validator): &sui::object::ID
Implementation
Function next_epoch_gas_price
public fun next_epoch_gas_price(self: &sui_system::validator::Validator): u64
Implementation
Function total_stake_amount
public fun total_stake_amount(self: &sui_system::validator::Validator): u64
Implementation
Function stake_amount
public fun stake_amount(self: &sui_system::validator::Validator): u64
Implementation
Function total_stake
Return the total amount staked with this validator
public fun total_stake(self: &sui_system::validator::Validator): u64
Implementation
Function voting_power
Return the voting power of this validator.
public fun voting_power(self: &sui_system::validator::Validator): u64
Implementation
Function set_voting_power
Set the voting power of this validator, called only from validator_set.
public(package) fun set_voting_power(self: &mut sui_system::validator::Validator, new_voting_power: u64)
Implementation
Function pending_stake_amount
public fun pending_stake_amount(self: &sui_system::validator::Validator): u64
Implementation
Function pending_stake_withdraw_amount
public fun pending_stake_withdraw_amount(self: &sui_system::validator::Validator): u64
Implementation
Function gas_price
public fun gas_price(self: &sui_system::validator::Validator): u64
Implementation
Function commission_rate
public fun commission_rate(self: &sui_system::validator::Validator): u64
Implementation
Function pool_token_exchange_rate_at_epoch
public fun pool_token_exchange_rate_at_epoch(self: &sui_system::validator::Validator, epoch: u64): sui_system::staking_pool::PoolTokenExchangeRate
Implementation
Function staking_pool_id
public fun staking_pool_id(self: &sui_system::validator::Validator): sui::object::ID
Implementation
Function is_duplicate
public fun is_duplicate(self: &sui_system::validator::Validator, other: &sui_system::validator::Validator): bool
Implementation
Function is_equal_some_and_value
fun is_equal_some_and_valueT(a: &std::option::Option<T>, b: &T): bool
Implementation
Function is_equal_some
fun is_equal_someT(a: &std::option::Option<T>, b: &std::option::Option<T>): bool
Implementation
Function new_unverified_validator_operation_cap_and_transfer
Create a new UnverifiedValidatorOperationCap, transfer to the validator, and registers it, thus revoking the previous cap's permission.
public(package) fun new_unverified_validator_operation_cap_and_transfer(self: &mut sui_system::validator::Validator, ctx: &mut sui::tx_context::TxContext)
Implementation
Function update_name
Update name of the validator.
public(package) fun update_name(self: &mut sui_system::validator::Validator, name: vector<u8>)
Implementation
Function update_description
Update description of the validator.
public(package) fun update_description(self: &mut sui_system::validator::Validator, description: vector<u8>)
Implementation
Function update_image_url
Update image url of the validator.
public(package) fun update_image_url(self: &mut sui_system::validator::Validator, image_url: vector<u8>)
Implementation
Function update_project_url
Update project url of the validator.
public(package) fun update_project_url(self: &mut sui_system::validator::Validator, project_url: vector<u8>)
Implementation
Function update_next_epoch_network_address
Update network address of this validator, taking effects from next epoch
public(package) fun update_next_epoch_network_address(self: &mut sui_system::validator::Validator, net_address: vector<u8>)
Implementation
Function update_candidate_network_address
Update network address of this candidate validator
public(package) fun update_candidate_network_address(self: &mut sui_system::validator::Validator, net_address: vector<u8>)
Implementation
Function update_next_epoch_p2p_address
Update p2p address of this validator, taking effects from next epoch
public(package) fun update_next_epoch_p2p_address(self: &mut sui_system::validator::Validator, p2p_address: vector<u8>)
Implementation
Function update_candidate_p2p_address
Update p2p address of this candidate validator
public(package) fun update_candidate_p2p_address(self: &mut sui_system::validator::Validator, p2p_address: vector<u8>)
Implementation
Function update_next_epoch_primary_address
Update primary address of this validator, taking effects from next epoch
public(package) fun update_next_epoch_primary_address(self: &mut sui_system::validator::Validator, primary_address: vector<u8>)
Implementation
Function update_candidate_primary_address
Update primary address of this candidate validator
public(package) fun update_candidate_primary_address(self: &mut sui_system::validator::Validator, primary_address: vector<u8>)
Implementation
Function update_next_epoch_worker_address
Update worker address of this validator, taking effects from next epoch
public(package) fun update_next_epoch_worker_address(self: &mut sui_system::validator::Validator, worker_address: vector<u8>)
Implementation
Function update_candidate_worker_address
Update worker address of this candidate validator
public(package) fun update_candidate_worker_address(self: &mut sui_system::validator::Validator, worker_address: vector<u8>)
Implementation
Function update_next_epoch_protocol_pubkey
Update protocol public key of this validator, taking effects from next epoch
public(package) fun update_next_epoch_protocol_pubkey(self: &mut sui_system::validator::Validator, protocol_pubkey: vector<u8>, proof_of_possession: vector<u8>)
Implementation
Function update_candidate_protocol_pubkey
Update protocol public key of this candidate validator
public(package) fun update_candidate_protocol_pubkey(self: &mut sui_system::validator::Validator, protocol_pubkey: vector<u8>, proof_of_possession: vector<u8>)
Implementation
Function update_next_epoch_network_pubkey
Update network public key of this validator, taking effects from next epoch
public(package) fun update_next_epoch_network_pubkey(self: &mut sui_system::validator::Validator, network_pubkey: vector<u8>)
Implementation
Function update_candidate_network_pubkey
Update network public key of this candidate validator
public(package) fun update_candidate_network_pubkey(self: &mut sui_system::validator::Validator, network_pubkey: vector<u8>)
Implementation
Function update_next_epoch_worker_pubkey
Update Narwhal worker public key of this validator, taking effects from next epoch
public(package) fun update_next_epoch_worker_pubkey(self: &mut sui_system::validator::Validator, worker_pubkey: vector<u8>)
Implementation
Function update_candidate_worker_pubkey
Update Narwhal worker public key of this candidate validator
public(package) fun update_candidate_worker_pubkey(self: &mut sui_system::validator::Validator, worker_pubkey: vector<u8>)
Implementation
Function effectuate_staged_metadata
Effectutate all staged next epoch metadata for this validator. NOTE: this function SHOULD ONLY be called by validator_set when advancing an epoch.
public(package) fun effectuate_staged_metadata(self: &mut sui_system::validator::Validator)
Implementation
Function validate_metadata
Aborts if validator metadata is valid
public fun validate_metadata(metadata: &sui_system::validator::ValidatorMetadata)
Implementation
Function validate_metadata_bcs
public fun validate_metadata_bcs(metadata: vector<u8>)
Implementation
Function get_staking_pool_ref
public(package) fun get_staking_pool_ref(self: &sui_system::validator::Validator): &sui_system::staking_pool::StakingPool
Implementation
Function new_from_metadata
Create a new validator from the given ValidatorMetadata, called by both new and new_for_testing.
fun new_from_metadata(metadata: sui_system::validator::ValidatorMetadata, gas_price: u64, commission_rate: u64, ctx: &mut sui::tx_context::TxContext): sui_system::validator::Validator