relayer

package
v0.0.0-...-a168d6f Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagAppRpcURL         = "celestia.app-rpc-url"
	FlagAppRpcTimeout     = "celestia.app-rpc-timeout"
	FlagChainID           = "celestia.chain-id"
	FlagGasPrices         = "celestia.gas-prices"
	FlagGasAdjustment     = "celestia.gas-adjustment"
	FlagNodeRpcURL        = "celestia.node-rpc-url"
	FlagNodeAuthToken     = "celestia.node-auth-token"
	FlagOverrideNamespace = "celestia.override-namespace"
	FlagQueryInterval     = "celestia.proof-query-interval"
	FlagMaxFlushSize      = "celestia.max-flush-size"

	DefaultConfigTemplate = `` /* 1084-byte string literal not displayed */

)
View Source
const (
	CelestiaPublishKeyName  = "blob"
	CelestiaFeegrantKeyName = "feegrant"
)
View Source
const (
	DefaultMaxFlushSize = int(20)
	MaxMaxFlushSize     = int(100)
)

Variables

View Source
var DefaultCelestiaConfig = CelestiaConfig{
	AppRpcURL:          "https://rpc-mocha.pops.one:443",
	AppRpcTimeout:      30 * time.Second,
	ChainID:            "celestia-1",
	GasPrice:           "0.01utia",
	GasAdjustment:      1.0,
	NodeRpcURL:         "http://127.0.0.1:26658",
	NodeAuthToken:      "auth-token",
	ProofQueryInterval: 12 * time.Second,
	MaxFlushSize:       32,
}

Functions

This section is empty.

Types

type CelestiaConfig

type CelestiaConfig struct {
	// RPC URL of celestia-app
	AppRpcURL string `mapstructure:"app-rpc-url"`

	// RPC Timeout for celestia-app
	AppRpcTimeout time.Duration `mapstructure:"app-rpc-timeout"`

	// Celestia chain ID
	ChainID string `mapstructure:"chain-id"`

	// Gas price to pay for Celestia transactions
	GasPrice string `mapstructure:"gas-prices"`

	// Gas adjustment for Celestia transactions
	GasAdjustment float64 `mapstructure:"gas-adjustment"`

	// RPC URL of celestia-node
	NodeRpcURL string `mapstructure:"node-rpc-url"`

	// RPC Timeout for celestia-node
	NodeAuthToken string `mapstructure:"node-auth-token"`

	// Overrides built-in namespace used
	OverrideNamespace string `mapstructure:"override-namespace"`

	// Query Celestia for new block proofs this often
	ProofQueryInterval time.Duration `mapstructure:"proof-query-interval"`

	// Only flush at most this many block proofs in an injected tx per block proposal
	MaxFlushSize int `mapstructure:"max-flush-size"`
}

CelestiaConfig defines the configuration for the in-process Celestia relayer.

func CelestiaConfigFromAppOpts

func CelestiaConfigFromAppOpts(appOpts servertypes.AppOptions) CelestiaConfig

type Relayer

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

Relayer is responsible for posting new blocks to Celestia and relaying block proofs from Celestia via the current proposer

func NewRelayer

func NewRelayer(
	logger log.Logger,
	cdc codec.BinaryCodec,
	appOpts servertypes.AppOptions,
	celestiaNamespace appns.Namespace,
	keyDir string,
	celestiaPublishBlockInterval int,
) (*Relayer, error)

NewRelayer creates a new Relayer instance

func (*Relayer) CreateClient

func (r *Relayer) CreateClient(ctx sdk.Context) *celestia.CreateClient

TODO: do create client async, worst case scenario, it will be created in the same block as the first proofs

func (*Relayer) GetCachedHeaders

func (r *Relayer) GetCachedHeaders(proofLimit int, latestProvenHeight int64) []*celestia.Header

GetCachedHeaders queries through the cached block proofs, extracts the celestia height they were published, and pulls in the cached header. If a header does not exist, it may have already been included in an earlier block. Finally, if there are no header/client updates, we check if an update client is needed to keep the client from expiring.

func (*Relayer) GetCachedProofs

func (r *Relayer) GetCachedProofs(proofLimit int, latestProvenHeight int64) []*celestia.BlobProof

GetCachedProofs() returns the next set of proofs to verify on-chain

func (*Relayer) GetLocalBlockAtHeight

func (r *Relayer) GetLocalBlockAtHeight(ctx context.Context, rollchainBlockHeight int64) ([]byte, error)

func (*Relayer) GetUpdateClient

func (r *Relayer) GetUpdateClient() *celestia.Header

func (*Relayer) HasCachedProof

func (r *Relayer) HasCachedProof(block int64) bool

func (*Relayer) NotifyCommitHeight

func (r *Relayer) NotifyCommitHeight(height int64)

NotifyCommitHeight is called by the app to notify the relayer of the latest commit height

func (*Relayer) NotifyProvenHeight

func (r *Relayer) NotifyProvenHeight(height int64)

NotifyProvenHeight is called by the app to notify the relayer of the latest proven height i.e. the height of the highest incremental block that was proven to be posted to Celestia.

func (*Relayer) PostBlocks

func (r *Relayer) PostBlocks(ctx sdk.Context, blocks []int64)

PostBlocks is call in the preblocker, the proposer will publish at this point with their block accepted

func (*Relayer) ProposePostNextBlocks

func (r *Relayer) ProposePostNextBlocks(ctx sdk.Context) []int64

PostNextBlocks is called by the current proposing validator during PrepareProposal. If on the publish boundary, it will return the block heights that will be published It will not publish the block being proposed.

func (*Relayer) SetClientContext

func (r *Relayer) SetClientContext(clientCtx client.Context)

func (*Relayer) SetUpdateClient

func (r *Relayer) SetUpdateClient(updateClient *celestia.Header)

A non-nil set is performed when trusting period is 2/3 time from expiration a nil clears it

func (*Relayer) Start

func (r *Relayer) Start(
	ctx context.Context,
	provenHeight int64,
	commitHeight int64,
) error

Start begins the relayer process

func (*Relayer) ValidateNewClient

func (r *Relayer) ValidateNewClient(ctx sdk.Context, client *celestia.CreateClient) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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