inter

package
v0.0.0-...-34d0e24 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShortTermGas    = 0
	LongTermGas     = 1
	GasPowerConfigs = 2
)
View Source
const MaxSerializationVersion = 1
View Source
const (
	// MinAccomplicesForProof defines how many validators must have signed the same wrong vote.
	// Otherwise, wrong-signer is not liable as a protection against singular software/hardware failures
	MinAccomplicesForProof = 2
)
View Source
const SigSize = 64

Variables

View Source
var (
	ErrSerMalformedEvent = errors.New("serialization of malformed event")
	ErrTooLowEpoch       = errors.New("serialization of events with epoch<256 and version=0 is unsupported")
	ErrUnknownVersion    = errors.New("unknown serialization version")
)
View Source
var ErrUnknownTxType = errors.New("unknown tx type")

Functions

func CalcMisbehaviourProofsHash

func CalcMisbehaviourProofsHash(mps []MisbehaviourProof) hash.Hash

func CalcPayloadHash

func CalcPayloadHash(e EventPayloadI) hash.Hash

func CalcReceiptsHash

func CalcReceiptsHash(receipts []*types.ReceiptForStorage) hash.Hash

func CalcTxHash

func CalcTxHash(txs types.Transactions) hash.Hash

func EmptyPayloadHash

func EmptyPayloadHash(version uint8) hash.Hash

func EventIDsToHex

func EventIDsToHex(ids hash.Events) []hexutil.Bytes

func FilterSkippedTxs

func FilterSkippedTxs(txs types.Transactions, skippedTxs []uint32) types.Transactions

func HexToEventIDs

func HexToEventIDs(bb []interface{}) hash.Events

func MarshalTxsCSER

func MarshalTxsCSER(txs types.Transactions, w *cser.Writer) error

func RPCMarshalEvent

func RPCMarshalEvent(e EventI) map[string]interface{}

RPCMarshalEvent converts the given event to the RPC output .

func RPCMarshalEventPayload

func RPCMarshalEventPayload(event EventPayloadI, inclTx bool, fullTx bool) (map[string]interface{}, error)

RPCMarshalEventPayload converts the given event to the RPC output which depends on fullTx. If inclTx is true transactions are returned. When fullTx is true the returned block contains full transaction details, otherwise it will only contain transaction hashes.

func TransactionMarshalCSER

func TransactionMarshalCSER(w *cser.Writer, tx *types.Transaction) error

func TransactionUnmarshalCSER

func TransactionUnmarshalCSER(r *cser.Reader) (*types.Transaction, error)

Types

type Block

type Block struct {
	Time        Timestamp
	Atropos     hash.Event
	Events      hash.Events
	Txs         []common.Hash // non event txs (received via genesis or LLR)
	InternalTxs []common.Hash // DEPRECATED in favor of using only Txs fields and method internal.IsInternal
	SkippedTxs  []uint32      // indexes of skipped txs, starting from first tx of first event, ending with last tx of last event
	GasUsed     uint64
	Root        hash.Hash
}

func (*Block) EstimateSize

func (b *Block) EstimateSize() int

type BlockVoteDoublesign

type BlockVoteDoublesign struct {
	Block idx.Block
	Pair  [2]LlrSignedBlockVotes
}

func (BlockVoteDoublesign) GetVote

func (p BlockVoteDoublesign) GetVote(i int) hash.Hash

type EpochVoteDoublesign

type EpochVoteDoublesign struct {
	Pair [2]LlrSignedEpochVote
}

type Event

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

func (*Event) AnyBlockVotes

func (e *Event) AnyBlockVotes() bool

func (*Event) AnyEpochVote

func (e *Event) AnyEpochVote() bool

func (*Event) AnyMisbehaviourProofs

func (e *Event) AnyMisbehaviourProofs() bool

func (*Event) AnyTxs

func (e *Event) AnyTxs() bool

func (*Event) CreationTime

func (e *Event) CreationTime() Timestamp

func (*Event) Extra

func (e *Event) Extra() []byte

func (*Event) GasPowerLeft

func (e *Event) GasPowerLeft() GasPowerLeft

func (*Event) GasPowerUsed

func (e *Event) GasPowerUsed() uint64

func (*Event) HashToSign

func (e *Event) HashToSign() hash.Hash

func (*Event) Locator

func (e *Event) Locator() EventLocator

func (*Event) MarshalBinary

func (e *Event) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaller interface.

func (*Event) MarshalCSER

func (e *Event) MarshalCSER(w *cser.Writer) error

func (*Event) MedianTime

func (e *Event) MedianTime() Timestamp

