Skip to content

Latest commit

 

History

History
962 lines (547 loc) · 22.3 KB

StatelessVerkleStateManager.md

File metadata and controls

962 lines (547 loc) · 22.3 KB

@ethereumjs/statemanager / StatelessVerkleStateManager

Class: StatelessVerkleStateManager

Stateless Verkle StateManager implementation for the VM.

Experimental.

This State Manager enables stateless block execution by building a temporary (1-block) state from the verkle block witness. The Stateless Verkle State Manager then uses that populated state to fetch data requested by the the VM.

Implements

  • EVMStateManagerInterface

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new StatelessVerkleStateManager(opts?)

Instantiate the StateManager interface.

Parameters

Name Type
opts StatelessVerkleStateManagerOpts

Defined in

statelessVerkleStateManager.ts:178

Properties

_accountCache

Optional _accountCache: AccountCache

Defined in

statelessVerkleStateManager.ts:138


_codeCache

Optional _codeCache: CodeCache

Defined in

statelessVerkleStateManager.ts:140


_storageCache

Optional _storageCache: StorageCache

Defined in

statelessVerkleStateManager.ts:139


accessWitness

Optional accessWitness: AccessWitness

Defined in

statelessVerkleStateManager.ts:171


originalStorageCache

originalStorageCache: OriginalStorageCache

Implementation of

EVMStateManagerInterface.originalStorageCache

Defined in

statelessVerkleStateManager.ts:142

Methods

checkChunkWitnessPresent

checkChunkWitnessPresent(address, codeOffset): boolean

Parameters

Name Type
address Address
codeOffset number

Returns

boolean

Defined in

statelessVerkleStateManager.ts:344


checkpoint

checkpoint(): Promise<void>

Checkpoints the current state of the StateManager instance. State changes that follow can then be committed by calling commit or reverted by calling rollback.

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.checkpoint

Defined in

statelessVerkleStateManager.ts:806


chunkifyCode

chunkifyCode(code): void

Parameters

Name Type
code Uint8Array

Returns

void

Defined in

statelessVerkleStateManager.ts:328


clearCaches

clearCaches(): void

Clears all underlying caches

Returns

void

Defined in

statelessVerkleStateManager.ts:881


clearContractStorage

clearContractStorage(address): Promise<void>

Clears all storage entries for the account corresponding to address.

Parameters

Name Type Description
address Address Address to clear the storage of

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.clearContractStorage

Defined in

statelessVerkleStateManager.ts:495


commit

commit(): Promise<void>

Commits the current change-set to the instance since the last call to checkpoint.

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.commit

Defined in

statelessVerkleStateManager.ts:817


deleteAccount

deleteAccount(address): Promise<void>

Deletes an account from state under the provided address.

Parameters

Name Type Description
address Address Address of the account which should be deleted

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.deleteAccount

Defined in

statelessVerkleStateManager.ts:595


dumpStorage

dumpStorage(_): Promise<StorageDump>

Dumps the RLP-encoded storage values for an account specified by address.

Parameters

Name Type
_ Address

Returns

Promise<StorageDump>

  • The state of the account as an Object map. Keys are are the storage keys, values are the storage values as strings. Both are represented as hex strings without the 0x prefix.

Implementation of

EVMStateManagerInterface.dumpStorage

Defined in

statelessVerkleStateManager.ts:870


dumpStorageRange

dumpStorageRange(_, __, ___): Promise<StorageRange>

Parameters

Name Type
_ Address
__ bigint
___ number

Returns

Promise<StorageRange>

Implementation of

EVMStateManagerInterface.dumpStorageRange

Defined in

statelessVerkleStateManager.ts:874


flush

flush(): Promise<void>

Writes all cache items to the trie

Returns

Promise<void>

Defined in

statelessVerkleStateManager.ts:844


generateCanonicalGenesis

generateCanonicalGenesis(_initState): Promise<void>

Parameters

Name Type
_initState any

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.generateCanonicalGenesis

Defined in

statelessVerkleStateManager.ts:887


getAccount

getAccount(address): Promise<undefined | Account>

Parameters

Name Type
address Address

Returns

Promise<undefined | Account>

Implementation of

EVMStateManagerInterface.getAccount

Defined in

statelessVerkleStateManager.ts:505


getComputedValue

getComputedValue(accessedState): null | string

Parameters

Name Type
accessedState AccessedStateWithAddress

Returns

null | string

Defined in

statelessVerkleStateManager.ts:717


getContractCode

getContractCode(address): Promise<Uint8Array>

Gets the code corresponding to the provided address.

Parameters

Name Type Description
address Address Address to get the code for

Returns

Promise<Uint8Array>

  • Resolves with the code corresponding to the provided address. Returns an empty Uint8Array if the account has no associated code.

Implementation of

EVMStateManagerInterface.getContractCode

Defined in

statelessVerkleStateManager.ts:391


getContractStorage

getContractStorage(address, key): Promise<Uint8Array>

Gets the storage value associated with the provided address and key. This method returns the shortest representation of the stored value.

Parameters

Name Type Description
address Address Address of the account to get the storage for
key Uint8Array Key in the account's storage to get the value for. Must be 32 bytes long.

Returns

Promise<Uint8Array>

  • The storage value for the account corresponding to the provided address at the provided key. If this does not exist an empty Uint8Array is returned.

Implementation of

EVMStateManagerInterface.getContractStorage

Defined in

statelessVerkleStateManager.ts:455


