Documentation ¶
Index ¶
- Constants
- Variables
- func CompareBlsPublicKey(k1, k2 BlsPublicKey) int
- func CompareCommittee(c1, c2 *Committee) int
- func CompareNodeID(id1, id2 *Slot) int
- func CompareNodeIDList(l1, l2 SlotList) int
- func EncodeWrapper(shardState State, isStaking bool) ([]byte, error)
- func ExternalSlotsAvailableForEpoch(epoch *big.Int) int
- func GetHashFromNodeList(nodeList []Slot) []byte
- type BLSSignature
- type BlsPublicKey
- func (pk BlsPublicKey) Big() *big.Int
- func (pk *BlsPublicKey) FromLibBLSPublicKey(key *bls.PublicKey) error
- func (pk BlsPublicKey) Hex() string
- func (pk BlsPublicKey) IsEmpty() bool
- func (pk BlsPublicKey) MarshalText() (text []byte, err error)
- func (pk *BlsPublicKey) ToLibBLSPublicKey(key *bls.PublicKey) error
- type Committee
- type CommitteeLegacy
- type Slot
- type SlotLegacy
- type SlotList
- type SlotListLegacy
- type StakedSlots
- type State
- type StateLegacy
Constants ¶
const ( PublicKeySizeInBytes = 48 BLSSignatureSizeInBytes = 96 )
PublicKeySizeInBytes ..
const (
// BeaconChainShardID is the ShardID of the BeaconChain
BeaconChainShardID = 0
)
Variables ¶
var ( // ErrValidNotInCommittee .. ErrValidNotInCommittee = errors.New("slot signer not this slot's subcommittee") // ErrSubCommitteeNil .. ErrSubCommitteeNil = errors.New("subcommittee is nil pointer") // ErrSuperCommitteeNil .. ErrSuperCommitteeNil = errors.New("supercommittee is nil pointer") )
var ( // ErrShardIDNotInSuperCommittee .. ErrShardIDNotInSuperCommittee = errors.New("shardID not in super committee") )
var ( // Schedule is the sharding configuration schedule. // Depends on the type of the network. Defaults to the mainnet schedule. Schedule shardingconfig.Schedule = shardingconfig.MainnetSchedule )
TODO ek – Schedule should really be part of a general-purpose network
configuration. We are OK for the time being, until the day we should let one node process join multiple networks.
Functions ¶
func CompareBlsPublicKey ¶
func CompareBlsPublicKey(k1, k2 BlsPublicKey) int
CompareBlsPublicKey compares two BlsPublicKey, lexicographically.
func CompareCommittee ¶
CompareCommittee compares two committees and their leader/node list.
func CompareNodeIDList ¶
CompareNodeIDList compares two node ID lists.
func EncodeWrapper ¶ added in v1.3.0
EncodeWrapper ..
func ExternalSlotsAvailableForEpoch ¶ added in v1.3.5
ExternalSlotsAvailableForEpoch ..
func GetHashFromNodeList ¶
GetHashFromNodeList will sort the list, then use Keccak256 to hash the list NOTE: do not modify the underlining content for hash
Types ¶
type BLSSignature ¶ added in v1.3.1
type BLSSignature [BLSSignatureSizeInBytes]byte
BLSSignature defines the bls signature
type BlsPublicKey ¶
type BlsPublicKey [PublicKeySizeInBytes]byte
BlsPublicKey defines the bls public key
func FromLibBLSPublicKeyUnsafe ¶ added in v1.3.0
func FromLibBLSPublicKeyUnsafe(key *bls.PublicKey) *BlsPublicKey
FromLibBLSPublicKeyUnsafe could give back nil, use only in cases when have invariant that return value won't be nil
func (*BlsPublicKey) FromLibBLSPublicKey ¶
func (pk *BlsPublicKey) FromLibBLSPublicKey(key *bls.PublicKey) error
FromLibBLSPublicKey replaces the key contents with the given key,
func (BlsPublicKey) Hex ¶
func (pk BlsPublicKey) Hex() string
Hex returns the hex string of bls public key
func (BlsPublicKey) IsEmpty ¶
func (pk BlsPublicKey) IsEmpty() bool
IsEmpty returns whether the bls public key is empty 0 bytes
func (BlsPublicKey) MarshalText ¶ added in v1.3.5
func (pk BlsPublicKey) MarshalText() (text []byte, err error)
MarshalText so that we can use this as JSON printable when used as key in a map
func (*BlsPublicKey) ToLibBLSPublicKey ¶
func (pk *BlsPublicKey) ToLibBLSPublicKey(key *bls.PublicKey) error
ToLibBLSPublicKey copies the key contents into the given key.
type Committee ¶
Committee contains the active nodes in one shard
func (*Committee) AddressForBLSKey ¶ added in v1.3.3
func (c *Committee) AddressForBLSKey(key BlsPublicKey) (*common.Address, error)
AddressForBLSKey ..
func (*Committee) BLSPublicKeys ¶ added in v1.3.3
BLSPublicKeys ..
func (Committee) StakedValidators ¶ added in v1.3.3
func (c Committee) StakedValidators() *StakedSlots
StakedValidators filters for non-harmony operated nodes, returns (
totalStakedValidatorsCount, totalStakedBLSKeys, addrsOnNetworkSlice, addrsOnNetworkSet,
)
type CommitteeLegacy ¶ added in v1.3.0
type CommitteeLegacy struct { ShardID uint32 `json:"shard-id"` Slots SlotListLegacy `json:"subcommittee"` }
CommitteeLegacy contains the active nodes in one shard
type Slot ¶ added in v1.3.0
type Slot struct { EcdsaAddress common.Address `json:"ecdsa-address"` BlsPublicKey BlsPublicKey `json:"bls-pubkey"` // nil means our node, 0 means not active, > 0 means staked node EffectiveStake *numeric.Dec `json:"effective-stake" rlp:"nil"` }
Slot represents node id (BLS address)
type SlotLegacy ¶ added in v1.3.0
type SlotLegacy struct { EcdsaAddress common.Address `json:"ecdsa-address"` BlsPublicKey BlsPublicKey `json:"bls-pubkey"` }
SlotLegacy represents node id (BLS address)
type SlotList ¶ added in v1.3.0
type SlotList []Slot
SlotList is a list of Slot.
type SlotListLegacy ¶ added in v1.3.0
type SlotListLegacy []SlotLegacy
SlotListLegacy is a list of SlotList.
type StakedSlots ¶ added in v1.3.3
type StakedSlots struct { CountStakedValidator int CountStakedBLSKey int Addrs []common.Address LookupSet map[common.Address]struct{} }
StakedSlots gives overview of subset of shard state that is coming via an stake, that is, view epos
type State ¶
State is the collection of all committees
func DecodeWrapper ¶ added in v1.3.0
DecodeWrapper ..
func (*State) FindCommitteeByID ¶
FindCommitteeByID returns the committee configuration for the given shard, or nil if the given shard is not found.
func (*State) MarshalJSON ¶ added in v1.3.2
MarshalJSON ..
func (*State) StakedValidators ¶ added in v1.3.3
func (ss *State) StakedValidators() *StakedSlots
StakedValidators filters for non-harmony operated nodes, returns (
totalStakedValidatorsCount, totalStakedBLSKeys, addrsOnNetworkSlice, addrsOnNetworkSet,
)