Documentation
¶
Index ¶
- Constants
- Variables
- func QueryForEvent(eventType string) tmpubsub.Query
- type BaseLayerClient
- func (b *BaseLayerClient) GetProposer() *types.Sequencer
- func (b *BaseLayerClient) GetSequencersList() []*types.Sequencer
- func (b *BaseLayerClient) Init(config []byte, pubsub *pubsub.Server, logger log.Logger, options ...Option) error
- func (b *BaseLayerClient) RetrieveBatch(stateIndex ...uint64) (*ResultRetrieveBatch, error)
- func (b *BaseLayerClient) Start() error
- func (b *BaseLayerClient) Stop() error
- func (b *BaseLayerClient) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) *ResultSubmitBatch
- type BaseResult
- type Batch
- type BatchMetaData
- type Config
- type DAMetaData
- type EventDataNewSettlementBatchAccepted
- type EventDataSequencersListUpdated
- type HubClient
- type LayerClient
- type Option
- type PostBatchResp
- type ResultRetrieveBatch
- type ResultSubmitBatch
- type StatusCode
Constants ¶
const ( EventNewSettlementBatchAccepted = "NewSettlementBatchAccepted" EventSequencersListUpdated = "SequencersListUpdated" )
Define the event types
const (
// EventTypeKey is a reserved composite key for event name.
EventTypeKey = "settlement.event"
)
Define the event type keys
Variables ¶
var ( // ErrBatchNotFound is returned when a batch is not found for the rollapp. ErrBatchNotFound = errors.New("batch not found") // ErrNoSequencerForRollapp is returned when a sequencer is not found for the rollapp. ErrNoSequencerForRollapp = errors.New("no sequencer registered on the hub for this rollapp") )
var (
EventQueryNewSettlementBatchAccepted = QueryForEvent(EventNewSettlementBatchAccepted)
)
Define queries
Functions ¶
func QueryForEvent ¶
QueryForEvent returns a query for the given event.
Types ¶
type BaseLayerClient ¶
type BaseLayerClient struct {
// contains filtered or unexported fields
}
BaseLayerClient is intended only for usage in tests.
func (*BaseLayerClient) GetProposer ¶
func (b *BaseLayerClient) GetProposer() *types.Sequencer
GetProposer returns the sequencer which is currently the proposer
func (*BaseLayerClient) GetSequencersList ¶
func (b *BaseLayerClient) GetSequencersList() []*types.Sequencer
GetSequencersList returns the current list of sequencers from the settlement layer
func (*BaseLayerClient) Init ¶
func (b *BaseLayerClient) Init(config []byte, pubsub *pubsub.Server, logger log.Logger, options ...Option) error
Init is called once. it initializes the struct members.
func (*BaseLayerClient) RetrieveBatch ¶
func (b *BaseLayerClient) RetrieveBatch(stateIndex ...uint64) (*ResultRetrieveBatch, error)
RetrieveBatch Gets the batch which contains the given slHeight. Empty slHeight returns the latest batch.
func (*BaseLayerClient) Start ¶
func (b *BaseLayerClient) Start() error
Start is called once, after init. It initializes the query client.
func (*BaseLayerClient) Stop ¶
func (b *BaseLayerClient) Stop() error
Stop is called once, after Start.
func (*BaseLayerClient) SubmitBatch ¶
func (b *BaseLayerClient) SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) *ResultSubmitBatch
SubmitBatch submits the batch to the settlement layer. This should create a transaction which (potentially) triggers a state transition in the settlement layer.
type BaseResult ¶
type BaseResult struct {
// Code is to determine if the action succeeded.
Code StatusCode
// Message may contain settlement layer specific information (like detailed error message, etc)
Message string
// StateIndex is the rollapp-specific index the batch was saved in the SL
StateIndex uint64
}
BaseResult contains basic information returned by the settlement layer.
type Batch ¶
type Batch struct {
StartHeight uint64
EndHeight uint64
AppHashes [][32]byte
// MetaData about the batch in the DA layer
MetaData *BatchMetaData
}
Batch defines a batch structure for the settlement layer
type BatchMetaData ¶
type BatchMetaData struct {
DA *DAMetaData
}
BatchMetaData aggregates all the batch metadata.
type DAMetaData ¶
type DAMetaData struct {
// Height is the height of the block in the da layer
Height uint64
// Client is the client to use to fetch data from the da layer
Client da.Client
}
DAMetaData contains meta data about a batch on the Data Availability Layer.
func (*DAMetaData) FromPath ¶
func (d *DAMetaData) FromPath(path string) (*DAMetaData, error)
FromPath parses a path to a DAMetaData.
func (*DAMetaData) ToPath ¶
func (d *DAMetaData) ToPath() string
ToPath converts a DAMetaData to a path.
type EventDataNewSettlementBatchAccepted ¶
type EventDataNewSettlementBatchAccepted struct {
// EndHeight is the height of the last accepted batch
EndHeight uint64
// StateIndex is the rollapp-specific index the batch was saved in the SL
StateIndex uint64
}
EventDataNewSettlementBatchAccepted defines the structure of the event data for the EventNewSettlementBatchAccepted
type EventDataSequencersListUpdated ¶
type EventDataSequencersListUpdated struct {
// Sequencers is the list of sequencers
Sequencers []types.Sequencer
}
EventDataSequencersListUpdated defines the structure of the event data for the EventSequencersListUpdated
type HubClient ¶
type HubClient interface {
Start() error
Stop() error
PostBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) (PostBatchResp, error)
GetLatestBatch(rollappID string) (*ResultRetrieveBatch, error)
GetBatchAtIndex(rollappID string, index uint64) (*ResultRetrieveBatch, error)
GetSequencers(rollappID string) ([]*types.Sequencer, error)
}
HubClient is an helper interface for a more granualr interaction with the hub. Implementing a new settlement layer client basically requires embedding the base client and implementing the helper interfaces.
type LayerClient ¶
type LayerClient interface {
// Init is called once for the client initialization
Init(config []byte, pubsub *pubsub.Server, logger log.Logger, options ...Option) error
// Start is called once, after Init. It's implementation should start the client service.
Start() error
// Stop is called once, after Start. It should stop the client service.
Stop() error
// SubmitBatch submits the batch to the settlement layer. This should create a transaction which (potentially)
// triggers a state transition in the settlement layer.
SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) *ResultSubmitBatch
// RetrieveBatch Gets the batch which contains the given height. Empty height returns the latest batch.
RetrieveBatch(stateIndex ...uint64) (*ResultRetrieveBatch, error)
// GetSequencersList returns the list of the sequencers for this chain.
GetSequencersList() []*types.Sequencer
// GetProposer returns the current proposer for this chain.
GetProposer() *types.Sequencer
}
LayerClient defines generic interface for Settlement layer interaction.
type Option ¶
type Option func(LayerClient)
Option is a function that sets a parameter on the settlement layer.
func WithHubClient ¶
WithHubClient is an option which sets the hub client.
type PostBatchResp ¶
PostBatchResp is an helper interface for a more granualr interaction with the hub. Implementing a new settlement layer client basically requires embedding the base client and implementing the helper interfaces.
type ResultRetrieveBatch ¶
type ResultRetrieveBatch struct {
BaseResult
*Batch
}
ResultRetrieveBatch contains information returned from settlement layer after batch retrieva
type ResultSubmitBatch ¶
type ResultSubmitBatch struct {
BaseResult
}
ResultSubmitBatch contains information returned from settlement layer after batch submission.
type StatusCode ¶
type StatusCode uint64
StatusCode is a type for settlement layer return status.
const ( StatusUnknown StatusCode = iota StatusSuccess StatusTimeout StatusError )
settlement layer return codes.