func (*Event) NetForkID

func (e *Event) NetForkID() uint16

func (*Event) PayloadHash

func (e *Event) PayloadHash() hash.Hash

func (*Event) PrevEpochHash

func (e *Event) PrevEpochHash() *hash.Hash

func (*Event) Version

func (e *Event) Version() uint8

type EventI

type EventI interface {
	dag.Event
	Version() uint8
	NetForkID() uint16
	CreationTime() Timestamp
	MedianTime() Timestamp
	PrevEpochHash() *hash.Hash
	Extra() []byte
	GasPowerLeft() GasPowerLeft
	GasPowerUsed() uint64

	HashToSign() hash.Hash
	Locator() EventLocator

	AnyTxs() bool
	AnyBlockVotes() bool
	AnyEpochVote() bool
	AnyMisbehaviourProofs() bool
	PayloadHash() hash.Hash
}

func RPCUnmarshalEvent

func RPCUnmarshalEvent(fields map[string]interface{}) EventI

RPCUnmarshalEvent converts the RPC output to the header.

type EventIs

type EventIs []EventI

EventIs is a ordered slice of events.

func (*EventIs) Add

func (ee *EventIs) Add(e ...EventI)

Add appends hash to the slice.

func (EventIs) Bases

func (ee EventIs) Bases() dag.Events

func (EventIs) IDs

func (ee EventIs) IDs() hash.Events

func (EventIs) Len

func (ee EventIs) Len() int

func (EventIs) Less

func (ee EventIs) Less(i, j int) bool

func (EventIs) String

func (ee EventIs) String() string

String returns human readable representation.

func (EventIs) Swap

func (ee EventIs) Swap(i, j int)

type EventLocator

type EventLocator struct {
	BaseHash    hash.Hash
	NetForkID   uint16
	Epoch       idx.Epoch
	Seq         idx.Event
	Lamport     idx.Lamport
	Creator     idx.ValidatorID
	PayloadHash hash.Hash
}

func (EventLocator) HashToSign

func (l EventLocator) HashToSign() hash.Hash

func (EventLocator) ID

func (l EventLocator) ID() hash.Event

type EventPayload

type EventPayload struct {
	SignedEvent
	// contains filtered or unexported fields
}

func (*EventPayload) AnyBlockVotes

func (e *EventPayload) AnyBlockVotes() bool

func (*EventPayload) AnyEpochVote

func (e *EventPayload) AnyEpochVote() bool

func (*EventPayload) AnyMisbehaviourProofs

func (e *EventPayload) AnyMisbehaviourProofs() bool

func (*EventPayload) AnyTxs

func (e *EventPayload) AnyTxs() bool

func (*EventPayload) BlockVotes

func (e *EventPayload) BlockVotes() LlrBlockVotes

func (*EventPayload) CreationTime

func (e *EventPayload) CreationTime() Timestamp

func (*EventPayload) DecodeRLP

func (e *EventPayload) DecodeRLP(src *rlp.Stream) error

DecodeRLP implements rlp.Decoder interface.

func (*EventPayload) EncodeRLP

func (e *EventPayload) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder interface.

func (*EventPayload) EpochVote

func (e *EventPayload) EpochVote() LlrEpochVote

func (*EventPayload) Extra

func (e *EventPayload) Extra() []byte

func (*EventPayload) GasPowerLeft

func (e *EventPayload) GasPowerLeft() GasPowerLeft

func (*EventPayload) GasPowerUsed

func (e *EventPayload) GasPowerUsed() uint64

func (*EventPayload) MarshalBinary

func (e *EventPayload) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaller interface.

func (*EventPayload) MarshalCSER

func (e *EventPayload) MarshalCSER(w *cser.Writer) error

func (*EventPayload) MedianTime

func (e *EventPayload) MedianTime() Timestamp

func (*EventPayload) MisbehaviourProofs

func (e *EventPayload) MisbehaviourProofs() []MisbehaviourProof

func (*EventPayload) NetForkID

func (e *EventPayload) NetForkID() uint16

func (*EventPayload) PayloadHash

func (e *EventPayload) PayloadHash() hash.Hash

func (*EventPayload) PrevEpochHash

func (e *EventPayload) PrevEpochHash() *hash.Hash

func (*EventPayload) Sig

func (e *EventPayload) Sig() Signature

func (*EventPayload) Size

func (e *EventPayload) Size() int

func (*EventPayload) Txs

func (e *EventPayload) Txs() types.Transactions

func (*EventPayload) UnmarshalBinary

func (e *EventPayload) UnmarshalBinary(raw []byte) (err error)

