statediff

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const APIName = "statediff"

APIName is the namespace used for the state diffing service API

View Source
const APIVersion = "0.0.1"

APIVersion is the version of the state diffing service API

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountMap added in v0.1.0

type AccountMap map[string]accountWrapper

AccountMap is a mapping of hex encoded path => account wrapper

type Builder added in v0.1.0

type Builder interface {
	BuildStateDiffObject(args sd.Args, params sd.Params) (sd.StateObject, error)
	BuildStateTrieObject(current *types.Block) (sd.StateObject, error)
	WriteStateDiffObject(args sd.StateRoots, params sd.Params, output sdtypes.StateNodeSink, codeOutput sdtypes.CodeSink) error
}

Builder interface exposes the method for building a state diff between two blocks

func NewBuilder added in v0.1.0

func NewBuilder(stateCache state.Database, workers uint) (Builder, error)

NewBuilder is used to create a statediff builder

type Config added in v0.1.0

type Config struct {
	ServiceWorkers  uint
	TrieWorkers     uint
	WorkerQueueSize uint
	PreRuns         []RangeRequest
}

Config holds config params for the statediffing service

type LvLDBReaderConfig added in v0.2.6

type LvLDBReaderConfig struct {
	TrieConfig        *trie.Config
	ChainConfig       *params.ChainConfig
	Path, AncientPath string
	DBCacheSize       int
}

LvLDBReaderConfig struct for initializing a LvlDBReader

type LvlDBReader

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

LvlDBReader exposes the necessary Reader methods on lvldb

func NewLvlDBReader

func NewLvlDBReader(conf LvLDBReaderConfig) (*LvlDBReader, error)

NewLvlDBReader creates a new Read using LevelDB

func (*LvlDBReader) GetBlockByHash

func (ldr *LvlDBReader) GetBlockByHash(hash common.Hash) (*types.Block, error)

GetBlockByHash gets block by hash

func (*LvlDBReader) GetBlockByNumber

func (ldr *LvlDBReader) GetBlockByNumber(number uint64) (*types.Block, error)

func (*LvlDBReader) GetReceiptsByHash

func (ldr *LvlDBReader) GetReceiptsByHash(hash common.Hash) (types.Receipts, error)

GetReceiptsByHash gets receipt by hash

func (*LvlDBReader) GetTdByHash

func (ldr *LvlDBReader) GetTdByHash(hash common.Hash) (*big.Int, error)

GetTdByHash gets td by hash

func (*LvlDBReader) StateDB

func (ldr *LvlDBReader) StateDB() state.Database

StateDB returns the underlying statedb

type PublicStateDiffAPI

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

PublicStateDiffAPI provides an RPC interface that can be used to fetch historical diffs from leveldb directly

func NewPublicStateDiffAPI

func NewPublicStateDiffAPI(sds StateDiffService) *PublicStateDiffAPI

NewPublicStateDiffAPI creates an rpc interface for the underlying statediff service

func (*PublicStateDiffAPI) StateDiffAt

func (api *PublicStateDiffAPI) StateDiffAt(ctx context.Context, blockNumber uint64, params sd.Params) (*sd.Payload, error)

StateDiffAt returns a state diff payload at the specific blockheight

func (*PublicStateDiffAPI) StateTrieAt

func (api *PublicStateDiffAPI) StateTrieAt(ctx context.Context, blockNumber uint64, params sd.Params) (*sd.Payload, error)

StateTrieAt returns a state trie payload at the specific blockheight

func (*PublicStateDiffAPI) WriteStateDiffAt added in v0.2.0

func (api *PublicStateDiffAPI) WriteStateDiffAt(ctx context.Context, blockNumber uint64, params sd.Params) error

WriteStateDiffAt writes a state diff object directly to DB at the specific blockheight

func (*PublicStateDiffAPI) WriteStateDiffsInRange added in v0.2.6

func (api *PublicStateDiffAPI) WriteStateDiffsInRange(ctx context.Context, start, stop uint64, params sd.Params) error

WriteStateDiffsInRange writes the state diff objects for the provided block range, with the provided params

type RangeRequest added in v0.2.6

type RangeRequest struct {
	Start, Stop uint64
	Params      sd.Params
}

RangeRequest holds range quest work params

type Reader added in v0.2.6

