query

package
v0.0.0-...-3ea1ddd Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 18 Imported by: 13

Documentation

Index

Constants

View Source
const (
	// RequestTimeout indicates how long before a request is considered to have timed out.
	RequestTimeout = 1 * time.Minute

	// RetryInterval specifies how long we will wait between retry intervals.
	RetryInterval = 10 * time.Second

	// AuditInterval specifies how often to audit the list of pending queries.
	AuditInterval = time.Second

	// SignedQueryRequestChannelSize is the buffer size of the incoming query request channel.
	SignedQueryRequestChannelSize = 500

	// QueryRequestBufferSize is the buffer size of the per-network query request channel.
	QueryRequestBufferSize = 250

	// QueryResponseBufferSize is the buffer size of the single query response channel from the watchers.
	QueryResponseBufferSize = 500

	// QueryResponsePublicationChannelSize is the buffer size of the single query response channel back to the P2P publisher.
	QueryResponsePublicationChannelSize = 500
)
View Source
const EvmContractAddressLength = 20
View Source
const MSG_VERSION uint8 = 1

MSG_VERSION is the current version of the CCQ message protocol.

View Source
const SolanaMaxAccountsPerQuery = 100

According to the spec, the query only supports up to 100 accounts. https://github.com/solana-labs/solana/blob/9d132441fdc6282a8be4bff0bc77d6a2fefe8b59/rpc-client-api/src/request.rs#L204

View Source
const SolanaMaxCommitmentLength = 12

According to the Solana spec, the longest comment string is nine characters. Allow a few more, just in case. https://pkg.go.dev/github.com/gagliardetto/solana-go/rpc#CommitmentType

View Source
const SolanaMaxSeedLen = solana.MaxSeedLength

According to the spec, a seed may be at most 32 bytes. https://github.com/gagliardetto/solana-go/blob/6fe3aea02e3660d620433444df033fc3fe6e64c1/keys.go#L557

View Source
const SolanaMaxSeeds = solana.MaxSeeds

According to the spec, there may be at most 16 seeds. https://github.com/gagliardetto/solana-go/blob/6fe3aea02e3660d620433444df033fc3fe6e64c1/keys.go#L559

View Source
const SolanaPublicKeyLength = solana.PublicKeyLength

Solana public keys are fixed length.

Variables

View Source
var (
	TotalWatcherTime = promauto.NewHistogramVec(
		prometheus.HistogramOpts{
			Name:    "ccq_guardian_total_watcher_query_time_in_ms",
			Help:    "Time from time spent in the watcher per query in ms by chain",
			Buckets: []float64{1.0, 5.0, 10.0, 100.0, 250.0, 500.0, 1000.0, 5000.0, 10000.0, 30000.0},
		}, []string{"chain_name"})
)

Functions

func GetQueryResponseDigestFromBytes

func GetQueryResponseDigestFromBytes(b []byte) common.Hash

GetQueryResponseDigestFromBytes computes the digest bytes for a query response byte array.

func PostSignedQueryRequest

func PostSignedQueryRequest(signedQueryReqSendC chan<- *gossipv1.SignedQueryRequest, req *gossipv1.SignedQueryRequest) error

PostSignedQueryRequest posts a signed query request to the specified channel.

func QueryRequestDigest

func QueryRequestDigest(env common.Environment, b []byte) ethCommon.Hash

QueryRequestDigest returns the query signing prefix based on the environment.

func SignedQueryRequestEqual

func SignedQueryRequestEqual(left *gossipv1.SignedQueryRequest, right *gossipv1.SignedQueryRequest) bool

func StartWorkers

func StartWorkers(
	ctx context.Context,
	logger *zap.Logger,
	errC chan error,
	w Watcher,
	queryReqC <-chan *PerChainQueryInternal,
	config PerChainConfig,
	tag string,
)

StartWorkers is used by the watchers to start the query handler worker routines.

func ValidatePerChainQueryRequestType

func ValidatePerChainQueryRequestType(qt ChainSpecificQueryType) error

Types

type ChainSpecificQuery