UnmarshalBinary implements encoding.BinaryUnmarshaller interface.

func (*EventPayload) Version

func (e *EventPayload) Version() uint8

type EventPayloadI

type EventPayloadI interface {
	EventI
	Sig() Signature

	Txs() types.Transactions
	EpochVote() LlrEpochVote
	BlockVotes() LlrBlockVotes
	MisbehaviourProofs() []MisbehaviourProof
}

type EventPayloads

type EventPayloads []*EventPayload

EventPayloads is a ordered slice of EventPayload.

func (*EventPayloads) Add

func (ee *EventPayloads) Add(e ...*EventPayload)

Add appends hash to the slice.

func (EventPayloads) Bases

func (ee EventPayloads) Bases() dag.Events

func (EventPayloads) IDs

func (ee EventPayloads) IDs() hash.Events

func (EventPayloads) Len

func (ee EventPayloads) Len() int

func (EventPayloads) Less

func (ee EventPayloads) Less(i, j int) bool

func (EventPayloads) String

func (ee EventPayloads) String() string

String returns human readable representation.

func (EventPayloads) Swap

func (ee EventPayloads) Swap(i, j int)

type Events

type Events []*Event

Events is a ordered slice of events.

func (*Events) Add

func (ee *Events) Add(e ...*Event)

Add appends hash to the slice.

func (Events) Bases

func (ee Events) Bases() dag.Events

func (Events) IDs

func (ee Events) IDs() hash.Events

func (Events) Interfaces

func (ee Events) Interfaces() EventIs

func (Events) Len

func (ee Events) Len() int

func (Events) Less

func (ee Events) Less(i, j int) bool

func (Events) String

func (ee Events) String() string

String returns human readable representation.

func (Events) Swap

func (ee Events) Swap(i, j int)

type EventsDoublesign

type EventsDoublesign struct {
	Pair [2]SignedEventLocator
}

type GasPowerLeft

type GasPowerLeft struct {
	Gas [GasPowerConfigs]uint64
}

GasPowerLeft is long-term gas power left and short-term gas power left

func (GasPowerLeft) Add

func (g GasPowerLeft) Add(diff uint64)

Add add to all gas power lefts

func (GasPowerLeft) Max

func (g GasPowerLeft) Max() uint64

Max returns maximum within long-term gas power left and short-term gas power left

func (GasPowerLeft) Min

func (g GasPowerLeft) Min() uint64

Min returns minimum within long-term gas power left and short-term gas power left

func (GasPowerLeft) String

func (g GasPowerLeft) String() string

String returns string representation.

func (GasPowerLeft) Sub

func (g GasPowerLeft) Sub(diff uint64) GasPowerLeft

Sub subtracts from all gas power lefts

type LlrBlockVotes

type LlrBlockVotes struct {
	Start idx.Block
	Epoch idx.Epoch
	Votes []hash.Hash
}

func (LlrBlockVotes) Hash

func (bvs LlrBlockVotes) Hash() hash.Hash

func (LlrBlockVotes) LastBlock

func (bvs LlrBlockVotes) LastBlock() idx.Block

func (LlrBlockVotes) MarshalCSER

func (bvs LlrBlockVotes) MarshalCSER(w *cser.Writer) error

func (*LlrBlockVotes) UnmarshalCSER

func (bvs *LlrBlockVotes) UnmarshalCSER(r *cser.Reader) error

type LlrEpochVote

type LlrEpochVote struct {
	Epoch idx.Epoch
	Vote  hash.Hash
}

func (LlrEpochVote) Hash

func (ers LlrEpochVote) Hash() hash.Hash

func (LlrEpochVote) MarshalCSER

func (ers LlrEpochVote) MarshalCSER(w *cser.Writer) error

func (*LlrEpochVote) UnmarshalCSER

func (ers *LlrEpochVote) UnmarshalCSER(r *cser.Reader) error

type LlrSignedBlockVotes

type LlrSignedBlockVotes struct {
	Signed                       SignedEventLocator
	TxsAndMisbehaviourProofsHash hash.Hash
	EpochVoteHash                hash.Hash
	Val                          LlrBlockVotes
}

func AsSignedBlockVotes

func AsSignedBlockVotes(e EventPayloadI) LlrSignedBlockVotes

func (LlrSignedBlockVotes) CalcPayloadHash

func (bvs LlrSignedBlockVotes) CalcPayloadHash() hash.Hash

func (LlrSignedBlockVotes) Size

func (bvs LlrSignedBlockVotes) Size() uint64

type LlrSignedEpochVote

