genesis

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: AGPL-3.0 Imports: 11 Imported by: 5

Documentation

Index

Constants

View Source
const (
	MinBlockRateMs          = 100
	DefaultBlockRateMs      = 900
	MinConsensusTimeout     = 2000
	DefaultConsensusTimeout = 10000
)
View Source
const (
	RootRound uint64 = 1
	Timestamp uint64 = 1668208271000 // 11.11.2022 @ 11:11:11
)

Variables

View Source
var (
	ErrGenesisPartitionRecordIsNil = errors.New("genesis partition record is nil")
	ErrNodesAreMissing             = errors.New("nodes are missing")
	ErrVerifiersEmpty              = errors.New("verifier list is empty")
)
View Source
var (
	ErrRootValidatorsSize = errors.New("registered root nodes do not match consensus total root nodes")
	ErrGenesisRootIssNil  = errors.New("root genesis record is nil")
	ErrNoRootValidators   = errors.New("root nodes not set")
	ErrConsensusIsNil     = errors.New("consensus is nil")
)
View Source
var (
	ErrPartitionGenesisIsNil            = errors.New("partition genesis is nil")
	ErrKeysAreMissing                   = errors.New("partition keys are missing")
	ErrMissingRootValidators            = errors.New("missing root nodes")
	ErrPartitionUnicityCertificateIsNil = errors.New("partition unicity certificate is nil")
)
View Source
var (
	ErrPartitionNodeIsNil           = errors.New("partition node is nil")
	ErrNodeIdentifierIsEmpty        = errors.New("node identifier is empty")
	ErrSigningPublicKeyIsInvalid    = errors.New("signing public key is invalid")
	ErrEncryptionPublicKeyIsInvalid = errors.New("encryption public key is invalid")
)
View Source
var (
	ErrValidatorPublicInfoIsEmpty    = errors.New("public key info is empty")
	ErrPubKeyNodeIdentifierIsEmpty   = errors.New("public key info node identifier is empty")
	ErrPubKeyInfoSigningKeyIsInvalid = errors.New("public key info singing key is invalid")
	ErrPubKeyInfoEncryptionIsInvalid = errors.New("public key info encryption key is invalid")
)
View Source
var (
	ErrConsensusParamsIsNil          = errors.New("consensus record is nil")
	ErrInvalidNumberOfRootValidators = errors.New("invalid number of root nodes")
	ErrBlockRateTooSmall             = errors.New("block rate too small")
	ErrUnknownHashAlgorithm          = errors.New("unknown hash algorithm")
	ErrInvalidConsensusTimeout       = errors.New("invalid consensus timeout")
	ErrSignerIsNil                   = errors.New("signer is nil")
	ErrRootValidatorInfoMissing      = errors.New("missing root node public info")
)
View Source
var (
	ErrRootGenesisIsNil       = errors.New("root genesis is nil")
	ErrRootGenesisRecordIsNil = errors.New("root genesis record is nil")
	ErrPartitionsNotFound     = errors.New("root genesis has no partitions records")
)
View Source
var (
	ErrSystemDescriptionIsNil = errors.New("system description record is nil")
	ErrT2TimeoutIsNil         = errors.New("t2 timeout is zero")
)

Functions

func CheckPartitionSystemIdentifiersUnique

func CheckPartitionSystemIdentifiersUnique[T SystemDescriptionRecordGetter](records []T) error

func GetMinQuorumThreshold

func GetMinQuorumThreshold(totalRootValidators uint32) uint32

GetMinQuorumThreshold calculates minimal quorum threshold from total number of validators

func NewValidatorTrustBase

func NewValidatorTrustBase(publicKeyInfo []*PublicKeyInfo) (map[string]abcrypto.Verifier, error)

NewValidatorTrustBase creates a verifier to node id map from public key info using the signing public key.

func ValidatorInfoUnique

func ValidatorInfoUnique(validators []*PublicKeyInfo) error

ValidatorInfoUnique checks for duplicates in the slice, makes sure that there are no validators that share the same id or public key. There is one exception, currently a validator can use the same key for encryption and signing.

Types

type ConsensusParams

