emulator

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0, MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ValidTicket gpbft.Ticket = []byte("filled in by driver")

ValidTicket is a sentinel value to generate and set a valid gpbft.Ticket when delivering messages via Driver.deliverMessage.

Functions

This section is empty.

Types

type Driver

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

Driver drives the emulation of a GPBFT instance for one honest participant, and allows frame-by-frame control over progress of a GPBFT instance.

func NewDriver

func NewDriver(t *testing.T, o ...gpbft.Option) *Driver

NewDriver instantiates a new Driver with the given GPBFT options. See Driver.RequireStartInstance.

func (*Driver) AddInstance

func (d *Driver) AddInstance(instance *Instance)

AddInstance adds an instance to the list of instances known by the driver.

func (*Driver) DeliverAlarm added in v0.3.0

func (d *Driver) DeliverAlarm() (bool, error)

func (*Driver) PeekLastBroadcastRequest added in v0.3.0

func (d *Driver) PeekLastBroadcastRequest() *gpbft.GMessage

PeekLastBroadcastRequest gets the last broadcast requested by the subject participant without removing it from the pending broadcasts.

func (*Driver) RequireCommit

func (d *Driver) RequireCommit(round uint64, vote gpbft.ECChain, justification *gpbft.Justification)

func (*Driver) RequireCommitForBottom

func (d *Driver) RequireCommitForBottom(round uint64)

func (*Driver) RequireConverge

func (d *Driver) RequireConverge(round uint64, vote gpbft.ECChain, justification *gpbft.Justification)

func (*Driver) RequireDecide

func (d *Driver) RequireDecide(vote gpbft.ECChain, justification *gpbft.Justification)

func (*Driver) RequireDecision

func (d *Driver) RequireDecision(instanceID uint64, expect gpbft.ECChain)

func (*Driver) RequireDeliverAlarm

func (d *Driver) RequireDeliverAlarm()

func (*Driver) RequireDeliverMessage

func (d *Driver) RequireDeliverMessage(message *gpbft.GMessage)

func (*Driver) RequireErrOnDeliverMessage

func (d *Driver) RequireErrOnDeliverMessage(message *gpbft.GMessage, err error, contains string)

func (*Driver) RequireNoBroadcast

func (d *Driver) RequireNoBroadcast()

func (*Driver) RequirePeekAtLastVote added in v0.3.0

func (d *Driver) RequirePeekAtLastVote(phase gpbft.Phase, round uint64, vote gpbft.ECChain)

RequirePeekAtLastVote asserts that the last message broadcasted by the subject participant was for the given phase, round and vote.

func (*Driver) RequirePrepare

func (d *Driver) RequirePrepare(value gpbft.ECChain)

func (*Driver) RequirePrepareAtRound

func (d *Driver) RequirePrepareAtRound(round uint64, value gpbft.ECChain, justification *gpbft.Justification)

func (*Driver) RequireQuality

func (d *Driver) RequireQuality()

func (*Driver) RequireStartInstance added in v0.3.0

func (d *Driver) RequireStartInstance(id uint64)

RequireStartInstance asserts that instance with the given ID is started. See StartInstance.

func (*Driver) SetSigning added in v0.3.0

func (d *Driver) SetSigning(signing Signing)

func (*Driver) StartInstance

func (d *Driver) StartInstance(id uint64) error

StartInstance sets the current instances and starts emulation for it by signalling the start of instance to the emulated honest gpbft.Participant.

See NewInstance.

type Instance

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

Instance represents a GPBFT instance capturing all the information necessary for GPBFT to function, along with the final decision reached if any.

func NewInstance

func NewInstance(t *testing.T, id uint64, powerEntries gpbft.PowerEntries, proposal ...gpbft.TipSet) *Instance

NewInstance instantiates a new Instance for emulation. If absent, the constructor will implicitly generate any missing but required values such as public keys Power Table CID, etc. for the given params. The given proposal must contain at least one tipset.

See Driver.RequireStartInstance.

func (*Instance) GetDecision

func (i *Instance) GetDecision() *gpbft.Justification

func (*Instance) ID

func (i *Instance) ID() uint64

func (*Instance) NewCommit

func (i *Instance) NewCommit(round uint64, proposal gpbft.ECChain) gpbft.Payload

func (*Instance) NewConverge

func (i *Instance) NewConverge(round uint64, proposal gpbft.ECChain) gpbft.Payload

func (*Instance) NewDecide

func (i *Instance) NewDecide(round uint64, proposal gpbft.ECChain) gpbft.Payload

func (*Instance) NewJustification

func (i *Instance) NewJustification(round uint64, phase gpbft.Phase, vote gpbft.ECChain, from ...gpbft.ActorID) *gpbft.Justification

func (*Instance) NewJustificationWithPayload added in v0.3.0

func (i *Instance) NewJustificationWithPayload(payload gpbft.Payload, from ...gpbft.ActorID) *gpbft.Justification

func (*Instance) NewMessageBuilder

func (i *Instance) NewMessageBuilder(payload gpbft.Payload, justification *gpbft.Justification, withTicket bool) *gpbft.MessageBuilder

func (*Instance) NewPayload

func (i *Instance) NewPayload(round uint64, phase gpbft.Phase, value gpbft.ECChain) gpbft.Payload

func (*Instance) NewPrepare

func (i *Instance) NewPrepare(round uint64, proposal gpbft.ECChain) gpbft.Payload

func (*Instance) NewQuality

func (i *Instance) NewQuality(proposal gpbft.ECChain) gpbft.Payload

func (*Instance) PowerTable added in v0.0.4

func (i *Instance) PowerTable() *gpbft.PowerTable

func (*Instance) Proposal

func (i *Instance) Proposal() gpbft.ECChain

func (*Instance) SetSigning added in v0.3.0

func (i *Instance) SetSigning(signing Signing)

func (*Instance) SupplementalData

func (i *Instance) SupplementalData() gpbft.SupplementalData

type MessageCache added in v0.5.0

type MessageCache map[gpbft.Instant]*gpbft.GMessage

MessageCache is a repository of messages keyed by their instance, round and phase. This cache is used for testing purposes only and has no eviction strategy. It is primarily used to store messages from self for rebroadcast.

func NewMessageCache added in v0.5.0

func NewMessageCache() MessageCache

func (MessageCache) Get added in v0.5.0

func (mc MessageCache) Get(instant gpbft.Instant) (*gpbft.GMessage, bool)

func (MessageCache) PutIfAbsent added in v0.5.0

func (mc MessageCache) PutIfAbsent(msg *gpbft.GMessage) bool

type Signing added in v0.3.0

type Signing interface {
	gpbft.Verifier
	gpbft.Signer
	gpbft.SigningMarshaler
}

func AdhocSigning added in v0.3.0

func AdhocSigning() Signing

AdhocSigning marshals, signs and verifies messages on behalf of any given public key but uniquely and deterministically so using crc32 hash function for performance. This implementation is not secure nor collision resistant. A typical Instance power table is small enough to make the risk of collisions negligible.

func ErroneousSigning added in v0.3.0

func ErroneousSigning() Signing

ErroneousSigning returns an error for every Signing API that can return an error.

func PanicSigning added in v0.3.0

func PanicSigning() Signing

PanicSigning panics for every Signing API.

Jump to

Keyboard shortcuts

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