@ethereumjs/statemanager / RPCStateManager
EVMStateManagerInterface
• new RPCStateManager(opts
)
Name | Type |
---|---|
opts |
RPCStateManagerOpts |
• Readonly
common: Common
• originalStorageCache: OriginalStorageCache
EVMStateManagerInterface.originalStorageCache
▸ accountExists(address
): Promise
<boolean
>
Checks if an account
exists at address
Name | Type | Description |
---|---|---|
address |
Address |
Address of the account to check |
Promise
<boolean
>
▸ 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.
Promise
<void
>
EVMStateManagerInterface.checkpoint
▸ clearCaches(): void
Clears the internal cache so all accounts, contract code, and storage slots will initially be retrieved from the provider
void
▸ clearContractStorage(address
): Promise
<void
>
Clears all storage entries for the account corresponding to address
.
Name | Type | Description |
---|---|---|
address |
Address |
Address to clear the storage of |
Promise
<void
>
EVMStateManagerInterface.clearContractStorage
▸ commit(): Promise
<void
>
Commits the current change-set to the instance since the last call to checkpoint.
Partial implementation, called from the subclass.
Promise
<void
>
EVMStateManagerInterface.commit
▸ deleteAccount(address
): Promise
<void
>
Deletes an account from state under the provided address
.
Name | Type | Description |
---|---|---|
address |
Address |
Address of the account which should be deleted |
Promise
<void
>
EVMStateManagerInterface.deleteAccount
▸ dumpStorage(address
): Promise
<StorageDump
>
Dumps the RLP-encoded storage values for an account
specified by address
.
Name | Type | Description |
---|---|---|
address |
Address |
The address of the account to return storage for |
Promise
<StorageDump
>
Object
map.
Keys are the storage keys, values are the storage values as strings.
Both are represented as 0x
prefixed hex strings.EVMStateManagerInterface.dumpStorage
▸ dumpStorageRange(_address
, _startKey
, _limit
): Promise
<StorageRange
>
Name | Type |
---|---|
_address |
Address |
_startKey |
bigint |
_limit |
number |
Promise
<StorageRange
>
EVMStateManagerInterface.dumpStorageRange
▸ flush(): Promise
<void
>
Promise
<void
>
▸ generateCanonicalGenesis(_initState
): Promise
<void
>
Name | Type |
---|---|
_initState |
any |
Promise
<void
>
EVMStateManagerInterface.generateCanonicalGenesis
▸ getAccount(address
): Promise
<undefined
| Account
>
Gets the code corresponding to the provided address
.
Name | Type | Description |
---|---|---|
address |
Address |
Address to get the account for |
Promise
<undefined
| Account
>
Uint8Array
if the account has no associated code.EVMStateManagerInterface.getAccount
▸ getAppliedKey(address
): Uint8Array
Returns the applied key for a given address Used for saving preimages
Name | Type | Description |
---|---|---|
address |
Uint8Array |
The address to return the applied key |
Uint8Array
EVMStateManagerInterface.getAppliedKey
▸ getContractCode(address
): Promise
<Uint8Array
>
Gets the code corresponding to the provided address
.
Name | Type | Description |
---|---|---|
address |
Address |
Address to get the code for |
Promise
<Uint8Array
>
Uint8Array
if the account has no associated code.EVMStateManagerInterface.getContractCode
▸ 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.
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. |
Promise
<Uint8Array
>
Uint8Array
is returned.EVMStateManagerInterface.getContractStorage
▸ getProof(address
, storageSlots?
): Promise
<Proof
>
Get an EIP-1186 proof from the provider
Name | Type | Default value | Description |
---|---|---|---|
address |
Address |
undefined |
address to get proof of |
storageSlots |
Uint8Array [] |
[] |
storage slots to get proof of |
Promise
<Proof
>
an EIP-1186 formatted proof
EVMStateManagerInterface.getProof
▸ getStateRoot(): Promise
<Uint8Array
>
Deprecated
This method is not used by the RPC State Manager and is a stub required by the State Manager interface
Promise
<Uint8Array
>
EVMStateManagerInterface.getStateRoot
▸ hasStateRoot(): never
Deprecated
This method is not used by the RPC State Manager and is a stub required by the State Manager interface
never
EVMStateManagerInterface.hasStateRoot
▸ 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
.
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 |
Promise
<void
>
EVMStateManagerInterface.modifyAccountFields
▸ putAccount(address
, account
): Promise
<void
>
Saves an account into state under the provided address
.
Name | Type | Description |
---|---|---|
address |
Address |
Address under which to store account |
account |
undefined | Account |
The account to store |
Promise
<void
>
EVMStateManagerInterface.putAccount
▸ 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.
Name | Type | Description |
---|---|---|
address |
Address |
Address of the account to add the code for |
value |
Uint8Array |
The value of the code |
Promise
<void
>
EVMStateManagerInterface.putContractCode
▸ putContractStorage(address
, key
, value
): Promise
<void
>
Adds value to the cache for the account
corresponding to address
at the provided key
.
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. |
Promise
<void
>
EVMStateManagerInterface.putContractStorage
▸ revert(): Promise
<void
>
Reverts the current change-set to the instance since the last call to checkpoint.
Partial implementation , called from the subclass.
Promise
<void
>
EVMStateManagerInterface.revert
▸ setBlockTag(blockTag
): void
Sets the new block tag used when querying the provider and clears the internal cache.
Name | Type | Description |
---|---|---|
blockTag |
bigint | "earliest" |
the new block tag to use when querying the provider |
void
▸ 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
Name | Type |
---|---|
_root |
Uint8Array |
Promise
<void
>
EVMStateManagerInterface.setStateRoot
▸ shallowCopy(): RPCStateManager
Note that the returned statemanager will share the same JsonRpcProvider as the original
RPCStateManager
EVMStateManagerInterface.shallowCopy