Skip to content

Latest commit

 

History

History
480 lines (294 loc) · 10.8 KB

stateManager.md

File metadata and controls

480 lines (294 loc) · 10.8 KB

Table of Contents

StateManager

Interface for getting and setting data from an underlying state trie

getAccount

Gets the ethereumjs-account associated with address. Returns an empty account if the account does not exist.

Parameters

putAccount

Saves an ethereumjs-account into state under the provided address

Parameters

putContractCode

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

Parameters

  • address Buffer Address of the account to add the code for
  • value Buffer The value of the code
  • cb Function Callback function

getContractCode

Gets the code corresponding to the provided address

Parameters

getContractStorage

Gets the storage value associated with the provided address and key

Parameters

putContractStorage

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

Parameters

  • address Buffer Address to set a storage value for
  • key Buffer Key to set the value at
  • value Buffer Value to set at key for account corresponding to address
  • cb Function Callback function

clearContractStorage

Clears all storage entries for the account corresponding to address

Parameters

  • address Buffer Address to clear the storage of
  • cb Function Callback function

checkpoint

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

Parameters

commit

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

Parameters

revert

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

Parameters

getStateRoot

Gets the state-root of the Merkle-Patricia trie representation of the state of this StateManager. Will error if there are uncommitted checkpoints on the instance.

Parameters

setStateRoot

Sets the state of the instance to that represented by the provided stateRoot. Will error if there are uncommitted checkpoints on the instance or if the state root does not exist in the state trie.

Parameters

  • stateRoot Buffer The state-root to reset the instance to
  • cb Function Callback function

generateCanonicalGenesis

Generates a canonical genesis state on the instance based on the configured chain parameters. Will error if there are uncommitted checkpoints on the instance.

Parameters

accountIsEmpty

Checks if the account corresponding to address is empty as defined in EIP-161 (https://github.com/ethereum/EIPs/blob/master/EIPS/eip-161.md)

Parameters

cleanupTouchedAccounts

Removes accounts form the state trie that have been touched, as defined in EIP-161 (https://github.com/ethereum/EIPs/blob/master/EIPS/eip-161.md).

Parameters

DefaultStateManager

Default implementation of the StateManager interface

Parameters

copy

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

dumpStorage

Dumps the the storage values for an account specified by address

Parameters

hasGenesisState

Checks whether the current instance has the canonical genesis state for the configured chain parameters.

Parameters

generateGenesis

Initializes the provided genesis state into the state trie

Parameters

getAccount~callback

Callback for getAccount method

Type: Function

Parameters

  • error Error an error that may have happened or null
  • account Account An ethereumjs-account instance corresponding to the provided address

getContractCode~callback

Callback for getContractCode method

Type: Function

Parameters

  • error Error an error that may have happened or null
  • code Buffer The code corresponding to the provided address. Returns an empty Buffer if the account has no associated code.

getContractStorage~callback

Callback for getContractStorage method

Type: Function

Parameters

  • error Error an error that may have happened or null
  • storageValue Buffer The storage value for the account corresponding to the provided address at the provided key. If this does not exists an empty Buffer is returned

getStateRoot~callback

Callback for getStateRoot method

Type: Function

Parameters

  • error Error an error that may have happened or null. Will be an error if the un-committed checkpoints on the instance.
  • stateRoot Buffer The state-root of the StateManager

dumpStorage~callback

Callback for dumpStorage method

Type: Function

Parameters

  • error Error an error that may have happened or null
  • accountState Object 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.

hasGenesisState~callback

Callback for hasGenesisState method

Type: Function

Parameters

  • error Error an error that may have happened or null
  • hasGenesisState Boolean Whether the storage trie contains the canonical genesis state for the configured chain parameters.

accountIsEmpty~callback

Callback for accountIsEmpty method

Type: Function

Parameters

  • error Error an error that may have happened or null
  • empty Boolean True if the account is empty false otherwise