type LlrSignedEpochVote struct {
	Signed                       SignedEventLocator
	TxsAndMisbehaviourProofsHash hash.Hash
	BlockVotesHash               hash.Hash
	Val                          LlrEpochVote
}

func AsSignedEpochVote

func AsSignedEpochVote(e EventPayloadI) LlrSignedEpochVote

func (LlrSignedEpochVote) CalcPayloadHash

func (ev LlrSignedEpochVote) CalcPayloadHash() hash.Hash

func (LlrSignedEpochVote) Size

func (ev LlrSignedEpochVote) Size() uint64

type MisbehaviourProof

type MisbehaviourProof struct {
	EventsDoublesign *EventsDoublesign `rlp:"nil"`

	BlockVoteDoublesign *BlockVoteDoublesign `rlp:"nil"`

	WrongBlockVote *WrongBlockVote `rlp:"nil"`

	EpochVoteDoublesign *EpochVoteDoublesign `rlp:"nil"`

	WrongEpochVote *WrongEpochVote `rlp:"nil"`
}

type MutableEventPayload

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

func (*MutableEventPayload) AnyBlockVotes

func (e *MutableEventPayload) AnyBlockVotes() bool

func (*MutableEventPayload) AnyEpochVote

func (e *MutableEventPayload) AnyEpochVote() bool

func (*MutableEventPayload) AnyMisbehaviourProofs

func (e *MutableEventPayload) AnyMisbehaviourProofs() bool

func (*MutableEventPayload) AnyTxs

func (e *MutableEventPayload) AnyTxs() bool

func (*MutableEventPayload) BlockVotes

func (e *MutableEventPayload) BlockVotes() LlrBlockVotes

func (*MutableEventPayload) Build

func (e *MutableEventPayload) Build() *EventPayload

func (*MutableEventPayload) CreationTime

func (e *MutableEventPayload) CreationTime() Timestamp

func (*MutableEventPayload) DecodeRLP

func (e *MutableEventPayload) DecodeRLP(src *rlp.Stream) error

DecodeRLP implements rlp.Decoder interface.

func (*MutableEventPayload) EpochVote

func (e *MutableEventPayload) EpochVote() LlrEpochVote

func (*MutableEventPayload) Extra

func (e *MutableEventPayload) Extra() []byte

func (*MutableEventPayload) GasPowerLeft

func (e *MutableEventPayload) GasPowerLeft() GasPowerLeft

func (*MutableEventPayload) GasPowerUsed

func (e *MutableEventPayload) GasPowerUsed() uint64

func (*MutableEventPayload) HashToSign

func (e *MutableEventPayload) HashToSign() hash.Hash

func (*MutableEventPayload) Locator

func (e *MutableEventPayload) Locator() EventLocator

func (*MutableEventPayload) MedianTime

func (e *MutableEventPayload) MedianTime() Timestamp

func (*MutableEventPayload) MisbehaviourProofs

func (e *MutableEventPayload) MisbehaviourProofs() []MisbehaviourProof

func (*MutableEventPayload) NetForkID

func (e *MutableEventPayload) NetForkID() uint16

func (*MutableEventPayload) PayloadHash

func (e *MutableEventPayload) PayloadHash() hash.Hash

func (*MutableEventPayload) PrevEpochHash

func (e *MutableEventPayload) PrevEpochHash() *hash.Hash

func (*MutableEventPayload) SetBlockVotes

func (e *MutableEventPayload) SetBlockVotes(v LlrBlockVotes)

func (*MutableEventPayload) SetCreationTime

func (e *MutableEventPayload) SetCreationTime(v Timestamp)

func (*MutableEventPayload) SetEpochVote

func (e *MutableEventPayload) SetEpochVote(v LlrEpochVote)

func (*MutableEventPayload) SetExtra

func (e *MutableEventPayload) SetExtra(v []byte)

func (*MutableEventPayload) SetGasPowerLeft

func (e *MutableEventPayload) SetGasPowerLeft(v GasPowerLeft)

func (*MutableEventPayload) SetGasPowerUsed

func (e *MutableEventPayload) SetGasPowerUsed(v uint64)

func (*MutableEventPayload) SetMedianTime

func (e *MutableEventPayload) SetMedianTime(v Timestamp)

func (*MutableEventPayload) SetMisbehaviourProofs

func (e *MutableEventPayload) SetMisbehaviourProofs(v []MisbehaviourProof)

func (*MutableEventPayload) SetNetForkID

func (e *MutableEventPayload) SetNetForkID(v uint16)

func (*MutableEventPayload) SetPayloadHash

