state

package
v0.0.0-...-4b51c2d Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccountTrieNodeType         byte = 0x20
	ContractStorageTrieNodeType byte = 0x21
	ContractByteCodeType        byte = 0x22
)
View Source
const MaxContractBytecodeLength = 32768
View Source
const MaxTrieNodeLength = 1024
View Source
const MaxTrieProofLength = 65

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	*portalwire.PortalProtocolAPI
}

func NewStateNetworkAPI

func NewStateNetworkAPI(portalProtocolAPI *portalwire.PortalProtocolAPI) *API

func (*API) StateAddEnr

func (p *API) StateAddEnr(enr string) (bool, error)

func (*API) StateDeleteEnr

func (p *API) StateDeleteEnr(nodeId string) (bool, error)

func (*API) StateFindContent

func (p *API) StateFindContent(enr string, contentKey string) (interface{}, error)

func (*API) StateFindNodes

func (p *API) StateFindNodes(enr string, distances []uint) ([]string, error)

func (*API) StateGetContent

func (p *API) StateGetContent(contentKeyHex string) (*portalwire.ContentInfo, error)

func (*API) StateGetEnr

func (p *API) StateGetEnr(nodeId string) (string, error)

func (*API) StateGossip

func (p *API) StateGossip(contentKeyHex, contentHex string) (int, error)

func (*API) StateLocalContent

func (p *API) StateLocalContent(contentKeyHex string) (string, error)

func (*API) StateLookupEnr

func (p *API) StateLookupEnr(nodeId string) (string, error)

func (*API) StateOffer

func (p *API) StateOffer(enr string, contentItems [][2]string) (string, error)

func (*API) StatePing

func (p *API) StatePing(enr string) (*portalwire.PortalPongResp, error)

func (*API) StateRecursiveFindNodes

func (p *API) StateRecursiveFindNodes(nodeId string) ([]string, error)

func (*API) StateRoutingTableInfo

func (p *API) StateRoutingTableInfo() *portalwire.RoutingTableInfo

func (*API) StateStore

func (p *API) StateStore(contentKeyHex string, contextHex string) (bool, error)

func (*API) StateTraceGetContent

func (p *API) StateTraceGetContent(contentKeyHex string) (*portalwire.TraceContentResult, error)

type AccountTrieNodeKey

type AccountTrieNodeKey struct {
	Path     Nibbles
	NodeHash common.Bytes32
}

AccountTrieNodeKey test data from https://github.com/ethereum/portal-network-specs/blob/master/state/state-network-test-vectors.md

func (*AccountTrieNodeKey) ByteLength

func (a *AccountTrieNodeKey) ByteLength(spec *common.Spec) uint64

func (*AccountTrieNodeKey) Deserialize

func (a *AccountTrieNodeKey) Deserialize(dr *codec.DecodingReader) error

func (*AccountTrieNodeKey) FixedLength

func (a *AccountTrieNodeKey) FixedLength(spec *common.Spec) uint64

func (*AccountTrieNodeKey) HashTreeRoot

func (a *AccountTrieNodeKey) HashTreeRoot(spec *common.Spec, hFn tree.HashFn) common.Root

func (*AccountTrieNodeKey) Serialize

func (a *AccountTrieNodeKey) Serialize(w *codec.EncodingWriter) error

type AccountTrieNodeWithProof

type AccountTrieNodeWithProof struct {
	/// An proof for the account trie node.
	Proof TrieProof
	/// A block at which the proof is anchored.
	BlockHash common.Bytes32
}

AccountTrieNodeWithProof A content value type, used when offering a trie node from the account trie.

func (*AccountTrieNodeWithProof) ByteLength

func (a *AccountTrieNodeWithProof) ByteLength() uint64

func (*AccountTrieNodeWithProof) Deserialize

func (a *AccountTrieNodeWithProof) Deserialize(dr *codec.DecodingReader) error

func (*AccountTrieNodeWithProof) FixedLength

func (a *AccountTrieNodeWithProof) FixedLength() uint64

func (*AccountTrieNodeWithProof) HashTreeRoot

func (a *AccountTrieNodeWithProof) HashTreeRoot(hFn tree.HashFn) common.Root

func (*AccountTrieNodeWithProof) Serialize

