stateroot

package
v0.0.0-...-f94ef0f Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrStateMismatch means that local state root doesn't match the one
	// signed by state validators.
	ErrStateMismatch = errors.New("stateroot mismatch")
)

Functions

This section is empty.

Types

type Module

type Module struct {
	Store *storage.MemCachedStore
	// contains filtered or unexported fields
}

Module represents module for local processing of state roots.

func NewModule

NewModule returns new instance of stateroot module.

func (*Module) AddMPTBatch

func (s *Module) AddMPTBatch(index uint32, b mpt.Batch, cache *storage.MemCachedStore) (*mpt.Trie, *state.MPTRoot, error)

AddMPTBatch updates using provided batch.

func (*Module) AddStateRoot

func (s *Module) AddStateRoot(sr *state.MPTRoot) error

AddStateRoot adds validated state root provided by network.

func (*Module) CleanStorage

func (s *Module) CleanStorage() error

CleanStorage removes all MPT-related data from the storage (MPT nodes, validated stateroots) except local stateroot for the current height and GC flag. This method is aimed to clean outdated MPT data before state sync process can be started. Note: this method is aimed to be called for genesis block only, an error is returned otherwice.

func (*Module) CurrentLocalHeight

func (s *Module) CurrentLocalHeight() uint32

CurrentLocalHeight returns height of the local state root.

func (*Module) CurrentLocalStateRoot

func (s *Module) CurrentLocalStateRoot() common.Hash

CurrentLocalStateRoot returns hash of the local state root.

func (*Module) CurrentValidatedHeight

func (s *Module) CurrentValidatedHeight() uint32

CurrentValidatedHeight returns current state root validated height.

func (*Module) FindStates

func (s *Module) FindStates(root common.Hash, prefix, start []byte, max int) ([]storage.KeyValue, error)

FindStates returns set of key-value pairs with key matching the prefix starting from the `prefix`+`start` path from MPT trie with the specified root. `max` is the maximum number of elements to be returned. If nil `start` specified, then item with key equals to prefix is included into result; if empty `start` specified, then item with key equals to prefix is not included into result.

func (*Module) GC

func (s *Module) GC(index uint32, store storage.Store) time.Duration

GC performs garbage collection.

func (*Module) GetState

func (s *Module) GetState(root common.Hash, key []byte) ([]byte, error)

GetState returns value at the specified key fom the MPT with the specified root.

func (*Module) GetStateProof

func (s *Module) GetStateProof(root common.Hash, key []byte) ([][]byte, error)

GetStateProof returns proof of having key in the MPT with the specified root.

func (*Module) GetStateRoot

func (s *Module) GetStateRoot(height uint32) (*state.MPTRoot, error)

GetStateRoot returns state root for a given height.

func (*Module) GetStateValidators

func (s *Module) GetStateValidators(height uint32) keys.PublicKeys

GetStateValidators returns current state validators.

func (*Module) Init

func (s *Module) Init(height uint32) error

Init initializes state root module at the given height.

func (*Module) JumpToState

func (s *Module) JumpToState(sr *state.MPTRoot)

JumpToState performs jump to the state specified by given stateroot index.

func (*Module) SetUpdateValidatorsCallback

func (s *Module) SetUpdateValidatorsCallback(f func(uint32, keys.PublicKeys))

SetUpdateValidatorsCallback sets callback for sending signed root.

func (*Module) UpdateCurrentLocal

func (s *Module) UpdateCurrentLocal(mpt *mpt.Trie, sr *state.MPTRoot)

UpdateCurrentLocal updates local caches using provided state root.

func (*Module) UpdateStateValidators

func (s *Module) UpdateStateValidators(height uint32, pubs keys.PublicKeys)

UpdateStateValidators updates list of state validator keys.

func (*Module) VerifyStateRoot

func (s *Module) VerifyStateRoot(r *state.MPTRoot) error

VerifyStateRoot checks if state root is valid.

type VerifierFunc

type VerifierFunc func(common.Address, hash.Hashable, *transaction.Witness) error

VerifierFunc is a function that allows to check witness of account for Hashable item with GAS limit.

Jump to

Keyboard shortcuts

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