Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseBlockContext ¶ added in v1.1.0
type BaseBlockContext struct { // Number represents the block number of the block when it was first created. Number *big.Int // Time represents the timestamp of the block when it was first created. Time uint64 // BaseFee represents the base fee of the block when it was first created. BaseFee *big.Int // Coinbase represents the coinbase of the block when it was first created. Coinbase common.Address }
BaseBlockContext stores block-level information (e.g. block.number or block.timestamp) when the block is first created. We need to store these values because cheatcodes like warp or roll will directly modify the block header. We use these values during the cloning process to ensure that execution semantics are maintained while still allowing the cheatcodes to function as expected. We could expand this struct to hold additional values (e.g. difficulty) but we will ere to add values only as necessary.
func NewBaseBlockContext ¶ added in v1.1.0
func NewBaseBlockContext(number uint64, time uint64, baseFee *big.Int, coinbase common.Address) *BaseBlockContext
NewBaseBlockContext returns a new BaseBlockContext with the provided parameters.
type Block ¶
type Block struct { // Hash represents the block hash for this block. Hash common.Hash // Header represents the block header for this current block. Header *types.Header // Messages represent internal EVM core.Message objects. Messages are derived from transactions after validation // of a transaction occurs and can be thought of as an internal EVM transaction. It contains typical transaction // fields plainly (e.g., no transaction signature is included, the sender is derived and simply supplied as a field // in a message). Messages []*core.Message // MessageResults represents the results recorded while executing transactions. MessageResults []*MessageResults // BaseContext stores the initial (base) block context before the execution of any transactions // within the block. Since transactions that use cheatcodes can affect the block header // permanently, we need to store the original values so that we can maintain execution // semantics and allow for the chain to be clone-able. BaseContext *BaseBlockContext }
Block represents a rudimentary block structure generated by sending messages to a test chain.
type DeployedContractBytecode ¶
type DeployedContractBytecode struct { // Address represents the Ethereum address where the deployed contract containing the method exists. Address common.Address // InitBytecode describes the bytecode used to deploy the contract. InitBytecode []byte // RuntimeBytecode describes the bytecode which was deployed by the InitBytecode. This is expected to be non-nil. RuntimeBytecode []byte }
DeployedContractBytecode describes the init and runtime bytecode recorded for a given contract address.
type DeployedContractBytecodeChange ¶
type DeployedContractBytecodeChange struct { // Contract describes the contract address which was affected as well as the relevant init and runtime bytecode. // If this change represents a creation, this is the new bytecode information. If it represents destruction, this // is the destroyed bytecode information. Contract *DeployedContractBytecode // Creation indicates whether the change made was a contract creation. This cannot be true if SelfDestructed or // Destroyed are true. Creation bool // DynamicCreation indicates whether the change made was a _dynamic_ contract creation. This cannot be true if // Creation is false. DynamicCreation bool // SelfDestructed indicates whether the change made was due to a self-destruct instruction being executed. This // cannot be true if Creation is true. // Note: This may not be indicative of contract removal (as is the case with Destroyed), as proposed changes to // the `SELFDESTRUCT` instruction aim to not remove contract code. SelfDestructed bool // Destroyed indicates whether the contract was destroyed as a result of the operation, indicating the code // provided by Contract is no longer available. Destroyed bool }
DeployedContractBytecodeChange describes a change made to a given contract addresses' code due to state updates (e.g. from a transaction being processed).
type GenericHookFunc ¶
type GenericHookFunc func()
GenericHookFunc defines a basic function that takes no arguments and returns none, to be used as a hook during execution.
type GenericHookFuncs ¶
type GenericHookFuncs []GenericHookFunc
GenericHookFuncs wraps a list of GenericHookFunc items. It provides operations to push new hooks into the top or bottom of the list and execute in forward or backward directions.
func (*GenericHookFuncs) Execute ¶
func (t *GenericHookFuncs) Execute(forward bool, clear bool)
Execute takes each hook in the list and executes it in the given order, indicating whether they should be cleared. If the forward flag is provided, hooks are executed from index 0 to the end, otherwise they are executed in reverse. If the clear flag is provided, it sets the hooks to empty/nil afterwards on the immediate pointer. Copies of the pointer should be considered carefully here.
func (*GenericHookFuncs) Push ¶
func (t *GenericHookFuncs) Push(f GenericHookFunc)
Push pushes a provided hook onto the stack (end of the list).
type MedusaStateDB ¶ added in v1.0.0
type MedusaStateDB interface { vm.StateDB IntermediateRoot(bool) common.Hash Finalise(bool) Logs() []*types.Log GetLogs(common.Hash, uint64, common.Hash) []*types.Log TxIndex() int SetBalance(common.Address, *uint256.Int, tracing.BalanceChangeReason) SetTxContext(common.Hash, int) Commit(uint64, bool) (common.Hash, error) SetLogger(*tracing.Hooks) Error() error }
MedusaStateDB provides an interface that supersedes the stateDB interface exposed by geth. All of these functions are implemented by the vanilla geth statedb. This interface allows the TestChain to use a forked statedb and native geth statedb interoperably.
type MessageResults ¶
type MessageResults struct { // PostStateRoot refers to the state root hash after the execution of this transaction. PostStateRoot common.Hash // ExecutionResult describes the core.ExecutionResult returned after processing a given call. ExecutionResult *core.ExecutionResult // Receipt represents the transaction receipt Receipt *types.Receipt // ContractDeploymentChanges describes changes made to deployed contracts, such as creation and destruction. ContractDeploymentChanges []DeployedContractBytecodeChange // AdditionalResults represents results of arbitrary types which can be stored by any part of the application, // such as a tracers. AdditionalResults map[string]any // OnRevertHookFuncs refers hook functions that should be executed when this transaction is reverted. // This is to be used when a non-vm safe operation occurs, such as patching chain ID mid-execution, to ensure // that when the transaction is reverted, the value is also restored. // The hooks are executed as a stack (to support revert operations). OnRevertHookFuncs GenericHookFuncs }
MessageResults represents metadata obtained from the execution of a CallMessage in a Block. This contains results such as contracts deployed, and other variables tracked by a chain.TestChain.