database

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package database exposes the postgres database

Index

Constants

This section is empty.

Variables

View Source
var (
	TableValidatorRegistration  = tableBase + "_validator_registration"
	TableExecutionPayload       = tableBase + "_execution_payload"
	TableBuilderBlockSubmission = tableBase + "_builder_block_submission"
	TableDeliveredPayload       = tableBase + "_payload_delivered"
	TableBlockBuilder           = tableBase + "_blockbuilder"
)

Functions

func NewNullInt64

func NewNullInt64(i int64) sql.NullInt64

func NewNullString

func NewNullString(s string) sql.NullString

Types

type BlockBuilderEntry added in v0.7.0

type BlockBuilderEntry struct {
	ID         int64     `db:"id"          json:"id"`
	InsertedAt time.Time `db:"inserted_at" json:"inserted_at"`

	BuilderPubkey string `db:"builder_pubkey" json:"builder_pubkey"`
	Description   string `db:"description"    json:"description"`

	IsHighPrio    bool `db:"is_high_prio"   json:"is_high_prio"`
	IsBlacklisted bool `db:"is_blacklisted" json:"is_blacklisted"`

	LastSubmissionID   sql.NullInt64 `db:"last_submission_id"   json:"last_submission_id"`
	LastSubmissionSlot uint64        `db:"last_submission_slot" json:"last_submission_slot"`

	NumSubmissionsTotal    uint64 `db:"num_submissions_total"    json:"num_submissions_total"`
	NumSubmissionsSimError uint64 `db:"num_submissions_simerror" json:"num_submissions_simerror"`
	NumSubmissionsTopBid   uint64 `db:"num_submissions_topbid"   json:"num_submissions_topbid"`

	NumSentGetHeader  uint64 `db:"num_sent_getheader"  json:"num_sent_getheader"`
	NumSentGetPayload uint64 `db:"num_sent_getpayload" json:"num_sent_getpayload"`
}

type BuilderBlockSubmissionEntry

type BuilderBlockSubmissionEntry struct {
	ID         int64     `db:"id"`
	InsertedAt time.Time `db:"inserted_at"`

	// Delivered ExecutionPayload
	ExecutionPayloadID sql.NullInt64 `db:"execution_payload_id"`

	// Sim Result
	SimSuccess bool   `db:"sim_success"`
	SimError   string `db:"sim_error"`

	// BidTrace data
	Signature string `db:"signature"`

	Slot       uint64 `db:"slot"`
	ParentHash string `db:"parent_hash"`
	BlockHash  string `db:"block_hash"`

	BuilderPubkey        string `db:"builder_pubkey"`
	ProposerPubkey       string `db:"proposer_pubkey"`
	ProposerFeeRecipient string `db:"proposer_fee_recipient"`

	GasUsed  uint64 `db:"gas_used"`
	GasLimit uint64 `db:"gas_limit"`

	NumTx int    `db:"num_tx"`
	Value string `db:"value"`

	// Helpers
	Epoch             uint64 `db:"epoch"`
	BlockNumber       uint64 `db:"block_number"`
	WasMostProfitable bool   `db:"was_most_profitable"`
}

type DatabaseService

type DatabaseService struct {
	DB *sqlx.DB
}

func NewDatabaseService

func NewDatabaseService(dsn string) (*DatabaseService, error)

func (*DatabaseService) Close

func (s *DatabaseService) Close() error

func (*DatabaseService) GetBlockBuilderByPubkey added in v0.7.0

func (s *DatabaseService) GetBlockBuilderByPubkey(pubkey string) (*BlockBuilderEntry, error)

func (*DatabaseService) GetBlockBuilders added in v0.7.0

func (s *DatabaseService) GetBlockBuilders() ([]*BlockBuilderEntry, error)

func (*DatabaseService) GetBlockSubmissionEntry

func (s *DatabaseService) GetBlockSubmissionEntry(slot uint64, proposerPubkey, blockHash string) (entry *BuilderBlockSubmissionEntry, err error)

func (*DatabaseService) GetBuilderSubmissions added in v0.5.1

func (s *DatabaseService) GetBuilderSubmissions(filters GetBuilderSubmissionsFilters) ([]*BuilderBlockSubmissionEntry, error)

func (*DatabaseService) GetExecutionPayloadEntryByID

func (s *DatabaseService) GetExecutionPayloadEntryByID(executionPayloadID int64) (entry *ExecutionPayloadEntry, err error)

func (*DatabaseService) GetExecutionPayloadEntryBySlotPkHash

func (s *DatabaseService) GetExecutionPayloadEntryBySlotPkHash(slot uint64, proposerPubkey, blockHash string) (entry *ExecutionPayloadEntry, err error)

