Documentation ¶
Index ¶
- Constants
- Variables
- func HeadersMatch(expected []*types.Header, headers []*types.Header) bool
- func MakeJWTSecret() (string, [32]byte, error)
- func OracleCheck(packet interface{}, state *OracleState, s *Suite) (interface{}, error)
- func RunGeth(dir string, jwtPath string) (*node.Node, error)
- type Addresses
- type BlockBodiesPacket
- type BlockBodiesRLPPacket
- type BlockBodiesRLPResponse
- type BlockBodiesResponse
- type BlockBody
- type BlockHeadersPacket
- type BlockHeadersRLPPacket
- type BlockHeadersRLPResponse
- type BlockHeadersRequest
- type Chain
- func (c *Chain) ForkID() forkid.ID
- func (c *Chain) GetBlock(number int) *types.Block
- func (c *Chain) GetHeaders(req *GetBlockHeadersPacket) ([]*types.Header, error)
- func (c *Chain) GetSender(idx int) (common.Address, uint64)
- func (c *Chain) Head() *types.Block
- func (c *Chain) Len() int
- func (c *Chain) SignTx(from common.Address, tx *types.Transaction) (*types.Transaction, error)
- func (c *Chain) TD() *big.Int
- type Conn
- type EngineClient
- type GetBlockBodiesPacket
- type GetBlockBodiesRequest
- type GetBlockHeadersPacket
- type GetBlockHeadersRequest
- type GetPooledTransactionsPacket
- type GetPooledTransactionsRequest
- type GetReceiptsPacket
- type GetReceiptsRequest
- type HashOrNumber
- type NewBlockHashesPacket
- type NewBlockPacket
- type NewPooledTransactionHashesPacket
- type NewPooledTransactionHashesPacket68
- type OracleState
- type Packet
- type PacketSpecification
- type PooledTransactionsPacket
- type PooledTransactionsRLPPacket
- type PooledTransactionsRLPResponse
- type PooledTransactionsResponse
- type Proto
- type Receipt
- type ReceiptsPacket
- type ReceiptsRLPPacket
- type ReceiptsRLPResponse
- type ReceiptsResponse
- type StatusPacket
- type Suite
- func (s *Suite) GenPacket(f *filler.Filler, packetType int) (Packet, error)
- func (s *Suite) GetHeaders(req *GetBlockHeadersPacket) ([]*types.Header, error)
- func (s *Suite) InitializeAndConnect() error
- func (s *Suite) ReadMsg(proto Proto, code uint64, msg interface{}) error
- func (s *Suite) SendForkchoiceUpdated() error
- func (s *Suite) SendMsg(proto Proto, code uint64, msg interface{}) error
- func (s *Suite) SendTxs(txs []*types.Transaction) error
- type TransactionsPacket
Constants ¶
const ( StatusMsg = 0x00 NewBlockHashesMsg = 0x01 TransactionsMsg = 0x02 GetBlockHeadersMsg = 0x03 BlockHeadersMsg = 0x04 GetBlockBodiesMsg = 0x05 BlockBodiesMsg = 0x06 NewBlockMsg = 0x07 NewPooledTransactionHashesMsg = 0x08 GetPooledTransactionsMsg = 0x09 PooledTransactionsMsg = 0x0a GetReceiptsMsg = 0x0f ReceiptsMsg = 0x10 )
const (
ETH68 = 68
)
ETH68 Constants to match up protocol versions and messages
const ProtocolName = "eth"
ProtocolName is the official short name of the `eth` protocol used during devp2p capability negotiation.
Variables ¶
var ProtocolVersions = []uint{ETH68}
ProtocolVersions are the supported versions of the `eth` protocol (first is primary).
Functions ¶
func HeadersMatch ¶
HeadersMatch headersMatch returns whether the received headers match the given request
func MakeJWTSecret ¶
func OracleCheck ¶
func OracleCheck(packet interface{}, state *OracleState, s *Suite) (interface{}, error)
OracleCheck 检查并修正生成的数据包,然后更新Oracle状态
Types ¶
type BlockBodiesPacket ¶
type BlockBodiesPacket struct { RequestId uint64 BlockBodiesResponse }
BlockBodiesPacket is the network packet for block content distribution with request ID wrapping.
type BlockBodiesRLPPacket ¶
type BlockBodiesRLPPacket struct { RequestId uint64 BlockBodiesRLPResponse }
BlockBodiesRLPPacket is the BlockBodiesRLPResponse with request ID wrapping.
type BlockBodiesRLPResponse ¶
BlockBodiesRLPResponse is used for replying to block body requests, in cases where we already have them RLP-encoded, and thus can avoid the decode-encode roundtrip.
type BlockBodiesResponse ¶
type BlockBodiesResponse []*BlockBody
BlockBodiesResponse is the network packet for block content distribution.
func (*BlockBodiesResponse) Kind ¶
func (*BlockBodiesResponse) Kind() byte
func (*BlockBodiesResponse) Name ¶
func (*BlockBodiesResponse) Name() string
func (*BlockBodiesResponse) Unpack ¶
func (p *BlockBodiesResponse) Unpack() ([][]*types.Transaction, [][]*types.Header, [][]*types.Withdrawal)
Unpack retrieves the transactions and uncles from the range packet and returns them in a split flat format that's more consistent with the internal data structures.
type BlockBody ¶
type BlockBody struct { Transactions []*types.Transaction // Transactions contained within a block Uncles []*types.Header // Uncles contained within a block Withdrawals []*types.Withdrawal `rlp:"optional"` // Withdrawals contained within a block }
BlockBody represents the data content of a single block.
type BlockHeadersPacket ¶
type BlockHeadersPacket struct { RequestId uint64 BlockHeadersRequest }
BlockHeadersPacket represents a block header response over with request ID wrapping.
type BlockHeadersRLPPacket ¶
type BlockHeadersRLPPacket struct { RequestId uint64 BlockHeadersRLPResponse }
BlockHeadersRLPPacket represents a block header response with request ID wrapping.
type BlockHeadersRLPResponse ¶
BlockHeadersRLPResponse represents a block header response, to use when we already have the headers rlp encoded.
type BlockHeadersRequest ¶
BlockHeadersRequest represents a block header response.
func (*BlockHeadersRequest) Kind ¶
func (*BlockHeadersRequest) Kind() byte
func (*BlockHeadersRequest) Name ¶
func (*BlockHeadersRequest) Name() string
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
func (*Chain) GetHeaders ¶
func (c *Chain) GetHeaders(req *GetBlockHeadersPacket) ([]*types.Header, error)
GetHeaders returns the headers base on an ethGetPacketHeadersPacket.
func (*Chain) GetSender ¶
GetSender returns the address associated with account at the index in the pre-funded accounts list.
func (*Chain) SignTx ¶
func (c *Chain) SignTx(from common.Address, tx *types.Transaction) (*types.Transaction, error)
SignTx signs a transaction for the specified from account, so long as that account was in the hivechain accounts dump.
type Conn ¶
type EngineClient ¶
type EngineClient struct {
// contains filtered or unexported fields
}
EngineClient is a wrapper around engine-related data.
func NewEngineClient ¶
func NewEngineClient(dir, url, jwt string) (*EngineClient, error)
NewEngineClient creates a new engine client.
type GetBlockBodiesPacket ¶
type GetBlockBodiesPacket struct { RequestId uint64 GetBlockBodiesRequest }
GetBlockBodiesPacket represents a block body query with request ID wrapping.
type GetBlockBodiesRequest ¶
GetBlockBodiesRequest represents a block body query.
func (*GetBlockBodiesRequest) Kind ¶
func (*GetBlockBodiesRequest) Kind() byte
func (*GetBlockBodiesRequest) Name ¶
func (*GetBlockBodiesRequest) Name() string
type GetBlockHeadersPacket ¶
type GetBlockHeadersPacket struct { RequestId uint64 *GetBlockHeadersRequest }
GetBlockHeadersPacket represents a block header query with request ID wrapping.
type GetBlockHeadersRequest ¶
type GetBlockHeadersRequest struct { Origin HashOrNumber // Block from which to retrieve headers Amount uint64 // Maximum number of headers to retrieve Skip uint64 // Blocks to skip between consecutive headers Reverse bool // Query direction (false = rising towards latest, true = falling towards genesis) }
GetBlockHeadersRequest represents a block header query.
func (*GetBlockHeadersRequest) Kind ¶
func (*GetBlockHeadersRequest) Kind() byte
func (*GetBlockHeadersRequest) Name ¶
func (*GetBlockHeadersRequest) Name() string
type GetPooledTransactionsPacket ¶
type GetPooledTransactionsPacket struct { RequestId uint64 GetPooledTransactionsRequest }
GetPooledTransactionsPacket represents a transaction query with request ID wrapping.
type GetPooledTransactionsRequest ¶
GetPooledTransactionsRequest represents a transaction query.
func (*GetPooledTransactionsRequest) Kind ¶
func (*GetPooledTransactionsRequest) Kind() byte
func (*GetPooledTransactionsRequest) Name ¶
func (*GetPooledTransactionsRequest) Name() string
type GetReceiptsPacket ¶
type GetReceiptsPacket struct { RequestId uint64 GetReceiptsRequest }
GetReceiptsPacket represents a block receipts query with request ID wrapping.
type GetReceiptsRequest ¶
GetReceiptsRequest represents a block receipts query.
func (*GetReceiptsRequest) Kind ¶
func (*GetReceiptsRequest) Kind() byte
func (*GetReceiptsRequest) Name ¶
func (*GetReceiptsRequest) Name() string
type HashOrNumber ¶
type HashOrNumber struct { Hash common.Hash // Block hash from which to retrieve headers (excludes Number) Number uint64 // Block hash from which to retrieve headers (excludes Hash) }
HashOrNumber is a combined field for specifying an origin block.
type NewBlockHashesPacket ¶
type NewBlockHashesPacket []struct { Hash common.Hash // Hash of one particular block being announced Number uint64 // Number of one particular block being announced }
NewBlockHashesPacket is the network packet for the block announcements.
func (*NewBlockHashesPacket) Kind ¶
func (*NewBlockHashesPacket) Kind() byte
func (*NewBlockHashesPacket) Name ¶
func (*NewBlockHashesPacket) Name() string
type NewBlockPacket ¶
NewBlockPacket is the network packet for the block propagation message.
func (*NewBlockPacket) Kind ¶
func (*NewBlockPacket) Kind() byte
func (*NewBlockPacket) Name ¶
func (*NewBlockPacket) Name() string
type NewPooledTransactionHashesPacket ¶
NewPooledTransactionHashesPacket represents a transaction announcement packet on eth/68 and newer.
func (*NewPooledTransactionHashesPacket) Kind ¶
func (*NewPooledTransactionHashesPacket) Kind() byte
func (*NewPooledTransactionHashesPacket) Name ¶
func (*NewPooledTransactionHashesPacket) Name() string
type NewPooledTransactionHashesPacket68 ¶
NewPooledTransactionHashesPacket68 represents a transaction announcement packet on eth/68 and newer.
type OracleState ¶
type OracleState struct { LatestBlockNumber uint64 TotalDifficulty *big.Int AccountBalances map[common.Address]string AccountNonces map[common.Address]uint64 BlockHashes map[uint64]common.Hash NetworkID uint64 ProtocolVersion uint32 GenesisHash common.Hash PacketHistory []interface{} GasLimit uint64 GenesisConfig *params.ChainConfig GenesisBlock *types.Block GenesisAlloc types.GenesisAlloc CurrentHeader *types.Header Senders map[common.Address]uint64 PendingTransactions []*types.Transaction PendingTransactionMap map[common.Hash]*types.Transaction PendingTransactionTypes map[common.Hash]byte PendingTransactionSizes map[common.Hash]uint32 LastPendingUpdateTime time.Time }
OracleState 用于维护Oracle的状态
type Packet ¶
type Packet interface { Name() string // Name returns a string corresponding to the message type. Kind() byte // Kind returns the message type. }
Packet represents a p2p message in the `eth` protocol.
type PacketSpecification ¶
type PooledTransactionsPacket ¶
type PooledTransactionsPacket struct { RequestId uint64 PooledTransactionsResponse }
PooledTransactionsPacket is the network packet for transaction distribution with request ID wrapping.
type PooledTransactionsRLPPacket ¶
type PooledTransactionsRLPPacket struct { RequestId uint64 PooledTransactionsRLPResponse }
PooledTransactionsRLPPacket is PooledTransactionsRLPResponse with request ID wrapping.
type PooledTransactionsRLPResponse ¶
PooledTransactionsRLPResponse is the network packet for transaction distribution, used in the cases we already have them in rlp-encoded form
type PooledTransactionsResponse ¶
type PooledTransactionsResponse []*types.Transaction
PooledTransactionsResponse is the network packet for transaction distribution.
func (*PooledTransactionsResponse) Kind ¶
func (*PooledTransactionsResponse) Kind() byte
func (*PooledTransactionsResponse) Name ¶
func (*PooledTransactionsResponse) Name() string
type Receipt ¶
type Receipt struct { // Consensus fields: These fields are defined by the Yellow Paper Type uint8 `json:"type,omitempty"` PostState []byte `json:"root"` Status uint64 `json:"status"` CumulativeGasUsed uint64 `json:"cumulativeGasUsed" gencodec:"required"` Bloom types.Bloom `json:"logsBloom" gencodec:"required"` Logs []*types.Log `json:"logs" gencodec:"required"` // Implementation fields: These fields are added by geth when processing a transaction. TxHash common.Hash `json:"transactionHash" gencodec:"required"` ContractAddress common.Address `json:"contractAddress"` GasUsed uint64 `json:"gasUsed" gencodec:"required"` EffectiveGasPrice *big.Int `json:"effectiveGasPrice"` // required, but tag omitted for backwards compatibility BlobGasUsed uint64 `json:"blobGasUsed,omitempty"` BlobGasPrice *big.Int `json:"blobGasPrice,omitempty"` // Inclusion information: These fields provide information about the inclusion of the // transaction corresponding to this receipt. BlockHash common.Hash `json:"blockHash,omitempty"` BlockNumber *big.Int `json:"blockNumber,omitempty"` TransactionIndex uint `json:"transactionIndex"` }
Receipt represents the results of a transaction.
type ReceiptsPacket ¶
type ReceiptsPacket struct { RequestId uint64 ReceiptsResponse }
ReceiptsPacket is the network packet for block receipts distribution with request ID wrapping.
type ReceiptsRLPPacket ¶
type ReceiptsRLPPacket struct { RequestId uint64 ReceiptsRLPResponse }
ReceiptsRLPPacket is ReceiptsRLPResponse with request ID wrapping.
type ReceiptsRLPResponse ¶
ReceiptsRLPResponse is used for receipts, when we already have it encoded
type ReceiptsResponse ¶
ReceiptsResponse is the network packet for block receipts distribution.
func (*ReceiptsResponse) Kind ¶
func (*ReceiptsResponse) Kind() byte
func (*ReceiptsResponse) Name ¶
func (*ReceiptsResponse) Name() string
type StatusPacket ¶
type StatusPacket struct { ProtocolVersion uint32 NetworkID uint64 TD *big.Int Head common.Hash Genesis common.Hash ForkID forkid.ID }
StatusPacket is the network packet for the status message.
func (*StatusPacket) Kind ¶
func (*StatusPacket) Kind() byte
func (*StatusPacket) Name ¶
func (*StatusPacket) Name() string
type Suite ¶
func (*Suite) GetHeaders ¶
func (s *Suite) GetHeaders(req *GetBlockHeadersPacket) ([]*types.Header, error)
func (*Suite) InitializeAndConnect ¶
InitializeAndConnect 封装了初始化、连接和对等过程
func (*Suite) SendForkchoiceUpdated ¶
type TransactionsPacket ¶
type TransactionsPacket []*types.Transaction
TransactionsPacket is the network packet for broadcasting new transactions.
func (*TransactionsPacket) Kind ¶
func (*TransactionsPacket) Kind() byte
func (*TransactionsPacket) Name ¶
func (*TransactionsPacket) Name() string