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 ¶
- Variables
- type Cursor
- func (*Cursor) Descriptor() ([]byte, []int)deprecated
- func (x *Cursor) GetAttestOffset() uint64
- func (x *Cursor) GetConfLevel() uint32
- func (x *Cursor) GetConfirmed() bool
- func (x *Cursor) GetDstChainId() uint64
- func (x *Cursor) GetSrcChainId() uint64
- func (x *Cursor) GetStreamOffsetsByShard() map[uint64]uint64
- func (*Cursor) ProtoMessage()
- func (x *Cursor) ProtoReflect() protoreflect.Message
- func (x *Cursor) Reset()
- func (x *Cursor) String() string
- type CursorIndexKey
- type CursorIterator
- type CursorPrimaryKey
- type CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey
- func (this CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey) WithSrcChainId(src_chain_id uint64) CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey
- func (this CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey) WithSrcChainIdConfLevel(src_chain_id uint64, conf_level uint32) CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey
- func (this CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey) WithSrcChainIdConfLevelDstChainId(src_chain_id uint64, conf_level uint32, dst_chain_id uint64) CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey
- func (this CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey) WithSrcChainIdConfLevelDstChainIdAttestOffset(src_chain_id uint64, conf_level uint32, dst_chain_id uint64, ...) CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey
- type CursorTable
- type CursorsStore
- type Store
Constants ¶
This section is empty.
Variables ¶
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) GetAttestOffset ¶
func (*Cursor) GetConfLevel ¶
func (*Cursor) GetConfirmed ¶
func (*Cursor) GetDstChainId ¶
func (*Cursor) GetSrcChainId ¶
func (*Cursor) GetStreamOffsetsByShard ¶
func (*Cursor) ProtoMessage ¶
func (*Cursor) ProtoMessage()
func (*Cursor) ProtoReflect ¶
func (x *Cursor) ProtoReflect() protoreflect.Message
type CursorIndexKey ¶
type CursorIndexKey interface {
// contains filtered or unexported methods
}
type CursorIterator ¶
func (CursorIterator) Value ¶
func (i CursorIterator) Value() (*Cursor, error)
type CursorPrimaryKey ¶
type CursorPrimaryKey = CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey
primary key starting index..
type CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey ¶
type CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey struct {
// contains filtered or unexported fields
}
func (CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey) WithSrcChainId ¶
func (this CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey) WithSrcChainId(src_chain_id uint64) CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey
func (CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey) WithSrcChainIdConfLevel ¶
func (this CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey) WithSrcChainIdConfLevel(src_chain_id uint64, conf_level uint32) CursorSrcChainIdConfLevelDstChainIdAttestOffsetIndexKey
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 (*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 ¶
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.