type ChainSpecificQuery interface {
	Type() ChainSpecificQueryType
	Marshal() ([]byte, error)
	Unmarshal(data []byte) error
	UnmarshalFromReader(reader *bytes.Reader) error
	Validate() error
}

ChainSpecificQuery is the interface that must be implemented by a chain specific query.

type ChainSpecificQueryType

type ChainSpecificQueryType uint8

ChainSpecificQueryType is used to interpret the data in a per chain query request.

const EthCallByTimestampQueryRequestType ChainSpecificQueryType = 2

EthCallByTimestampQueryRequestType is the type of an EVM eth_call_by_timestamp query request.

const EthCallQueryRequestType ChainSpecificQueryType = 1

EthCallQueryRequestType is the type of an EVM eth_call query request.

const EthCallWithFinalityQueryRequestType ChainSpecificQueryType = 3

EthCallWithFinalityQueryRequestType is the type of an EVM eth_call_with_finality query request.

const SolanaAccountQueryRequestType ChainSpecificQueryType = 4

SolanaAccountQueryRequestType is the type of a Solana sol_account query request.

const SolanaPdaQueryRequestType ChainSpecificQueryType = 5

SolanaPdaQueryRequestType is the type of a Solana sol_pda query request.

type ChainSpecificResponse

type ChainSpecificResponse interface {
	Type() ChainSpecificQueryType
	Marshal() ([]byte, error)
	Unmarshal(data []byte) error
	UnmarshalFromReader(reader *bytes.Reader) error
	Validate() error
}

ChainSpecificResponse is the interface that must be implemented by a chain specific response.

type EthCallByTimestampQueryRequest

type EthCallByTimestampQueryRequest struct {
	// TargetTimeInUs specifies the desired timestamp in microseconds.
	TargetTimestamp uint64

	// TargetBlockIdHint is optional. If specified, it identifies the block prior to the desired timestamp. It must be a hex string starting with 0x. It may be a block number or a block hash.
	TargetBlockIdHint string

	// FollowingBlockIdHint is optional. If specified, it identifies the block immediately following the desired timestamp. It must be a hex string starting with 0x. It may be a block number or a block hash.
	FollowingBlockIdHint string

	// CallData is an array of specific queries to be performed on the specified block, in a single RPC call.
	CallData []*EthCallData
}

EthCallByTimestampQueryRequest implements ChainSpecificQuery for an EVM eth_call_by_timestamp query request.

func (*EthCallByTimestampQueryRequest) CallDataList

func (ecr *EthCallByTimestampQueryRequest) CallDataList() []*EthCallData

func (*EthCallByTimestampQueryRequest) Equal

Equal verifies that two EVM eth_call_by_timestamp queries are equal.

func (*EthCallByTimestampQueryRequest) Marshal

func (ecd *EthCallByTimestampQueryRequest) Marshal() ([]byte, error)

Marshal serializes the binary representation of an EVM eth_call_by_timestamp request. This method calls Validate() and relies on it to range checks lengths, etc.

func (*EthCallByTimestampQueryRequest) Type

func (*EthCallByTimestampQueryRequest) Unmarshal

func (ecd *EthCallByTimestampQueryRequest) Unmarshal(data []byte) error

Unmarshal deserializes an EVM eth_call_by_timestamp query from a byte array

func (*EthCallByTimestampQueryRequest) UnmarshalFromReader

func (ecd *EthCallByTimestampQueryRequest) UnmarshalFromReader(reader *bytes.Reader) error

UnmarshalFromReader deserializes an EVM eth_call_by_timestamp query from a byte array

func (*EthCallByTimestampQueryRequest) Validate

func (ecd *EthCallByTimestampQueryRequest) Validate() error

Validate does basic validation on an EVM eth_call_by_timestamp query.

type EthCallByTimestampQueryResponse

type EthCallByTimestampQueryResponse struct {
	TargetBlockNumber    uint64
	TargetBlockHash      common.Hash
	TargetBlockTime      time.Time
	FollowingBlockNumber uint64
	FollowingBlockHash   common.Hash
	FollowingBlockTime   time.Time

	// Results is the array of responses matching CallData in EthCallByTimestampQueryRequest
	Results [][]byte
}

