slotattestation

package
v1.0.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

Types

type Manager

type Manager struct {
	module.Module
	// contains filtered or unexported fields
}

Manager is the manager of slot attestations. It works in two phases:

  1. It stores "future" attestations temporarily until the corresponding slot becomes committable.

  2. 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 NewManager(
	subModule module.Module,
	lastCommittedSlot iotago.SlotIndex,
	lastCumulativeWeight uint64,
	bucketedStorage func(slot iotago.SlotIndex) (kvstore.KVStore, error),
	committeeFunc func(slot iotago.SlotIndex) (*account.SeatedAccounts, bool),
	apiProvider iotago.APIProvider,
) *Manager

func (*Manager) AddAttestationFromValidationBlock

func (m *Manager) AddAttestationFromValidationBlock(block *blocks.Block) error

AddAttestationFromValidationBlock adds an attestation from a block to the future attestations (beyond the attestation window).

func (*Manager) Commit

func (m *Manager) Commit(slot iotago.SlotIndex) (newCW uint64, attestationsRoot iotago.Identifier, err error)

func (*Manager) Export

func (m *Manager) Export(writer io.WriteSeeker, targetSlot iotago.SlotIndex) error

func (*Manager) Get

func (m *Manager) Get(slot iotago.SlotIndex) (attestations []*iotago.Attestation, err error)

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

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) Import

func (m *Manager) Import(reader io.ReadSeeker) error

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 (m *Manager) RestoreFromDisk() error

func (*Manager) Rollback

func (m *Manager) Rollback(targetSlot iotago.SlotIndex) error

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.

Jump to

Keyboard shortcuts

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