type ConsensusParams struct {
	TotalRootValidators uint32            `json:"total_root_validators,omitempty"` // Number of root validator nodes in the root cluster (1 in case of monolithic root chain)
	BlockRateMs         uint32            `json:"block_rate_ms,omitempty"`         // Block rate (round time t3 in monolithic root chain)
	ConsensusTimeoutMs  uint32            `json:"consensus_timeout_ms,omitempty"`  // Time to abandon proposal and vote for timeout (only used in distributed implementation)
	QuorumThreshold     uint32            `json:"quorum_threshold,omitempty"`      // Optionally define a different, higher quorum threshold (only used for distributed implementation)
	HashAlgorithm       uint32            `json:"hash_algorithm,omitempty"`        // Hash algorithm for UnicityTree calculation
	Signatures          map[string][]byte `json:"signatures,omitempty"`            // Signed hash of all fields excluding signatures
	// contains filtered or unexported fields
}

func (*ConsensusParams) Bytes

func (x *ConsensusParams) Bytes() []byte

func (*ConsensusParams) IsValid

func (x *ConsensusParams) IsValid() error

func (*ConsensusParams) Sign

func (x *ConsensusParams) Sign(id string, signer crypto.Signer) error

func (*ConsensusParams) Verify

func (x *ConsensusParams) Verify(verifiers map[string]crypto.Verifier) error

type EvmPartitionParams

type EvmPartitionParams struct {
	BlockGasLimit uint64
	GasUnitPrice  uint64
	// contains filtered or unexported fields
}

type FeeCreditBill

type FeeCreditBill struct {
	UnitID         types.UnitID         `json:"unit_id,omitempty"`
	OwnerPredicate types.PredicateBytes `json:"owner_predicate,omitempty"`
	// contains filtered or unexported fields
}

type GenesisPartitionRecord

type GenesisPartitionRecord struct {
	Nodes                   []*PartitionNode          `json:"nodes,omitempty"`
	Certificate             *types.UnicityCertificate `json:"certificate,omitempty"`
	SystemDescriptionRecord *SystemDescriptionRecord  `json:"system_description_record,omitempty"`
	// contains filtered or unexported fields
}

func (*GenesisPartitionRecord) GetSystemDescriptionRecord

func (x *GenesisPartitionRecord) GetSystemDescriptionRecord() *SystemDescriptionRecord

func (*GenesisPartitionRecord) IsValid

func (x *GenesisPartitionRecord) IsValid(verifiers map[string]crypto.Verifier, hashAlgorithm gocrypto.Hash) error

type GenesisRootRecord

type GenesisRootRecord struct {
	RootValidators []*PublicKeyInfo `json:"root_validators,omitempty"`
	Consensus      *ConsensusParams `json:"consensus,omitempty"`
	// contains filtered or unexported fields
}

func (*GenesisRootRecord) FindPubKeyById

func (x *GenesisRootRecord) FindPubKeyById(id string) *PublicKeyInfo

FindPubKeyById returns matching PublicKeyInfo matching node id or nil if not found

func (*GenesisRootRecord) IsValid

func (x *GenesisRootRecord) IsValid() error

IsValid only validates Consensus structure and that it signed by the listed root nodes

func (*GenesisRootRecord) Verify

func (x *GenesisRootRecord) Verify() error

Verify calls IsValid and makes sure that consensus total number of validators matches number of registered root validators and number of signatures in consensus structure

type MoneyPartitionParams

type MoneyPartitionParams struct {
	SystemDescriptionRecords []*SystemDescriptionRecord
	// contains filtered or unexported fields
}

type PartitionGenesis

type PartitionGenesis struct {
	SystemDescriptionRecord *SystemDescriptionRecord  `json:"system_description_record,omitempty"`
	Certificate             *types.UnicityCertificate `json:"certificate,omitempty"`
	RootValidators          []*PublicKeyInfo          `json:"root_validators,omitempty"`
	Keys                    []*PublicKeyInfo          `json:"keys,omitempty"`
	Params                  []byte                    `json:"params,omitempty"`
	// contains filtered or unexported fields
}

func (*PartitionGenesis) FindRootPubKeyInfoById

func (x *PartitionGenesis) FindRootPubKeyInfoById(id string) *PublicKeyInfo

func (*PartitionGenesis) IsValid

func (x *PartitionGenesis) IsValid(verifiers map[string]crypto.Verifier, hashAlgorithm gocrypto.Hash) error

type PartitionNode