EthCallByTimestampQueryResponse implements ChainSpecificResponse for an EVM eth_call_by_timestamp query response.

func (*EthCallByTimestampQueryResponse) Equal

Equal verifies that two EVM eth_call_by_timestamp responses are equal.

func (*EthCallByTimestampQueryResponse) Marshal

func (ecr *EthCallByTimestampQueryResponse) Marshal() ([]byte, error)

Marshal serializes the binary representation of an EVM eth_call_by_timestamp response. This method calls Validate() and relies on it to range checks lengths, etc.

func (*EthCallByTimestampQueryResponse) Type

func (*EthCallByTimestampQueryResponse) Unmarshal

func (ecr *EthCallByTimestampQueryResponse) Unmarshal(data []byte) error

Unmarshal deserializes an EVM eth_call_by_timestamp response from a byte array

func (*EthCallByTimestampQueryResponse) UnmarshalFromReader

func (ecr *EthCallByTimestampQueryResponse) UnmarshalFromReader(reader *bytes.Reader) error

UnmarshalFromReader deserializes an EVM eth_call_by_timestamp response from a byte array

func (*EthCallByTimestampQueryResponse) Validate

func (ecr *EthCallByTimestampQueryResponse) Validate() error

Validate does basic validation on an EVM eth_call_by_timestamp response.

type EthCallData

type EthCallData struct {
	// To specifies the contract address to be queried.
	To []byte

	// Data is the ABI encoded parameters to the query.
	Data []byte
}

EthCallData specifies the parameters to a single EVM eth_call request.

type EthCallQueryRequest

type EthCallQueryRequest struct {
	// BlockId identifies the block to be queried. It must be a hex string starting with 0x. It may be a block number or a block hash.
	BlockId string

	// CallData is an array of specific queries to be performed on the specified block, in a single RPC call.
	CallData []*EthCallData
}

EthCallQueryRequest implements ChainSpecificQuery for an EVM eth_call query request.

func (*EthCallQueryRequest) CallDataList

func (ecr *EthCallQueryRequest) CallDataList() []*EthCallData

func (*EthCallQueryRequest) Equal

func (left *EthCallQueryRequest) Equal(right *EthCallQueryRequest) bool

Equal verifies that two EVM eth_call queries are equal.

func (*EthCallQueryRequest) Marshal

func (ecd *EthCallQueryRequest) Marshal() ([]byte, error)

Marshal serializes the binary representation of an EVM eth_call request. This method calls Validate() and relies on it to range checks lengths, etc.

func (*EthCallQueryRequest) Type

func (*EthCallQueryRequest) Unmarshal

func (ecd *EthCallQueryRequest) Unmarshal(data []byte) error

Unmarshal deserializes an EVM eth_call query from a byte array

func (*EthCallQueryRequest) UnmarshalFromReader

func (ecd *EthCallQueryRequest) UnmarshalFromReader(reader *bytes.Reader) error

UnmarshalFromReader deserializes an EVM eth_call query from a byte array

func (*EthCallQueryRequest) Validate

func (ecd *EthCallQueryRequest) Validate() error

Validate does basic validation on an EVM eth_call query.

type EthCallQueryResponse

type EthCallQueryResponse struct {
	BlockNumber uint64
	Hash        common.Hash
	Time        time.Time

	// Results is the array of responses matching CallData in EthCallQueryRequest
	Results [][]byte
}

EthCallQueryResponse implements ChainSpecificResponse for an EVM eth_call query response.

func (*EthCallQueryResponse) Equal

func (left *EthCallQueryResponse) Equal(right *EthCallQueryResponse) bool

Equal verifies that two EVM eth_call responses are equal.

func (*EthCallQueryResponse) Marshal

func (ecr *EthCallQueryResponse) Marshal() ([]byte, error)

Marshal serializes the binary representation of an EVM eth_call response. This method calls Validate() and relies on it to range checks lengths, etc.

func (*EthCallQueryResponse) Type

func (*EthCallQueryResponse) Unmarshal

func (ecr *EthCallQueryResponse) Unmarshal(data []byte) error