func (e *MutableEventPayload) SetPayloadHash(v hash.Hash)

func (*MutableEventPayload) SetPrevEpochHash

func (e *MutableEventPayload) SetPrevEpochHash(v *hash.Hash)

func (*MutableEventPayload) SetSig

func (e *MutableEventPayload) SetSig(v Signature)

func (*MutableEventPayload) SetTxs

func (e *MutableEventPayload) SetTxs(v types.Transactions)

func (*MutableEventPayload) SetVersion

func (e *MutableEventPayload) SetVersion(v uint8)

func (*MutableEventPayload) Sig

func (e *MutableEventPayload) Sig() Signature

func (*MutableEventPayload) Size

func (e *MutableEventPayload) Size() int

func (*MutableEventPayload) Txs

func (e *MutableEventPayload) Txs() types.Transactions

func (*MutableEventPayload) UnmarshalBinary

func (e *MutableEventPayload) UnmarshalBinary(raw []byte) (err error)

UnmarshalBinary implements encoding.BinaryUnmarshaller interface.

func (*MutableEventPayload) UnmarshalCSER

func (e *MutableEventPayload) UnmarshalCSER(r *cser.Reader) error

func (*MutableEventPayload) Version

func (e *MutableEventPayload) Version() uint8

type Signature

type Signature [SigSize]byte

Signature is a secp256k1 signature in R|S format

func BytesToSignature

func BytesToSignature(b []byte) (sig Signature)

func (Signature) Bytes

func (s Signature) Bytes() []byte

type SignedEvent

type SignedEvent struct {
	Event
	// contains filtered or unexported fields
}

func (*SignedEvent) AnyBlockVotes

func (e *SignedEvent) AnyBlockVotes() bool

func (*SignedEvent) AnyEpochVote

func (e *SignedEvent) AnyEpochVote() bool

func (*SignedEvent) AnyMisbehaviourProofs

func (e *SignedEvent) AnyMisbehaviourProofs() bool

func (*SignedEvent) AnyTxs

func (e *SignedEvent) AnyTxs() bool

func (*SignedEvent) CreationTime

func (e *SignedEvent) CreationTime() Timestamp

func (*SignedEvent) Extra

func (e *SignedEvent) Extra() []byte

func (*SignedEvent) GasPowerLeft

func (e *SignedEvent) GasPowerLeft() GasPowerLeft

func (*SignedEvent) GasPowerUsed

func (e *SignedEvent) GasPowerUsed() uint64

func (*SignedEvent) MedianTime

func (e *SignedEvent) MedianTime() Timestamp

func (*SignedEvent) NetForkID

func (e *SignedEvent) NetForkID() uint16

func (*SignedEvent) PayloadHash

func (e *SignedEvent) PayloadHash() hash.Hash

func (*SignedEvent) PrevEpochHash

func (e *SignedEvent) PrevEpochHash() *hash.Hash

func (*SignedEvent) Sig

func (e *SignedEvent) Sig() Signature

func (*SignedEvent) Version

func (e *SignedEvent) Version() uint8

type SignedEventLocator

type SignedEventLocator struct {
	Locator EventLocator
	Sig     Signature
}

func AsSignedEventLocator

func AsSignedEventLocator(e EventPayloadI) SignedEventLocator

func (SignedEventLocator) Size

func (r SignedEventLocator) Size() uint64

type Timestamp

type Timestamp uint64

Timestamp is a UNIX nanoseconds timestamp

func BytesToTimestamp

func BytesToTimestamp(b []byte) Timestamp

BytesToTimestamp converts bytes to timestamp.

func FromUnix

func FromUnix(t int64) Timestamp

func MaxTimestamp

func MaxTimestamp(x, y Timestamp) Timestamp

MaxTimestamp return max value.

func (Timestamp) Bytes

func (t Timestamp) Bytes() []byte

Bytes gets the byte representation of the index.

func (Timestamp) Time

func (t Timestamp) Time() time.Time

func (Timestamp) Unix

func (t Timestamp) Unix() int64

Unix returns t as a Unix time, the number of seconds elapsed since January 1, 1970 UTC. The result does not depend on the location associated with t.

type WrongBlockVote

type WrongBlockVote struct {
	Block      idx.Block
	Pals       [MinAccomplicesForProof]LlrSignedBlockVotes
	WrongEpoch bool
}

func (WrongBlockVote) GetVote

func (p WrongBlockVote) GetVote(i int) hash.Hash

type WrongEpochVote

type WrongEpochVote struct {
	Pals [MinAccomplicesForProof]LlrSignedEpochVote
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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