-
Notifications
You must be signed in to change notification settings - Fork 78
Event
An event (or an event block) is a vertex in the DAG, which stores the structure of consensus messages. Each event has a number of links to past events (parents). The links are the graph edges.
In this wiki, we may use event
and event block
interchangeably. Do not confuse event block
and block
- those are different terms.
Each event is a signed consensus message by a validator sent to the network, which states that:
I have observed and have validated the following past events (and their parents), which are included as parents of this event. I originate the transactions list belonging to this event
.
A combination of such messages are used to compute the final order of transactions, which is exactly the same on all the nodes, regardless of network delays, clock drifts, and malicious validators. This is done by the aBFT consensus algorithm.
// EventHeaderData is the graph vertex in the Lachesis consensus algorithm
// Doesn't contain transactions, only their hash
// Doesn't contain event signature
type EventHeaderData struct {
Version uint32
Epoch idx.Epoch
Seq idx.Event
Frame idx.Frame
IsRoot bool
Creator idx.StakerID
PrevEpochHash common.Hash
Parents hash.Events
GasPowerLeft [2]uint64
GasPowerUsed uint64
Lamport idx.Lamport
ClaimedTime Timestamp
MedianTime Timestamp
TxHash common.Hash
Extra []byte
// caches
hash atomic.Value
}
// EventHeader is the graph vertex in the Lachesis consensus algorithm
// Doesn't contain transactions, only their hash
type EventHeader struct {
EventHeaderData
Sig []byte
}
// Event is the graph vertex in the Lachesis consensus algorithm
type Event struct {
EventHeader
Transactions types.Transactions
// caches
size atomic.Value
}
- event.Epoch - epoch number (see epoch). Not less than
1
. - event.Seq - sequence number. Equal to self-parent’s
seq + 1
, if no self-parent, then1
. - event.Frame - frame number (see consensus). Not less than
1
. - event.IsRoot - true if event is root (see consensus).
- event.Creator - ID of validator which created event.
- event.PrevEpochHash - hash of finalized state of previous epoch.
- event.Parents - list of parents (graph edges). May be empty. If
Seq > 1
, then first element is self-parent. - event.GasPowerLeft - amount of not spent validator's gas power for each gas power window, after connection of this event (see gas_power).
- event.GasPowerUsed - amount of spent validator's gas power in this event (see gas_power).
- event.Lamport - Lamport time. If parents list is not empty, then
max(parent’s {Lamport time}s) + 1
, else1
. - event.ClaimedTime - UnixNano timestamp. Specified by the creator of event. Cannot be lower than claimed time of self-parent (if self-parent exists). CAN be too-far-in-future, or too-far-in-past.
- event.MedianTime - UnixNano timestamp. Weighted median of highest observed events (their ClaimedTime) from each validator. Events from the cheater validators aren’t counted. It's protection against "too-far-in-future" and "too-far-in-past".
- event.TxHash - Merkle tree root of event transactions.
- event.Transactions - list of originated transactions.
- event.Sig - ECDSA256 secp256k1 validator's signature in the R/S/V format (65 bytes). Verified via PubKey recovering, hashing and matching with a creator's address.