proxy

package
v0.0.0-...-c763619 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: Apache-2.0, Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrNoData

func ErrNoData() error

func GetCertifiedCommit

func GetCertifiedCommit(h int64, client rpcclient.Client, cert lite.Verifier) (types.SignedHeader, error)

GetCertifiedCommit gets the signed header for a given height and certifies it. Returns error if unable to get a proven header.

func GetWithProof

func GetWithProof(prt *merkle.ProofRuntime, key []byte, reqHeight int64, node rpcclient.Client,
	cert lite.Verifier) (
	val bytes.HexBytes, height int64, proof *merkle.Proof, err error)

GetWithProof will query the key on the given node, and verify it has a valid proof, as defined by the Verifier.

If there is any error in checking, returns an error.

func GetWithProofOptions

func GetWithProofOptions(prt *merkle.ProofRuntime, path string, key []byte, opts rpcclient.ABCIQueryOptions,
	node rpcclient.Client, cert lite.Verifier) (
	*ctypes.ResultABCIQuery, error)

GetWithProofOptions is useful if you want full access to the ABCIQueryOptions. XXX Usage of path? It's not used, and sometimes it's /, sometimes /key, sometimes /store.

func IsErrNoData

func IsErrNoData(err error) bool

IsErrNoData checks whether an error is due to a query returning empty data

func NewVerifier

func NewVerifier(
	chainID,
	rootDir string,
	client lclient.SignStatusClient,
	logger log.Logger,
	cacheSize int,
) (*lite.DynamicVerifier, error)

func RPCRoutes

func RPCRoutes(c rpcclient.Client) map[string]*rpcserver.RPCFunc

RPCRoutes just routes everything to the given client, as if it were a tendermint fullnode.

if we want security, the client must implement it as a secure client

func StartProxy

func StartProxy(c rpcclient.Client, listenAddr string, logger log.Logger, maxOpenConnections int) error

StartProxy will start the websocket manager on the client, set up the rpc routes to proxy via the given client, and start up an http/rpc server on the location given by bind (eg. :1234) NOTE: This function blocks - you may want to call it in a go-routine.

func ValidateBlock

func ValidateBlock(meta *types.Block, sh types.SignedHeader) error

func ValidateBlockMeta

func ValidateBlockMeta(meta *types.BlockMeta, sh types.SignedHeader) error

func ValidateHeader

func ValidateHeader(head *types.Header, sh types.SignedHeader) error

func VerifyEx

func VerifyEx(cert lite.Verifier, sh types.SignedHeader) error

note: validators will sort by power when the globalHeight is gt the veneus1Height when that happens ,Verifier#verify will be failed because of `globalHeight` is always '0' case1: height is lt veneus1Height: L56: cert#Verify will success case2: height is gt veneus1Height: L56 shoudle be failed ,L168 wil success

Types

type Wrapper

type Wrapper struct {
	rpcclient.Client
	// contains filtered or unexported fields
}

Wrapper wraps a rpcclient with a Verifier and double-checks any input that is provable before passing it along. Allows you to make any rpcclient fully secure.

func SecureClient

func SecureClient(c rpcclient.Client, cert *lite.DynamicVerifier) Wrapper

SecureClient uses a given Verifier to wrap an connection to an untrusted host and return a cryptographically secure rpc client.

If it is wrapping an HTTP rpcclient, it will also wrap the websocket interface

func (Wrapper) ABCIQuery

func (w Wrapper) ABCIQuery(path string, data bytes.HexBytes) (*ctypes.ResultABCIQuery, error)

ABCIQuery uses default options for the ABCI query and verifies the returned proof

func (Wrapper) ABCIQueryWithOptions

func (w Wrapper) ABCIQueryWithOptions(path string, data bytes.HexBytes,
	opts rpcclient.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)

ABCIQueryWithOptions exposes all options for the ABCI query and verifies the returned proof

func (Wrapper) Block

func (w Wrapper) Block(height *int64) (*ctypes.ResultBlock, error)

Block returns an entire block and verifies all signatures

func (Wrapper) BlockchainInfo

func (w Wrapper) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)

BlockchainInfo requests a list of headers and verifies them all... Rather expensive.

TODO: optimize this if used for anything needing performance

func (Wrapper) Commit

func (w Wrapper) Commit(height *int64) (*ctypes.ResultCommit, error)

Commit downloads the Commit and certifies it with the lite.

This is the foundation for all other verification in this module

func (Wrapper) LatestBlockNumber

func (w Wrapper) LatestBlockNumber() (int64, error)

func (Wrapper) RegisterOpDecoder

func (w Wrapper) RegisterOpDecoder(typ string, dec merkle.OpDecoder)

func (Wrapper) SubscribeWS

func (w Wrapper) SubscribeWS(ctx *rpctypes.Context, query string) (*ctypes.ResultSubscribe, error)

SubscribeWS subscribes for events using the given query and remote address as a subscriber, but does not verify responses (UNSAFE)!

func (Wrapper) Tx

func (w Wrapper) Tx(hash []byte, prove bool) (*ctypes.ResultTx, error)

Tx queries for a given tx and verifies the proof if it was requested

func (Wrapper) UnsubscribeAllWS

func (w Wrapper) UnsubscribeAllWS(ctx *rpctypes.Context) (*ctypes.ResultUnsubscribe, error)

UnsubscribeAllWS calls original client's UnsubscribeAll using remote address as a subscriber.

func (Wrapper) UnsubscribeWS

func (w Wrapper) UnsubscribeWS(ctx *rpctypes.Context, query string) (*ctypes.ResultUnsubscribe, error)

UnsubscribeWS calls original client's Unsubscribe using remote address as a subscriber.

Jump to

Keyboard shortcuts

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