Unmarshal deserializes an EVM eth_call response from a byte array

func (*EthCallQueryResponse) UnmarshalFromReader

func (ecr *EthCallQueryResponse) UnmarshalFromReader(reader *bytes.Reader) error

UnmarshalFromReader deserializes an EVM eth_call response from a byte array

func (*EthCallQueryResponse) Validate

func (ecr *EthCallQueryResponse) Validate() error

Validate does basic validation on an EVM eth_call response.

type EthCallWithFinalityQueryRequest

type EthCallWithFinalityQueryRequest struct {
	// BlockId identifies the block to be queried. It must be a hex string starting with 0x. It may be a block number or a block hash.
	BlockId string

	// Finality is required. It identifies the level of finality the block must reach before the query is performed. Valid values are "finalized" and "safe".
	Finality string

	// CallData is an array of specific queries to be performed on the specified block, in a single RPC call.
	CallData []*EthCallData
}

EthCallWithFinalityQueryRequest implements ChainSpecificQuery for an EVM eth_call_with_finality query request.

func (*EthCallWithFinalityQueryRequest) CallDataList

func (ecr *EthCallWithFinalityQueryRequest) CallDataList() []*EthCallData

func (*EthCallWithFinalityQueryRequest) Equal

Equal verifies that two EVM eth_call_with_finality queries are equal.

func (*EthCallWithFinalityQueryRequest) Marshal

func (ecd *EthCallWithFinalityQueryRequest) Marshal() ([]byte, error)

Marshal serializes the binary representation of an EVM eth_call_with_finality request. This method calls Validate() and relies on it to range checks lengths, etc.

func (*EthCallWithFinalityQueryRequest) Type

func (*EthCallWithFinalityQueryRequest) Unmarshal

func (ecd *EthCallWithFinalityQueryRequest) Unmarshal(data []byte) error

Unmarshal deserializes an EVM eth_call_with_finality query from a byte array

func (*EthCallWithFinalityQueryRequest) UnmarshalFromReader

func (ecd *EthCallWithFinalityQueryRequest) UnmarshalFromReader(reader *bytes.Reader) error

UnmarshalFromReader deserializes an EVM eth_call_with_finality query from a byte array

func (*EthCallWithFinalityQueryRequest) Validate

func (ecd *EthCallWithFinalityQueryRequest) Validate() error

Validate does basic validation on an EVM eth_call_with_finality query.

type EthCallWithFinalityQueryResponse

type EthCallWithFinalityQueryResponse struct {
	BlockNumber uint64
	Hash        common.Hash
	Time        time.Time

	// Results is the array of responses matching CallData in EthCallQueryRequest
	Results [][]byte
}

EthCallWithFinalityQueryResponse implements ChainSpecificResponse for an EVM eth_call_with_finality query response.

func (*EthCallWithFinalityQueryResponse) Equal

Equal verifies that two EVM eth_call_with_finality responses are equal.

func (*EthCallWithFinalityQueryResponse) Marshal

func (ecr *EthCallWithFinalityQueryResponse) Marshal() ([]byte, error)

Marshal serializes the binary representation of an EVM eth_call_with_finality response. This method calls Validate() and relies on it to range checks lengths, etc.

func (*EthCallWithFinalityQueryResponse) Type

func (*EthCallWithFinalityQueryResponse) Unmarshal

func (ecr *EthCallWithFinalityQueryResponse) Unmarshal(data []byte) error

Unmarshal deserializes an EVM eth_call_with_finality response from a byte array

func (*EthCallWithFinalityQueryResponse) UnmarshalFromReader

func (ecr *EthCallWithFinalityQueryResponse) UnmarshalFromReader(reader *bytes.Reader) error

UnmarshalFromReader deserializes an EVM eth_call_with_finality response from a byte array

func (*EthCallWithFinalityQueryResponse) Validate

func (ecr *EthCallWithFinalityQueryResponse) Validate() error

Validate does basic validation on an EVM eth_call_with_finality response.

type PerChainConfig

type PerChainConfig struct {
	TimestampCacheSupported bool
	NumWorkers              int
}

func GetPerChainConfig

