Documentation ¶
Overview ¶
Package blockdb saves chain and block data for inspection later to aid in debugging ibctest failures.
Index ¶
- func ConnectDB(ctx context.Context, databasePath string) (*sql.DB, error)
- func Migrate(db *sql.DB, gitSha string) error
- type BlockSaver
- type Chain
- type Collector
- type CosmosMessageResult
- type Event
- type EventAttribute
- type Query
- func (q *Query) CosmosMessages(ctx context.Context, chainPkey int64) ([]CosmosMessageResult, error)
- func (q *Query) CurrentSchemaVersion(ctx context.Context) (SchemaVersionResult, error)
- func (q *Query) RecentTestCases(ctx context.Context, limit int) ([]TestCaseResult, error)
- func (q *Query) Transactions(ctx context.Context, chainPkey int64) ([]TxResult, error)
- type SchemaVersionResult
- type TestCase
- type TestCaseResult
- type Tx
- type TxFinder
- type TxResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectDB ¶
ConnectDB connects to the sqlite database at databasePath. Auto-creates directory path via MkdirAll. Pings database once to ensure connection. Pass :memory: as databasePath for in-memory database.
func Migrate ¶
Migrate migrates db in an idempotent manner. If an error is returned, it's acceptable to delete the database and start over. The basic ERD is as follows:
┌────────────────────┐ ┌────────────────────┐ ┌────────────────────┐ ┌────────────────────┐ │ │ │ │ │ │ │ │ │ │ ╱│ │ ╱│ │ ╱│ │ │ Test Case │───────┼──│ Chain │───────○─│ Block │────────○─│ Tx │ │ │ ╲│ │ ╲│ │ ╲│ │ │ │ │ │ │ │ │ │ └────────────────────┘ └────────────────────┘ └────────────────────┘ └────────────────────┘
The gitSha ensures we can trace back to the version of the codebase that produced the schema. Warning: Typical best practice wraps each migration step into its own transaction. For simplicity given this is an embedded database, we omit transactions.
Types ¶
type BlockSaver ¶
BlockSaver saves transactions for block at height.
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain tracks its blocks and a block's transactions.
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector saves block transactions at regular intervals.
func NewCollector ¶
func NewCollector(log *zap.Logger, finder TxFinder, saver BlockSaver, rate time.Duration) *Collector
NewCollector creates a valid Collector that polls every duration at rate. The rate should be less than the time it takes to produce a block. Typically, a rate that will collect a few times a second is sufficient such as 100-200ms.
type CosmosMessageResult ¶
type CosmosMessageResult struct { Height int64 Index int Type string // URI for proto definition, e.g. /ibc.core.client.v1.MsgCreateClient ClientChainID sql.NullString ClientID sql.NullString CounterpartyClientID sql.NullString ConnID sql.NullString CounterpartyConnID sql.NullString PortID sql.NullString CounterpartyPortID sql.NullString ChannelID sql.NullString CounterpartyChannelID sql.NullString }
type Event ¶
type Event struct { Type string Attributes []EventAttribute }
Event is an alternative representation of tendermint/abci/types.Event, so that the blockdb package does not depend directly on tendermint.
type EventAttribute ¶
type EventAttribute struct {
Key, Value string
}
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query is a service that queries the database.
func (*Query) CosmosMessages ¶
CosmosMessages returns a summary of Cosmos messages for the chainID. In Cosmos, a transaction may have 1 or more associated messages. chainPkey is the chain primary key "chain.id", not to be confused with the column "chain_id".
func (*Query) CurrentSchemaVersion ¶
func (q *Query) CurrentSchemaVersion(ctx context.Context) (SchemaVersionResult, error)
CurrentSchemaVersion returns the latest git sha and time that produced the sqlite schema.
func (*Query) RecentTestCases ¶
RecentTestCases returns aggregated data for each test case and chain combination.
type SchemaVersionResult ¶
type TestCase ¶
type TestCase struct {
// contains filtered or unexported fields
}
TestCase is a single test invocation.
func CreateTestCase ¶
CreateTestCase starts tracking new test case with testName.
type TestCaseResult ¶
type TestCaseResult struct { ID int64 Name string GitSha string // Git commit that ran the test. CreatedAt time.Time ChainPKey int64 // chain primary key ChainID string // E.g. osmosis-1001 ChainType string // E.g. cosmos, penumbra ChainHeight sql.NullInt64 TxTotal sql.NullInt64 }
TestCaseResult is a combination of a single test case and single chain associated with the test case.