Skip to content

Latest commit

 

History

History
719 lines (404 loc) · 16.4 KB

RPCStateManager.md

File metadata and controls

719 lines (404 loc) · 16.4 KB

@ethereumjs/statemanager / RPCStateManager

Class: RPCStateManager

Implements

  • EVMStateManagerInterface

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new RPCStateManager(opts)

Parameters

Name Type
opts RPCStateManagerOpts

Defined in

rpcStateManager.ts:50

Properties

common

Readonly common: Common

Defined in

rpcStateManager.ts:48


originalStorageCache

originalStorageCache: OriginalStorageCache

Implementation of

EVMStateManagerInterface.originalStorageCache

Defined in

rpcStateManager.ts:44

Methods

accountExists

accountExists(address): Promise<boolean>

Checks if an account exists at address

Parameters

Name Type Description
address Address Address of the account to check

Returns

Promise<boolean>

Defined in

rpcStateManager.ts:225


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.

Partial implementation, called from the subclass.

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.checkpoint

Defined in

rpcStateManager.ts:387


clearCaches

clearCaches(): void

Clears the internal cache so all accounts, contract code, and storage slots will initially be retrieved from the provider

Returns

void

Defined in

rpcStateManager.ts:111


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

rpcStateManager.ts:194


commit

commit(): Promise<void>

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

Partial implementation, called from the subclass.

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.commit

Defined in

rpcStateManager.ts:398


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

rpcStateManager.ts:343


dumpStorage

dumpStorage(address): Promise<StorageDump>

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

Parameters

Name Type Description
address Address The address of the account to return storage for

Returns

Promise<StorageDump>

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

Implementation of

EVMStateManagerInterface.dumpStorage

Defined in

rpcStateManager.ts:205


dumpStorageRange

dumpStorageRange(_address, _startKey, _limit): Promise<StorageRange>

Parameters

Name Type
_address Address
_startKey bigint
_limit number

Returns

Promise<StorageRange>

Implementation of

EVMStateManagerInterface.dumpStorageRange

Defined in

rpcStateManager.ts:216


flush

flush(): Promise<void>

Returns

Promise<void>

Defined in

rpcStateManager.ts:415


generateCanonicalGenesis

generateCanonicalGenesis(_initState): Promise<void>

Parameters

Name Type
_initState any

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.generateCanonicalGenesis

Defined in

rpcStateManager.ts:438


getAccount

getAccount(address): Promise<undefined | Account>

Gets the code corresponding to the provided address.

Parameters

Name Type Description
address Address Address to get the account for

Returns

Promise<undefined | Account>

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

Implementation of

EVMStateManagerInterface.getAccount

Defined in

rpcStateManager.ts:251


getAppliedKey

getAppliedKey(address): Uint8Array

Returns the applied key for a given address Used for saving preimages

Parameters

Name Type Description
address Uint8Array The address to return the applied key

Returns

Uint8Array

  • The applied key (e.g. hashed address)

Implementation of

EVMStateManagerInterface.getAppliedKey

Defined in

rpcStateManager.ts:376


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

rpcStateManager.ts:123


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

rpcStateManager.ts:155


getProof

getProof(address, storageSlots?): Promise<Proof>

Get an EIP-1186 proof from the provider

Parameters

Name Type Default value Description
address Address undefined address to get proof of
storageSlots Uint8Array[] [] storage slots to get proof of

Returns

Promise<Proof>

an EIP-1186 formatted proof

Implementation of

EVMStateManagerInterface.getProof

Defined in

rpcStateManager.ts:356


getStateRoot

getStateRoot(): Promise<Uint8Array>

Deprecated

This method is not used by the RPC State Manager and is a stub required by the State Manager interface

Returns

Promise<Uint8Array>

Implementation of

EVMStateManagerInterface.getStateRoot

Defined in

rpcStateManager.ts:422


hasStateRoot

hasStateRoot(): never

Deprecated

This method is not used by the RPC State Manager and is a stub required by the State Manager interface

Returns

never

Implementation of

EVMStateManagerInterface.hasStateRoot

Defined in

rpcStateManager.ts:434


modifyAccountFields

modifyAccountFields(address, accountFields): Promise<void>

Gets the account associated with address, modifies the given account fields, then saves the account into state. Account fields can include nonce, balance, storageRoot, and codeHash.

Parameters

Name Type Description
address Address Address of the account to modify
accountFields Partial<Pick<Account, "nonce" | "balance" | "storageRoot" | "codeHash">> Object containing account fields and values to modify

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.modifyAccountFields

Defined in

rpcStateManager.ts:314


putAccount

putAccount(address, account): Promise<void>

Saves an account into state under the provided address.

Parameters

Name Type Description
address Address Address under which to store account
account undefined | Account The account to store

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.putAccount

Defined in

rpcStateManager.ts:290


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

rpcStateManager.ts:141


putContractStorage

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

Adds value to the cache 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 empty or filled with zeros, deletes the value.

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.putContractStorage

Defined in

rpcStateManager.ts:186


revert

revert(): Promise<void>

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

Partial implementation , called from the subclass.

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.revert

Defined in

rpcStateManager.ts:409


setBlockTag

setBlockTag(blockTag): void

Sets the new block tag used when querying the provider and clears the internal cache.

Parameters

Name Type Description
blockTag bigint | "earliest" the new block tag to use when querying the provider

Returns

void

Defined in

rpcStateManager.ts:101


setStateRoot

setStateRoot(_root): Promise<void>

Deprecated

This method is not used by the RPC State Manager and is a stub required by the State Manager interface

Parameters

Name Type
_root Uint8Array

Returns

Promise<void>

Implementation of

EVMStateManagerInterface.setStateRoot

Defined in

rpcStateManager.ts:429


shallowCopy

shallowCopy(): RPCStateManager

Note that the returned statemanager will share the same JsonRpcProvider as the original

Returns

RPCStateManager

RPCStateManager

Implementation of

EVMStateManagerInterface.shallowCopy

Defined in

rpcStateManager.ts:79