base

package
v0.0.135 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package base contains the base sql implementation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NonceFieldName is the field name of the nonce.
	NonceFieldName string
	// DomainIDFieldName gets the chain id field name.
	DomainIDFieldName string
	// BlockNumberFieldName is the name of the block number field.
	BlockNumberFieldName string
	// LeafIndexFieldName is the field name of the leaf index.
	LeafIndexFieldName string
)

Functions

func GetAllModels

func GetAllModels() (allModels []interface{})

GetAllModels gets all models to migrate see: https://medium.com/@SaifAbid/slice-interfaces-8c78f8b6345d for an explanation of why we can't do this at initialization time

Types

type AcceptedAttestation

type AcceptedAttestation struct {
	// AAOrigin is the chainID of the Origin contract.
	AAOrigin uint32 `gorm:"column:origin"`
	// AADestination is the chainID of the Destination contract.
	AADestination uint32 `gorm:"column:destination"`
	// AANonce is the nonce of the attestation.
	AANonce uint32 `gorm:"column:nonce"`
	// AARoot is the root of the attestation.
	AARoot string `gorm:"column:root"`
}

AcceptedAttestation is used to track every received accepted attestation over all mirrors. Monitoring uses these accepted attestations' nonces to check for missing messages on destination chains.

type BlockEndModel

type BlockEndModel struct {
	// CreatedAt is the creation time
	CreatedAt time.Time
	// UpdatedAt is the update time
	UpdatedAt time.Time
	// DeletedAt time
	DeletedAt gorm.DeletedAt `gorm:"index"`
	// DomainID is the chain id of the chain we're watching blocks on. This is our primary index.
	DomainID uint32 `gorm:"column:domain_id;primaryKey;autoIncrement:false"`
	// BlockHeight is the highest height we've seen on the chain
	BlockNumber uint32 `gorm:"block_number"`
}

BlockEndModel is used to make sure we haven't missed any events while offline. since we event source - rather than use a state machine this is needed to make sure we haven't missed any events by allowing us to go back and source any events we may have missed.

this does not inherit from gorm.model to allow us to use ChainID as a primary key.

type CommittedMessage

type CommittedMessage struct {
	gorm.Model
	CMVersion uint16 `gorm:"column:cm_version"`
	// CMDomainID is the id of the domain we're renaming
	CMDomainID uint32 `gorm:"column:domain_id;uniqueIndex:cm_idx_id"`
	// CMMessage is the fully detailed message that was created
	CMMessage []byte `gorm:"column:message"`
	// CMLeaf is the leaf
	CMLeaf []byte `gorm:"column:leaf"`
	// CMOrigin returns the slip-44 of the message
	CMOrigin uint32 `gorm:"column:origin"`
	// CMSender is the sender of the message
	CMSender []byte `gorm:"column:sender"`
	// CMNonce is the nonce of the message
	CMNonce uint32 `gorm:"column:nonce;uniqueIndex:cm_idx_id"`
	// CMDestination is the sip-44 destination of the message
	CMDestination uint32 `gorm:"column:destination"`
	// CMRecipient is the recipient of the message
	CMRecipient []byte `gorm:"column:recipient"`
	// CMBody is the body of the message
	CMBody []byte `gorm:"column:body"`
	// CMOptimisticSeconds is the optimistic seconds of the message
	CMOptimisticSeconds uint32 `gorm:"column:optimistic_seconds"`
	// CMNotaryTip is the notarytip
	CMNotaryTip []byte `gorm:"column:notary_tip"`
	// CMBroadcasterTip is the relayer tip
	CMBroadcasterTip []byte `gorm:"column:broadcaster_tip"`
	// CMProverTip is the prover tip
	CMProverTip []byte `gorm:"column:prover_tip"`
	// CMExecutorTip is the processor tip
	CMExecutorTip []byte `gorm:"column:executor_tip"`
}

CommittedMessage is a committed message it allows for querying on both the committed message and the underlying fields.

func (CommittedMessage) Body

func (c CommittedMessage) Body() []byte

Body is the message contents.

func (CommittedMessage) DestinationDomain

func (c CommittedMessage) DestinationDomain() uint32

DestinationDomain is the slip-44 id of the destination.

func (CommittedMessage) Encode

func (c CommittedMessage) Encode() ([]byte, error)

Encode encodes the message Deprecated: will be removed.

func (CommittedMessage) Header

func (c CommittedMessage) Header() types.Header

Header gets the header.

func (CommittedMessage) Leaf

func (c CommittedMessage) Leaf() [32]byte

Leaf gets the leaf.

func (CommittedMessage) Message

func (c CommittedMessage) Message() []byte

Message gets the message.

func (CommittedMessage) Nonce

func (c CommittedMessage) Nonce() uint32

Nonce is the count of all previous messages to the destination.

func (CommittedMessage) OptimisticSeconds

func (c CommittedMessage) OptimisticSeconds() uint32

OptimisticSeconds gets the optimistic seconds count.

func (CommittedMessage) OriginDomain

func (c CommittedMessage) OriginDomain() uint32

OriginDomain returns the Slip-44 ID.

func (CommittedMessage) Recipient

func (c CommittedMessage) Recipient() common.Hash

Recipient is the address of the recipient.

func (CommittedMessage) Sender

