Documentation ¶
Index ¶
- Constants
- func MistToSui(mist string) (int64, error)
- type AddressToValidator
- type Checkpoints
- type Epoch
- type Errors
- type FeatureFlags
- type GasPrice
- type MetricValue
- type Metrics
- func (metrics *Metrics) CalculateCertificatesRatio()
- func (metrics *Metrics) CalculateCheckpointsRatio()
- func (metrics *Metrics) CalculateRoundsRatio()
- func (metrics *Metrics) CalculateTransactionsRatio()
- func (metrics *Metrics) GetEpochLabel() string
- func (metrics *Metrics) GetEpochProgress() (int, error)
- func (metrics *Metrics) GetMillisecondsTillNextEpoch() (int64, error)
- func (metrics *Metrics) GetTimeUntilNextEpochDisplay() []string
- func (metrics *Metrics) GetValue(metric enums.MetricType) MetricValue
- func (metrics *Metrics) IsHealthy(metric enums.MetricType, valueRPC any) bool
- func (metrics *Metrics) IsUnhealthy(metric enums.MetricType, valueRPC any) bool
- func (metrics *Metrics) SetProtocolValue(value any) error
- func (metrics *Metrics) SetSystemStateValue(value any) error
- func (metrics *Metrics) SetValidatorsApyValue(value any) error
- func (metrics *Metrics) SetValue(metric enums.MetricType, value any) error
- type Objects
- type Peers
- type Protocol
- type Release
- type Rounds
- type SuiSystemState
- type Transactions
- type Validator
- type ValidatorAtRisk
- type ValidatorReport
- type ValidatorReporter
- type Validators
- func (validators Validators) GetMaxRefGasPrice() (int, error)
- func (validators Validators) GetMeanRefGasPrice() (int, error)
- func (validators Validators) GetMedianRefGasPrice() (int, error)
- func (validators Validators) GetMinRefGasPrice() (int, error)
- func (validators Validators) GetNextRefGasPrice() (int, error)
- func (validators Validators) GetWeightedMeanRefGasPrice() (int, error)
- type ValidatorsApy
- type ValidatorsApyParsed
- type ValidatorsAtRisk
- type ValidatorsReports
Constants ¶
const ( TransactionsPerSecondWindow = 5 CheckpointsPerSecondWindow = 5 RoundsPerSecondWindow = 5 CertificatesPerSecondWindow = 5 TransactionsPerSecondLag = 5 CheckpointsPerSecondLag = 10 LatestCheckpointLag = 30 HighestSyncedCheckpointLag = 30 TotalTransactionsSyncPercentage = 99 TotalCheckpointsSyncPercentage = 99 )
const ( ErrUnexpectedMetricValueType = "unexpected value type for %s: %T" ErrUnsupportedValidatorsAtRiskAttr = "unsupported validatorsAtRisk attribute type: %v" ErrUnsupportedValidatorsReportAttr = "unsupported validatorsReport attribute type: %v" ErrUnsupportedSuiAddressAttr = "unsupported suiAddress attribute type: %v" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AddressToValidator ¶
Validators represents a validator nodes on the Sui blockchain network.
type Checkpoints ¶
type Checkpoints struct { CheckpointsHistory []int LatestCheckpoint int HighestKnownCheckpoint int HighestSyncedCheckpoint int LastExecutedCheckpoint int CheckpointsPerSecond int CheckpointExecBacklog int CheckpointSyncBacklog int CheckSyncPercentage int }
Checkpoints represents information about checkpoints on the Sui blockchain network.
type Epoch ¶
type Epoch struct { EpochStartTimeUTC string EpochDurationHHMM string DurationTillEpochEndHHMM string CurrentEpoch int EpochTotalDuration int EpochPercentage int TimeTillNextEpoch int64 }
Epoch represents information about the current epoch on the Sui blockchain network.
type FeatureFlags ¶ added in v1.2.1
type FeatureFlags struct { AcceptZkloginInMultisig bool `json:"accept_zklogin_in_multisig"` AdvanceEpochStartTimeInSafeMode bool `json:"advance_epoch_start_time_in_safe_mode"` AdvanceToHighestSupportedProtocolVersion bool `json:"advance_to_highest_supported_protocol_version"` AllowReceivingObjectID bool `json:"allow_receiving_object_id"` BanEntryInit bool `json:"ban_entry_init"` CommitRootStateDigest bool `json:"commit_root_state_digest"` ConsensusOrderEndOfEpochLast bool `json:"consensus_order_end_of_epoch_last"` DisableInvariantViolationCheckInSwapLoc bool `json:"disable_invariant_violation_check_in_swap_loc"` DisallowAddingAbilitiesOnUpgrade bool `json:"disallow_adding_abilities_on_upgrade"` DisallowChangeStructTypeParamsOnUpgrade bool `json:"disallow_change_struct_type_params_on_upgrade"` EnableEffectsV2 bool `json:"enable_effects_v2"` EnableJwkConsensusUpdates bool `json:"enable_jwk_consensus_updates"` EndOfEpochTransactionSupported bool `json:"end_of_epoch_transaction_supported"` HardenedOtwCheck bool `json:"hardened_otw_check"` IncludeConsensusDigestInPrologue bool `json:"include_consensus_digest_in_prologue"` LoadedChildObjectFormat bool `json:"loaded_child_object_format"` LoadedChildObjectFormatType bool `json:"loaded_child_object_format_type"` LoadedChildObjectsFixed bool `json:"loaded_child_objects_fixed"` MissingTypeIsCompatibilityError bool `json:"missing_type_is_compatibility_error"` NarwhalCertificateV2 bool `json:"narwhal_certificate_v2"` NarwhalHeaderV2 bool `json:"narwhal_header_v2"` NarwhalNewLeaderElectionSchedule bool `json:"narwhal_new_leader_election_schedule"` NarwhalVersionedMetadata bool `json:"narwhal_versioned_metadata"` NoExtraneousModuleBytes bool `json:"no_extraneous_module_bytes"` PackageDigestHashModule bool `json:"package_digest_hash_module"` PackageUpgrades bool `json:"package_upgrades"` RandomBeacon bool `json:"random_beacon"` ReceiveObjects bool `json:"receive_objects"` RecomputeHasPublicTransferInExecution bool `json:"recompute_has_public_transfer_in_execution"` ScoringDecisionWithValidityCutoff bool `json:"scoring_decision_with_validity_cutoff"` SimpleConservationChecks bool `json:"simple_conservation_checks"` SimplifiedUnwrapThenDelete bool `json:"simplified_unwrap_then_delete"` ThroughputAwareConsensusSubmission bool `json:"throughput_aware_consensus_submission"` TxnBaseCostAsMultiplier bool `json:"txn_base_cost_as_multiplier"` UpgradedMultisigSupported bool `json:"upgraded_multisig_supported"` VerifyLegacyZkloginAddress bool `json:"verify_legacy_zklogin_address"` ZkloginAuth bool `json:"zklogin_auth"` }
FeatureFlags represents the various feature flags of the Sui blockchain network. Each flag represents a specific feature of the network that can be toggled on or off.
type GasPrice ¶
type GasPrice struct { MinReferenceGasPrice int // The minimum gas price (in wei) that transactions should pay in order to be included in the next block. MaxReferenceGasPrice int // The maximum gas price (in wei) that transactions should pay in order to avoid overpaying and wasting funds. MeanReferenceGasPrice int // The average gas price (in wei) of transactions that were included in the last few blocks. StakeWeightedMeanReferenceGasPrice int // The average gas price (in wei) weighted by the amount of stake that each validator has on the network. MedianReferenceGasPrice int // The middle value of the sorted list of gas prices (in wei) that were included in the last few blocks. EstimatedNextReferenceGasPrice int // The gas price (in wei) that is estimated to be included in the next block based on recent network activity and congestion. }
GasPrice represents the different reference gas prices used on the network.
type MetricValue ¶
type MetricValue interface{}
type Metrics ¶
type Metrics struct { ValidatorsApyParsed ValidatorsApyParsed Uptime string Version string Commit string SystemState SuiSystemState CurrentVotingRight float64 Epoch Protocol Rounds Objects Transactions Checkpoints GasPrice Peers Errors Updated bool }
Metrics represents various metrics about the Sui blockchain network.
func (*Metrics) CalculateCertificatesRatio ¶
func (metrics *Metrics) CalculateCertificatesRatio()
CalculateCertificatesRatio calculates the current certificates per second (CPS) based on the number of certificates created within the current period. The CPS value is then stored in the Metrics struct.
func (*Metrics) CalculateCheckpointsRatio ¶
func (metrics *Metrics) CalculateCheckpointsRatio()
CalculateCheckpointsRatio calculates the current checkpoints per second (CPS) based on the number of checkpoints generated within the current period. The CPS value is then stored in the Metrics struct.
func (*Metrics) CalculateRoundsRatio ¶
func (metrics *Metrics) CalculateRoundsRatio()
CalculateRoundsRatio calculates the current rounds per second (RPS) based on the number of rounds processed within the current period. The RPS value is then stored in the Metrics struct.
func (*Metrics) CalculateTransactionsRatio ¶
func (metrics *Metrics) CalculateTransactionsRatio()
CalculateTransactionsRatio calculates the current transaction per second (TPS) based on the number of transactions processed within the current period. The TPS value is then stored in the Metrics struct.
func (*Metrics) GetEpochLabel ¶
GetEpochLabel returns a string representing the current epoch number.
func (*Metrics) GetEpochProgress ¶
GetEpochProgress calculates and returns the percentage of current epoch progress.
func (*Metrics) GetMillisecondsTillNextEpoch ¶
GetMillisecondsTillNextEpoch returns the milliseconds till the next epoch.
func (*Metrics) GetTimeUntilNextEpochDisplay ¶
GetTimeUntilNextEpochDisplay returns the remaining time till the next epoch in human-readable format.
func (*Metrics) GetValue ¶
func (metrics *Metrics) GetValue(metric enums.MetricType) MetricValue
GetValue returns the metric value for the given metric type.
func (*Metrics) IsHealthy ¶
func (metrics *Metrics) IsHealthy(metric enums.MetricType, valueRPC any) bool
IsHealthy checks if the given metric's value satisfies the threshold defined for it. If the metric type is not recognized, returns true. The valueRPC argument is the value retrieved from the Sui RPC endpoint for the corresponding metric. Returns true if the metric value is healthy, false otherwise.
func (*Metrics) IsUnhealthy ¶
func (metrics *Metrics) IsUnhealthy(metric enums.MetricType, valueRPC any) bool
func (*Metrics) SetProtocolValue ¶ added in v1.2.1
func (*Metrics) SetSystemStateValue ¶
SetSystemStateValue sets the SUI system state metrics based on the parsed data.
func (*Metrics) SetValidatorsApyValue ¶
SetValidatorsApyValue sets the validators apy metrics based on the parsed data.
type Objects ¶ added in v1.2.3
type Objects struct {
}Object represents information about objects on the Sui blockchain network.
type Peers ¶
type Peers struct {
NetworkPeers int
}
Peers represents information about peers on the Sui blockchain network.
type Protocol ¶ added in v1.2.1
type Protocol struct { MinSupportedProtocolVersion string `json:"minSupportedProtocolVersion"` MaxSupportedProtocolVersion string `json:"maxSupportedProtocolVersion"` ProtocolVersion string `json:"protocolVersion"` FeatureFlags FeatureFlags `json:"featureFlags"` }
Protocol represents the protocol information of the Sui blockchain network. It includes the minimum and maximum supported protocol versions, the current protocol version, and the feature flags.
type Release ¶ added in v1.2.1
type Release struct { TagName string `json:"tag_name"` CommitHash string `json:"target_commitish"` Name string `json:"name"` PublishedAt string `json:"published_at"` CreatedAt string `json:"created_at"` URL string `json:"html_url"` Author struct { Login string `json:"login"` } `json:"author"` Draft bool `json:"draft"` PreRelease bool `json:"prerelease"` }
Release represents a GitHub release.
func GetReleases ¶ added in v1.2.1
getReleases fetches releases for a given repo and filters them by network name.
type Rounds ¶
type Rounds struct { RoundsHistory []int LastCommittedLeaderRound int HighestAcceptedRound int RoundsPerSecond int ConsensusRoundProberCurrentRoundGaps int }
Rounds represents information about rounds on the Sui blockchain network.
type SuiSystemState ¶
type SuiSystemState struct { AddressToValidator AddressToValidator Epoch string `json:"epoch"` ProtocolVersion string `json:"protocolVersion"` SystemStateVersion string `json:"systemStateVersion"` StorageFundTotalObjectStorageRebates string `json:"storageFundTotalObjectStorageRebates"` StorageFundNonRefundableBalance string `json:"storageFundNonRefundableBalance"` ReferenceGasPrice string `json:"referenceGasPrice"` SafeModeStorageRewards string `json:"safeModeStorageRewards"` SafeModeComputationRewards string `json:"safeModeComputationRewards"` SafeModeStorageRebates string `json:"safeModeStorageRebates"` SafeModeNonRefundableStorageFee string `json:"safeModeNonRefundableStorageFee"` EpochStartTimestampMs string `json:"epochStartTimestampMs"` EpochDurationMs string `json:"epochDurationMs"` StakeSubsidyStartEpoch string `json:"stakeSubsidyStartEpoch"` MaxValidatorCount string `json:"maxValidatorCount"` MinValidatorJoiningStake string `json:"minValidatorJoiningStake"` ValidatorLowStakeThreshold string `json:"validatorLowStakeThreshold"` ValidatorVeryLowStakeThreshold string `json:"validatorVeryLowStakeThreshold"` ValidatorLowStakeGracePeriod string `json:"validatorLowStakeGracePeriod"` StakeSubsidyBalance string `json:"stakeSubsidyBalance"` StakeSubsidyDistributionCounter string `json:"stakeSubsidyDistributionCounter"` StakeSubsidyCurrentDistributionAmount string `json:"stakeSubsidyCurrentDistributionAmount"` StakeSubsidyPeriodLength string `json:"stakeSubsidyPeriodLength"` TotalStake string `json:"totalStake"` PendingActiveValidatorsID string `json:"pendingActiveValidatorsId"` PendingActiveValidatorsSize string `json:"pendingActiveValidatorsSize"` StakingPoolMappingsID string `json:"stakingPoolMappingsId"` StakingPoolMappingsSize string `json:"stakingPoolMappingsSize"` InactivePoolsID string `json:"inactivePoolsId"` InactivePoolsSize string `json:"inactivePoolsSize"` ValidatorCandidatesID string `json:"validatorCandidatesId"` ValidatorCandidatesSize string `json:"validatorCandidatesSize"` ActiveValidators Validators `json:"activeValidators"` PendingRemovals []interface{} `json:"pendingRemovals"` AtRiskValidators [][]interface{} `json:"atRiskValidators"` ValidatorReportRecords [][]interface{} `json:"validatorReportRecords"` ValidatorsAtRiskParsed ValidatorsAtRisk ValidatorReportsParsed ValidatorsReports StakeSubsidyDecreaseRate int `json:"stakeSubsidyDecreaseRate"` SafeMode bool `json:"safeMode"` }
SuiSystemState represents the current state of the Sui blockchain system.
type Transactions ¶
type Transactions struct { TransactionsHistory []int CertificatesHistory []int TotalTransactionsBlocks int TotalTransactionCertificates int TotalTransactionCertificatesCreated int CertificatesPerSecond int NonConsensusLatency int TotalTransactionEffects int TransactionsPerSecond int TxSyncPercentage int }
Transactions represents information about transactions on the Sui blockchain network.
type Validator ¶
type Validator struct { SuiAddress string `json:"suiAddress"` ProtocolPubkeyBytes string `json:"protocolPubkeyBytes"` NetworkPubkeyBytes string `json:"networkPubkeyBytes"` WorkerPubkeyBytes string `json:"workerPubkeyBytes"` ProofOfPossessionBytes string `json:"proofOfPossessionBytes"` Name string `json:"name"` Description string `json:"description"` ImageURL string `json:"imageUrl"` ProjectURL string `json:"projectUrl"` NetAddress string `json:"netAddress"` P2PAddress string `json:"p2pAddress"` PrimaryAddress string `json:"primaryAddress"` WorkerAddress string `json:"workerAddress"` NextEpochProtocolPubkeyBytes interface{} `json:"nextEpochProtocolPubkeyBytes"` NextEpochProofOfPossession interface{} `json:"nextEpochProofOfPossession"` NextEpochNetworkPubkeyBytes interface{} `json:"nextEpochNetworkPubkeyBytes"` NextEpochWorkerPubkeyBytes interface{} `json:"nextEpochWorkerPubkeyBytes"` NextEpochNetAddress interface{} `json:"nextEpochNetAddress"` NextEpochP2PAddress interface{} `json:"nextEpochP2pAddress"` NextEpochPrimaryAddress interface{} `json:"nextEpochPrimaryAddress"` NextEpochWorkerAddress interface{} `json:"nextEpochWorkerAddress"` VotingPower string `json:"votingPower"` OperationCapID string `json:"operationCapId"` GasPrice string `json:"gasPrice"` CommissionRate string `json:"commissionRate"` NextEpochStake string `json:"nextEpochStake"` NextEpochGasPrice string `json:"nextEpochGasPrice"` NextEpochCommissionRate string `json:"nextEpochCommissionRate"` StakingPoolID string `json:"stakingPoolId"` StakingPoolActivationEpoch string `json:"stakingPoolActivationEpoch"` StakingPoolDeactivationEpoch interface{} `json:"stakingPoolDeactivationEpoch"` StakingPoolSuiBalance string `json:"stakingPoolSuiBalance"` RewardsPool string `json:"rewardsPool"` PoolTokenBalance string `json:"poolTokenBalance"` PendingStake string `json:"pendingStake"` PendingTotalSuiWithdraw string `json:"pendingTotalSuiWithdraw"` PendingPoolTokenWithdraw string `json:"pendingPoolTokenWithdraw"` ExchangeRatesID string `json:"exchangeRatesId"` ExchangeRatesSize string `json:"exchangeRatesSize"` APY string }
Validators represents a validator nodes on the Sui blockchain network.
type ValidatorAtRisk ¶
ValidatorAtRisk represents a validator node at risk on the Sui blockchain network.
func NewValidatorAtRisk ¶
func NewValidatorAtRisk(name, address, epochsAtRisk string) ValidatorAtRisk
NewValidatorAtRisk creates a new ValidatorAtRisk instance with the specified name, address, and epochs at risk.
type ValidatorReport ¶
type ValidatorReport struct { Name string Reporters []ValidatorReporter SlashingPercentage float64 }
ValidatorReport represents validator reporters.
func NewValidatorReport ¶
func NewValidatorReport(name string, slashingPct float64, reporters []ValidatorReporter) ValidatorReport
NewValidatorReport creates a new ValidatorReport instance with the specified name, slashing percentage, and reporters.
type ValidatorReporter ¶
ValidatorReporter contains information about a validator reporter.
func NewValidatorReporter ¶
func NewValidatorReporter(name, address string, votingPower int) ValidatorReporter
NewValidatorReporter creates a new ValidatorReporter instance with the specified name, address, and voting power.
type Validators ¶
type Validators []*Validator
Validators represents a validator nodes on the Sui blockchain network.
func (Validators) GetMaxRefGasPrice ¶
func (validators Validators) GetMaxRefGasPrice() (int, error)
GetMaxRefGasPrice returns the maximum reference gas price among all validators. If there are no validators or if all validators have an invalid gas price, it returns an error.
func (Validators) GetMeanRefGasPrice ¶
func (validators Validators) GetMeanRefGasPrice() (int, error)
GetMeanRefGasPrice calculates the mean reference gas price among all validators. If there are no validators or if all validators have an invalid gas price, it returns an error.
func (Validators) GetMedianRefGasPrice ¶
func (validators Validators) GetMedianRefGasPrice() (int, error)
GetMedianRefGasPrice calculates the median reference gas price among all validators. If there are no validators or if all validators have an invalid gas price, it returns an error.
func (Validators) GetMinRefGasPrice ¶
func (validators Validators) GetMinRefGasPrice() (int, error)
GetMinRefGasPrice returns the minimum reference gas price among all validators. If there are no validators or if all validators have an invalid gas price, it returns an error.
func (Validators) GetNextRefGasPrice ¶
func (validators Validators) GetNextRefGasPrice() (int, error)
GetNextRefGasPrice calculates the next reference gas price for the Sui blockchain network. The reference gas price is determined by sorting the validators by their gas prices and selecting the gas price for which the cumulative voting power of validators exceeds two-thirds of the total voting power. If there are no validators or if all validators have an invalid gas price or voting power, it returns an error.
func (Validators) GetWeightedMeanRefGasPrice ¶
func (validators Validators) GetWeightedMeanRefGasPrice() (int, error)
GetWeightedMeanRefGasPrice calculates the stake-weighted mean reference gas price among all validators. If there are no validators or if all validators have an invalid gas price or stake, it returns an error.
type ValidatorsApy ¶
type ValidatorsApy struct { Apys []struct { Address string `json:"address"` Apy float64 `json:"apy"` } `json:"apys"` }
ValidatorsApy represents the APYs of validators.
type ValidatorsApyParsed ¶
type ValidatorsAtRisk ¶
type ValidatorsAtRisk []ValidatorAtRisk
type ValidatorsReports ¶
type ValidatorsReports []ValidatorReport
ValidatorsReports is a map where the key is the address of a validator and the value is a ValidatorReports instance containing all the reports for that validator.