getProof

getProof(_, __?): Promise<Proof>

Parameters

Name Type Default value
_ Address undefined
__ Uint8Array[] []

Returns

Promise<Proof>

Implementation of

EVMStateManagerInterface.getProof

Defined in

statelessVerkleStateManager.ts:621


getStateRoot

getStateRoot(): Promise<Uint8Array>

Gets the verkle root. NOTE: this needs some examination in the code where this is needed and if we have the verkle root present

Returns

Promise<Uint8Array>

  • Returns the verkle root of the StateManager

Implementation of

EVMStateManagerInterface.getStateRoot

Defined in

statelessVerkleStateManager.ts:852


getTransitionStateRoot

getTransitionStateRoot(_, __): Promise<Uint8Array>

Parameters

Name Type
_ DefaultStateManager
__ Uint8Array

Returns

Promise<Uint8Array>

Defined in

statelessVerkleStateManager.ts:242


getTreeKeyForBalance

getTreeKeyForBalance(stem): Uint8Array

Parameters

Name Type
stem Uint8Array

Returns

Uint8Array

Defined in

statelessVerkleStateManager.ts:307


getTreeKeyForCodeChunk

getTreeKeyForCodeChunk(address, chunkId): Uint8Array

Parameters

Name Type
address Address
chunkId number

Returns

Uint8Array

Defined in

statelessVerkleStateManager.ts:323


getTreeKeyForCodeHash

getTreeKeyForCodeHash(stem): Uint8Array

Parameters

Name Type
stem Uint8Array

Returns

Uint8Array

Defined in

statelessVerkleStateManager.ts:315


getTreeKeyForCodeSize

getTreeKeyForCodeSize(stem): Uint8Array

Parameters

Name Type
stem Uint8Array

Returns

Uint8Array

Defined in

statelessVerkleStateManager.ts:319


getTreeKeyForNonce

getTreeKeyForNonce(stem): Uint8Array

Parameters

Name Type
stem Uint8Array

Returns

Uint8Array

Defined in

statelessVerkleStateManager.ts:311


getTreeKeyForStorageSlot

getTreeKeyForStorageSlot(address, storageKey): Uint8Array

Parameters

Name Type
address Address
storageKey bigint

Returns

Uint8Array

Defined in

statelessVerkleStateManager.ts:338


getTreeKeyForVersion

getTreeKeyForVersion(stem): Uint8Array

Parameters

Name Type
stem Uint8Array

Returns

Uint8Array

Defined in

statelessVerkleStateManager.ts:303


hasStateRoot

hasStateRoot(_): Promise<boolean>

Parameters

Name Type
_ Uint8Array

Returns

Promise<boolean>

Implementation of

EVMStateManagerInterface.hasStateRoot

Defined in

statelessVerkleStateManager.ts:825


initVerkleExecutionWitness

initVerkleExecutionWitness(executionWitness?, accessWitness?): void

Parameters

Name Type
executionWitness? null | VerkleExecutionWitness
accessWitness? AccessWitness

Returns

void

Defined in

statelessVerkleStateManager.ts:246


modifyAccountFields

modifyAccountFields(address, accountFields): Promise<void>

Parameters

Name Type
address Address
accountFields Partial<Pick<Account, "nonce" | "balance" | "storageRoot" | "codeHash">>

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.modifyAccountFields

Defined in

statelessVerkleStateManager.ts:608


putAccount

putAccount(address, account): Promise<void>

Parameters

Name Type
address Address
account Account

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.putAccount

Defined in

statelessVerkleStateManager.ts:561


putContractCode

putContractCode(address, value): Promise<void>

Adds value to the state trie as code, and sets codeHash on the account corresponding to address to reference this.

Parameters

Name Type Description
address Address Address of the account to add the code for
value Uint8Array The value of the code

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.putContractCode

Defined in

statelessVerkleStateManager.ts:367


putContractStorage

putContractStorage(address, key, value): Promise<void>

Adds value to the state for the account corresponding to address at the provided key.

Parameters

Name Type Description
address Address Address to set a storage value for
key Uint8Array Key to set the value at. Must be 32 bytes long.
value Uint8Array Value to set at key for account corresponding to address. Cannot be more than 32 bytes. Leading zeros are stripped. If it is a empty or filled with zeros, deletes the value.

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.putContractStorage

Defined in

statelessVerkleStateManager.ts:480


revert

revert(): Promise<void>

Reverts the current change-set to the instance since the last call to checkpoint.

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.revert

Defined in

statelessVerkleStateManager.ts:833


setStateRoot

setStateRoot(_): Promise<void>

TODO: needed? Maybe in this context: reset to original pre state suffice

Parameters

Name Type
_ Uint8Array

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.setStateRoot

Defined in

statelessVerkleStateManager.ts:861


shallowCopy

shallowCopy(): EVMStateManagerInterface

Copies the current instance of the StateManager at the last fully committed point, i.e. as if all current checkpoints were reverted.

Returns

EVMStateManagerInterface

Implementation of

EVMStateManagerInterface.shallowCopy

Defined in

statelessVerkleStateManager.ts:355


verifyPostState

verifyPostState(): boolean

Returns

boolean

Defined in

statelessVerkleStateManager.ts:648


verifyProof

verifyProof(parentVerkleRoot): Promise<boolean>

Parameters

Name Type
parentVerkleRoot Uint8Array

Returns

Promise<boolean>

Defined in

statelessVerkleStateManager.ts:625