func (c CommittedMessage) Sender() common.Hash

Sender is the address of the sender.

func (CommittedMessage) Tips

func (c CommittedMessage) Tips() types.Tips

Tips gets the tips.

func (CommittedMessage) ToLeaf

func (c CommittedMessage) ToLeaf() (leaf [32]byte, err error)

ToLeaf converts a leaf to a keccac256.

func (CommittedMessage) Version

func (c CommittedMessage) Version() uint16

Version gets the message version.

type DispatchMessage

type DispatchMessage struct {
	// DMOrigin is the origin chainID of the message.
	DMOrigin uint32 `gorm:"column:origin"`
	// DMSender is the sender of the message.
	DMSender string `gorm:"column:sender"`
	// DMNonce is the nonce of the message.
	DMNonce uint32 `gorm:"column:nonce"`
	// DMDestination is the destination chainID of the message.
	DMDestination uint32 `gorm:"column:destination"`
	// DMRecipient is the recipient of the message.
	DMRecipient string `gorm:"column:recipient"`
	// DMOptimisticSeconds is the optimistic seconds of the message.
	DMOptimisticSeconds uint32 `gorm:"column:optimistic_seconds"`
	// DMNotaryTip is the notary tip of the message.
	DMNotaryTip []byte `gorm:"column:notary_tip"`
	// DMBroadcasterTip is the broadcaster tip of the message.
	DMBroadcasterTip []byte `gorm:"column:broadcaster_tip"`
	// DMProverTip is the prover tip of the message.
	DMProverTip []byte `gorm:"column:prover_tip"`
	// DMExecutorTip is the executor tip of the message.
	DMExecutorTip []byte `gorm:"column:executor_tip"`
	// DMBody is the body of the message.
	DMBody []byte `gorm:"column:body"`
}

DispatchMessage is used to store information about dispatched messages from the Origin contract. Monitoring uses these messages' nonces to check for missing messages on destination chains.

type ProcessedEthTx

type ProcessedEthTx struct {
	TxHash string `gorm:"txhash;uniqueIndex:idx_txhash;size:66"`
	// RawTx is the raw serialized transaction
	RawTx []byte `gorm:"column:raw_tx"`
	// RawEthTx is the txid that caused the event
	RawEthTx uint
	// OriginatingEvent is the event that originated the tx
	EthTx RawEthTX `gorm:"foreignkey:RawEthTx"`
	// GasFeeCap contains the gas fee cap stored in wei
	GasFeeCap uint64
	// GasTipCap contains the gas tip cap stored in wei
	GasTipCap uint64
}

ProcessedEthTx contains a processed ethereum transaction.

type RawEthTX

type RawEthTX struct {
	gorm.Model
	// From is the sender of the transaction
	From string `gorm:"from"`
	// To is the contract address the transaction was sent to.
	To string `gorm:"index"`
	// ChainID is the chain id the transaction hash will be sent on
	ChainID uint64 `gorm:"column:chain_id;uniqueIndex:idx_id"`
	// Nonce is the nonce of the raw evm tx
	Nonce uint64 `gorm:"column:nonce;uniqueIndex:idx_id"`
	// RawTx is the raw serialized transaction
	RawTx []byte `gorm:"column:raw_tx"`
}

RawEthTX contains a raw evm transaction that is unsigned note: idx_id contains a composite index of (chain_id,nonce)

type Store

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

Store is the sqlite store. It extends the base store for sqlite specific queries.

func NewStore

func NewStore(db *gorm.DB) *Store

NewStore creates a new tore.

func (Store) DB

func (s Store) DB() *gorm.DB

DB gets the database.

func (Store) GetMessageLatestBlockEnd

func (s Store) GetMessageLatestBlockEnd(ctx context.Context, domainID uint32) (blockNumber uint32, err error)

GetMessageLatestBlockEnd gets the latest block end for a given domain.

func (Store) GetNonceForChainID

func (s Store) GetNonceForChainID(ctx context.Context, fromAddress common.Address, chainID *big.Int) (nonce uint64, err error)

GetNonceForChainID gets a nonce for a chainid.

func (Store) RetrieveLatestCommittedMessageNonce

func (s Store) RetrieveLatestCommittedMessageNonce(ctx context.Context, domainID uint32) (_ uint32, err error)

RetrieveLatestCommittedMessageNonce gets the latest commitedd message by nonce.

func (Store) StoreCommittedMessage

func (s Store) StoreCommittedMessage(ctx context.Context, domainID uint32, message types.CommittedMessage) error

StoreCommittedMessage stores a raw committed message building off the leaf index this method is idempotent.

func (Store) StoreMessageLatestBlockEnd

func (s Store) StoreMessageLatestBlockEnd(ctx context.Context, domainID uint32, blockNumber uint32) error

StoreMessageLatestBlockEnd stores the latest message block height we've observed.

func (Store) StoreProcessedTx

func (s Store) StoreProcessedTx(ctx context.Context, tx *types.Transaction) error

StoreProcessedTx stores a processed text.

func (Store) StoreRawTx

func (s Store) StoreRawTx(ctx context.Context, tx *types.Transaction, chainID *big.Int, from common.Address) error

StoreRawTx stores a raw transaction.

Jump to

Keyboard shortcuts

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