message

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: GPL-3.0, LGPL-3.0 Imports: 17 Imported by: 15

Documentation

Index

Constants

View Source
const (
	// EthMsgSoftCapSize is the ideal size of encoded transaction bytes we send in
	// any [EthTxsGossip] or [AtomicTxGossip] message. We do not limit inbound messages to
	// this size, however. Max inbound message size is enforced by the codec
	// (512KB).
	EthMsgSoftCapSize = 64 * units.KiB
)
View Source
const MaxCodeHashesPerRequest = 5
View Source
const (
	Version = uint16(0)
)

Variables

View Source
var (
	Codec           codec.Manager
	CrossChainCodec codec.Manager
)

Functions

func BuildGossipMessage added in v0.8.7

func BuildGossipMessage(codec codec.Manager, msg GossipMessage) ([]byte, error)

func RequestToBytes added in v0.8.5

func RequestToBytes(codec codec.Manager, request Request) ([]byte, error)

RequestToBytes marshals the given request object into bytes

Types

type AtomicTxGossip added in v0.8.7

type AtomicTxGossip struct {
	Tx []byte `serialize:"true"`
}

func (AtomicTxGossip) Handle added in v0.8.7

func (msg AtomicTxGossip) Handle(handler GossipHandler, nodeID ids.NodeID) error

func (AtomicTxGossip) String added in v0.8.7

func (msg AtomicTxGossip) String() string

type BlockRequest added in v0.8.7

type BlockRequest struct {
	Hash    common.Hash `serialize:"true"`
	Height  uint64      `serialize:"true"`
	Parents uint16      `serialize:"true"`
}

BlockRequest is a request to retrieve Parents number of blocks starting from Hash from newest-oldest manner

func (BlockRequest) Handle added in v0.8.7

func (b BlockRequest) Handle(ctx context.Context, nodeID ids.NodeID, requestID uint32, handler RequestHandler) ([]byte, error)

func (BlockRequest) String added in v0.8.7

func (b BlockRequest) String() string

type BlockResponse added in v0.8.7

type BlockResponse struct {
	Blocks [][]byte `serialize:"true"`
}

BlockResponse is a response to a BlockRequest Blocks is slice of RLP encoded blocks starting with the block requested in BlockRequest.Hash. The next block is the parent, etc. handler: handlers.BlockRequestHandler

type BlockSignatureRequest added in v0.12.10

type BlockSignatureRequest struct {
	BlockID ids.ID `serialize:"true"`
}

BlockSignatureRequest is used to request a warp message's signature.

func (BlockSignatureRequest) Handle added in v0.12.10

func (s BlockSignatureRequest) Handle(ctx context.Context, nodeID ids.NodeID, requestID uint32, handler RequestHandler) ([]byte, error)

func (BlockSignatureRequest) String added in v0.12.10

func (s BlockSignatureRequest) String() string

type CodeRequest added in v0.8.7

type CodeRequest struct {
	// Hashes is a list of contract code hashes
	Hashes []common.Hash `serialize:"true"`
}

CodeRequest is a request to retrieve a contract code with specified Hash

func NewCodeRequest added in v0.8.7

func NewCodeRequest(hashes []common.Hash) CodeRequest

func (CodeRequest) Handle added in v0.8.7

func (c CodeRequest) Handle(ctx context.Context, nodeID ids.NodeID, requestID uint32, handler RequestHandler) ([]byte, error)

func (CodeRequest) String added in v0.8.7

func (c CodeRequest) String() string

type CodeResponse added in v0.8.7

type CodeResponse struct {
	Data [][]byte `serialize:"true"`
}

CodeResponse is a response to a CodeRequest crypto.Keccak256Hash of each element in Data is expected to equal the corresponding element in CodeRequest.Hashes handler: handlers.CodeRequestHandler

type CrossChainRequest added in v0.11.5

type CrossChainRequest interface {
	// CrossChainRequest should implement String() for logging.
	fmt.Stringer

	// Handle allows [CrossChainRequest] to call respective methods on handler to handle
	// this particular request type
	Handle(ctx context.Context, requestingChainID ids.ID, requestID uint32, handler CrossChainRequestHandler) ([]byte, error)
}

CrossChainRequest represents the interface a cross chain request should implement

type CrossChainRequestHandler added in v0.11.5

type CrossChainRequestHandler interface {
	HandleEthCallRequest(ctx context.Context, requestingchainID ids.ID, requestID uint32, ethCallRequest EthCallRequest) ([]byte, error)
}

CrossChainRequestHandler interface handles incoming requests from another chain

func NewCrossChainHandler added in v0.11.5

func NewCrossChainHandler(b ethapi.Backend, codec codec.Manager) CrossChainRequestHandler

NewCrossChainHandler creates and returns a new instance of CrossChainRequestHandler

type EthCallRequest added in v0.11.5

type EthCallRequest struct {
	RequestArgs []byte `serialize:"true"`
}

EthCallRequest has the JSON Data necessary to execute a new EVM call on the blockchain

func (EthCallRequest) Handle added in v0.11.5

func (e EthCallRequest) Handle(ctx context.Context, requestingChainID ids.ID, requestID uint32, handler CrossChainRequestHandler) ([]byte, error)