type ContractByteCode

type ContractByteCode []byte

func (ContractByteCode) ByteLength

func (t ContractByteCode) ByteLength() (out uint64)

func (*ContractByteCode) Deserialize

func (t *ContractByteCode) Deserialize(dr *codec.DecodingReader) error

func (*ContractByteCode) FixedLength

func (t *ContractByteCode) FixedLength() uint64

func (ContractByteCode) HashTreeRoot

func (t ContractByteCode) HashTreeRoot(hFn tree.HashFn) tree.Root

func (ContractByteCode) Serialize

func (t ContractByteCode) Serialize(w *codec.EncodingWriter) error

type ContractBytecodeContainer

type ContractBytecodeContainer struct {
	Code ContractByteCode
}

ContractBytecodeContainer A content value type, used when retrieving contract's bytecode.

func (ContractBytecodeContainer) ByteLength

func (t ContractBytecodeContainer) ByteLength() (out uint64)

func (*ContractBytecodeContainer) Deserialize

func (*ContractBytecodeContainer) FixedLength

func (t *ContractBytecodeContainer) FixedLength() uint64

func (ContractBytecodeContainer) HashTreeRoot

func (t ContractBytecodeContainer) HashTreeRoot(hFn tree.HashFn) tree.Root

func (ContractBytecodeContainer) Serialize

type ContractBytecodeKey

type ContractBytecodeKey struct {
	AddressHash common.Bytes32
	CodeHash    common.Bytes32
}

func (*ContractBytecodeKey) ByteLength

func (c *ContractBytecodeKey) ByteLength(spec *common.Spec) uint64

func (*ContractBytecodeKey) Deserialize

func (c *ContractBytecodeKey) Deserialize(dr *codec.DecodingReader) error

func (*ContractBytecodeKey) FixedLength

func (c *ContractBytecodeKey) FixedLength(spec *common.Spec) uint64

func (*ContractBytecodeKey) HashTreeRoot

func (c *ContractBytecodeKey) HashTreeRoot(spec *common.Spec, hFn tree.HashFn) common.Root

func (*ContractBytecodeKey) Serialize

func (c *ContractBytecodeKey) Serialize(w *codec.EncodingWriter) error

type ContractBytecodeWithProof

type ContractBytecodeWithProof struct {
	// A contract's bytecode.
	Code ContractByteCode
	// A proof for the account state of the corresponding contract.
	AccountProof TrieProof
	// A block at which the proof is anchored.
	BlockHash common.Bytes32
}

ContractBytecodeWithProof A content value type, used when offering contract's bytecode.

func (*ContractBytecodeWithProof) ByteLength

func (c *ContractBytecodeWithProof) ByteLength() uint64

func (*ContractBytecodeWithProof) Deserialize

func (*ContractBytecodeWithProof) FixedLength

func (c *ContractBytecodeWithProof) FixedLength() uint64

func (*ContractBytecodeWithProof) HashTreeRoot

func (c *ContractBytecodeWithProof) HashTreeRoot(hFn tree.HashFn) common.Root

func (*ContractBytecodeWithProof) Serialize

type ContractStorageTrieNodeKey

type ContractStorageTrieNodeKey struct {
	AddressHash common.Bytes32
	Path        Nibbles
	NodeHash    common.Bytes32
}

func (*ContractStorageTrieNodeKey) ByteLength

func (c *ContractStorageTrieNodeKey) ByteLength(spec *common.Spec) uint64

func (*ContractStorageTrieNodeKey) Deserialize

func (*ContractStorageTrieNodeKey) FixedLength

func (c *ContractStorageTrieNodeKey) FixedLength(spec *common.Spec) uint64

func (*ContractStorageTrieNodeKey) HashTreeRoot

func (c *ContractStorageTrieNodeKey) HashTreeRoot(spec *common.Spec, hFn tree.HashFn) common.Root

func (*ContractStorageTrieNodeKey) Serialize

type ContractStorageTrieNodeWithProof

type ContractStorageTrieNodeWithProof struct {
	// A proof for the contract storage trie node.
	StorageProof TrieProof
	// A proof for the account state.
	AccountProof TrieProof
	// A block at which the proof is anchored.
	BlockHash common.Bytes32
}