func GetPerChainConfig(chainID vaa.ChainID) PerChainConfig

GetPerChainConfig returns the config for the specified chain. If the chain is not configured it returns an empty struct, which is not an error. It just means that queries are not supported for that chain.

func (PerChainConfig) QueriesSupported

func (config PerChainConfig) QueriesSupported() bool

QueriesSupported can be used by the watcher to determine if queries are supported for the chain.

type PerChainQueryInternal

type PerChainQueryInternal struct {
	RequestID  string
	RequestIdx int
	Request    *PerChainQueryRequest
}

PerChainQueryInternal is an internal representation of a query request that is passed to the watcher.

func (*PerChainQueryInternal) ID

func (pcqi *PerChainQueryInternal) ID() string

type PerChainQueryRequest

type PerChainQueryRequest struct {
	// ChainId indicates which chain this query is destine for.
	ChainId vaa.ChainID

	// Query is the chain specific query data.
	Query ChainSpecificQuery
}

PerChainQueryRequest represents a query request for a single chain.

func (*PerChainQueryRequest) Equal

func (left *PerChainQueryRequest) Equal(right *PerChainQueryRequest) bool

Equal verifies that two query requests are equal.

func (*PerChainQueryRequest) Marshal

func (perChainQuery *PerChainQueryRequest) Marshal() ([]byte, error)

Marshal serializes the binary representation of a per chain query request. This method calls Validate() and relies on it to range checks lengths, etc.

func (*PerChainQueryRequest) Unmarshal

func (perChainQuery *PerChainQueryRequest) Unmarshal(data []byte) error

Unmarshal deserializes the binary representation of a per chain query request from a byte array

func (*PerChainQueryRequest) UnmarshalFromReader

func (perChainQuery *PerChainQueryRequest) UnmarshalFromReader(reader *bytes.Reader) error

UnmarshalFromReader deserializes the binary representation of a per chain query request from an existing reader

func (*PerChainQueryRequest) Validate

func (perChainQuery *PerChainQueryRequest) Validate() error

Validate does basic validation on a per chain query request.

type PerChainQueryResponse

type PerChainQueryResponse struct {
	// ChainId indicates which chain this query was destine for.
	ChainId vaa.ChainID

	// Response is the chain specific query data.
	Response ChainSpecificResponse
}

PerChainQueryResponse represents a query response for a single chain.

func (*PerChainQueryResponse) Equal

func (left *PerChainQueryResponse) Equal(right *PerChainQueryResponse) bool

Equal checks for equality on two per chain query responses.

func (*PerChainQueryResponse) Marshal

func (perChainResponse *PerChainQueryResponse) Marshal() ([]byte, error)

Marshal marshalls a per chain query response.

func (*PerChainQueryResponse) Unmarshal

func (perChainResponse *PerChainQueryResponse) Unmarshal(data []byte) error

Unmarshal deserializes the binary representation of a per chain query response from a byte array

func (*PerChainQueryResponse) UnmarshalFromReader

func (perChainResponse *PerChainQueryResponse) UnmarshalFromReader(reader *bytes.Reader) error

UnmarshalFromReader deserializes the binary representation of a per chain query response from an existing reader

func (*PerChainQueryResponse) Validate

func (perChainResponse *PerChainQueryResponse) Validate() error

ValidatePerChainResponse performs basic validation on a per chain query response.

type PerChainQueryResponseInternal

type PerChainQueryResponseInternal struct {
	RequestID  string
	RequestIdx int
	ChainId    vaa.ChainID
	Status     QueryStatus
	Response   ChainSpecificResponse
}

This is the query response returned from the watcher to the query handler.

func CreatePerChainQueryResponseInternal

func CreatePerChainQueryResponseInternal(reqId string, reqIdx int, chainId vaa.ChainID, status QueryStatus, response ChainSpecificResponse) *PerChainQueryResponseInternal

CreatePerChainQueryResponseInternal creates a PerChainQueryResponseInternal and returns a pointer to it.

type QueryHandler

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

QueryHandler defines the cross chain query handler.

func NewQueryHandler

