cursor

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package cursor provides a persisted attestation streamer cursor store. The goal of this package is to persist and identify safe/finalized bootstrap cursors per streamer.

Problems it solves: - Relayer source of truth is submitted (and finalized) xmsg offsets on destination portals. - An attestation is only "fully relayed" when all xmsgs are submitted AND finalized. - Empty attestations are not submitted, so no proof exists that is has been processed. - While submissions are not finalized, they can technically reorg, and need to be resubmitted.

Solution: - Persist attestations (cursors) immediately once submitted, but don't mark as "confirmed". - Monitor finalized submit cursors on destination portals. - Mark any cursor lower than on-chain finalized offsets as confirmed. - Empty cursors are confirmed once previous non-empty cursor is confirmed. - On worker bootstrap, use latest confirmed cursors if higher than on-chain offset.

Index

Constants

This section is empty.

Variables

View Source
var File_relayer_app_cursor_cursors_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Cursor

type Cursor struct {
	SrcChainId           uint64            `protobuf:"varint,1,opt,name=src_chain_id,json=srcChainId,proto3" json:"src_chain_id,omitempty"`     // Chain ID as per https://chainlist.org
	DstChainId           uint64            `protobuf:"varint,2,opt,name=dst_chain_id,json=dstChainId,proto3" json:"dst_chain_id,omitempty"`     // Chain ID as per https://chainlist.org
	ConfLevel            uint32            `protobuf:"varint,3,opt,name=conf_level,json=confLevel,proto3" json:"conf_level,omitempty"`          // Confirmation level of the cross-chain block
	AttestOffset         uint64            `protobuf:"varint,4,opt,name=attest_offset,json=attestOffset,proto3" json:"attest_offset,omitempty"` // Offset of the cross-chain block
	Confirmed            bool              `protobuf:"varint,5,opt,name=confirmed,proto3" json:"confirmed,omitempty"`                           // Is the cursor confirmed
	StreamOffsetsByShard map[uint64]uint64 ``                                                                                                   // Highest XMsg StreamOffset by ShardID
	/* 215-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*Cursor) Descriptor deprecated

func (*Cursor) Descriptor() ([]byte, []int)

Deprecated: Use Cursor.ProtoReflect.Descriptor instead.

func (*Cursor) GetAttestOffset

func (x *Cursor) GetAttestOffset() uint64

func (*Cursor) GetConfLevel

func (x *Cursor) GetConfLevel() uint32

func (*Cursor) GetConfirmed

func (x *Cursor) GetConfirmed() bool

func (*Cursor) GetDstChainId

func (x *Cursor) GetDstChainId() uint64

func (*Cursor) GetSrcChainId

func (x *Cursor) GetSrcChainId() uint64

func (*Cursor) GetStreamOffsetsByShard

func (x *Cursor) GetStreamOffsetsByShard() map[uint64]uint64

func (*Cursor) ProtoMessage

func (*Cursor) ProtoMessage()

func (*Cursor) ProtoReflect

func (x *Cursor) ProtoReflect() protoreflect.Message

func (*Cursor) Reset

func (x *Cursor) Reset()

func (*Cursor) String

func (x *Cursor) String() string

type CursorIndexKey

type CursorIndexKey interface {
	// contains filtered or unexported methods
}

type CursorIterator

type CursorIterator struct {
	ormtable.Iterator
}

func (CursorIterator) Value

func (i CursorIterator) Value() (*Cursor, error)

type CursorPrimaryKey

primary key starting index..

type CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey

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

func (CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey) WithSrcChainId

func (CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey) WithSrcChainIdConfLevel

func (CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey) WithSrcChainIdConfLevelDstChainId

func (this CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey) WithSrcChainIdConfLevelDstChainId(src_chain_id uint64, conf_level uint32, dst_chain_id uint64) CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey

func (CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey) WithSrcChainIdConfLevelDstChainIdAttestOffset

func (this CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey) WithSrcChainIdConfLevelDstChainIdAttestOffset(src_chain_id uint64, conf_level uint32, dst_chain_id uint64, attest_offset uint64) CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey

type CursorTable

type CursorTable interface {
	Insert(ctx context.Context, cursor *Cursor) error
	Update(ctx context.Context, cursor *Cursor) error
	Save(ctx context.Context, cursor *Cursor) error
	Delete(ctx context.Context, cursor *Cursor) error
	Has(ctx context.Context, src_chain_id uint64, conf_level uint32, dst_chain_id uint64, attest_offset uint64) (found bool, err error)
	// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
	Get(ctx context.Context, src_chain_id uint64, conf_level uint32, dst_chain_id uint64, attest_offset uint64) (*Cursor, error)
	List(ctx context.Context, prefixKey CursorIndexKey, opts ...ormlist.Option) (CursorIterator, error)
	ListRange(ctx context.Context, from, to CursorIndexKey, opts ...ormlist.Option) (CursorIterator, error)
	DeleteBy(ctx context.Context, prefixKey CursorIndexKey) error
	DeleteRange(ctx context.Context, from, to CursorIndexKey) error
	// contains filtered or unexported methods
}

func NewCursorTable

func NewCursorTable(db ormtable.Schema) (CursorTable, error)

type CursorsStore

type CursorsStore interface {
	CursorTable() CursorTable
	// contains filtered or unexported methods
}

func NewCursorsStore

func NewCursorsStore(db ormtable.Schema) (CursorsStore, error)

type Store

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

Store provides a persisted attestation streamer cursor store.

func New

func New(
	db db.DB,
	submitCursorFunc submitCursorFunc,
	network netconf.Network,
) (*Store, error)

New returns a new cursor store.

func (*Store) Insert added in v0.12.0

func (s *Store) Insert(
	ctx context.Context,
	srcVersion xchain.ChainVersion,
	destChain uint64,
	attestOffset uint64,
	submittedMsgs map[xchain.StreamID][]xchain.Msg,
) error

Insert cursor for the provided streamer if it doesn't exist, otherwise ignore (keep existing).

func (*Store) StartLoops

func (s *Store) StartLoops(ctx context.Context)

StartLoops starts goroutines to periodically confirm and trim streams. It returns immediately.

func (*Store) WorkerOffsets

func (s *Store) WorkerOffsets(
	ctx context.Context,
	destChain uint64,
) (map[xchain.ChainVersion]uint64, error)

WorkerOffsets returns confirmed offsets for the provided destination chain.

Jump to

Keyboard shortcuts

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