type Reader interface {
	GetBlockByHash(hash common.Hash) (*types.Block, error)
	GetBlockByNumber(number uint64) (*types.Block, error)
	GetReceiptsByHash(hash common.Hash) (types.Receipts, error)
	GetTdByHash(hash common.Hash) (*big.Int, error)
	StateDB() state.Database
}

Reader interface required by the statediffing service

type Service

type Service struct {
	// Used to build the state diff objects
	Builder Builder
	// contains filtered or unexported fields
}

Service is the underlying struct for the state diffing service

func NewStateDiffService

func NewStateDiffService(lvlDBReader Reader, indexer ind.Indexer, conf Config) (*Service, error)

NewStateDiffService creates a new Service

func (*Service) APIs

func (sds *Service) APIs() []rpc.API

APIs returns the RPC descriptors the Service offers

func (*Service) Loop

func (sds *Service) Loop(wg *sync.WaitGroup) error

Loop is an empty service loop for awaiting rpc requests

func (*Service) Protocols

func (sds *Service) Protocols() []p2p.Protocol

Protocols exports the services p2p protocols, this service has none

func (*Service) Run added in v0.2.7

func (sds *Service) Run(rngs []RangeRequest) error

Run does a one-off processing run on the provided RangeRequests + any pre-runs, exiting afterwards

func (*Service) Start

func (sds *Service) Start() error

Start is used to begin the service

func (*Service) StateDiffAt

func (sds *Service) StateDiffAt(blockNumber uint64, params sd.Params) (*sd.Payload, error)

StateDiffAt returns a state diff object payload at the specific blockheight This operation cannot be performed back past the point of db pruning; it requires an archival node for historical data

func (*Service) StateDiffFor added in v0.2.0

func (sds *Service) StateDiffFor(blockHash common.Hash, params sd.Params) (*sd.Payload, error)

StateDiffFor returns a state diff object payload for the specific blockhash This operation cannot be performed back past the point of db pruning; it requires an archival node for historical data

func (*Service) StateTrieAt

func (sds *Service) StateTrieAt(blockNumber uint64, params sd.Params) (*sd.Payload, error)

StateTrieAt returns a state trie object payload at the specified blockheight This operation cannot be performed back past the point of db pruning; it requires an archival node for historical data

func (*Service) Stop

func (sds *Service) Stop() error

Stop is used to close down the service

func (*Service) WriteStateDiffAt added in v0.2.0

func (sds *Service) WriteStateDiffAt(blockNumber uint64, params sd.Params) error

WriteStateDiffAt writes a state diff at the specific blockheight directly to the database This operation cannot be performed back past the point of db pruning; it requires an archival node for historical data

func (*Service) WriteStateDiffFor added in v0.2.0

func (sds *Service) WriteStateDiffFor(blockHash common.Hash, params sd.Params) error

WriteStateDiffFor writes a state diff for the specific blockHash directly to the database This operation cannot be performed back past the point of db pruning; it requires an archival node for historical data

func (*Service) WriteStateDiffsInRange added in v0.2.6

func (sds *Service) WriteStateDiffsInRange(start, stop uint64, params sd.Params) error

WriteStateDiffsInRange adds a RangeRequest to the work queue

type StateDiffService added in v0.2.6

type StateDiffService interface {
	// Lifecycle Start() and Stop()
	node.Lifecycle
	// APIs and Protocols() interface for node service registration
	APIs() []rpc.API
	Protocols() []p2p.Protocol
	// Loop is the main event loop for processing state diffs
	Loop(wg *sync.WaitGroup) error
	// Run is a one-off command to run on a predefined set of ranges
	Run(ranges []RangeRequest) error
	// StateDiffAt method to get state diff object at specific block
	StateDiffAt(blockNumber uint64, params sd.Params) (*sd.Payload, error)
	// StateDiffFor method to get state diff object at specific block
	StateDiffFor(blockHash common.Hash, params sd.Params) (*sd.Payload, error)
	// StateTrieAt method to get state trie object at specific block
	StateTrieAt(blockNumber uint64, params sd.Params) (*sd.Payload, error)
	// WriteStateDiffAt method to write state diff object directly to DB
	WriteStateDiffAt(blockNumber uint64, params sd.Params) error
	// WriteStateDiffFor method to get state trie object at specific block
	WriteStateDiffFor(blockHash common.Hash, params sd.Params) error
	// WriteStateDiffsInRange method to wrtie state diff objects within the range directly to the DB
	WriteStateDiffsInRange(start, stop uint64, params sd.Params) error
}

StateDiffService is the state-diffing service interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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