Documentation
¶
Index ¶
- func NewProvider() module.Provider[*engine.Engine, attestation.Attestations]
- type Manager
- func (m *Manager) AddAttestationFromValidationBlock(block *blocks.Block) error
- func (m *Manager) Commit(slot iotago.SlotIndex) (newCW uint64, attestationsRoot iotago.Identifier, err error)
- func (m *Manager) Export(writer io.WriteSeeker, targetSlot iotago.SlotIndex) error
- func (m *Manager) Get(slot iotago.SlotIndex) (attestations []*iotago.Attestation, err error)
- func (m *Manager) GetMap(slot iotago.SlotIndex) (ads.Map[iotago.Identifier, iotago.AccountID, *iotago.Attestation], error)
- func (m *Manager) Import(reader io.ReadSeeker) error
- func (m *Manager) Reset()
- func (m *Manager) RestoreFromDisk() error
- func (m *Manager) Rollback(targetSlot iotago.SlotIndex) error
- func (m *Manager) Shutdown()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewProvider ¶
func NewProvider() module.Provider[*engine.Engine, attestation.Attestations]
Types ¶
type Manager ¶
Manager is the manager of slot attestations. It works in two phases:
It stores "future" attestations temporarily until the corresponding slot becomes committable.
When a slot is being committed: a. Apply the future attestations of the committed slot to the pending attestations window which is of size MaxCommittableAge. b. Determine attestations from window for current slot = committed slot - attestationCommitmentOffset and store in bucketed storage as committed attestations. c. Compute the new cumulative weight based on the newly committed attestations and the previous weight.
Example with attestationCommitmentOffset = 2 and lastCommittedSlot = 12:
| 9 | 10 | 11 | 12 | 13 | 14 | 15 | | | | | | | | | | | |<-----------|----------->|<-----------|------------|------------> | | | Pending Attestations | Future Attestations | | | | | | | | | | |<-----------|------------|------------|----------->| | | | | Committed Attestations | | | | Explanation: - Slots before 12 are committed according to their window. - When committing slot 13, the future attestations from 13 are applied to the pending attestations window and the attestations to be committed determined. - Attestations to be committed at 13 are those at the lower bound of the window, i.e. slot 11 - The lower bound of the window is advanced to slot 12. - The last committed slot is advanced to 13. - future attestations: everything above lastCommittedSlot - pending attestations: sliding window of size attestationCommitmentOffset, add to pending attestations (ratified accepted) blocks of slot that we are committing - obtain and evict from it attestations that *commit to* lastCommittedSlot-attestationCommitmentOffset - committed attestations: retrieved at slot that we are committing, stored at slot lastCommittedSlot-attestationCommitmentOffset
func NewManager ¶
func (*Manager) AddAttestationFromValidationBlock ¶
AddAttestationFromValidationBlock adds an attestation from a block to the future attestations (beyond the attestation window).
func (*Manager) Get ¶
Get returns the attestations that are included in the commitment of the given slot as list. If attestationCommitmentOffset=3 and commitment is 10, then the returned attestations are blocks from 7 to 10 that commit to at least 7.
func (*Manager) GetMap ¶
func (m *Manager) GetMap(slot iotago.SlotIndex) (ads.Map[iotago.Identifier, iotago.AccountID, *iotago.Attestation], error)
GetMap returns the attestations that are included in the commitment of the given slot as ds.AuthenticatedMap. If attestationCommitmentOffset=3 and commitment is 10, then the returned attestations are blocks from 7 to 10 that commit to at least 7.
func (*Manager) Reset ¶
func (m *Manager) Reset()
Reset resets the component to a clean state as if it was created at the last commitment.
func (*Manager) RestoreFromDisk ¶
func (*Manager) Rollback ¶
Rollback rolls back the component state as if the last committed slot was targetSlot. It populates pendingAttestation store with previously committed attestations in order to create correct commitment in the future. As it modifies in-memory storage, it should only be called on the target engine as calling it on a temporary component will have no effect.