Documentation ¶
Overview ¶
Package base contains the base sql implementation
Index ¶
- Variables
- func AttestationToDBAttestation(attestation Attestation) types.DBAttestation
- func GetAllModels() (allModels []interface{})
- func MessageToDBMessage(message Message) types.DBMessage
- func StateToDBState(state State) types.DBState
- type Attestation
- type Message
- type State
- type Store
- func (s Store) DB() *gorm.DB
- func (s Store) ExecuteMessage(ctx context.Context, messageMask types.DBMessage) error
- func (s Store) GetAttestation(ctx context.Context, attestationMask types.DBAttestation) (*agentsTypes.Attestation, error)
- func (s Store) GetAttestationBlockNumber(ctx context.Context, attestationMask types.DBAttestation) (*uint64, error)
- func (s Store) GetAttestationMinimumTimestamp(ctx context.Context, attestationMask types.DBAttestation, ...) (*uint64, error)
- func (s Store) GetAttestationTimestamp(ctx context.Context, attestationMask types.DBAttestation) (*uint64, error)
- func (s Store) GetBlockNumber(ctx context.Context, messageMask types.DBMessage) (uint64, error)
- func (s Store) GetEarliestSnapshotFromAttestation(ctx context.Context, attestationMask types.DBAttestation, ...) (*[32]byte, error)
- func (s Store) GetExecutableMessages(ctx context.Context, messageMask types.DBMessage, currentTime uint64, page int) ([]agentsTypes.Message, error)
- func (s Store) GetLastBlockNumber(ctx context.Context, chainID uint32) (uint64, error)
- func (s Store) GetMessage(ctx context.Context, messageMask types.DBMessage) (*agentsTypes.Message, error)
- func (s Store) GetMessageMinimumTime(ctx context.Context, messageMask types.DBMessage) (*uint64, error)
- func (s Store) GetMessages(ctx context.Context, messageMask types.DBMessage, page int) ([]agentsTypes.Message, error)
- func (s Store) GetPotentialSnapshotRoots(ctx context.Context, chainID uint32, nonce uint32) ([]string, error)
- func (s Store) GetSnapshotRootsInNonceRange(ctx context.Context, chainID uint32, startNonce uint32, endNonce uint32) ([]string, error)
- func (s Store) GetState(ctx context.Context, stateMask types.DBState) (*agentsTypes.State, error)
- func (s Store) GetStateMetadata(ctx context.Context, stateMask types.DBState) (snapshotRoot *[32]byte, proof *json.RawMessage, treeHeight *uint32, ...)
- func (s Store) GetUnsetMinimumTimeMessages(ctx context.Context, messageMask types.DBMessage, page int) ([]agentsTypes.Message, error)
- func (s Store) SetMinimumTime(ctx context.Context, messageMask types.DBMessage, minimumTime uint64) error
- func (s Store) StoreAttestation(ctx context.Context, attestation agentsTypes.Attestation, destination uint32, ...) error
- func (s Store) StoreMessage(ctx context.Context, message agentsTypes.Message, blockNumber uint64, ...) error
- func (s Store) StoreState(ctx context.Context, state agentsTypes.State, snapshotRoot [32]byte, ...) error
- func (s Store) StoreStates(ctx context.Context, states []agentsTypes.State, snapshotRoot [32]byte, ...) error
Constants ¶
This section is empty.
Variables ¶
var ( // ChainIDFieldName gets the chain id field name. ChainIDFieldName string // DestinationFieldName is the field name of the destination. DestinationFieldName string // NonceFieldName is the field name of the tx hash. NonceFieldName string // AttestationNonceFieldName is the field name of the attestation nonce. AttestationNonceFieldName string // RootFieldName is the name of the block number field. RootFieldName string // BlockNumberFieldName is the name of the block number field. BlockNumberFieldName string // DestinationBlockNumberFieldName is the index field name. DestinationBlockNumberFieldName string // ExecutedFieldName is the executed field name. ExecutedFieldName string // MinimumTimeSetFieldName is the minimum time set field name. MinimumTimeSetFieldName string // MinimumTimeFieldName is the minimum time field name. MinimumTimeFieldName string // SnapshotRootFieldName is the snapshot root field name. SnapshotRootFieldName string )
var PageSize = 50_000
PageSize is the amount of entries per page of logs.
Functions ¶
func AttestationToDBAttestation ¶ added in v0.0.63
func AttestationToDBAttestation(attestation Attestation) types.DBAttestation
AttestationToDBAttestation converts an Attestation to a DBAttestation.
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
func MessageToDBMessage ¶
MessageToDBMessage converts a Message to a DBMessage.
func StateToDBState ¶ added in v0.0.130
StateToDBState converts a State to a DBState.
Types ¶
type Attestation ¶ added in v0.0.63
type Attestation struct { // Destination is the destination of the attestation. Destination uint32 `gorm:"column:destination;primaryKey"` // SnapshotRoot is the snapshot root. SnapshotRoot string `gorm:"column:snapshot_root;primaryKey"` // Height is the height of the snapshot Merkle tree. Height uint8 `gorm:"column:height"` // AttestationNonce is the nonce of the attestation. AttestationNonce uint32 `gorm:"column:attestation_nonce;primaryKey"` // SummitBlockNumber is the block number when the attestation was created in Summit. SummitBlockNumber uint64 `gorm:"column:summit_block_number"` // SummitTimestamp is the timestamp of the block when the attestation was created in Summit. SummitTimestamp uint64 `gorm:"column:summit_timestamp"` // DestinationBlockNumber is the block number that the attestation was submitted on the destination. DestinationBlockNumber uint64 `gorm:"column:destination_block_number"` // DestinationTimestamp is the timestamp of the block that the attestation was submitted on the destination. DestinationTimestamp uint64 `gorm:"column:destination_timestamp"` }
Attestation is the information about an attestation parsed by the Executor.
func DBAttestationToAttestation ¶ added in v0.0.63
func DBAttestationToAttestation(dbAttestation types.DBAttestation) Attestation
DBAttestationToAttestation converts a DBAttestation to an Attestation.
type Message ¶
type Message struct { // ChainID is the chain id. ChainID uint32 `gorm:"column:chain_id;primaryKey"` // Destination is the destination. Destination uint32 `gorm:"column:destination;primaryKey"` // Nonce is the nonce. Nonce uint32 `gorm:"column:nonce;primaryKey"` // Message is the message. Message []byte `gorm:"column:message"` // BlockNumber is the block number. BlockNumber uint64 `gorm:"column:block_number"` // Executed is if the message has been executed. Executed bool `gorm:"column:executed"` // MinimumTimeSet is if the MinimumTime field has been set from an Attestation. MinimumTimeSet bool `gorm:"column:minimum_time_set"` // MinimumTime is the minimum time that the message can be executed. MinimumTime uint64 `gorm:"column:minimum_time"` }
Message is the information about a message parsed by the Executor.
func AgentsTypesMessageToMessage ¶
func AgentsTypesMessageToMessage(message agentsTypes.Message, blockNumber uint64, minimumTimeSet bool, minimumTime uint64) (Message, error)
AgentsTypesMessageToMessage converts an agentsTypes.Message to a Message.
func DBMessageToMessage ¶
DBMessageToMessage converts a DBMessage to a Message.
type State ¶ added in v0.0.130
type State struct { // SnapshotRoot is the snapshot root. SnapshotRoot string `gorm:"column:snapshot_root;primaryKey"` // Root is the origin Merkle tree's root. Root string `gorm:"column:root;primaryKey"` // ChainID is the origin chain id. ChainID uint32 `gorm:"column:chain_id;primaryKey"` // Nonce is the origin Merkle tree's nonce. Nonce uint32 `gorm:"column:nonce;primaryKey"` // OriginBlockNumber is the block number that the state was taken from on the origin. OriginBlockNumber uint64 `gorm:"column:origin_block_number"` // OriginTimestamp is the timestamp of the block that the state was taken from on the origin. OriginTimestamp uint64 `gorm:"column:origin_timestamp"` // Proof is the Snapshot Merkle Tree proof for the state. Proof json.RawMessage `gorm:"column:proof"` // TreeHeight is the height of the Snapshot Merkle Tree that the state belongs to. TreeHeight uint32 `gorm:"column:tree_height"` // StateIndex is the index of the state in the Snapshot. StateIndex uint32 `gorm:"column:state_index"` }
State is the information about a state, received from the `Summit` and parsed by the Executor.
func AgentsTypesStateToState ¶ added in v0.0.130
func AgentsTypesStateToState(state agentsTypes.State, snapshotRoot [32]byte, proof [][]byte, treeHeight, stateIndex uint32) (State, error)
AgentsTypesStateToState converts an agentsTypes.State to a State.
func DBStateToState ¶ added in v0.0.130
DBStateToState converts a DBState to a State.
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) ExecuteMessage ¶ added in v0.0.86
ExecuteMessage marks a message as executed in the database. TODO: Make batch update.
func (Store) GetAttestation ¶ added in v0.0.63
func (s Store) GetAttestation(ctx context.Context, attestationMask types.DBAttestation) (*agentsTypes.Attestation, error)
GetAttestation gets an attestation that has fields matching the attestation mask.
func (Store) GetAttestationBlockNumber ¶ added in v0.0.63
func (s Store) GetAttestationBlockNumber(ctx context.Context, attestationMask types.DBAttestation) (*uint64, error)
GetAttestationBlockNumber gets the block number of an attestation.
func (Store) GetAttestationMinimumTimestamp ¶ added in v0.0.130
func (s Store) GetAttestationMinimumTimestamp(ctx context.Context, attestationMask types.DBAttestation, snapshotRoots []string) (*uint64, error)
GetAttestationMinimumTimestamp takes a list of snapshot roots and returns the timestamp of the attestation with the lowest block number.
func (Store) GetAttestationTimestamp ¶ added in v0.0.130
func (s Store) GetAttestationTimestamp(ctx context.Context, attestationMask types.DBAttestation) (*uint64, error)
GetAttestationTimestamp gets the timestamp of an attestation.
func (Store) GetBlockNumber ¶ added in v0.0.63
GetBlockNumber gets the block number of a message from the database.
func (Store) GetEarliestSnapshotFromAttestation ¶ added in v0.0.130
func (s Store) GetEarliestSnapshotFromAttestation(ctx context.Context, attestationMask types.DBAttestation, snapshotRoots []string) (*[32]byte, error)
GetEarliestSnapshotFromAttestation takes a list of snapshot roots, checks which one has the lowest block number, and returns that snapshot root back.
func (Store) GetExecutableMessages ¶ added in v0.0.86
func (s Store) GetExecutableMessages(ctx context.Context, messageMask types.DBMessage, currentTime uint64, page int) ([]agentsTypes.Message, error)
GetExecutableMessages gets executable messages from the database.
func (Store) GetLastBlockNumber ¶
GetLastBlockNumber gets the last block number that had a message in the database.
func (Store) GetMessage ¶
func (s Store) GetMessage(ctx context.Context, messageMask types.DBMessage) (*agentsTypes.Message, error)
GetMessage gets a message from the database.
func (Store) GetMessageMinimumTime ¶ added in v0.0.86
func (s Store) GetMessageMinimumTime(ctx context.Context, messageMask types.DBMessage) (*uint64, error)
GetMessageMinimumTime gets the minimum time for a message to be executed.
func (Store) GetMessages ¶
func (s Store) GetMessages(ctx context.Context, messageMask types.DBMessage, page int) ([]agentsTypes.Message, error)
GetMessages gets messages from the database, paginated and ordered in ascending order by nonce.
func (Store) GetPotentialSnapshotRoots ¶ added in v0.0.130
func (s Store) GetPotentialSnapshotRoots(ctx context.Context, chainID uint32, nonce uint32) ([]string, error)
GetPotentialSnapshotRoots gets all snapshot roots that are greater than or equal to a specified nonce and matches a specified chain ID.
func (Store) GetSnapshotRootsInNonceRange ¶ added in v0.0.130
func (s Store) GetSnapshotRootsInNonceRange(ctx context.Context, chainID uint32, startNonce uint32, endNonce uint32) ([]string, error)
GetSnapshotRootsInNonceRange gets all snapshot roots for all states in a specified nonce range.
func (Store) GetStateMetadata ¶ added in v0.0.130
func (s Store) GetStateMetadata(ctx context.Context, stateMask types.DBState) (snapshotRoot *[32]byte, proof *json.RawMessage, treeHeight *uint32, stateIndex *uint32, err error)
GetStateMetadata gets the snapshot root, proof, and tree height of a state from the database.
func (Store) GetUnsetMinimumTimeMessages ¶ added in v0.0.86
func (s Store) GetUnsetMinimumTimeMessages(ctx context.Context, messageMask types.DBMessage, page int) ([]agentsTypes.Message, error)
GetUnsetMinimumTimeMessages gets messages from the database that have not had their minimum time set.
func (Store) SetMinimumTime ¶ added in v0.0.86
func (s Store) SetMinimumTime(ctx context.Context, messageMask types.DBMessage, minimumTime uint64) error
SetMinimumTime sets the minimum time of a message.
func (Store) StoreAttestation ¶ added in v0.0.63
func (s Store) StoreAttestation(ctx context.Context, attestation agentsTypes.Attestation, destination uint32, destinationBlockNumber, destinationTimestamp uint64) error
StoreAttestation stores an attestation.
func (Store) StoreMessage ¶
func (s Store) StoreMessage(ctx context.Context, message agentsTypes.Message, blockNumber uint64, minimumTimeSet bool, minimumTime uint64) error
StoreMessage stores a message in the database.