cheat

package
v0.0.0-...-eb934a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HundredETH = big.NewInt(0).Mul(big.NewInt(100), big.NewInt(1000000000000000000))

Functions

func OpenGethRawDB

func OpenGethRawDB(dataDirPath string, readOnly bool) (ethdb.Database, error)

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

func OpenGethDB(dataDirPath string, readOnly bool) (*Cheater, error)

OpenGethDB opens a geth database to apply cheats to.

func (*Cheater) Close

func (ch *Cheater) Close() error

func (*Cheater) RunAndClose

func (ch *Cheater) RunAndClose(fn HeadFn) error

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

type HeadFn func(headState *state.StateDB) error

func OvmOwners

func OvmOwners(conf *OvmOwnersConfig) HeadFn

func SetBalance

func SetBalance(addr common.Address, amount *big.Int) HeadFn

func SetCode

func SetCode(addr common.Address, code hexutil.Bytes) HeadFn

func SetNonce

func SetNonce(addr common.Address, nonce uint64) HeadFn

func StorageDiff

func StorageDiff(out io.Writer, addressA, addressB common.Address) HeadFn

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

func StorageGet(address common.Address, key common.Hash, w io.Writer) HeadFn

StorageGet just reads the storage of the given address at the given key.

func StoragePatch

func StoragePatch(patch io.Reader, address common.Address) HeadFn

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

func StorageReadAll(address common.Address, w io.Writer) HeadFn

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!).

func StorageSet

func StorageSet(address common.Address, key common.Hash, value common.Hash) HeadFn

StorageSet modifies the storage of the given address at the given key to the given value.

type OvmOwnersConfig

type OvmOwnersConfig struct {
	Network   string         `json:"network"`
	Owner     common.Address `json:"owner"`
	Sequencer common.Address `json:"sequencer"`
	Proposer  common.Address `json:"proposer"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL