ccq

package
v0.0.0-...-753386a Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const CCQ_SERVER_SIGNING_KEY = "CCQ SERVER SIGNING KEY"
View Source
const DEV_NETWORK_ID = "/wormhole/dev"
View Source
const ETH_CALL_SIG_LENGTH = 4
View Source
const MAX_BODY_SIZE = 5 * 1024 * 1024

Variables

View Source
var QueryServerCmd = &cobra.Command{
	Use:   "query-server",
	Short: "Run the cross-chain query server",
	Run:   runQueryServer,
}

Functions

func FetchCurrentGuardianSet

func FetchCurrentGuardianSet(rpcUrl, coreAddr string) (*common.GuardianSet, error)

func NewHTTPServer

func NewHTTPServer(addr string, t *pubsub.Topic, permissions *Permissions, signerKey *ecdsa.PrivateKey, p *PendingResponses, logger *zap.Logger, env common.Environment, loggingMap *LoggingMap) *http.Server

func NewStatusServer

func NewStatusServer(addr string, logger *zap.Logger, env common.Environment) *statusServer

func RunPrometheusScraper

func RunPrometheusScraper(ctx context.Context, logger *zap.Logger, info promremotew.PromTelemetryInfo) error

Types

type AllowedCall

type AllowedCall struct {
	EthCall             *EthCall             `json:"ethCall"`
	EthCallByTimestamp  *EthCallByTimestamp  `json:"ethCallByTimestamp"`
	EthCallWithFinality *EthCallWithFinality `json:"ethCallWithFinality"`
	SolanaAccount       *SolanaAccount       `json:"solAccount"`
	SolanaPda           *SolanaPda           `json:"solPDA"`
}

type Config

type Config struct {
	AllowAnythingSupported bool    `json:"AllowAnythingSupported"`
	DefaultRateLimit       float64 `json:"DefaultRateLimit"`
	DefaultBurstSize       int     `json:"DefaultBurstSize"`
	Permissions            []User  `json:"Permissions"`
}

type ErrorEntry

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

type EthCall

type EthCall struct {
	Chain           int    `json:"chain"`
	ContractAddress string `json:"contractAddress"`
	Call            string `json:"call"`
}

type EthCallByTimestamp

type EthCallByTimestamp struct {
	Chain           int    `json:"chain"`
	ContractAddress string `json:"contractAddress"`
	Call            string `json:"call"`
}

type EthCallWithFinality

type EthCallWithFinality struct {
	Chain           int    `json:"chain"`
	ContractAddress string `json:"contractAddress"`
	Call            string `json:"call"`
}

type GuardianSignature

type GuardianSignature struct {
	Index     int
	Signature string
}

type LoggingMap

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

LoggingMap is used to track the requests for which we should log response. It contains a map keyed by the request signature where the payload is time the request was received. Requests will be removed from the map after two minutes.

func NewLoggingMap

func NewLoggingMap() *LoggingMap

NewLoggingMap creates the map used to track requests for which we should log responses.

func (*LoggingMap) AddRequest

func (lm *LoggingMap) AddRequest(requestSignature string)

AddRequest adds a request to the map, giving it an expiration time two minutes into the future.

func (*LoggingMap) CleanUp

func (lm *LoggingMap) CleanUp(logger *zap.Logger)

CleanUp iterates over the map and removes all entries that are more than two minutes old.

func (*LoggingMap) ShouldLogResponse

func (lm *LoggingMap) ShouldLogResponse(requestSignature string) bool

ShouldLogResponse returns true if the request is in the map.

func (*LoggingMap) Start

func (lm *LoggingMap) Start(ctx context.Context, logger *zap.Logger, errC chan error)

Start starts a go routine to clean up requests that have been in the map for two minutes.

type P2PSub

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

type PendingResponse

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

func NewPendingResponse

func NewPendingResponse(req *gossipv1.SignedQueryRequest, userName string, queryRequest *query.QueryRequest) *PendingResponse

type PendingResponses

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

func NewPendingResponses

func NewPendingResponses(logger *zap.Logger) *PendingResponses

func (*PendingResponses) Add

func (*PendingResponses) Get

func (p *PendingResponses) Get(signature string) *PendingResponse

func (*PendingResponses) NumPending

func (p *PendingResponses) NumPending() int

func (*PendingResponses) Remove

func (p *PendingResponses) Remove(r *PendingResponse)

type Permissions

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

func NewPermissions

func NewPermissions(fileName string, env common.Environment) (*Permissions, error)

NewPermissions creates a Permissions object which contains the per-user permissions.

func (*Permissions) GetUserEntry

func (perms *Permissions) GetUserEntry(apiKey string) (*permissionEntry, bool)

GetUserEntry returns the permissions entry for a given API key. It uses the lock to protect against updates.

func (*Permissions) Reload

func (perms *Permissions) Reload(logger *zap.Logger)

Reload reloads the permissions file.

func (*Permissions) StartWatcher

func (perms *Permissions) StartWatcher(ctx context.Context, logger *zap.Logger, errC chan error)

StartWatcher creates an fswatcher to watch for updates to the permissions file and reload it when it changes.

func (*Permissions) StopWatcher

func (perms *Permissions) StopWatcher()

StopWatcher stops the permissions file watcher.

type PermissionsMap

type PermissionsMap map[string]*permissionEntry

type SignedResponse

type SignedResponse struct {
	Response   *query.QueryResponsePublication
	Signatures []GuardianSignature
}

type SolanaAccount

type SolanaAccount struct {
	Chain   int    `json:"chain"`
	Account string `json:"account"`
}

type SolanaPda

type SolanaPda struct {
	Chain          int    `json:"chain"`
	ProgramAddress string `json:"programAddress"`
}

type User

type User struct {
	UserName      string        `json:"userName"`
	ApiKey        string        `json:"apiKey"`
	AllowUnsigned bool          `json:"allowUnsigned"`
	AllowAnything bool          `json:"allowAnything"`
	RateLimit     *float64      `json:"RateLimit"`
	BurstSize     *int          `json:"BurstSize"`
	LogResponses  bool          `json:"logResponses"`
	AllowedCalls  []AllowedCall `json:"allowedCalls"`
}

Jump to

Keyboard shortcuts

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