func (*DatabaseService) GetNumDeliveredPayloads

func (s *DatabaseService) GetNumDeliveredPayloads() (uint64, error)

func (*DatabaseService) GetRecentDeliveredPayloads

func (s *DatabaseService) GetRecentDeliveredPayloads(filters GetPayloadsFilters) ([]*DeliveredPayloadEntry, error)

func (*DatabaseService) IncBlockBuilderStatsAfterGetHeader added in v0.7.0

func (s *DatabaseService) IncBlockBuilderStatsAfterGetHeader(slot uint64, blockhash string) error

func (*DatabaseService) IncBlockBuilderStatsAfterGetPayload added in v0.7.0

func (s *DatabaseService) IncBlockBuilderStatsAfterGetPayload(slot uint64, blockhash string) error

func (*DatabaseService) SaveBuilderBlockSubmission

func (s *DatabaseService) SaveBuilderBlockSubmission(payload *types.BuilderSubmitBlockRequest, simError error, isMostProfitable bool) (entry *BuilderBlockSubmissionEntry, err error)

func (*DatabaseService) SaveDeliveredPayload

func (s *DatabaseService) SaveDeliveredPayload(slot uint64, proposerPubkey types.PubkeyHex, blockHash types.Hash, signedBlindedBeaconBlock *types.SignedBlindedBeaconBlock) error

func (*DatabaseService) SaveValidatorRegistration

func (s *DatabaseService) SaveValidatorRegistration(registration types.SignedValidatorRegistration) error

func (*DatabaseService) SetBlockBuilderStatus added in v0.7.0

func (s *DatabaseService) SetBlockBuilderStatus(pubkey string, isHighPrio, isBlacklisted bool) error

func (*DatabaseService) UpsertBlockBuilderEntryAfterSubmission added in v0.7.0

func (s *DatabaseService) UpsertBlockBuilderEntryAfterSubmission(lastSubmission *BuilderBlockSubmissionEntry, isError, isTopbid bool) error

type DeliveredPayloadEntry

type DeliveredPayloadEntry struct {
	ID         int64     `db:"id"`
	InsertedAt time.Time `db:"inserted_at"`

	ExecutionPayloadID       sql.NullInt64  `db:"execution_payload_id"`
	SignedBlindedBeaconBlock sql.NullString `db:"signed_blinded_beacon_block"`

	Slot  uint64 `db:"slot"`
	Epoch uint64 `db:"epoch"`

	BuilderPubkey        string `db:"builder_pubkey"`
	ProposerPubkey       string `db:"proposer_pubkey"`
	ProposerFeeRecipient string `db:"proposer_fee_recipient"`

	ParentHash  string `db:"parent_hash"`
	BlockHash   string `db:"block_hash"`
	BlockNumber uint64 `db:"block_number"`

	GasUsed  uint64 `db:"gas_used"`
	GasLimit uint64 `db:"gas_limit"`

	NumTx int    `db:"num_tx"`
	Value string `db:"value"`
}

type ExecutionPayloadEntry

type ExecutionPayloadEntry struct {
	ID         int64     `db:"id"`
	InsertedAt time.Time `db:"inserted_at"`

	Slot           uint64 `db:"slot"`
	ProposerPubkey string `db:"proposer_pubkey"`
	BlockHash      string `db:"block_hash"`

	Version string `db:"version"`
	Payload string `db:"payload"`
}

func PayloadToExecPayloadEntry

func PayloadToExecPayloadEntry(payload *types.BuilderSubmitBlockRequest) (*ExecutionPayloadEntry, error)

type GetBuilderSubmissionsFilters added in v0.5.1

type GetBuilderSubmissionsFilters struct {
	Slot        uint64
	Limit       uint64
	BlockHash   string
	BlockNumber uint64
}

type GetPayloadsFilters

type GetPayloadsFilters struct {
	Slot           uint64
	Cursor         uint64
	Limit          uint64
	BlockHash      string
	BlockNumber    uint64
	ProposerPubkey string
}

type IDatabaseService