func NewQueryHandler(
	logger *zap.Logger,
	env common.Environment,
	allowedRequestorsStr string,
	signedQueryReqC <-chan *gossipv1.SignedQueryRequest,
	chainQueryReqC map[vaa.ChainID]chan *PerChainQueryInternal,
	queryResponseReadC <-chan *PerChainQueryResponseInternal,
	queryResponseWriteC chan<- *QueryResponsePublication,
) *QueryHandler

func (*QueryHandler) Start

func (qh *QueryHandler) Start(ctx context.Context) error

Start initializes the query handler and starts the runnable.

type QueryRequest

type QueryRequest struct {
	Nonce           uint32
	PerChainQueries []*PerChainQueryRequest
}

QueryRequest defines a cross chain query request to be submitted to the guardians. It is the payload of the SignedQueryRequest gossip message.

func (*QueryRequest) Equal

func (left *QueryRequest) Equal(right *QueryRequest) bool

Equal verifies that two query requests are equal.

func (*QueryRequest) Marshal

func (queryRequest *QueryRequest) Marshal() ([]byte, error)

Marshal serializes the binary representation of a query request. This method calls Validate() and relies on it to range checks lengths, etc.

func (*QueryRequest) Unmarshal

func (queryRequest *QueryRequest) Unmarshal(data []byte) error

Unmarshal deserializes the binary representation of a query request from a byte array

func (*QueryRequest) UnmarshalFromReader

func (queryRequest *QueryRequest) UnmarshalFromReader(reader *bytes.Reader) error

UnmarshalFromReader deserializes the binary representation of a query request from an existing reader

func (*QueryRequest) Validate

func (queryRequest *QueryRequest) Validate() error

Validate does basic validation on a received query request.

type QueryResponsePublication

type QueryResponsePublication struct {
	Request           *gossipv1.SignedQueryRequest
	PerChainResponses []*PerChainQueryResponse
}

QueryResponsePublication is the response to a QueryRequest.

func (*QueryResponsePublication) Equal

Equal checks for equality on two query response publications.

func (*QueryResponsePublication) Marshal

func (msg *QueryResponsePublication) Marshal() ([]byte, error)

Marshal serializes the binary representation of a query response. This method calls Validate() and relies on it to range checks lengths, etc.

func (*QueryResponsePublication) Signature

func (resp *QueryResponsePublication) Signature() string

func (*QueryResponsePublication) SigningDigest

func (msg *QueryResponsePublication) SigningDigest() (common.Hash, error)

Similar to sdk/vaa/structs.go, In order to save space in the solana signature verification instruction, we hash twice so we only need to pass in the first hash (32 bytes) vs the full body data.

func (*QueryResponsePublication) Unmarshal

func (msg *QueryResponsePublication) Unmarshal(data []byte) error

Unmarshal deserializes the binary representation of a query response

func (*QueryResponsePublication) Validate

func (msg *QueryResponsePublication) Validate() error

Validate does basic validation on a received query request.

type QueryStatus

type QueryStatus int

QueryStatus is the status returned from the watcher to the query handler.

const (
	// QuerySuccess means the query was successful and the response should be returned to the requester.
	QuerySuccess QueryStatus = 1

	// QueryRetryNeeded means the query failed, but a retry may be helpful.
	QueryRetryNeeded QueryStatus = 0

	// QueryFatalError means the query failed, and there is no point in retrying it.
	QueryFatalError QueryStatus = -1
)

type SolanaAccountQueryRequest

type SolanaAccountQueryRequest struct {
	// Commitment identifies the commitment level to be used in the queried. Currently it may only "finalized".
	// Before we can support "confirmed", we need a way to read the account data and the block information atomically.
	// We would also need to deal with the fact that queries are only handled in the finalized watcher and it does not
	// have access to the latest confirmed slot needed for MinContextSlot retries.
	Commitment string

	// The minimum slot that the request can be evaluated at. Zero means unused.
	MinContextSlot uint64

	// The offset of the start of data to be returned. Unused if DataSliceLength is zero.
	DataSliceOffset uint64

	// The length of the data to be returned. Zero means all data is returned.
	DataSliceLength uint64

	// Accounts is an array of accounts to be queried.
	Accounts [][SolanaPublicKeyLength]byte
}

