beacon

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeaconEntriesForBlock

func BeaconEntriesForBlock(ctx context.Context, bSchedule Schedule, nv network.Version, epoch abi.ChainEpoch, parentEpoch abi.ChainEpoch, prev types.BeaconEntry) ([]types.BeaconEntry, error)

func ValidateBlockValues

func ValidateBlockValues(bSchedule Schedule, nv network.Version, h *types.BlockHeader, parentEpoch abi.ChainEpoch, prevEntry *types.BeaconEntry) error

ValidateBlockValues Verify that the beacon in the block header is correct, first get beacon server at block epoch and parent block epoch in schedule. if paraent beacon is the same beacon server. value beacon normally but if not equal, means that the pre entry in another beacon chain, so just validate beacon value in current block header. the first values is parent beacon the second value is current beacon.

Types

type BeaconPoint

type BeaconPoint struct {
	Start  abi.ChainEpoch
	Beacon RandomBeacon
}

type DrandBeacon

type DrandBeacon struct {
	// contains filtered or unexported fields
}

DrandBeacon connects Lotus with a drand network in order to provide randomness to the system in a way that's aligned with Filecoin rounds/epochs.

We connect to drand peers via their public HTTP endpoints. The peers are enumerated in the drandServers variable.

The root trust for the Drand chain is configured from build.DrandChain.

func NewDrandBeacon

func NewDrandBeacon(genTimeStamp, interval uint64, config cfg.DrandConf) (*DrandBeacon, error)

NewDrandBeacon create new beacon client from config, genesis block time and block delay

func (*DrandBeacon) Entry

func (db *DrandBeacon) Entry(ctx context.Context, round uint64) <-chan Response

Entry get a beacon value of specify block height,

func (*DrandBeacon) IsChained added in v1.15.0

func (db *DrandBeacon) IsChained() bool

func (*DrandBeacon) MaxBeaconRoundForEpoch

func (db *DrandBeacon) MaxBeaconRoundForEpoch(nv network.Version, filEpoch abi.ChainEpoch) uint64

MaxBeaconRoundForEpoch get the turn of beacon chain corresponding to chain height

func (*DrandBeacon) VerifyEntry

func (db *DrandBeacon) VerifyEntry(entry types.BeaconEntry, prevEntrySig []byte) error

type DrandHTTPClient

type DrandHTTPClient interface {
	SetUserAgent(string)
}

DrandHTTPClient interface overrides the user agent used by drand

type MockBeacon added in v1.17.0

type MockBeacon struct {
	// contains filtered or unexported fields
}

MockBeacon assumes that filecoin rounds are 1:1 mapped with the beacon rounds

func (*MockBeacon) Entry added in v1.17.0

func (mb *MockBeacon) Entry(ctx context.Context, index uint64) <-chan Response

func (*MockBeacon) IsChained added in v1.17.0

func (mb *MockBeacon) IsChained() bool

func (*MockBeacon) MaxBeaconRoundForEpoch added in v1.17.0

func (mb *MockBeacon) MaxBeaconRoundForEpoch(nv network.Version, epoch abi.ChainEpoch) uint64

func (*MockBeacon) RoundTime added in v1.17.0

func (mb *MockBeacon) RoundTime() time.Duration

func (*MockBeacon) SetMaxIndex added in v1.17.0

func (mb *MockBeacon) SetMaxIndex(maxIndex int, blockTillNoneWaiting bool)

SetMaxIndex sets the maximum index that the beacon will return, and optionally blocks until all waiting requests are satisfied. If maxIndex is -1, the beacon will return entries indefinitely.

func (*MockBeacon) VerifyEntry added in v1.17.0

func (mb *MockBeacon) VerifyEntry(from types.BeaconEntry, _prevEntrySig []byte) error

func (*MockBeacon) WaitingOnEntryCount added in v1.17.0

func (mb *MockBeacon) WaitingOnEntryCount() int

WaitingOnEntryCount returns the number of requests that are currently waiting for an entry. Where maxIndex has not been set, this will always return 0 as beacon entries are generated on demand.

type RandomBeacon

type RandomBeacon interface {
	Entry(context.Context, uint64) <-chan Response
	// VerifyEntry(types.BeaconEntry, types.BeaconEntry) error
	VerifyEntry(entry types.BeaconEntry, prevEntrySig []byte) error
	MaxBeaconRoundForEpoch(network.Version, abi.ChainEpoch) uint64
	IsChained() bool
}

RandomBeacon represents a system that provides randomness to Lotus. Other components interrogate the RandomBeacon to acquire randomness that's valid for a specific chain epoch. Also to verify beacon entries that have been posted on chain.

func NewMockBeacon

func NewMockBeacon(interval time.Duration) RandomBeacon

type Response

type Response struct {
	Entry types.BeaconEntry
	Err   error
}

type Schedule

type Schedule []BeaconPoint

func DrandConfigSchedule

func DrandConfigSchedule(genTimeStamp uint64, blockDelay uint64, drandSchedule map[abi.ChainEpoch]cfg.DrandEnum) (Schedule, error)

DrandConfigSchedule create new beacon schedule , used to select beacon server at specify chain height

func NewMockSchedule

func NewMockSchedule(interval time.Duration) Schedule

func (Schedule) BeaconForEpoch

func (bs Schedule) BeaconForEpoch(e abi.ChainEpoch) RandomBeacon

BeaconForEpoch select beacon at specify epoch

Jump to

Keyboard shortcuts

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