type IDatabaseService interface {
	SaveValidatorRegistration(registration types.SignedValidatorRegistration) error
	SaveBuilderBlockSubmission(payload *types.BuilderSubmitBlockRequest, simError error, isMostProfitable bool) (entry *BuilderBlockSubmissionEntry, err error)
	SaveDeliveredPayload(slot uint64, proposerPubkey types.PubkeyHex, blockHash types.Hash, signedBlindedBeaconBlock *types.SignedBlindedBeaconBlock) error

	GetBlockSubmissionEntry(slot uint64, proposerPubkey, blockHash string) (entry *BuilderBlockSubmissionEntry, err error)
	GetExecutionPayloadEntryByID(executionPayloadID int64) (entry *ExecutionPayloadEntry, err error)
	GetExecutionPayloadEntryBySlotPkHash(slot uint64, proposerPubkey, blockHash string) (entry *ExecutionPayloadEntry, err error)

	GetRecentDeliveredPayloads(filters GetPayloadsFilters) ([]*DeliveredPayloadEntry, error)
	GetNumDeliveredPayloads() (uint64, error)
	GetBuilderSubmissions(filters GetBuilderSubmissionsFilters) ([]*BuilderBlockSubmissionEntry, error)

	GetBlockBuilders() ([]*BlockBuilderEntry, error)
	GetBlockBuilderByPubkey(pubkey string) (*BlockBuilderEntry, error)
	SetBlockBuilderStatus(pubkey string, isHighPrio, isBlacklisted bool) error
	UpsertBlockBuilderEntryAfterSubmission(lastSubmission *BuilderBlockSubmissionEntry, isError, isTopbid bool) error
	IncBlockBuilderStatsAfterGetHeader(slot uint64, blockhash string) error
	IncBlockBuilderStatsAfterGetPayload(slot uint64, blockhash string) error
}

type MockDB

type MockDB struct{}

func (MockDB) GetBlockBuilderByPubkey added in v0.7.0

func (db MockDB) GetBlockBuilderByPubkey(pubkey string) (*BlockBuilderEntry, error)

func (MockDB) GetBlockBuilders added in v0.7.0

func (db MockDB) GetBlockBuilders() ([]*BlockBuilderEntry, error)

func (MockDB) GetBlockSubmissionEntry

func (db MockDB) GetBlockSubmissionEntry(slot uint64, proposerPubkey, blockHash string) (entry *BuilderBlockSubmissionEntry, err error)

func (MockDB) GetBuilderSubmissions added in v0.5.1

func (db MockDB) GetBuilderSubmissions(filters GetBuilderSubmissionsFilters) ([]*BuilderBlockSubmissionEntry, error)

func (MockDB) GetExecutionPayloadEntryByID

func (db MockDB) GetExecutionPayloadEntryByID(executionPayloadID int64) (entry *ExecutionPayloadEntry, err error)

func (MockDB) GetExecutionPayloadEntryBySlotPkHash

func (db MockDB) GetExecutionPayloadEntryBySlotPkHash(slot uint64, proposerPubkey, blockHash string) (entry *ExecutionPayloadEntry, err error)

func (MockDB) GetNumDeliveredPayloads

func (db MockDB) GetNumDeliveredPayloads() (uint64, error)

func (MockDB) GetRecentDeliveredPayloads

func (db MockDB) GetRecentDeliveredPayloads(filters GetPayloadsFilters) ([]*DeliveredPayloadEntry, error)

func (MockDB) IncBlockBuilderStatsAfterGetHeader added in v0.7.0

func (db MockDB) IncBlockBuilderStatsAfterGetHeader(slot uint64, blockhash string) error

func (MockDB) IncBlockBuilderStatsAfterGetPayload added in v0.7.0

func (db MockDB) IncBlockBuilderStatsAfterGetPayload(slot uint64, blockhash string) error

func (MockDB) SaveBuilderBlockSubmission

func (db MockDB) SaveBuilderBlockSubmission(payload *types.BuilderSubmitBlockRequest, simError error, isMostProfitable bool) (entry *BuilderBlockSubmissionEntry, err error)

func (MockDB) SaveDeliveredPayload

func (db MockDB) SaveDeliveredPayload(slot uint64, proposerPubkey types.PubkeyHex, blockHash types.Hash, signedBlindedBeaconBlock *types.SignedBlindedBeaconBlock) error

func (MockDB) SaveValidatorRegistration

func (db MockDB) SaveValidatorRegistration(registration types.SignedValidatorRegistration) error

func (MockDB) SetBlockBuilderStatus added in v0.7.0

func (db MockDB) SetBlockBuilderStatus(pubkey string, isHighPrio, isBlacklisted bool) error

func (MockDB) UpsertBlockBuilderEntryAfterSubmission added in v0.7.0

func (db MockDB) UpsertBlockBuilderEntryAfterSubmission(lastSubmission *BuilderBlockSubmissionEntry, isError, isTopbid bool) error

type ValidatorRegistrationEntry

type ValidatorRegistrationEntry struct {
	ID         int64     `db:"id"`
	InsertedAt time.Time `db:"inserted_at"`

	Pubkey       string `db:"pubkey"`
	FeeRecipient string `db:"fee_recipient"`
	Timestamp    uint64 `db:"timestamp"`
	GasLimit     uint64 `db:"gas_limit"`
	Signature    string `db:"signature"`
}

Jump to

Keyboard shortcuts

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