utils

package
v0.13.8 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2024 License: GPL-3.0, LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The spec of verkle key encoding can be found here.
	// https://notes.ethereum.org/@vbuterin/verkle_tree_eip#Tree-embedding
	VersionLeafKey    = 0
	BalanceLeafKey    = 1
	NonceLeafKey      = 2
	CodeKeccakLeafKey = 3
	CodeSizeLeafKey   = 4
)

Variables

This section is empty.

Functions

func BalanceKey

func BalanceKey(address []byte) []byte

BalanceKey returns the verkle tree key of the balance field for the specified account.

func BalanceKeyWithEvaluatedAddress

func BalanceKeyWithEvaluatedAddress(evaluated *verkle.Point) []byte

BalanceKeyWithEvaluatedAddress returns the verkle tree key of the balance field for the specified account. The difference between BalanceKey is the address evaluation is already computed to minimize the computational overhead.

func CodeChunkKey

func CodeChunkKey(address []byte, chunk *uint256.Int) []byte

CodeChunkKey returns the verkle tree key of the code chunk for the specified account.

func CodeChunkKeyWithEvaluatedAddress

func CodeChunkKeyWithEvaluatedAddress(addressPoint *verkle.Point, chunk *uint256.Int) []byte

CodeChunkKeyWithEvaluatedAddress returns the verkle tree key of the code chunk for the specified account. The difference between CodeChunkKey is the address evaluation is already computed to minimize the computational overhead.

func CodeKeccakKey

func CodeKeccakKey(address []byte) []byte

CodeKeccakKey returns the verkle tree key of the code keccak field for the specified account.

func CodeKeccakKeyWithEvaluatedAddress

func CodeKeccakKeyWithEvaluatedAddress(evaluated *verkle.Point) []byte

CodeKeccakKeyWithEvaluatedAddress returns the verkle tree key of the code keccak for the specified account. The difference between CodeKeccakKey is the address evaluation is already computed to minimize the computational overhead.

func CodeSizeKey

func CodeSizeKey(address []byte) []byte

CodeSizeKey returns the verkle tree key of the code size field for the specified account.

func CodeSizeKeyWithEvaluatedAddress

func CodeSizeKeyWithEvaluatedAddress(evaluated *verkle.Point) []byte

CodeSizeKeyWithEvaluatedAddress returns the verkle tree key of the code size for the specified account. The difference between CodeSizeKey is the address evaluation is already computed to minimize the computational overhead.

func GetTreeKey

func GetTreeKey(address []byte, treeIndex *uint256.Int, subIndex byte) []byte

GetTreeKey performs both the work of the spec's get_tree_key function, and that of pedersen_hash: it builds the polynomial in pedersen_hash without having to create a mostly zero-filled buffer and "type cast" it to a 128-long 16-byte array. Since at most the first 5 coefficients of the polynomial will be non-zero, these 5 coefficients are created directly.

func GetTreeKeyWithEvaluatedAddress

func GetTreeKeyWithEvaluatedAddress(evaluated *verkle.Point, treeIndex *uint256.Int, subIndex byte) []byte

GetTreeKeyWithEvaluatedAddress is basically identical to GetTreeKey, the only difference is a part of polynomial is already evaluated.

Specifically, poly = [2+256*64, address_le_low, address_le_high] is already evaluated.

func NonceKey

func NonceKey(address []byte) []byte

NonceKey returns the verkle tree key of the nonce field for the specified account.

func NonceKeyWithEvaluatedAddress

func NonceKeyWithEvaluatedAddress(evaluated *verkle.Point) []byte

NonceKeyWithEvaluatedAddress returns the verkle tree key of the nonce field for the specified account. The difference between NonceKey is the address evaluation is already computed to minimize the computational overhead.

func StorageSlotKey

func StorageSlotKey(address []byte, storageKey []byte) []byte

StorageSlotKey returns the verkle tree key of the storage slot for the specified account.

func StorageSlotKeyWithEvaluatedAddress

func StorageSlotKeyWithEvaluatedAddress(evaluated *verkle.Point, storageKey []byte) []byte

StorageSlotKeyWithEvaluatedAddress returns the verkle tree key of the storage slot for the specified account. The difference between StorageSlotKey is the address evaluation is already computed to minimize the computational overhead.

func VersionKey

func VersionKey(address []byte) []byte

VersionKey returns the verkle tree key of the version field for the specified account.

func VersionKeyWithEvaluatedAddress

func VersionKeyWithEvaluatedAddress(evaluated *verkle.Point) []byte

VersionKeyWithEvaluatedAddress returns the verkle tree key of the version field for the specified account. The difference between VersionKey is the address evaluation is already computed to minimize the computational overhead.

Types

type PointCache

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

PointCache is the LRU cache for storing evaluated address commitment.

func NewPointCache

func NewPointCache(maxItems int) *PointCache

NewPointCache returns the cache with specified size.

func (*PointCache) Get

func (c *PointCache) Get(addr []byte) *verkle.Point

Get returns the cached commitment for the specified address, or computing it on the flight.

func (*PointCache) GetStem

func (c *PointCache) GetStem(addr []byte) []byte

GetStem returns the first 31 bytes of the tree key as the tree stem. It only works for the account metadata whose treeIndex is 0.

Jump to

Keyboard shortcuts

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