settlement

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 7 Imported by: 20

Documentation

Index

Constants

View Source
const (
	// EventNewBatchAccepted should be emitted internally in order to communicate between the settlement layer and the hub client
	EventNewBatchAccepted      = "EventNewBatchAccepted"
	EventSequencersListUpdated = "SequencersListUpdated"
	EventHealthStatus          = "SettlementHealthStatus"
)
View Source
const (
	// EventTypeKey is a reserved composite key for event name.
	EventTypeKey = "settlement.event"
)

Variables

View Source
var (
	// ErrBatchNotFound is returned when a batch is not found for the rollapp.
	ErrBatchNotFound = errors.New("batch not found")
	// ErrEmptyResponse is returned when the response is empty.
	ErrEmptyResponse = errors.New("empty response")
	// ErrNoSequencerForRollapp is returned when a sequencer is not found for the rollapp.
	ErrNoSequencerForRollapp = errors.New("no sequencer registered on the hub for this rollapp")
	// ErrBatchNotAccepted is returned when a batch is not accepted by the settlement layer.
	ErrBatchNotAccepted = errors.New("batch not accepted")
)
View Source
var (
	EventHealthStatusList     = map[string][]string{EventTypeKey: {EventHealthStatus}}
	EventNewBatchAcceptedList = map[string][]string{EventTypeKey: {EventNewBatchAccepted}}
)
View Source
var (
	EventQueryNewSettlementBatchAccepted = uevent.QueryFor(EventTypeKey, EventNewBatchAccepted)
	EventQuerySettlementHealthStatus     = uevent.QueryFor(EventTypeKey, EventHealthStatus)
)

Queries

Functions

This section is empty.

Types

type BaseLayerClient

type BaseLayerClient struct {
	// contains filtered or unexported fields
}

BaseLayerClient is intended only for usage in tests.

func (*BaseLayerClient) GetHeightState added in v1.1.2

func (b *BaseLayerClient) GetHeightState(u uint64) (*ResultGetHeightState, error)

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 Config, pubsub *pubsub.Server, logger types.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) error

SubmitBatch tries submitting the batch in an async broadcast mode to the settlement layer. Events are emitted on success or failure.

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
	// TODO(omritoptix): Move StateIndex to be part of the batch struct
	// 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 *da.DASubmitMetaData
}

BatchMetaData aggregates all the batch metadata.

type Config

type Config struct {
	KeyringBackend string `mapstructure:"keyring_backend"`
	NodeAddress    string `mapstructure:"node_address"`
	KeyringHomeDir string `mapstructure:"keyring_home_dir"`
	DymAccountName string `mapstructure:"dym_account_name"`
	RollappID      string `mapstructure:"rollapp_id"`
	GasLimit       uint64 `mapstructure:"gas_limit"`
	GasPrices      string `mapstructure:"gas_prices"`
	GasFees        string `mapstructure:"gas_fees"`

	// For testing only. probably should be refactored
	ProposerPubKey string `json:"proposer_pub_key"`
	// Config used for sl shared grpc mock
	SLGrpc GrpcConfig `mapstructure:",squash"`
}

Config for the DymensionLayerClient

func (Config) Validate added in v1.1.0

func (c Config) Validate() error

type EventDataHealth added in v1.1.0

type EventDataHealth struct {
	// Error is the error that was encountered in case of a health check failure, nil implies healthy
	Error error
}

type EventDataNewBatchAccepted added in v1.1.0

type EventDataNewBatchAccepted 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
}

type EventDataSequencersListUpdated

type EventDataSequencersListUpdated struct {
	// Sequencers is the list of new sequencers
	Sequencers []types.Sequencer
}

type GrpcConfig added in v1.1.0

type GrpcConfig struct {
	Host        string `json:"host"`
	Port        int    `json:"port"`
	RefreshTime int    `json:"refresh_time"`
}

type HubClient

type HubClient interface {
	Start() error
	Stop() error
	PostBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) error
	GetLatestBatch(rollappID string) (*ResultRetrieveBatch, error)
	GetBatchAtIndex(rollappID string, index uint64) (*ResultRetrieveBatch, error)
	GetHeightState(rollappID string, index uint64) (*ResultGetHeightState, error)
	GetSequencers(rollappID string) ([]*types.Sequencer, error)
}

HubClient is a helper interface for a more granular interaction with the hub. Implementing a new settlement layer client basically requires embedding the base client and implementing the helper interfaces.

type LayerI added in v1.1.0

type LayerI interface {
	// Init is called once for the client initialization
	Init(config Config, pubsub *pubsub.Server, logger types.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 tries submitting the batch in an async way to the settlement layer. This should create a transaction which (potentially)
	// triggers a state transition in the settlement layer. Events are emitted on success or failure.
	SubmitBatch(batch *types.Batch, daClient da.Client, daResult *da.ResultSubmitBatch) error

	// 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

	GetHeightState(uint64) (*ResultGetHeightState, error)
}

LayerI defines generic interface for Settlement layer interaction.

type Option

type Option func(LayerI)

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

func WithHubClient

func WithHubClient(hubClient HubClient) Option

WithHubClient is an option which sets the hub client.

type ResultGetHeightState added in v1.1.2

type ResultGetHeightState struct {
	BaseResult // NOTE: the state index of this will not be populated
	State
}

type ResultRetrieveBatch

type ResultRetrieveBatch struct {
	BaseResult
	*Batch
}

ResultRetrieveBatch contains information returned from settlement layer after batch retrieva

type State added in v1.1.2

type State struct {
	StateIndex uint64
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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