Documentation
¶
Index ¶
- Constants
- Variables
- type CelestiaConfig
- type Relayer
- func (r *Relayer) CreateClient(ctx sdk.Context) *celestia.CreateClient
- func (r *Relayer) GetCachedHeaders(proofLimit int, latestProvenHeight int64) []*celestia.Header
- func (r *Relayer) GetCachedProofs(proofLimit int, latestProvenHeight int64) []*celestia.BlobProof
- func (r *Relayer) GetLocalBlockAtHeight(height int64) ([]byte, error)
- func (r *Relayer) GetUpdateClient() *celestia.Header
- func (r *Relayer) HasCachedProof(block int64) bool
- func (r *Relayer) NotifyCommitHeight(height int64)
- func (r *Relayer) NotifyProvenHeight(height int64)
- func (r *Relayer) PopulateUnprovenBlockStore()
- func (r *Relayer) PostBlocks(ctx sdk.Context, blocks []int64)
- func (r *Relayer) ProposePostNextBlocks(ctx sdk.Context, provenHeight int64) []int64
- func (r *Relayer) PruneBlockStore(previousProvenHeight int64)
- func (r *Relayer) PushSnapshotBlocks(height int64, block []byte)
- func (r *Relayer) SetClientContext(clientCtx client.Context)
- func (r *Relayer) SetUpdateClient(updateClient *celestia.Header)
- func (r *Relayer) Start() error
- func (r *Relayer) ValidateNewClient(ctx sdk.Context, client *celestia.CreateClient) error
- type RelayerInternalConfig
Constants ¶
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" FlagOverridePubInterval = "celestia.override-pub-interval" FlagQueryInterval = "celestia.proof-query-interval" FlagMaxFlushSize = "celestia.max-flush-size" DefaultConfigTemplate = `` /* 1180-byte string literal not displayed */ )
const ( CelestiaPublishKeyName = "blob" CelestiaFeegrantKeyName = "feegrant" )
const ( DefaultMaxFlushSize = int(20) MaxMaxFlushSize = int(100) )
Variables ¶
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"`
// Overrides built-in publish-to-celestia block interval
OverridePubInterval int `mapstructure:"override-pub-interval"`
// 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, homePath 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 ¶
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 ¶
GetCachedProofs() returns the next set of proofs to verify on-chain
func (*Relayer) GetLocalBlockAtHeight ¶
func (*Relayer) GetUpdateClient ¶
func (*Relayer) HasCachedProof ¶
func (*Relayer) NotifyCommitHeight ¶
NotifyCommitHeight is called by the app to notify the relayer of the latest commit height
func (*Relayer) NotifyProvenHeight ¶
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) PopulateUnprovenBlockStore ¶
func (r *Relayer) PopulateUnprovenBlockStore()
Called in Preblocker, gets the latest block(s) from cometbft and populates our store
func (*Relayer) PostBlocks ¶
PostBlocks is call in the preblocker, the proposer will publish at this point with their block accepted
func (*Relayer) ProposePostNextBlocks ¶
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) PruneBlockStore ¶
Only prune to the previous proven height when proven height changes on startup, the last block is replayed, those blocks need to persist for the replay
func (*Relayer) PushSnapshotBlocks ¶
func (*Relayer) SetClientContext ¶
func (*Relayer) SetUpdateClient ¶
A non-nil set is performed when trusting period is 2/3 time from expiration a nil clears it
func (*Relayer) ValidateNewClient ¶
type RelayerInternalConfig ¶
type RelayerInternalConfig struct {
// Database backend: goleveldb | cleveldb | boltdb | rocksdb
// * goleveldb (github.com/syndtr/goleveldb - most popular implementation)
// - pure go
// - stable
// * cleveldb (uses levigo wrapper)
// - fast
// - requires gcc
// - use cleveldb build tag (go build -tags cleveldb)
// * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt)
// - EXPERIMENTAL
// - may be faster is some use-cases (random reads - indexer)
// - use boltdb build tag (go build -tags boltdb)
// * rocksdb (uses github.com/tecbot/gorocksdb)
// - EXPERIMENTAL
// - requires gcc
// - use rocksdb build tag (go build -tags rocksdb)
// * badgerdb (uses github.com/dgraph-io/badger)
// - EXPERIMENTAL
// - use badgerdb build tag (go build -tags badgerdb)
DBBackend string
// Database directory
DBPath string
}
var RelayerInternalCfg RelayerInternalConfig