SolanaAccountQueryRequest implements ChainSpecificQuery for a Solana sol_account query request.

func (*SolanaAccountQueryRequest) AccountList

func (*SolanaAccountQueryRequest) Equal

Equal verifies that two Solana sol_account queries are equal.

func (*SolanaAccountQueryRequest) Marshal

func (saq *SolanaAccountQueryRequest) Marshal() ([]byte, error)

Marshal serializes the binary representation of a Solana sol_account request. This method calls Validate() and relies on it to range checks lengths, etc.

func (*SolanaAccountQueryRequest) Type

func (*SolanaAccountQueryRequest) Unmarshal

func (saq *SolanaAccountQueryRequest) Unmarshal(data []byte) error

Unmarshal deserializes a Solana sol_account query from a byte array

func (*SolanaAccountQueryRequest) UnmarshalFromReader

func (saq *SolanaAccountQueryRequest) UnmarshalFromReader(reader *bytes.Reader) error

UnmarshalFromReader deserializes a Solana sol_account query from a byte array

func (*SolanaAccountQueryRequest) Validate

func (saq *SolanaAccountQueryRequest) Validate() error

Validate does basic validation on a Solana sol_account query.

type SolanaAccountQueryResponse

type SolanaAccountQueryResponse struct {
	// SlotNumber is the slot number returned by the sol_account query
	SlotNumber uint64

	// BlockTime is the block time associated with the slot.
	BlockTime time.Time

	// BlockHash is the block hash associated with the slot.
	BlockHash [SolanaPublicKeyLength]byte

	Results []SolanaAccountResult
}

SolanaAccountQueryResponse implements ChainSpecificResponse for a Solana sol_account query response.

func (*SolanaAccountQueryResponse) Equal

Equal verifies that two Solana sol_account responses are equal.

func (*SolanaAccountQueryResponse) Marshal

func (sar *SolanaAccountQueryResponse) Marshal() ([]byte, error)

Marshal serializes the binary representation of a Solana sol_account response. This method calls Validate() and relies on it to range check lengths, etc.

func (*SolanaAccountQueryResponse) Type

func (*SolanaAccountQueryResponse) Unmarshal

func (sar *SolanaAccountQueryResponse) Unmarshal(data []byte) error

Unmarshal deserializes a Solana sol_account response from a byte array

func (*SolanaAccountQueryResponse) UnmarshalFromReader

func (sar *SolanaAccountQueryResponse) UnmarshalFromReader(reader *bytes.Reader) error

UnmarshalFromReader deserializes a Solana sol_account response from a byte array

func (*SolanaAccountQueryResponse) Validate

func (sar *SolanaAccountQueryResponse) Validate() error

Validate does basic validation on a Solana sol_account response.

type SolanaAccountResult

type SolanaAccountResult struct {
	// Lamports is the number of lamports assigned to the account.
	Lamports uint64

	// RentEpoch is the epoch at which this account will next owe rent.
	RentEpoch uint64

	// Executable is a boolean indicating if the account contains a program (and is strictly read-only).
	Executable bool

	// Owner is the public key of the owner of the account.
	Owner [SolanaPublicKeyLength]byte

	// Data is the data returned by the sol_account query.
	Data []byte
}

type SolanaPDAEntry

type SolanaPDAEntry struct {
	ProgramAddress [SolanaPublicKeyLength]byte
	Seeds          [][]byte
}

SolanaPDAEntry defines a single Solana Program derived address (PDA).

type SolanaPdaQueryRequest

type SolanaPdaQueryRequest struct {
	// Commitment identifies the commitment level to be used in the queried. Currently it may only "finalized".
	// Before we can support "confirmed", we need a way to read the account data and the block information atomically.
	// We would also need to deal with the fact that queries are only handled in the finalized watcher and it does not
	// have access to the latest confirmed slot needed for MinContextSlot retries.
	Commitment string

	// The minimum slot that the request can be evaluated at. Zero means unused.
	MinContextSlot uint64

	// The offset of the start of data to be returned. Unused if DataSliceLength is zero.
	DataSliceOffset uint64

	// The length of the data to be returned. Zero means all data is returned.
	DataSliceLength uint64

	// PDAs is an array of PDAs to be queried.
	PDAs []SolanaPDAEntry
}

