shard

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: LGPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// BeaconChainShardID is the ShardID of the BeaconChain
	BeaconChainShardID = 0
)

Variables

View Source
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")
)
View Source
var (

	// ErrShardIDNotInSuperCommittee ..
	ErrShardIDNotInSuperCommittee = errors.New("shardID not in super committee")
)
View Source
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 bls.SerializedPublicKey) int

CompareBLSPublicKey compares two SerializedPublicKey, lexicographically.

func CompareCommittee

func CompareCommittee(c1, c2 *Committee) int

CompareCommittee compares two committees and their leader/node list.

func CompareNodeID

func CompareNodeID(id1, id2 *Slot) int

CompareNodeID compares two node IDs.

func CompareNodeIDList

func CompareNodeIDList(l1, l2 SlotList) int

CompareNodeIDList compares two node ID lists.

func EncodeWrapper

func EncodeWrapper(shardState State, isStaking bool) ([]byte, error)

EncodeWrapper ..

func ExternalSlotsAvailableForEpoch

func ExternalSlotsAvailableForEpoch(epoch *big.Int) int

ExternalSlotsAvailableForEpoch ..

func GetHashFromNodeList

func GetHashFromNodeList(nodeList []Slot) []byte

GetHashFromNodeList will sort the list, then use Keccak256 to hash the list NOTE: do not modify the underlining content for hash

Types

type Committee

type Committee struct {
	ShardID uint32   `json:"shard-id"`
	Slots   SlotList `json:"subcommittee"`
}

Committee contains the active nodes in one shard

func (*Committee) AddressForBLSKey

func (c *Committee) AddressForBLSKey(key bls.SerializedPublicKey) (*common.Address, error)

AddressForBLSKey ..

func (*Committee) BLSPublicKeys

func (c *Committee) BLSPublicKeys() ([]bls.PublicKeyWrapper, error)

BLSPublicKeys ..

func (*Committee) DeepCopy

func (c *Committee) DeepCopy() Committee

DeepCopy returns a deep copy of the receiver.

func (*Committee) Hash

func (c *Committee) Hash() common.Hash

Hash ..

func (Committee) StakedValidators

func (c Committee) StakedValidators() *StakedSlots

StakedValidators ..

type CommitteeLegacy

type CommitteeLegacy struct {
	ShardID uint32         `json:"shard-id"`
	Slots   SlotListLegacy `json:"subcommittee"`
}

CommitteeLegacy contains the active nodes in one shard

type Slot

type Slot struct {
	EcdsaAddress common.Address          `json:"ecdsa-address"`
	BLSPublicKey bls.SerializedPublicKey `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)

func (Slot) Serialize

func (n Slot) Serialize() []byte

Serialize serialize Slot into bytes

func (Slot) String

func (n Slot) String() string

type SlotLegacy

type SlotLegacy struct {
	EcdsaAddress common.Address          `json:"ecdsa-address"`
	BLSPublicKey bls.SerializedPublicKey `json:"bls-pubkey"`
}

SlotLegacy represents node id (BLS address)

type SlotList

type SlotList []Slot

SlotList is a list of Slot.

func (SlotList) DeepCopy

func (l SlotList) DeepCopy() SlotList

DeepCopy returns a deep copy of the receiver.

func (SlotList) String

func (l SlotList) String() string

type SlotListLegacy

type SlotListLegacy []SlotLegacy

SlotListLegacy is a list of SlotList.

type StakedSlots

type StakedSlots struct {
	CountStakedValidator int
	CountStakedBLSKey    int
	Addrs                []common.Address
	LookupSet            map[common.Address]struct{}
	TotalEffectiveStaked numeric.Dec
}

StakedSlots gives overview of members in a subcommittee (aka a shard)

type State

type State struct {
	Epoch  *big.Int    `json:"epoch"`
	Shards []Committee `json:"shards"`
}

State is the collection of all committees

func DecodeWrapper

func DecodeWrapper(shardState []byte) (*State, error)

DecodeWrapper ..

func (*State) DeepCopy

func (ss *State) DeepCopy() *State

DeepCopy returns a deep copy of the receiver.

func (*State) FindCommitteeByID

func (ss *State) FindCommitteeByID(shardID uint32) (*Committee, error)

FindCommitteeByID returns the committee configuration for the given shard, or nil if the given shard is not found.

func (*State) Hash

func (ss *State) Hash() (h common.Hash)

Hash is the root hash of State

func (*State) MarshalJSON

func (ss *State) MarshalJSON() ([]byte, error)

MarshalJSON ..

func (*State) StakedValidators

func (ss *State) StakedValidators() *StakedSlots

StakedValidators here is supercommittee wide

func (*State) String

func (ss *State) String() string

String produces a non-pretty printed JSON string of the SuperCommittee

type StateLegacy

type StateLegacy []CommitteeLegacy

StateLegacy ..

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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