shardingconfig

package
v0.1.27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2022 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package shardingconfig defines types and utilities that deal with Harmony sharding configuration schedule.

Index

Constants

View Source
const (

	// DevNetHTTPPattern is the http pattern for devnet.
	DevNetHTTPPattern = "https://api.s%d.d.posichain.org"
	// DevNetWSPattern is the websocket pattern for devnet.
	DevNetWSPattern = "wss://ws.s%d.d.posichain.org"
)
View Source
const (

	// DockerNetHTTPPattern is the http pattern for devnet.
	DockerNetHTTPPattern = "https://api.s%d.k.posichain.org"
	// DockerNetWSPattern is the websocket pattern for devnet.
	DockerNetWSPattern = "wss://ws.s%d.k.posichain.org"
)
View Source
const (

	// MainNetHTTPPattern is the http pattern for mainnet.
	MainNetHTTPPattern = "https://api.s%d.posichain.org"
	// MainNetWSPattern is the websocket pattern for mainnet.
	MainNetWSPattern = "wss://ws.s%d.posichain.org"
)
View Source
const (

	// StressNetHTTPPattern is the http pattern for stressnet.
	StressNetHTTPPattern = "https://api.s%d.stn.posichain.org"
	// StressNetWSPattern is the websocket pattern for stressnet.
	StressNetWSPattern = "wss://ws.s%d.stn.posichain.org"
)
View Source
const (

	// TestNetHTTPPattern is the http pattern for testnet.
	TestNetHTTPPattern = "https://api.s%d.t.posichain.org"
	// TestNetWSPattern is the websocket pattern for testnet.
	TestNetWSPattern = "wss://ws.s%d.t.posichain.org"
)
View Source
const (
	// VLBPE is a Very Large Block Per Epoch
	VLBPE = 1000000000000
)

Variables

View Source
var DevnetSchedule devnetSchedule

DevnetSchedule is the long-running public devnet sharding configuration schedule.

View Source
var DockernetSchedule dockernetSchedule

DockernetSchedule is the local docker testnet sharding configuration schedule.

View Source
var LocalnetSchedule localnetSchedule

LocalnetSchedule is the local testnet sharding configuration schedule.

View Source
var MainnetSchedule mainnetSchedule

MainnetSchedule is the mainnet sharding configuration schedule.

View Source
var StressNetSchedule stressnetSchedule

StressNetSchedule is the long-running public stressNet sharding configuration schedule.

View Source
var TestnetSchedule testnetSchedule

TestnetSchedule is the long-running public testnet sharding configuration schedule.

Functions

func BLS

func BLS(pubkeys []string) []bls_cosi.PublicKeyWrapper

Types

type Allowlist

type Allowlist struct {
	MaxLimitPerShard int
	BLSPublicKeys    []bls_cosi.PublicKeyWrapper
}

type Instance

type Instance interface {
	// NumShards returns the number of shards in the network.
	NumShards() uint32

	// NumNodesPerShard returns number of nodes in each shard.
	NumNodesPerShard() int

	// NumHarmonyOperatedNodesPerShard returns number of nodes in each shard
	// that are operated by Harmony.
	NumHarmonyOperatedNodesPerShard() int

	// HarmonyVotePercent returns total percentage of voting power harmony nodes possess.
	HarmonyVotePercent() numeric.Dec

	// ExternalVotePercent returns total percentage of voting power external validators possess.
	ExternalVotePercent() numeric.Dec

	// HmyAccounts returns a list of Harmony accounts
	HmyAccounts() []genesis.DeployAccount

	// FnAccounts returns a list of Foundational node accounts
	FnAccounts() []genesis.DeployAccount

	// FindAccount returns the deploy account based on the blskey
	FindAccount(blsPubKey string) (bool, *genesis.DeployAccount)

	// ReshardingEpoch returns a list of Epoch while off-chain resharding happens
	ReshardingEpoch() []*big.Int

	// Count of blocks per epoch
	BlocksPerEpoch() uint64
	// HIP-16: The absolute number of maximum effective slots per shard limit for each validator. 0 means no limit.
	SlotsLimit() int

	// ExternalAllowlist returns the list of external leader keys in allowlist(HIP18)
	ExternalAllowlist() []bls.PublicKeyWrapper

	// ExternalAllowlistLimit returns the maximum number of external leader keys on each shard(HIP18)
	ExternalAllowlistLimit() int
}

Instance is one sharding configuration instance.

func MustNewInstance

func MustNewInstance(
	numShards uint32,
	numNodesPerShard, numHarmonyOperatedNodesPerShard int, slotsLimitPercent float32,
	harmonyVotePercent numeric.Dec,
	hmyAccounts []genesis.DeployAccount,
	fnAccounts []genesis.DeployAccount,
	allowlist Allowlist,
	reshardingEpoch []*big.Int, blocksPerEpoch uint64,
) Instance

MustNewInstance creates a new sharding configuration based upon given parameters. It panics if parameter validation fails. It is intended to be used for static initialization.

func NewInstance

func NewInstance(
	numShards uint32, numNodesPerShard, numHarmonyOperatedNodesPerShard, slotsLimit int, harmonyVotePercent numeric.Dec,
	hmyAccounts []genesis.DeployAccount,
	fnAccounts []genesis.DeployAccount,
	allowlist Allowlist,
	reshardingEpoch []*big.Int, blocksE uint64,
) (Instance, error)

NewInstance creates and validates a new sharding configuration based upon given parameters.

type NetworkID

type NetworkID byte

NetworkID is the network type of the blockchain.

const (
	MainNet NetworkID = iota
	TestNet
	DevNet
	DockerNet
	LocalNet
	StressNet
)

Constants for NetworkID.

type Schedule

type Schedule interface {
	InstanceForEpoch(epoch *big.Int) Instance

	// CalcEpochNumber returns the epoch number based on the block number
	CalcEpochNumber(blockNum uint64) *big.Int

	// IsLastBlock check if the block is the last block in the epoch
	// NOTE: This method is very critical for the epoch transition logic and other checks.
	IsLastBlock(blockNum uint64) bool

	// EpochLastBlock returns the last block number of an epoch
	// NOTE: This method id important for a few rpcs and validator APR calculation
	EpochLastBlock(epochNum uint64) uint64

	// VDFDifficulty returns number of iterations for VDF calculation
	VdfDifficulty() int

	// GetNetworkID() return networkID type.
	GetNetworkID() NetworkID

	// GetShardingStructure returns sharding structure.
	GetShardingStructure(int, int) []map[string]interface{}

	// IsSkippedEpoch returns if epoch was skipped on shard chain
	IsSkippedEpoch(uint32, *big.Int) bool
}

Schedule returns the sharding configuration instance for the given epoch.

func NewFixedSchedule

func NewFixedSchedule(instance Instance) Schedule

NewFixedSchedule returns a sharding configuration schedule that uses the given config instance for all epochs. Useful for testing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL