da

package
v0.0.0-...-2be2167 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventDAHealthStatus = "DAHealthStatus"
)

Define the event types

View Source
const (
	// EventTypeKey is a reserved composite key for event name.
	EventTypeKey = "da.event"
)

Define the event type keys

Variables

View Source
var (
	// ErrFailedTxBuild is returned when transaction build fails.
	ErrTxBroadcastConfigError = errors.New("Failed building tx")
	// ErrFailedTxBroadcast is returned when transaction broadcast fails.
	ErrTxBroadcastNetworkError = errors.New("Failed broadcasting tx")
	// ErrTxBroadcastTimeout is returned when transaction broadcast times out.
	ErrTxBroadcastTimeout = errors.New("Broadcast timeout error")
)
View Source
var (
	EventQueryDAHealthStatus = QueryForEvent(EventDAHealthStatus)
)

Define queries

Functions

func QueryForEvent

func QueryForEvent(eventType string) tmpubsub.Query

QueryForEvent returns a query for the given event.

Types

type BaseResult

type BaseResult struct {
	// Code is to determine if the action succeeded.
	Code StatusCode
	// Message may contain DA layer specific information (like DA block height/hash, detailed error message, etc)
	Message string
	// DAHeight informs about a height on Data Availability Layer for given result.
	DAHeight uint64
}

BaseResult contains basic information returned by DA layer.

type BatchRetriever

type BatchRetriever interface {
	// RetrieveBatches returns blocks at given data layer height from data availability layer.
	RetrieveBatches(dataLayerHeight uint64) ResultRetrieveBatch
}

BatchRetriever is additional interface that can be implemented by Data Availability Layer Client that is able to retrieve block data from DA layer. This gives the ability to use it for block synchronization.

type Client

type Client string

Client defines all the possible da clients

const (
	Mock     Client = "mock"
	Celestia Client = "celestia"
	Avail    Client = "avail"
	GRPC     Client = "grpc"
)

Data availability clients

type DataAvailabilityLayerClient

type DataAvailabilityLayerClient interface {
	// Init is called once to allow DA client to read configuration and initialize resources.
	Init(config []byte, pubsubServer *pubsub.Server, kvStore store.KVStore, logger log.Logger, options ...Option) error

	// Start is called once, after Init. It's implementation should start operation of DataAvailabilityLayerClient.
	Start() error

	// Stop is called once, when DataAvailabilityLayerClient is no longer needed.
	Stop() error

	// SubmitBatch submits the passed in block to the DA layer.
	// This should create a transaction which (potentially)
	// triggers a state transition in the DA layer.
	SubmitBatch(batch *types.Batch) ResultSubmitBatch

	// CheckBatchAvailability queries DA layer to check data availability of block corresponding at given height.
	CheckBatchAvailability(dataLayerHeight uint64) ResultCheckBatch

	GetClientType() Client
}

DataAvailabilityLayerClient defines generic interface for DA layer block submission. It also contains life-cycle methods.

type EventDataDAHealthStatus

type EventDataDAHealthStatus struct {
	// Healthy is true if the da layer is healthy
	Healthy bool
	// Error is the error that was encountered in case of a health check failure
	Error error
}

EventDataDAHealthStatus defines the structure of the event data for the EventDataDAHealthStatus

type Option

type Option func(DataAvailabilityLayerClient)

Option is a function that sets a parameter on the da layer.

type ResultCheckBatch

type ResultCheckBatch struct {
	BaseResult
	// DataAvailable is the actual answer whether the block is available or not.
	// It can be true if and only if Code is equal to StatusSuccess.
	DataAvailable bool
}

ResultCheckBatch contains information about block availability, returned from DA layer client.

type ResultRetrieveBatch

type ResultRetrieveBatch struct {
	BaseResult
	// Block is the full block retrieved from Data Availability Layer.
	// If Code is not equal to StatusSuccess, it has to be nil.
	Batches []*types.Batch
}

ResultRetrieveBatch contains batch of blocks returned from DA layer client.

type ResultSubmitBatch

type ResultSubmitBatch struct {
	BaseResult
}

ResultSubmitBatch contains information returned from DA layer after block submission.

func SubmitBatchHealthEventHelper

func SubmitBatchHealthEventHelper(pubsubServer *pubsub.Server, ctx context.Context, healthy bool, err error) (ResultSubmitBatch, error)

type StatusCode

type StatusCode uint64

StatusCode is a type for DA layer return status. TODO: define an enum of different non-happy-path cases that might need to be handled by Dymint independent of the underlying DA chain.

const (
	StatusUnknown StatusCode = iota
	StatusSuccess
	StatusTimeout
	StatusError
)

Data Availability return codes.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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