SolanaPdaQueryRequest implements ChainSpecificQuery for a Solana sol_pda query request.

func (*SolanaPdaQueryRequest) Equal

func (left *SolanaPdaQueryRequest) Equal(right *SolanaPdaQueryRequest) bool

Equal verifies that two Solana sol_pda queries are equal.

func (*SolanaPdaQueryRequest) Marshal

func (spda *SolanaPdaQueryRequest) Marshal() ([]byte, error)

Marshal serializes the binary representation of a Solana sol_pda request. This method calls Validate() and relies on it to range checks lengths, etc.

func (*SolanaPdaQueryRequest) PDAList

func (spda *SolanaPdaQueryRequest) PDAList() []SolanaPDAEntry

func (*SolanaPdaQueryRequest) Type

func (*SolanaPdaQueryRequest) Unmarshal

func (spda *SolanaPdaQueryRequest) Unmarshal(data []byte) error

Unmarshal deserializes a Solana sol_pda query from a byte array

func (*SolanaPdaQueryRequest) UnmarshalFromReader

func (spda *SolanaPdaQueryRequest) UnmarshalFromReader(reader *bytes.Reader) error

UnmarshalFromReader deserializes a Solana sol_pda query from a byte array

func (*SolanaPdaQueryRequest) Validate

func (spda *SolanaPdaQueryRequest) Validate() error

Validate does basic validation on a Solana sol_pda query.

type SolanaPdaQueryResponse

type SolanaPdaQueryResponse struct {
	// SlotNumber is the slot number returned by the sol_pda query
	SlotNumber uint64

	// BlockTime is the block time associated with the slot.
	BlockTime time.Time

	// BlockHash is the block hash associated with the slot.
	BlockHash [SolanaPublicKeyLength]byte

	Results []SolanaPdaResult
}

SolanaPdaQueryResponse implements ChainSpecificResponse for a Solana sol_pda query response.

func (*SolanaPdaQueryResponse) Equal

Equal verifies that two Solana sol_pda responses are equal.

func (*SolanaPdaQueryResponse) Marshal

func (sar *SolanaPdaQueryResponse) Marshal() ([]byte, error)

Marshal serializes the binary representation of a Solana sol_pda response. This method calls Validate() and relies on it to range check lengths, etc.

func (*SolanaPdaQueryResponse) Type

func (*SolanaPdaQueryResponse) Unmarshal

func (sar *SolanaPdaQueryResponse) Unmarshal(data []byte) error

Unmarshal deserializes a Solana sol_pda response from a byte array

func (*SolanaPdaQueryResponse) UnmarshalFromReader

func (sar *SolanaPdaQueryResponse) UnmarshalFromReader(reader *bytes.Reader) error

UnmarshalFromReader deserializes a Solana sol_pda response from a byte array

func (*SolanaPdaQueryResponse) Validate

func (sar *SolanaPdaQueryResponse) Validate() error

Validate does basic validation on a Solana sol_pda response.

type SolanaPdaResult

type SolanaPdaResult struct {
	// Account is the public key of the account derived from the PDA.
	Account [SolanaPublicKeyLength]byte

	// Bump is the bump value returned by the solana derivation function.
	Bump uint8

	// Lamports is the number of lamports assigned to the account.
	Lamports uint64

	// RentEpoch is the epoch at which this account will next owe rent.
	RentEpoch uint64

	// Executable is a boolean indicating if the account contains a program (and is strictly read-only).
	Executable bool

	// Owner is the public key of the owner of the account.
	Owner [SolanaPublicKeyLength]byte

	// Data is the data returned by the sol_pda query.
	Data []byte
}

type Watcher

type Watcher interface {
	QueryHandler(ctx context.Context, queryRequest *PerChainQueryInternal)
}

Watcher is the interface that any watcher that supports cross chain queries must implement.

Jump to

Keyboard shortcuts

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