multiversion

package
v0.0.0-...-8d92e95 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CodeCopyKey     = common.BytesToHash([]byte("codecopy"))
	CodeHashKey     = common.BytesToHash([]byte("codehash"))
	CodeSizeKey     = common.BytesToHash([]byte("codesize"))
	BalanceKey      = common.BytesToHash([]byte("balance"))
	SelfDestructKey = common.BytesToHash([]byte("selfdestruct"))
	NonceKey        = common.BytesToHash([]byte("nonce"))
)
View Source
var (
	ErrReadEstimate            = errors.New("multiversion store value contains estimate, cannot read, aborting")
	ErrNeedSequentialExecution = errors.New("transaction must execute sequentially, aborting")
)

Functions

func NewDeletedItem

func NewDeletedItem(index int, incarnation int) *valueItem

func NewEstimateItem

func NewEstimateItem(index int, incarnation int) *valueItem

func NewMultiVersionItem

func NewMultiVersionItem() *multiVersionItem

func NewValueItem

func NewValueItem(index int, incarnation int, value common.Hash) *valueItem

Types

type Abort

type Abort struct {
	DependentTxIdx int
	Err            error
}

Abort contains the information for a transaction's conflict

func NewEstimateAbort

func NewEstimateAbort(dependentTxIdx int) Abort

type AccessListTracer

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

func NewAccessListTracer

func NewAccessListTracer(multiVersionStore MultiVersionStore, msg blockchain.Message, transactionIndex int, incarnation int, abortedChannel chan Abort) *AccessListTracer

TODO-kaia: add initial value transfer to writeset?

func (*AccessListTracer) CaptureEnd

func (*AccessListTracer) CaptureEnd(output []byte, gasUsed uint64, err error)

func (*AccessListTracer) CaptureEnter

func (*AccessListTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int)

func (*AccessListTracer) CaptureExit

func (*AccessListTracer) CaptureExit(output []byte, gasUsed uint64, err error)

func (*AccessListTracer) CaptureFault

func (*AccessListTracer) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost, ccLeft, ccOpcode uint64, scope *vm.ScopeContext, depth int, err error)

func (*AccessListTracer) CaptureStart

func (a *AccessListTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int)

func (*AccessListTracer) CaptureState

func (a *AccessListTracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost, ccLeft, ccOpcode uint64, scope *vm.ScopeContext, depth int, err error)

CaptureState captures all opcodes that touch storage or addresses and adds them to the accesslist.

func (*AccessListTracer) CaptureTxEnd

func (a *AccessListTracer) CaptureTxEnd(restGas uint64)

func (*AccessListTracer) CaptureTxStart

func (*AccessListTracer) CaptureTxStart(gasLimit uint64)

func (*AccessListTracer) Delete

func (a *AccessListTracer) Delete(key StorageKey)

Delete implements types.KVStore.

func (*AccessListTracer) Get

func (a *AccessListTracer) Get(key StorageKey) common.Hash

Get implements types.KVStore.

func (*AccessListTracer) GetReadset

func (a *AccessListTracer) GetReadset() map[StorageKey][]common.Hash

GetReadset returns the readset

func (*AccessListTracer) GetWriteset

func (a *AccessListTracer) GetWriteset() map[StorageKey]common.Hash

GetWriteset returns the writeset

func (*AccessListTracer) Has

func (a *AccessListTracer) Has(key StorageKey) bool

Has implements types.KVStore.

func (*AccessListTracer) Set

func (a *AccessListTracer) Set(key StorageKey, value common.Hash)

Set implements types.KVStore.

func (*AccessListTracer) UpdateReadSet

func (a *AccessListTracer) UpdateReadSet(key StorageKey, value common.Hash)

func (*AccessListTracer) ValidGet

func (a *AccessListTracer) ValidGet(key StorageKey)

func (*AccessListTracer) ValidateReadset

func (a *AccessListTracer) ValidateReadset() bool

This function iterates over the readset, validating that the values in the readset are consistent with the values in the multiversion store and underlying parent store, and returns a boolean indicating validity

func (*AccessListTracer) WriteAbort

func (a *AccessListTracer) WriteAbort(abort Abort)

func (*AccessListTracer) WriteEstimatesToMultiVersionStore

func (a *AccessListTracer) WriteEstimatesToMultiVersionStore()

func (*AccessListTracer) WriteToMultiVersionStore

func (a *AccessListTracer) WriteToMultiVersionStore()

type ExtraKey

type ExtraKey common.Hash

type MultiVersionStore

