state

package
v0.28.4 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: Apache-2.0 Imports: 40 Imported by: 6

Documentation

Overview

Package state provides a structure for celestia-node's ability to access state-relevant information from as well as submit transactions/messages to the celestia network.

This package contains one main interface, `Accessor`, that defines the methods available for both accessing and updating state on the celestia network.

`Accessor` will contain three different implementations:

  1. Implementation over a gRPC connection with a celestia-core node called `CoreAccess`.
  2. Implementation over a libp2p stream with a state-providing node.
  3. Implementation over a local running instance of the celestia-application (this feature will be implemented in *Full* nodes).

Index

Constants

View Source
const (
	// DefaultGasPrice specifies the default gas price value to be used when the user
	// wants to use the global minimal gas price, which is fetched from the celestia-app.
	DefaultGasPrice float64 = -1.0

	DefaultMaxGasPrice = appconsts.DefaultMinGasPrice * 100
)
View Source
const (
	TxPriorityLow = iota + 1
	TxPriorityMedium
	TxPriorityHigh
)

Variables

View Source
var ErrGasPriceExceedsLimit = errors.New("state: estimated gas price exceeds max gas price in tx config")
View Source
var (
	ErrInvalidAmount = errors.New("state: amount must be greater than zero")
)

Functions

This section is empty.

Types

type AccAddress

type AccAddress = sdk.AccAddress

AccAddress is an alias to the AccAddress type from Cosmos-SDK.

type Address

type Address struct {
	sdk.Address
}

Address is an alias to the Address type from Cosmos-SDK. It is embedded into a struct to provide a non-interface type for JSON serialization.

func (Address) MarshalJSON added in v0.11.0

func (a Address) MarshalJSON() ([]byte, error)

func (*Address) UnmarshalJSON added in v0.11.0

func (a *Address) UnmarshalJSON(data []byte) error

type Balance

type Balance = sdk.Coin

Balance is an alias to the Coin type from Cosmos-SDK.

type ConfigOption added in v0.15.0

type ConfigOption func(cfg *TxConfig)

ConfigOption is the functional option that is applied to the TxConfig instance to configure parameters.

func WithFeeGranterAddress added in v0.15.0

func WithFeeGranterAddress(granter string) ConfigOption

WithFeeGranterAddress is an option that allows you to specify a GranterAddress to pay the fees.

func WithGas added in v0.15.0

func WithGas(gas uint64) ConfigOption

WithGas is an option that allows to specify Gas. Gas will be calculated in case it wasn't specified.

func WithGasPrice added in v0.15.0

func WithGasPrice(gasPrice float64) ConfigOption

WithGasPrice is an option that allows to specify a GasPrice, which is needed to calculate the fee. In case GasPrice is not specified, the global GasPrice fetched from celestia-app will be used.

func WithKeyName added in v0.15.0

func WithKeyName(key string) ConfigOption

WithKeyName is an option that allows you to specify an KeyName, which is needed to sign the transaction. This key should be associated with the address and stored locally in the key store. Default Account will be used in case it wasn't specified.

func WithMaxGasPrice added in v0.22.1

func WithMaxGasPrice(gasPrice float64) ConfigOption

WithMaxGasPrice is an option that allows you to specify a `maxGasPrice` field.

func WithSignerAddress added in v0.15.0

func WithSignerAddress(address string) ConfigOption

WithSignerAddress is an option that allows you to specify an address, that will sign the transaction. This address must be stored locally in the key store. Default signerAddress will be used in case it wasn't specified.

func WithTxPriority added in v0.22.1

func WithTxPriority(priority int) ConfigOption

WithTxPriority is an option that allows you to specify a priority of the tx.

type CoreAccessor

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

CoreAccessor implements service over a gRPC connection with a celestia-core node.

func NewCoreAccessor

func NewCoreAccessor(
	keyring keyring.Keyring,
	keyname string,
	getter libhead.Head[*header.ExtendedHeader],
	conn *grpc.ClientConn,
	network string,
	metrics *metrics,
	opts ...Option,
) (*CoreAccessor, error)

NewCoreAccessor dials the given celestia-core endpoint and constructs and returns a new CoreAccessor (state service) with the active connection.

func (*CoreAccessor) AccountAddress

func (ca *CoreAccessor) AccountAddress(context.Context) (Address, error)

func (*CoreAccessor) Balance

func (ca *CoreAccessor) Balance(ctx context.Context) (*Balance, error)

func (*CoreAccessor) BalanceForAddress

func (ca *CoreAccessor) BalanceForAddress(ctx context.Context, addr Address) (*Balance, error)

func (*CoreAccessor) BeginRedelegate

func (ca *CoreAccessor) BeginRedelegate(
	ctx context.Context,
	srcValAddr,
	dstValAddr ValAddress,
	amount Int,
	cfg *TxConfig,
) (*TxResponse, error)

func (*CoreAccessor) CancelUnbondingDelegation

func (ca *CoreAccessor) CancelUnbondingDelegation(
	ctx context.Context,
	valAddr ValAddress,
	amount,
	height Int,
	cfg *TxConfig,
) (*TxResponse, error)

func (*CoreAccessor) Delegate

func (ca *CoreAccessor) Delegate(
	ctx context.Context,
	delAddr ValAddress,
	amount Int,
	cfg *TxConfig,
) (*TxResponse, error)

func (*CoreAccessor) GrantFee added in v0.14.0

func (ca *CoreAccessor) GrantFee(
	ctx context.Context,
	grantee AccAddress,
	amount Int,
	cfg *TxConfig,
) (*TxResponse, error)

