certs

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0, MIT Imports: 13 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyPowerTableDiffs

func ApplyPowerTableDiffs(prevPowerTable gpbft.PowerEntries, diffs ...PowerTableDiff) (gpbft.PowerEntries, error)

Apply a set of power table diffs to the passed power table.

- The delta must be sorted by participant ID, ascending. - The returned power table is sorted by power, descending.

func MakePowerTableCID

func MakePowerTableCID(pt gpbft.PowerEntries) (gpbft.CID, error)

MakePowerTableCID returns the DagCBOR-blake2b256 CID of the given power entries. This method does not mutate, sort, validate, etc. the power entries.

func ValidateFinalityCertificates

func ValidateFinalityCertificates(verifier gpbft.Verifier, network gpbft.NetworkName, prevPowerTable gpbft.PowerEntries, nextInstance uint64, base *gpbft.TipSet,
	certs ...FinalityCertificate) (_nextInstance uint64, chain gpbft.ECChain, newPowerTable gpbft.PowerEntries, err error)

ValidateFinalityCertificates validates zero or more finality certificates, returning the next instance after the last valid finality certificates, any newly finalized tipsets, and the next power table to use as-of the last valid finality certificate. If passed a non-nil `base` tipset, validate that the finalized chain starts with that tipset (accept any finalized chain otherwise).

Returns an error if it encounters any invalid finality certificates, along with the last valid instance, finalized chain epochs, etc. E.g., if provided a partially valid chain of finality certificates, this function will return a (possibly empty) prefix of the EC chain correctly finalized, the instance of the first invalid finality certificate, and the power table that should be used to validate that finality certificate, along with the error encountered.

Types

type FinalityCertificate

type FinalityCertificate struct {
	// The GPBFT instance to which this finality certificate corresponds.
	GPBFTInstance uint64
	// The ECChain finalized during this instance, starting with the last tipset finalized in
	// the previous instance.
	ECChain gpbft.ECChain
	// Additional data signed by the participants in this instance. Currently used to certify
	// the power table used in the next instance.
	SupplementalData gpbft.SupplementalData
	// Indexes in the base power table of the certifiers (bitset)
	Signers bitfield.BitField
	// Aggregated signature of the certifiers
	Signature []byte
	// Changes between the power table used to validate this finality certificate and the power
	// used to validate the next finality certificate. Sorted by ParticipantID, ascending.
	PowerTableDelta PowerTableDiff
}

FinalityCertificate represents a single finalized GPBFT instance.

func NewFinalityCertificate

func NewFinalityCertificate(powerDelta PowerTableDiff, justification *gpbft.Justification) (*FinalityCertificate, error)

NewFinalityCertificate constructs a new finality certificate from the given power delta (from `MakePowerTableDiff`) and justification (from GPBFT).

Note, however, that this function does not attempt to validate the resulting finality certificate (beyond verifying that it is a justification for the correct round). You can do so by immediately calling `ValidateFinalityCertificates` on the result.

func (*FinalityCertificate) MarshalCBOR

func (t *FinalityCertificate) MarshalCBOR(w io.Writer) error

func (*FinalityCertificate) UnmarshalCBOR

func (t *FinalityCertificate) UnmarshalCBOR(r io.Reader) (err error)

type PowerTableDelta

type PowerTableDelta struct {
	// Participant with changed power
	ParticipantID gpbft.ActorID
	// Change in power from base (signed).
	PowerDelta gpbft.StoragePower
	// New signing key if relevant (else empty)
	SigningKey gpbft.PubKey
}

PowerTableDelta represents a single power table change between GPBFT instances. If the resulting power is 0 after applying the delta, the participant is removed from the power table.

func (*PowerTableDelta) IsZero

func (d *PowerTableDelta) IsZero() bool

func (*PowerTableDelta) MarshalCBOR

func (t *PowerTableDelta) MarshalCBOR(w io.Writer) error

func (*PowerTableDelta) UnmarshalCBOR

func (t *PowerTableDelta) UnmarshalCBOR(r io.Reader) (err error)

type PowerTableDiff added in v0.0.5

type PowerTableDiff []PowerTableDelta

func MakePowerTableDiff

func MakePowerTableDiff(oldPowerTable, newPowerTable gpbft.PowerEntries) PowerTableDiff

MakePowerTableDiff create a power table diff between the two given power tables. It makes no assumptions about order, but does assume that the power table entries are unique. The returned diff is sorted by participant ID ascending.

func (*PowerTableDiff) MarshalCBOR added in v0.0.5

func (t *PowerTableDiff) MarshalCBOR(w io.Writer) error

func (*PowerTableDiff) UnmarshalCBOR added in v0.0.5

func (t *PowerTableDiff) UnmarshalCBOR(r io.Reader) (err error)

Jump to

Keyboard shortcuts

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