type MultiVersionStore interface {
	GetLatest(key StorageKey) (value MultiVersionValueItem)
	GetLatestBeforeIndex(index int, key StorageKey) (value MultiVersionValueItem)
	GetParentState() *state.StateDB
	Has(index int, key StorageKey) bool
	WriteLatestToStore(state *state.StateDB)
	WriteLatestToStoreUntil(lastStoreIndex int, startIndex int, state *state.StateDB)
	SetWriteset(index int, incarnation int, writeset WriteSet)
	InvalidateWriteset(index int, incarnation int)
	SetEstimatedWriteset(index int, incarnation int, writeset WriteSet)
	GetAllWritesetKeys() map[int][]StorageKey
	SetReadset(index int, readset ReadSet)
	GetReadset(index int) ReadSet
	ClearReadset(index int)
	ValidateTransactionState(index int) (bool, []int)
	VersionedIndexedStore(msg blockchain.Message, index int, incarnation int, abortChannel chan Abort) *AccessListTracer
}

type MultiVersionValue

type MultiVersionValue interface {
	GetLatest() (value MultiVersionValueItem, found bool)
	GetLatestNonEstimate() (value MultiVersionValueItem, found bool)
	GetLatestBeforeIndex(index int) (value MultiVersionValueItem, found bool)
	Set(index int, incarnation int, value common.Hash)
	SetEstimate(index int, incarnation int)
	Delete(index int, incarnation int)
	Remove(index int)
}

type MultiVersionValueItem

type MultiVersionValueItem interface {
	IsDeleted() bool
	IsEstimate() bool
	Value() common.Hash
	Incarnation() int
	Index() int
}

type ReadSet

type ReadSet map[StorageKey][]common.Hash

type StorageKey

type StorageKey string

func ToStorageKey

func ToStorageKey(addr common.Address, slot common.Hash) StorageKey

func (StorageKey) Address

func (k StorageKey) Address() common.Address

func (StorageKey) Bytes

func (k StorageKey) Bytes() []byte

func (StorageKey) GetValue

func (k StorageKey) GetValue(stateDB *state.StateDB) common.Hash

func (StorageKey) SetValue

func (k StorageKey) SetValue(stateDB *state.StateDB, value common.Hash)

func (StorageKey) Slot

func (k StorageKey) Slot() common.Hash

func (StorageKey) String

func (k StorageKey) String() string

type Store

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

func NewMultiVersionStore

func NewMultiVersionStore(parentStore *state.StateDB) *Store

func (*Store) ClearReadset

func (s *Store) ClearReadset(index int)

func (*Store) GetAllWritesetKeys

func (s *Store) GetAllWritesetKeys() map[int][]StorageKey

GetAllWritesetKeys implements MultiVersionStore.

func (*Store) GetLatest

func (s *Store) GetLatest(key StorageKey) (value MultiVersionValueItem)

GetLatest implements MultiVersionStore.

func (*Store) GetLatestBeforeIndex

func (s *Store) GetLatestBeforeIndex(index int, key StorageKey) (value MultiVersionValueItem)

GetLatestBeforeIndex implements MultiVersionStore.

func (*Store) GetParentState

func (s *Store) GetParentState() *state.StateDB

func (*Store) GetReadset

func (s *Store) GetReadset(index int) ReadSet

func (*Store) Has

func (s *Store) Has(index int, key StorageKey) bool

Has implements MultiVersionStore. It checks if the key exists in the multiversion store at or before the specified index.

func (*Store) InvalidateWriteset

func (s *Store) InvalidateWriteset(index int, incarnation int)

InvalidateWriteset iterates over the keys for the given index and incarnation writeset and replaces with ESTIMATEs

func (*Store) SetEstimatedWriteset

func (s *Store) SetEstimatedWriteset(index int, incarnation int, writeset WriteSet)

SetEstimatedWriteset is used to directly write estimates instead of writing a writeset and later invalidating

func (*Store) SetReadset

func (s *Store) SetReadset(index int, readset ReadSet)

func (*Store) SetWriteset

func (s *Store) SetWriteset(index int, incarnation int, writeset WriteSet)

SetWriteset sets a writeset for a transaction index, and also writes all of the multiversion items in the writeset to the multiversion store. TODO: returns a list of NEW keys added

func (*Store) ValidateTransactionState

func (s *Store) ValidateTransactionState(index int) (bool, []int)

TODO: do we want to return bool + []int where bool indicates whether it was valid and then []int indicates only ones for which we need to wait due to estimates? - yes i think so?

func (*Store) VersionedIndexedStore

func (s *Store) VersionedIndexedStore(msg blockchain.Message, index int, incarnation int, abortChannel chan Abort) *AccessListTracer

func (*Store) WriteLatestToStore

func (s *Store) WriteLatestToStore(finalState *state.StateDB)

func (*Store) WriteLatestToStoreUntil

func (s *Store) WriteLatestToStoreUntil(lastStoreIndex int, startIndex int, finalState *state.StateDB)

type WriteSet

type WriteSet map[StorageKey]common.Hash

Jump to

Keyboard shortcuts

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