Documentation ¶
Index ¶
- Variables
- func OpenGethRawDB(dataDirPath string, readOnly bool) (ethdb.Database, error)
- type Cheater
- type HeadFn
- func OvmOwners(conf *OvmOwnersConfig) HeadFn
- func SetBalance(addr common.Address, amount *big.Int) HeadFn
- func SetCode(addr common.Address, code hexutil.Bytes) HeadFn
- func SetNonce(addr common.Address, nonce uint64) HeadFn
- func StorageDiff(out io.Writer, addressA, addressB common.Address) HeadFn
- func StorageGet(address common.Address, key common.Hash, w io.Writer) HeadFn
- func StoragePatch(patch io.Reader, address common.Address) HeadFn
- func StorageReadAll(address common.Address, w io.Writer) HeadFn
- func StorageSet(address common.Address, key common.Hash, value common.Hash) HeadFn
- type OvmOwnersConfig
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type Cheater ¶
type Cheater struct { // The database of the chain with the head block that we patch the state-root of, once the state is updated. DB ethdb.Database // Initialized chain, wrapping the database with in-memory presentation of headers and recent changes and such. Blockchain *core.BlockChain // The Cheater avoids making writes if this is set to True, and opens the DB as readonly. ReadOnly bool }
func OpenGethDB ¶
OpenGethDB opens a geth database to apply cheats to.
func (*Cheater) RunAndClose ¶
RunAndClose runs the given function on the head-state, and then persists any changes (if not ReadOnly), and updates the blockchain headers indexes to reflect the new state-root, so geth will believe the cheat (unless it ever re-applies the block).
type HeadFn ¶
func OvmOwners ¶
func OvmOwners(conf *OvmOwnersConfig) HeadFn
func StorageDiff ¶
StorageDiff compares the storage of two different accounts, and writes a patch with differences. Each difference is expressed with 1 character + or - to indicate the change from a to b, followed by key = value.
func StorageGet ¶
StorageGet just reads the storage of the given address at the given key.
func StoragePatch ¶
StoragePatch applies a patch of changes to the given state account trie. Changes are hex encoded key-value pairs separated by (=). Additions are prefixed with (+). Deletions are prefixed with (-) and overwrite it to a zero value. Comments (#) and empty lines are ignored.
func StorageReadAll ¶
StorageReadAll reads all values of the given address, and writes it as a (+) diff to the given output writer. Simply replace the (+) with (-) if you need to apply the diff as removal of values. Combined with StoragePatch this allows for quick surgery of 1 account in one database, to another account (maybe even in a different database!).