ContractStorageTrieNodeWithProof A content value type, used when offering a trie node from the contract storage trie.

func (*ContractStorageTrieNodeWithProof) ByteLength

func (c *ContractStorageTrieNodeWithProof) ByteLength() uint64

func (*ContractStorageTrieNodeWithProof) Deserialize

func (*ContractStorageTrieNodeWithProof) FixedLength

func (c *ContractStorageTrieNodeWithProof) FixedLength() uint64

func (*ContractStorageTrieNodeWithProof) HashTreeRoot

func (*ContractStorageTrieNodeWithProof) Serialize

type EncodedTrieNode

type EncodedTrieNode []byte

func (EncodedTrieNode) ByteLength

func (e EncodedTrieNode) ByteLength() (out uint64)

func (*EncodedTrieNode) Deserialize

func (e *EncodedTrieNode) Deserialize(dr *codec.DecodingReader) error

func (*EncodedTrieNode) FixedLength

func (e *EncodedTrieNode) FixedLength() uint64

func (EncodedTrieNode) HashTreeRoot

func (e EncodedTrieNode) HashTreeRoot(hFn tree.HashFn) tree.Root

func (*EncodedTrieNode) NodeHash

func (e *EncodedTrieNode) NodeHash() common.Bytes32

func (EncodedTrieNode) Serialize

func (e EncodedTrieNode) Serialize(w *codec.EncodingWriter) error

type Network

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

func NewStateNetwork

func NewStateNetwork(portalProtocol *portalwire.PortalProtocol, client *rpc.Client) *Network

func (*Network) Start

func (h *Network) Start() error

func (*Network) Stop

func (h *Network) Stop()

type Nibbles

type Nibbles struct {
	Nibbles []byte
}

func FromUnpackedNibbles

func FromUnpackedNibbles(nibbles []byte) (*Nibbles, error)

func (*Nibbles) ByteLength

func (n *Nibbles) ByteLength() uint64

func (*Nibbles) Deserialize

func (n *Nibbles) Deserialize(dr *codec.DecodingReader) error

func (*Nibbles) FixedLength

func (n *Nibbles) FixedLength() uint64

func (*Nibbles) HashTreeRoot

func (n *Nibbles) HashTreeRoot(h tree.HashFn) tree.Root

func (*Nibbles) Serialize

func (n *Nibbles) Serialize(w *codec.EncodingWriter) error

type Storage

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

func NewStateStorage

func NewStateStorage(store storage.ContentStorage, db *pebble.DB) *Storage

func (*Storage) Close

func (s *Storage) Close() error

func (*Storage) Get

func (s *Storage) Get(contentKey []byte, contentId []byte) ([]byte, error)

Get implements storage.ContentStorage.

func (*Storage) Put

func (s *Storage) Put(contentKey []byte, contentId []byte, content []byte) error

Put implements storage.ContentStorage.

func (*Storage) Radius

func (s *Storage) Radius() *uint256.Int

Radius implements storage.ContentStorage.

type TrieNode

type TrieNode struct {
	Node EncodedTrieNode
}

TrieNode A content value type, used when retrieving a trie node.

func (TrieNode) ByteLength

func (t TrieNode) ByteLength() (out uint64)

func (*TrieNode) Deserialize

func (t *TrieNode) Deserialize(dr *codec.DecodingReader) error

func (*TrieNode) FixedLength

func (t *TrieNode) FixedLength() uint64

func (TrieNode) HashTreeRoot

func (t TrieNode) HashTreeRoot(hFn tree.HashFn) tree.Root

func (TrieNode) Serialize

func (t TrieNode) Serialize(w *codec.EncodingWriter) error

type TrieProof

type TrieProof []EncodedTrieNode

func (TrieProof) ByteLength

func (r TrieProof) ByteLength() (out uint64)

func (*TrieProof) Deserialize

func (r *TrieProof) Deserialize(dr *codec.DecodingReader) error

func (*TrieProof) FixedLength

func (r *TrieProof) FixedLength() uint64

func (TrieProof) HashTreeRoot

func (r TrieProof) HashTreeRoot(hFn tree.HashFn) common.Root

func (TrieProof) Serialize

func (r TrieProof) Serialize(w *codec.EncodingWriter) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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