func (*CoreAccessor) LastPayForBlob added in v0.11.0

func (ca *CoreAccessor) LastPayForBlob() int64

func (*CoreAccessor) PayForBlobCount added in v0.11.0

func (ca *CoreAccessor) PayForBlobCount() int64

func (*CoreAccessor) QueryDelegation

func (ca *CoreAccessor) QueryDelegation(
	ctx context.Context,
	valAddr ValAddress,
) (*stakingtypes.QueryDelegationResponse, error)

func (*CoreAccessor) QueryRedelegations

func (ca *CoreAccessor) QueryRedelegations(
	ctx context.Context,
	srcValAddr,
	dstValAddr ValAddress,
) (*stakingtypes.QueryRedelegationsResponse, error)

func (*CoreAccessor) QueryUnbonding

func (*CoreAccessor) RevokeGrantFee added in v0.14.0

func (ca *CoreAccessor) RevokeGrantFee(
	ctx context.Context,
	grantee AccAddress,
	cfg *TxConfig,
) (*TxResponse, error)

func (*CoreAccessor) Start

func (ca *CoreAccessor) Start(ctx context.Context) error

func (*CoreAccessor) Stop

func (ca *CoreAccessor) Stop(_ context.Context) error

func (*CoreAccessor) SubmitPayForBlob added in v0.7.0

func (ca *CoreAccessor) SubmitPayForBlob(
	ctx context.Context,
	libBlobs []*libshare.Blob,
	cfg *TxConfig,
) (_ *TxResponse, err error)

SubmitPayForBlob builds, signs, and synchronously submits a MsgPayForBlob with additional options defined in `TxConfig`. It blocks until the transaction is committed and returns the TxResponse. The user can specify additional options that can bee applied to the Tx.

func (*CoreAccessor) Transfer

func (ca *CoreAccessor) Transfer(
	ctx context.Context,
	addr AccAddress,
	amount Int,
	cfg *TxConfig,
) (*TxResponse, error)

func (*CoreAccessor) Undelegate

func (ca *CoreAccessor) Undelegate(
	ctx context.Context,
	delAddr ValAddress,
	amount Int,
	cfg *TxConfig,
) (*TxResponse, error)

func (*CoreAccessor) WithMetrics added in v0.28.4

func (ca *CoreAccessor) WithMetrics() error

WithMetrics initializes metrics for the CoreAccessor

type Int

type Int = math.Int

Int is an alias to the Int type from Cosmos-SDK.

type Option added in v0.14.0

type Option func(ca *CoreAccessor)

func WithAdditionalCoreEndpoints added in v0.25.3

func WithAdditionalCoreEndpoints(conns []*grpc.ClientConn) Option

func WithEstimatorService added in v0.22.1

func WithEstimatorService(address string) Option

WithEstimatorService indicates to the CoreAccessor to pass the given address for the estimator service to the TxClient to use for all gas price and usage estimation queries.

func WithEstimatorServiceTLS added in v0.22.1

func WithEstimatorServiceTLS() Option

WithEstimatorServiceTLS indicates to the CoreAccessor to use TLS for the estimator service connection.

func WithTxWorkerAccounts added in v0.28.2

func WithTxWorkerAccounts(workerAccounts int) Option

WithTxWorkerAccounts configures the CoreAccessor to manage the provided number of worker accounts via the TxClient.

  • Value of 0 submits transactions immediately (without a submission queue).
  • Value of 1 uses synchronous submission (submission queue with default signer as author of transactions).
  • Value of > 1 uses parallel submission (submission queue with several accounts submitting blobs). Parallel submission is not guaranteed to include blobs in the same order as they were submitted.

type Tx

type Tx = coretypes.Tx

Tx is an alias to the Tx type from celestia-core.

type TxConfig added in v0.15.0

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

TxConfig specifies additional options that will be applied to the Tx.

func NewTxConfig added in v0.15.0

func NewTxConfig(opts ...ConfigOption) *TxConfig

NewTxConfig constructs a new TxConfig with the provided options. It starts with a DefaultGasPrice and then applies any additional options provided through the variadic parameter.

func (*TxConfig) FeeGranterAddress added in v0.15.0

func (cfg *TxConfig) FeeGranterAddress() string

func (*TxConfig) GasLimit added in v0.15.0

func (cfg *TxConfig) GasLimit() uint64

func (*TxConfig) GasPrice added in v0.15.0

func (cfg *TxConfig) GasPrice() float64

func (*TxConfig) KeyName added in v0.15.0

func (cfg *TxConfig) KeyName() string

func (*TxConfig) MarshalJSON added in v0.15.0

func (cfg *TxConfig) MarshalJSON() ([]byte, error)

func (*TxConfig) MaxGasPrice added in v0.22.1

func (cfg *TxConfig) MaxGasPrice() float64

MaxGasPrice will return the max gas price that the user set in the TxConfig. If no value was set, it will return the default value.

func (*TxConfig) SignerAddress added in v0.15.0

func (cfg *TxConfig) SignerAddress() string

func (*TxConfig) TxPriority added in v0.22.1

func (cfg *TxConfig) TxPriority() TxPriority

func (*TxConfig) UnmarshalJSON added in v0.15.0

func (cfg *TxConfig) UnmarshalJSON(data []byte) error

type TxPriority added in v0.22.1

type TxPriority int

type TxResponse

type TxResponse = sdk.TxResponse

TxResponse is an alias to the TxResponse type from Cosmos-SDK.

type ValAddress

type ValAddress = sdk.ValAddress

ValAddress is an alias to the ValAddress type from Cosmos-SDK.

Jump to

Keyboard shortcuts

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