Handle returns the encoded EthCallResponse by executing EVM call with the given EthCallRequest

func (EthCallRequest) String added in v0.11.5

func (e EthCallRequest) String() string

String converts EthCallRequest to a string

type EthCallResponse added in v0.11.5

type EthCallResponse struct {
	ExecutionResult []byte `serialize:"true"`
}

EthCallResponse represents the JSON return value of the executed EVM call

type EthTxsGossip added in v0.8.7

type EthTxsGossip struct {
	Txs []byte `serialize:"true"`
}

func (EthTxsGossip) Handle added in v0.8.7

func (msg EthTxsGossip) Handle(handler GossipHandler, nodeID ids.NodeID) error

func (EthTxsGossip) String added in v0.8.7

func (msg EthTxsGossip) String() string

type GossipHandler added in v0.8.5

type GossipHandler interface {
	HandleAtomicTx(nodeID ids.NodeID, msg AtomicTxGossip) error
	HandleEthTxs(nodeID ids.NodeID, msg EthTxsGossip) error
}

GossipHandler handles incoming gossip messages

type GossipMessage added in v0.8.7

type GossipMessage interface {
	// types implementing GossipMessage should also implement fmt.Stringer for logging purposes.
	fmt.Stringer

	// Handle this gossip message with the gossip handler.
	Handle(handler GossipHandler, nodeID ids.NodeID) error
}

func ParseGossipMessage added in v0.8.7

func ParseGossipMessage(codec codec.Manager, bytes []byte) (GossipMessage, error)

type LeafsRequest added in v0.8.7

type LeafsRequest struct {
	Root     common.Hash `serialize:"true"`
	Account  common.Hash `serialize:"true"`
	Start    []byte      `serialize:"true"`
	End      []byte      `serialize:"true"`
	Limit    uint16      `serialize:"true"`
	NodeType NodeType    `serialize:"true"`
}

LeafsRequest is a request to receive trie leaves at specified Root within Start and End byte range Limit outlines maximum number of leaves to returns starting at Start NodeType outlines which trie to read from state/atomic.

func (LeafsRequest) Handle added in v0.8.7

func (l LeafsRequest) Handle(ctx context.Context, nodeID ids.NodeID, requestID uint32, handler RequestHandler) ([]byte, error)

func (LeafsRequest) String added in v0.8.7

func (l LeafsRequest) String() string

type LeafsResponse added in v0.8.7

type LeafsResponse struct {
	// Keys and Vals provides the key-value pairs in the trie in the response.
	Keys [][]byte `serialize:"true"`
	Vals [][]byte `serialize:"true"`

	// More indicates if there are more leaves to the right of the last value in this response.
	//
	// This is not serialized since it is set in the client after verifying the response via
	// VerifyRangeProof and determining if there are in fact more leaves to the right of the
	// last value in this response.
	More bool

	// ProofVals contain the edge merkle-proofs for the range of keys included in the response.
	// The keys for the proof are simply the keccak256 hashes of the values, so they are not included in the response to save bandwidth.
	ProofVals [][]byte `serialize:"true"`
}

LeafsResponse is a response to a LeafsRequest Keys must be within LeafsRequest.Start and LeafsRequest.End and sorted in lexicographical order.

ProofVals must be non-empty and contain a valid range proof unless the key-value pairs in the response are the entire trie. If the key-value pairs make up the entire trie, ProofVals should be empty since the root will be sufficient to prove that the leaves are included in the trie.

More is a flag set in the client after verifying the response, which indicates if the last key-value pair in the response has any more elements to its right within the trie.

type MessageSignatureRequest added in v0.12.10

type MessageSignatureRequest struct {
	MessageID ids.ID `serialize:"true"`
}

MessageSignatureRequest is used to request a warp message's signature.

func (MessageSignatureRequest) Handle added in v0.12.10

func (s MessageSignatureRequest) Handle(ctx context.Context, nodeID ids.NodeID, requestID uint32, handler RequestHandler) ([]byte, error)

func (MessageSignatureRequest) String added in v0.12.10

func (s MessageSignatureRequest) String() string

type NodeType added in v0.8.7

type NodeType uint8

NodeType outlines the trie that a leaf node belongs to handlers.LeafsRequestHandler uses this information to determine which of the two tries (state/atomic) to fetch the information from

const (
	// StateTrieNode represents a leaf node that belongs to the coreth State trie
	StateTrieNode NodeType = iota + 1
	// AtomicTrieNode represents a leaf node that belongs to the coreth evm.AtomicTrie
	AtomicTrieNode
)

func (NodeType) String added in v0.8.7

func (nt NodeType) String() string

type NoopCrossChainRequestHandler added in v0.11.5

type NoopCrossChainRequestHandler struct{}

func (NoopCrossChainRequestHandler) HandleEthCallRequest added in v0.11.5

func (NoopCrossChainRequestHandler) HandleEthCallRequest(ctx context.Context, requestingchainID ids.ID, requestID uint32, ethCallRequest EthCallRequest) ([]byte, error)

type NoopMempoolGossipHandler added in v0.8.5

