Documentation
¶
Overview ¶
Database module defines the data DB struct which wraps specific DB interfaces for L1/L2 block headers, contract events, bridging schemas.
Index ¶
- Variables
- type BlockHeader
- type BlocksDB
- type BlocksView
- type BridgeMessage
- type BridgeMessagesDB
- type BridgeMessagesView
- type BridgeTransactionsDB
- type BridgeTransactionsView
- type BridgeTransfer
- type BridgeTransfersDB
- type BridgeTransfersView
- type Bytes
- type ContractEvent
- type ContractEventsDB
- type ContractEventsView
- type DB
- type L1BlockHeader
- type L1BridgeDeposit
- type L1BridgeDepositWithTransactionHashes
- type L1BridgeDepositsResponse
- type L1BridgeMessage
- type L1ContractEvent
- type L1TransactionDeposit
- type L2BlockHeader
- type L2BridgeMessage
- type L2BridgeMessageVersionedMessageHash
- type L2BridgeWithdrawal
- type L2BridgeWithdrawalWithTransactionHashes
- type L2BridgeWithdrawalsResponse
- type L2ContractEvent
- type L2TransactionWithdrawal
- type Logger
- func (l Logger) Error(ctx context.Context, msg string, data ...interface{})
- func (l Logger) Info(ctx context.Context, msg string, data ...interface{})
- func (l Logger) LogMode(lvl logger.LogLevel) logger.Interface
- func (l Logger) Trace(ctx context.Context, begin time.Time, ...)
- func (l Logger) Warn(ctx context.Context, msg string, data ...interface{})
- type MockBlocksDB
- type MockBlocksView
- func (m *MockBlocksView) L1BlockHeader(common.Hash) (*L1BlockHeader, error)
- func (m *MockBlocksView) L1BlockHeaderWithFilter(BlockHeader) (*L1BlockHeader, error)
- func (m *MockBlocksView) L1BlockHeaderWithScope(func(*gorm.DB) *gorm.DB) (*L1BlockHeader, error)
- func (m *MockBlocksView) L1LatestBlockHeader() (*L1BlockHeader, error)
- func (m *MockBlocksView) L2BlockHeader(common.Hash) (*L2BlockHeader, error)
- func (m *MockBlocksView) L2BlockHeaderWithFilter(BlockHeader) (*L2BlockHeader, error)
- func (m *MockBlocksView) L2BlockHeaderWithScope(func(*gorm.DB) *gorm.DB) (*L2BlockHeader, error)
- func (m *MockBlocksView) L2LatestBlockHeader() (*L2BlockHeader, error)
- type MockDB
- type RLPHeader
- type TokenPair
- type Transaction
- type WithdrawFilter
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ETHTokenPair = TokenPair{LocalTokenAddress: predeploys.LegacyERC20ETHAddr, RemoteTokenAddress: predeploys.LegacyERC20ETHAddr}
)
View Source
var (
SlowThresholdMilliseconds int64 = 500
)
Functions ¶
This section is empty.
Types ¶
type BlockHeader ¶
type BlockHeader struct {
Hash common.Hash `gorm:"primaryKey;serializer:bytes"`
ParentHash common.Hash `gorm:"serializer:bytes"`
Number *big.Int `gorm:"serializer:u256"`
Timestamp uint64
RLPHeader *RLPHeader `gorm:"serializer:rlp;column:rlp_bytes"`
}
func BlockHeaderFromHeader ¶ added in v1.1.4
func BlockHeaderFromHeader(header *types.Header) BlockHeader
func (BlockHeader) String ¶ added in v1.4.2
func (b BlockHeader) String() string
type BlocksDB ¶
type BlocksDB interface {
BlocksView
StoreL1BlockHeaders([]L1BlockHeader) error
StoreL2BlockHeaders([]L2BlockHeader) error
DeleteReorgedState(uint64) error
}
type BlocksView ¶
type BlocksView interface {
L1BlockHeader(common.Hash) (*L1BlockHeader, error)
L1BlockHeaderWithFilter(BlockHeader) (*L1BlockHeader, error)
L1BlockHeaderWithScope(func(db *gorm.DB) *gorm.DB) (*L1BlockHeader, error)
L1LatestBlockHeader() (*L1BlockHeader, error)
L2BlockHeader(common.Hash) (*L2BlockHeader, error)
L2BlockHeaderWithFilter(BlockHeader) (*L2BlockHeader, error)
L2BlockHeaderWithScope(func(db *gorm.DB) *gorm.DB) (*L2BlockHeader, error)
L2LatestBlockHeader() (*L2BlockHeader, error)
}
type BridgeMessage ¶ added in v1.1.4
type BridgeMessagesDB ¶ added in v1.1.4
type BridgeMessagesDB interface {
BridgeMessagesView
StoreL1BridgeMessages([]L1BridgeMessage) error
MarkRelayedL1BridgeMessage(common.Hash, uuid.UUID) error
StoreL2BridgeMessages([]L2BridgeMessage) error
MarkRelayedL2BridgeMessage(common.Hash, uuid.UUID) error
StoreL2BridgeMessageV1MessageHashes([]L2BridgeMessageVersionedMessageHash) error
}
type BridgeMessagesView ¶ added in v1.1.4
type BridgeMessagesView interface {
L1BridgeMessage(common.Hash) (*L1BridgeMessage, error)
L1BridgeMessageWithFilter(BridgeMessage) (*L1BridgeMessage, error)
L2BridgeMessage(common.Hash) (*L2BridgeMessage, error)
L2BridgeMessageWithFilter(BridgeMessage) (*L2BridgeMessage, error)
}
type BridgeTransactionsDB ¶ added in v1.1.4
type BridgeTransactionsDB interface {
BridgeTransactionsView
StoreL1TransactionDeposits([]L1TransactionDeposit) error
StoreL2TransactionWithdrawals([]L2TransactionWithdrawal) error
MarkL2TransactionWithdrawalProvenEvent(common.Hash, uuid.UUID) error
MarkL2TransactionWithdrawalFinalizedEvent(common.Hash, uuid.UUID, bool) error
}
type BridgeTransactionsView ¶ added in v1.1.4
type BridgeTransactionsView interface {
L1TransactionDeposit(common.Hash) (*L1TransactionDeposit, error)
L1LatestBlockHeader() (*L1BlockHeader, error)
L1LatestFinalizedBlockHeader() (*L1BlockHeader, error)
L2TransactionWithdrawal(common.Hash) (*L2TransactionWithdrawal, error)
L2LatestBlockHeader() (*L2BlockHeader, error)
L2LatestFinalizedBlockHeader() (*L2BlockHeader, error)
}
type BridgeTransfer ¶ added in v1.1.4
type BridgeTransfer struct {
CrossDomainMessageHash *common.Hash `gorm:"serializer:bytes"`
Tx Transaction `gorm:"embedded"`
TokenPair TokenPair `gorm:"embedded"`
}
type BridgeTransfersDB ¶ added in v1.1.4
type BridgeTransfersDB interface {
BridgeTransfersView
StoreL1BridgeDeposits([]L1BridgeDeposit) error
StoreL2BridgeWithdrawals([]L2BridgeWithdrawal) error
}
type BridgeTransfersView ¶ added in v1.1.4
type BridgeTransfersView interface {
L1BridgeDeposit(common.Hash) (*L1BridgeDeposit, error)
L1TxDepositSum() (float64, error)
L1BridgeDepositWithFilter(BridgeTransfer) (*L1BridgeDeposit, error)
L1BridgeDepositsByAddress(common.Address, string, int) (*L1BridgeDepositsResponse, error)
L2BridgeWithdrawal(common.Hash) (*L2BridgeWithdrawal, error)
L2BridgeWithdrawalSum(filter WithdrawFilter) (float64, error)
L2BridgeWithdrawalWithFilter(BridgeTransfer) (*L2BridgeWithdrawal, error)
L2BridgeWithdrawalsByAddress(common.Address, string, int) (*L2BridgeWithdrawalsResponse, error)
}
type ContractEvent ¶
type ContractEvent struct {
GUID uuid.UUID `gorm:"primaryKey"`
// Some useful derived fields
BlockHash common.Hash `gorm:"serializer:bytes"`
ContractAddress common.Address `gorm:"serializer:bytes"`
TransactionHash common.Hash `gorm:"serializer:bytes"`
LogIndex uint64
EventSignature common.Hash `gorm:"serializer:bytes"`
Timestamp uint64
// NOTE: NOT ALL THE DERIVED FIELDS ON `types.Log` ARE
// AVAILABLE. FIELDS LISTED ABOVE ARE FILLED IN
RLPLog *types.Log `gorm:"serializer:rlp;column:rlp_bytes"`
}
func ContractEventFromLog ¶ added in v1.1.4
func ContractEventFromLog(log *types.Log, timestamp uint64) ContractEvent
type ContractEventsDB ¶
type ContractEventsDB interface {
ContractEventsView
StoreL1ContractEvents([]L1ContractEvent) error
StoreL2ContractEvents([]L2ContractEvent) error
}
type ContractEventsView ¶
type ContractEventsView interface {
L1ContractEvent(uuid.UUID) (*L1ContractEvent, error)
L1ContractEventWithFilter(ContractEvent) (*L1ContractEvent, error)
L1ContractEventsWithFilter(ContractEvent, *big.Int, *big.Int) ([]L1ContractEvent, error)
L1LatestContractEventWithFilter(ContractEvent) (*L1ContractEvent, error)
L2ContractEvent(uuid.UUID) (*L2ContractEvent, error)
L2ContractEventWithFilter(ContractEvent) (*L2ContractEvent, error)
L2ContractEventsWithFilter(ContractEvent, *big.Int, *big.Int) ([]L2ContractEvent, error)
L2LatestContractEventWithFilter(ContractEvent) (*L2ContractEvent, error)
ContractEventsWithFilter(ContractEvent, string, *big.Int, *big.Int) ([]ContractEvent, error)
}
type DB ¶
type DB struct {
Blocks BlocksDB
ContractEvents ContractEventsDB
BridgeTransfers BridgeTransfersDB
BridgeMessages BridgeMessagesDB
BridgeTransactions BridgeTransactionsDB
// contains filtered or unexported fields
}
func NewDB ¶
NewDB connects to the configured DB, and provides client-bindings to it. The initial connection may fail, or the dial may be cancelled with the provided context.
func (*DB) ExecuteSQLMigration ¶ added in v1.1.6
type L1BlockHeader ¶
type L1BlockHeader struct {
BlockHeader `gorm:"embedded"`
}
type L1BridgeDeposit ¶ added in v1.1.4
type L1BridgeDeposit struct {
BridgeTransfer `gorm:"embedded"`
TransactionSourceHash common.Hash `gorm:"primaryKey;serializer:bytes"`
}
type L1BridgeDepositWithTransactionHashes ¶ added in v1.1.4
type L1BridgeDepositsResponse ¶ added in v1.1.6
type L1BridgeDepositsResponse struct {
Deposits []L1BridgeDepositWithTransactionHashes
Cursor string
HasNextPage bool
}
type L1BridgeMessage ¶ added in v1.1.4
type L1BridgeMessage struct {
BridgeMessage `gorm:"embedded"`
TransactionSourceHash common.Hash `gorm:"serializer:bytes"`
}
type L1ContractEvent ¶
type L1ContractEvent struct {
ContractEvent `gorm:"embedded"`
}
type L1TransactionDeposit ¶ added in v1.1.4
type L2BlockHeader ¶
type L2BlockHeader struct {
BlockHeader `gorm:"embedded"`
}
type L2BridgeMessage ¶ added in v1.1.4
type L2BridgeMessage struct {
BridgeMessage `gorm:"embedded"`
TransactionWithdrawalHash common.Hash `gorm:"serializer:bytes"`
}
type L2BridgeMessageVersionedMessageHash ¶ added in v1.4.2
type L2BridgeWithdrawal ¶ added in v1.1.4
type L2BridgeWithdrawal struct {
BridgeTransfer `gorm:"embedded"`
TransactionWithdrawalHash common.Hash `gorm:"primaryKey;serializer:bytes"`
}
type L2BridgeWithdrawalWithTransactionHashes ¶ added in v1.1.4
type L2BridgeWithdrawalWithTransactionHashes struct {
L2BridgeWithdrawal L2BridgeWithdrawal `gorm:"embedded"`
L2TransactionHash common.Hash `gorm:"serializer:bytes"`
L2BlockHash common.Hash `gorm:"serializer:bytes"`
ProvenL1TransactionHash common.Hash `gorm:"serializer:bytes"`
FinalizedL1TransactionHash common.Hash `gorm:"serializer:bytes"`
}
type L2BridgeWithdrawalsResponse ¶ added in v1.1.6
type L2BridgeWithdrawalsResponse struct {
Withdrawals []L2BridgeWithdrawalWithTransactionHashes
Cursor string
HasNextPage bool
}
type L2ContractEvent ¶
type L2ContractEvent struct {
ContractEvent `gorm:"embedded"`
}
type L2TransactionWithdrawal ¶ added in v1.1.4
type L2TransactionWithdrawal struct {
WithdrawalHash common.Hash `gorm:"serializer:bytes;primaryKey"`
Nonce *big.Int `gorm:"serializer:u256"`
InitiatedL2EventGUID uuid.UUID
ProvenL1EventGUID *uuid.UUID
FinalizedL1EventGUID *uuid.UUID
Succeeded *bool
Tx Transaction `gorm:"embedded"`
GasLimit *big.Int `gorm:"serializer:u256"`
}
type Logger ¶ added in v1.2.0
type Logger struct {
// contains filtered or unexported fields
}
type MockBlocksDB ¶ added in v1.1.6
type MockBlocksDB struct {
MockBlocksView
}
func (*MockBlocksDB) DeleteReorgedState ¶ added in v1.6.1
func (m *MockBlocksDB) DeleteReorgedState(timestamp uint64) error
func (*MockBlocksDB) StoreL1BlockHeaders ¶ added in v1.1.6
func (m *MockBlocksDB) StoreL1BlockHeaders(headers []L1BlockHeader) error
func (*MockBlocksDB) StoreL2BlockHeaders ¶ added in v1.1.6
func (m *MockBlocksDB) StoreL2BlockHeaders(headers []L2BlockHeader) error
type MockBlocksView ¶ added in v1.1.6
func (*MockBlocksView) L1BlockHeader ¶ added in v1.1.6
func (m *MockBlocksView) L1BlockHeader(common.Hash) (*L1BlockHeader, error)
func (*MockBlocksView) L1BlockHeaderWithFilter ¶ added in v1.1.6
func (m *MockBlocksView) L1BlockHeaderWithFilter(BlockHeader) (*L1BlockHeader, error)
func (*MockBlocksView) L1BlockHeaderWithScope ¶ added in v1.4.2
func (m *MockBlocksView) L1BlockHeaderWithScope(func(*gorm.DB) *gorm.DB) (*L1BlockHeader, error)
func (*MockBlocksView) L1LatestBlockHeader ¶ added in v1.1.6
func (m *MockBlocksView) L1LatestBlockHeader() (*L1BlockHeader, error)
func (*MockBlocksView) L2BlockHeader ¶ added in v1.1.6
func (m *MockBlocksView) L2BlockHeader(common.Hash) (*L2BlockHeader, error)
func (*MockBlocksView) L2BlockHeaderWithFilter ¶ added in v1.1.6
func (m *MockBlocksView) L2BlockHeaderWithFilter(BlockHeader) (*L2BlockHeader, error)
func (*MockBlocksView) L2BlockHeaderWithScope ¶ added in v1.4.2
func (m *MockBlocksView) L2BlockHeaderWithScope(func(*gorm.DB) *gorm.DB) (*L2BlockHeader, error)
func (*MockBlocksView) L2LatestBlockHeader ¶ added in v1.1.6
func (m *MockBlocksView) L2LatestBlockHeader() (*L2BlockHeader, error)
type MockDB ¶ added in v1.1.6
type MockDB struct {
MockBlocks *MockBlocksDB
DB *DB
}
MockDB is a mock database that can be used for testing
type Transaction ¶
type WithdrawFilter ¶ added in v1.4.2
type WithdrawFilter uint8
const ( All WithdrawFilter = iota // Same as "initialized" Proven Finalized )
Source Files
¶
Click to show internal directories.
Click to hide internal directories.