Documentation ¶
Overview ¶
Package base contains the base sql implementation
Index ¶
- Variables
- func GetAllModels() (allModels []interface{})
- type AcceptedAttestation
- type BlockEndModel
- type CommittedMessage
- func (c CommittedMessage) BaseMessage() types.BaseMessage
- func (c CommittedMessage) Body() []byte
- func (c CommittedMessage) DestinationDomain() uint32
- func (c CommittedMessage) Encode() ([]byte, error)
- func (c CommittedMessage) Flag() types.MessageFlag
- func (c CommittedMessage) Header() types.Header
- func (c CommittedMessage) Leaf() [32]byte
- func (c CommittedMessage) Message() []byte
- func (c CommittedMessage) Nonce() uint32
- func (c CommittedMessage) OptimisticSeconds() uint32
- func (c CommittedMessage) OriginDomain() uint32
- func (c CommittedMessage) ToLeaf() (leaf [32]byte, err error)
- type ProcessedEthTx
- type RawEthTX
- type SentMessage
- type Store
- func (s Store) DB() *gorm.DB
- func (s Store) GetMessageLatestBlockEnd(ctx context.Context, domainID uint32) (blockNumber uint32, err error)
- func (s Store) GetNonceForChainID(ctx context.Context, fromAddress common.Address, chainID *big.Int) (nonce uint64, err error)
- func (s Store) RetrieveLatestCommittedMessageNonce(ctx context.Context, domainID uint32) (_ uint32, err error)
- func (s Store) StoreCommittedMessage(ctx context.Context, domainID uint32, message types.CommittedMessage) error
- func (s Store) StoreMessageLatestBlockEnd(ctx context.Context, domainID uint32, blockNumber uint32) error
- func (s Store) StoreProcessedTx(ctx context.Context, tx *types.Transaction) error
- func (s Store) StoreRawTx(ctx context.Context, tx *types.Transaction, chainID *big.Int, ...) error
Constants ¶
This section is empty.
Variables ¶
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 CMFlag uint8 `gorm:"column:cm_flag"` // 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"` // 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"` // 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"` }
CommittedMessage is a committed message it allows for querying on both the committed message and the underlying fields.
func (CommittedMessage) BaseMessage ¶ added in v0.0.171
func (c CommittedMessage) BaseMessage() types.BaseMessage
BaseMessage gets the base message if it exists.
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) Flag ¶ added in v0.0.171
func (c CommittedMessage) Flag() types.MessageFlag
Flag gets the message flag.
func (CommittedMessage) Header ¶
func (c CommittedMessage) Header() types.Header
Header gets the header.
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) ToLeaf ¶
func (c CommittedMessage) ToLeaf() (leaf [32]byte, err error)
ToLeaf converts a leaf to a keccac256.
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 SentMessage ¶ added in v0.0.171
type SentMessage struct { // SMOrigin is the origin chainID of the message. SMOrigin uint32 `gorm:"column:origin"` // SMSender is the sender of the message. SMSender string `gorm:"column:sender"` // SMNonce is the nonce of the message. SMNonce uint32 `gorm:"column:nonce"` // SMDestination is the destination chainID of the message. SMDestination uint32 `gorm:"column:destination"` // SMRecipient is the recipient of the message. SMRecipient string `gorm:"column:recipient"` // SMOptimisticSeconds is the optimistic seconds of the message. SMOptimisticSeconds uint32 `gorm:"column:optimistic_seconds"` // SMNotaryTip is the notary tip of the message. SMNotaryTip []byte `gorm:"column:notary_tip"` // SMBroadcasterTip is the broadcaster tip of the message. SMBroadcasterTip []byte `gorm:"column:broadcaster_tip"` // SMProverTip is the prover tip of the message. SMProverTip []byte `gorm:"column:prover_tip"` // SMExecutorTip is the executor tip of the message. SMExecutorTip []byte `gorm:"column:executor_tip"` // SMBody is the body of the message. SMBody []byte `gorm:"column:body"` }
SentMessage is used to store information about sent messages from the Origin contract. Monitoring uses these messages' nonces to check for missing messages on destination chains.
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 (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 ¶
StoreProcessedTx stores a processed text.