query

package
v7.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGeneralizedIndexFromPath

func GetGeneralizedIndexFromPath(info *SszInfo, path Path) (uint64, error)

GetGeneralizedIndexFromPath calculates the generalized index for a given path. To calculate the generalized index, two inputs are needed: 1. The sszInfo of the root object, to be able to navigate the SSZ structure 2. The path to the field (e.g., "field_a.field_b[3].field_c") It walks the path step by step, updating the generalized index at each step.

func PopulateVariableLengthInfo

func PopulateVariableLengthInfo(sszInfo *SszInfo, value reflect.Value) error

PopulateVariableLengthInfo populates runtime information for SSZ fields of variable-sized types. This function updates the SszInfo structure with actual lengths and offsets that can only be determined at runtime for variable-sized items like Lists and variable-sized Container fields.

Types

type Path

type Path struct {
	// If true, the path is querying for the length of the final element in Elements field
	Length bool
	// Sequence of path elements representing the navigation through the SSZ structure
	Elements []PathElement
}

Path represents the entire path structure for SSZ-QL queries. It consists of multiple PathElements and a flag indicating if the path is querying for length.

func ParsePath

func ParsePath(rawPath string) (Path, error)

ParsePath parses a raw path string into a slice of PathElements. note: field names are stored in snake case format. rawPath has to be provided in snake case. 1. Supports dot notation for field access (e.g., "field1.field2"). 2. Supports array indexing using square brackets (e.g., "array_field[0]"). 3. Supports length access using len() notation (e.g., "len(array_field)"). 4. Handles leading dots and validates path format.

type PathElement

type PathElement struct {
	Name string
	// [Optional] Index for List/Vector elements
	Index *uint64
}

PathElement represents a single element in a path.

type SSZDimension

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

SSZDimension holds parsed SSZ tag information for current dimension. Mutually exclusive fields indicate whether the dimension is a vector or a list.

func ParseSSZTag

func ParseSSZTag(tag *reflect.StructTag) (*SSZDimension, *reflect.StructTag, error)

ParseSSZTag parses SSZ-specific tags (like `ssz-max` and `ssz-size`) and returns the first dimension and the remaining SSZ tags. This function validates the tags and returns an error if they are malformed.

func (*SSZDimension) GetListLimit

func (d *SSZDimension) GetListLimit() (uint64, error)

GetListLimit returns the limit for a list in current dimension

func (*SSZDimension) GetVectorLength

func (d *SSZDimension) GetVectorLength() (uint64, error)

GetVectorLength returns the length for a vector in current dimension

func (*SSZDimension) IsList

func (d *SSZDimension) IsList() bool

IsList returns true if this dimension represents a list.

func (*SSZDimension) IsVector

func (d *SSZDimension) IsVector() bool

IsVector returns true if this dimension represents a vector.

type SSZObject

type SSZObject interface {
	HashTreeRoot() ([32]byte, error)
	SizeSSZ() int
}

type SSZType

type SSZType int

SSZType represents the type supported by SSZ. https://github.com/ethereum/consensus-specs/blob/master/ssz/simple-serialize.md#typing

const (
	// Basic types
	Uint8 SSZType = iota
	Uint16
	Uint32
	Uint64
	Boolean

	// Composite types
	Container
	Vector
	List
	Bitvector
	Bitlist

	// Added in EIP-7916
	ProgressiveList
	Union
)

SSZ type constants.

func (SSZType) String

func (t SSZType) String() string

type SszInfo

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

SszInfo holds the all necessary data for analyzing SSZ data types.

func AnalyzeObject

func AnalyzeObject(obj SSZObject) (*SszInfo, error)

AnalyzeObject analyzes given object and returns its SSZ information.

func CalculateOffsetAndLength

func CalculateOffsetAndLength(sszInfo *SszInfo, path Path) (*SszInfo, uint64, uint64, error)

CalculateOffsetAndLength calculates the offset and length of a given path within the SSZ object. By walking the given path, it accumulates the offsets based on SszInfo.

func (*SszInfo) BitlistInfo

func (info *SszInfo) BitlistInfo() (*bitlistInfo, error)

func (*SszInfo) BitvectorInfo

func (info *SszInfo) BitvectorInfo() (*bitvectorInfo, error)

func (*SszInfo) ContainerInfo

func (info *SszInfo) ContainerInfo() (*containerInfo, error)

func (*SszInfo) HashTreeRoot

func (info *SszInfo) HashTreeRoot() ([32]byte, error)

HashTreeRoot calls the HashTreeRoot method on the stored interface if it implements SSZObject. Returns the 32-byte hash tree root or an error if the interface doesn't support hashing.

func (*SszInfo) ListInfo

func (info *SszInfo) ListInfo() (*listInfo, error)

func (*SszInfo) Print

func (info *SszInfo) Print() string

Print returns a string representation of the SszInfo, which is useful for debugging.

func (*SszInfo) Size

func (info *SszInfo) Size() uint64

func (*SszInfo) String

func (info *SszInfo) String() string

String implements the Stringer interface for SszInfo. This follows the notation used in the consensus specs.

func (*SszInfo) VectorInfo

func (info *SszInfo) VectorInfo() (*vectorInfo, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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