type PartitionNode struct {
	NodeIdentifier            string                                   `json:"node_identifier,omitempty"`
	SigningPublicKey          []byte                                   `json:"signing_public_key,omitempty"`
	EncryptionPublicKey       []byte                                   `json:"encryption_public_key,omitempty"`
	BlockCertificationRequest *certification.BlockCertificationRequest `json:"block_certification_request,omitempty"`
	T2Timeout                 uint32                                   `json:"t2timeout,omitempty"`
	Params                    []byte                                   `json:"params,omitempty"`
	// contains filtered or unexported fields
}

func (*PartitionNode) IsValid

func (x *PartitionNode) IsValid() error

type PartitionRecord

type PartitionRecord struct {
	SystemDescriptionRecord *SystemDescriptionRecord `json:"system_description_record,omitempty"`
	Validators              []*PartitionNode         `json:"validators,omitempty"`
	// contains filtered or unexported fields
}

func (*PartitionRecord) GetPartitionNode

func (x *PartitionRecord) GetPartitionNode(id string) *PartitionNode

func (*PartitionRecord) GetSystemDescriptionRecord

func (x *PartitionRecord) GetSystemDescriptionRecord() *SystemDescriptionRecord

func (*PartitionRecord) GetSystemIdentifier

func (x *PartitionRecord) GetSystemIdentifier() types.SystemID

func (*PartitionRecord) IsValid

func (x *PartitionRecord) IsValid() error

type PublicKeyInfo

type PublicKeyInfo struct {
	NodeIdentifier      string `json:"node_identifier,omitempty"`
	SigningPublicKey    []byte `json:"signing_public_key,omitempty"`
	EncryptionPublicKey []byte `json:"encryption_public_key,omitempty"`
	// contains filtered or unexported fields
}

func (*PublicKeyInfo) IsValid

func (x *PublicKeyInfo) IsValid() error

IsValid validates that all fields are correctly set and public keys are correct.

func (*PublicKeyInfo) NodeID

func (x *PublicKeyInfo) NodeID() (peer.ID, error)

NodeID - returns node identifier as peer.ID from encryption public key The NodeIdentifier (string) could also be used with Decode(), but there are a lot of unit tests that init the field as "test" or to some other invalid id

type RootGenesis

type RootGenesis struct {
	Root       *GenesisRootRecord        `json:"root,omitempty"`
	Partitions []*GenesisPartitionRecord `json:"partitions,omitempty"`
	// contains filtered or unexported fields
}

func (*RootGenesis) GetPartitionRecords

func (x *RootGenesis) GetPartitionRecords() []*PartitionRecord

func (*RootGenesis) GetRoundHash

func (x *RootGenesis) GetRoundHash() []byte

func (*RootGenesis) GetRoundNumber

func (x *RootGenesis) GetRoundNumber() uint64

func (*RootGenesis) IsValid

func (x *RootGenesis) IsValid() error

IsValid verifies that the genesis file is signed by the generator and that the public key is included

func (*RootGenesis) NodeIDs

func (x *RootGenesis) NodeIDs() ([]peer.ID, error)

NodeIDs returns IDs of all root validator nodes.

func (*RootGenesis) Verify

func (x *RootGenesis) Verify() error

Verify basically same as IsValid, but verifies that the consensus structure and UC Seals are signed by all root validators

type SystemDescriptionRecord

type SystemDescriptionRecord struct {
	SystemIdentifier types.SystemID `json:"system_identifier,omitempty"`
	T2Timeout        uint32         `json:"t2timeout,omitempty"`
	FeeCreditBill    *FeeCreditBill `json:"fee_credit_bill,omitempty"`
	// contains filtered or unexported fields
}

func (*SystemDescriptionRecord) AddToHasher

func (x *SystemDescriptionRecord) AddToHasher(hasher hash.Hash)

func (*SystemDescriptionRecord) GetSystemIdentifier

func (x *SystemDescriptionRecord) GetSystemIdentifier() types.SystemID

func (*SystemDescriptionRecord) Hash

func (x *SystemDescriptionRecord) Hash(hashAlgorithm gocrypto.Hash) []byte

func (*SystemDescriptionRecord) IsValid

func (x *SystemDescriptionRecord) IsValid() error

type SystemDescriptionRecordGetter

type SystemDescriptionRecordGetter interface {
	GetSystemDescriptionRecord() *SystemDescriptionRecord
}

Jump to

Keyboard shortcuts

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