type NoopMempoolGossipHandler struct{}

func (NoopMempoolGossipHandler) HandleAtomicTx added in v0.8.5

func (NoopMempoolGossipHandler) HandleAtomicTx(nodeID ids.NodeID, msg AtomicTxGossip) error

func (NoopMempoolGossipHandler) HandleEthTxs added in v0.8.5

func (NoopMempoolGossipHandler) HandleEthTxs(nodeID ids.NodeID, msg EthTxsGossip) error

type NoopRequestHandler added in v0.8.10

type NoopRequestHandler struct{}

func (NoopRequestHandler) HandleAtomicTrieLeafsRequest added in v0.8.10

func (NoopRequestHandler) HandleAtomicTrieLeafsRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, leafsRequest LeafsRequest) ([]byte, error)

func (NoopRequestHandler) HandleBlockRequest added in v0.8.10

func (NoopRequestHandler) HandleBlockRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, request BlockRequest) ([]byte, error)

func (NoopRequestHandler) HandleBlockSignatureRequest added in v0.12.10

func (NoopRequestHandler) HandleBlockSignatureRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, signatureRequest BlockSignatureRequest) ([]byte, error)

func (NoopRequestHandler) HandleCodeRequest added in v0.8.10

func (NoopRequestHandler) HandleCodeRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, codeRequest CodeRequest) ([]byte, error)

func (NoopRequestHandler) HandleMessageSignatureRequest added in v0.12.10

func (NoopRequestHandler) HandleMessageSignatureRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, signatureRequest MessageSignatureRequest) ([]byte, error)

func (NoopRequestHandler) HandleStateTrieLeafsRequest added in v0.8.10

func (NoopRequestHandler) HandleStateTrieLeafsRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, leafsRequest LeafsRequest) ([]byte, error)

type Request added in v0.8.5

type Request interface {
	// Requests should implement String() for logging.
	fmt.Stringer

	// Handle allows `Request` to call respective methods on handler to handle
	// this particular request type
	Handle(ctx context.Context, nodeID ids.NodeID, requestID uint32, handler RequestHandler) ([]byte, error)
}

Request represents a Network request type

func BytesToRequest added in v0.8.5

func BytesToRequest(codec codec.Manager, requestBytes []byte) (Request, error)

BytesToRequest unmarshals the given requestBytes into Request object

type RequestHandler added in v0.8.5

type RequestHandler interface {
	HandleStateTrieLeafsRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, leafsRequest LeafsRequest) ([]byte, error)
	HandleAtomicTrieLeafsRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, leafsRequest LeafsRequest) ([]byte, error)
	HandleBlockRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, request BlockRequest) ([]byte, error)
	HandleCodeRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, codeRequest CodeRequest) ([]byte, error)
	HandleMessageSignatureRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, signatureRequest MessageSignatureRequest) ([]byte, error)
	HandleBlockSignatureRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, signatureRequest BlockSignatureRequest) ([]byte, error)
}

RequestHandler interface handles incoming requests from peers Must have methods in format of handleType(context.Context, ids.NodeID, uint32, request Type) error so that the Request object of relevant Type can invoke its respective handle method on this struct. Also see GossipHandler for implementation style.

type ResponseHandler added in v0.8.5

type ResponseHandler interface {
	// OnResponse is invoked when the peer responded to a request
	OnResponse(response []byte) error
	// OnFailure is invoked when there was a failure in processing a request
	OnFailure() error
}

ResponseHandler handles response for a sent request Only one of OnResponse or OnFailure is called for a given requestID, not both

type SignatureResponse added in v0.12.10

type SignatureResponse struct {
	Signature [bls.SignatureLen]byte `serialize:"true"`
}

SignatureResponse is the response to a BlockSignatureRequest or MessageSignatureRequest. The response contains a BLS signature of the requested message, signed by the responding node's BLS private key.

type SyncSummary added in v0.8.10

type SyncSummary struct {
	BlockNumber uint64      `serialize:"true"`
	BlockHash   common.Hash `serialize:"true"`
	BlockRoot   common.Hash `serialize:"true"`
	AtomicRoot  common.Hash `serialize:"true"`
	// contains filtered or unexported fields
}

SyncSummary provides the information necessary to sync a node starting at the given block.

func NewSyncSummary added in v0.8.10

func NewSyncSummary(blockHash common.Hash, blockNumber uint64, blockRoot common.Hash, atomicRoot common.Hash) (SyncSummary, error)

func NewSyncSummaryFromBytes added in v0.8.10

func NewSyncSummaryFromBytes(summaryBytes []byte, acceptImpl func(SyncSummary) (block.StateSyncMode, error)) (SyncSummary, error)

func (SyncSummary) Accept added in v0.8.10

func (SyncSummary) Bytes added in v0.8.10

func (s SyncSummary) Bytes() []byte

func (SyncSummary) Height added in v0.8.10

func (s SyncSummary) Height() uint64

func (SyncSummary) ID added in v0.8.10

func (s SyncSummary) ID() ids.ID

func (SyncSummary) String added in v0.8.10

func (s SyncSummary) String() string

Jump to

Keyboard shortcuts

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