calls

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallMessage

type CallMessage struct {
	// From represents a core.Message's from parameter (sender), indicating who sent a transaction/message to the
	// Ethereum core to apply a state update.
	From common.Address `json:"from"`

	// To represents the receiving address for a given core.Message.
	To *common.Address `json:"to"`

	// Nonce represents the core.Message sender's nonce
	Nonce uint64 `json:"nonce"`

	// Value represents ETH value to be sent to the receiver of the message.
	Value *big.Int `json:"value"`

	// GasLimit represents the maximum amount of gas the sender is willing to spend to cover the cost of executing the
	// message or transaction.
	GasLimit uint64 `json:"gasLimit"`

	// GasPrice represents the price which the sender is willing to pay for each unit of gas used during execution
	// of the message.
	GasPrice *big.Int `json:"gasPrice"`

	// GasFeeCap represents the maximum fee to enforce for gas related costs (related to 1559 transaction executed).
	// The use of nil here indicates that the gas price oracle should be relied on instead.
	GasFeeCap *big.Int `json:"gasFeeCap"`

	// GasTipCap represents the fee cap to use for 1559 transaction. The use of nil here indicates that the gas price
	// oracle should be relied on instead.
	GasTipCap *big.Int `json:"gasTipCap"`

	// Data represents the underlying message data to be sent to the receiver. If the receiver is a smart contract,
	// this will likely house your call parameters and other serialized data. If MsgDataAbiValues is non-nil, this
	// value is not used.
	Data []byte `json:"data,omitempty"`

	// DataAbiValues represents the underlying message data to be sent to the receiver. If the receiver is a smart
	// contract, this will likely house your call parameters and other serialized data. This overrides Data if it is
	// set, allowing Data to be sourced from method ABI input arguments instead.
	DataAbiValues *CallMessageDataAbiValues `json:"dataAbiValues,omitempty"`

	// AccessList represents a core.Message's AccessList parameter which represents the storage slots and contracts
	// that will be accessed during the execution of this message.
	AccessList coreTypes.AccessList

	// SkipAccountChecks represents a core.Message's SkipAccountChecks. If it is set to true, then the message nonce
	// is not checked against the account nonce in state and will not verify if the sender is an EOA.
	SkipAccountChecks bool
}

CallMessage implements and extends Ethereum's coreTypes.Message, used to apply EVM/state updates.

func NewCallMessage

func NewCallMessage(from common.Address, to *common.Address, nonce uint64, value *big.Int, gasLimit uint64, gasPrice, gasFeeCap, gasTipCap *big.Int, data []byte) *CallMessage

NewCallMessage instantiates a new call message from a given set of parameters, with call data set from bytes.

func NewCallMessageWithAbiValueData

func NewCallMessageWithAbiValueData(from common.Address, to *common.Address, nonce uint64, value *big.Int, gasLimit uint64, gasPrice, gasFeeCap, gasTipCap *big.Int, abiData *CallMessageDataAbiValues) *CallMessage

NewCallMessageWithAbiValueData instantiates a new call message from a given set of parameters, with call data set from method ABI specified inputs.

func (*CallMessage) Clone

func (m *CallMessage) Clone() (*CallMessage, error)

Clone creates a copy of the given message and its underlying components, or an error if one occurs.

func (*CallMessage) FillFromTestChainProperties

func (m *CallMessage) FillFromTestChainProperties(chain *chain.TestChain)

FillFromTestChainProperties populates gas limit, price, nonce, and other fields automatically based on the worker's underlying test chain properties if they are not yet set.

func (CallMessage) MarshalJSON

func (c CallMessage) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*CallMessage) ToCoreMessage added in v0.1.2

func (m *CallMessage) ToCoreMessage() *core.Message

func (*CallMessage) UnmarshalJSON

func (c *CallMessage) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type CallMessageDataAbiValues

type CallMessageDataAbiValues struct {
	// Method defines the ABI method definition used to pack input argument values.
	Method *abi.Method

	// InputValues represents the ABI packable input argument values to use alongside the Method to produce the call
	// data.
	InputValues []any
	// contains filtered or unexported fields
}

CallMessageDataAbiValues describes a CallMessage Data field which is represented by ABI input argument values. This is represented at runtime by an abi.Method and its input values. Note: The data may be serialized. When deserializing, the Resolve method must be called to resolve the abi.Method and transform the encoded input data into compatible input values for the method.

func (*CallMessageDataAbiValues) Clone

Clone creates a copy of the given message data and its underlying components, or an error if one occurs.

func (*CallMessageDataAbiValues) MarshalJSON

func (d *CallMessageDataAbiValues) MarshalJSON() ([]byte, error)

MarshalJSON provides custom JSON marshalling for the struct. Returns the JSON marshalled data, or an error if one occurs.

func (*CallMessageDataAbiValues) Pack

func (d *CallMessageDataAbiValues) Pack() ([]byte, error)

Pack packs all the ABI argument InputValues into call data for the relevant Method it targets. If this was deserialized, Resolve must be called first to resolve necessary runtime data (such as the Method).

func (*CallMessageDataAbiValues) Resolve

func (d *CallMessageDataAbiValues) Resolve(contractAbi abi.ABI) error

Resolve takes a previously unmarshalled CallMessageDataAbiValues and resolves all internal data needed for it to be used at runtime by resolving the abi.Method it references from the provided contract ABI.

func (*CallMessageDataAbiValues) UnmarshalJSON

func (d *CallMessageDataAbiValues) UnmarshalJSON(b []byte) error

UnmarshalJSON provides custom JSON unmarshalling for the struct. Returns an error if one occurs.

type CallSequence

type CallSequence []*CallSequenceElement

CallSequence describes a sequence of calls sent to a chain.

func ExecuteCallSequence

func ExecuteCallSequence(chain *chain.TestChain, callSequence CallSequence) (CallSequence, error)

ExecuteCallSequence executes a provided CallSequence on the provided chain. It returns the slice of the call sequence which was tested, and an error if one occurred. If no error occurred, it can be expected that the returned call sequence contains all elements originally provided.

func ExecuteCallSequenceIteratively

func ExecuteCallSequenceIteratively(chain *chain.TestChain, fetchElementFunc ExecuteCallSequenceFetchElementFunc, executionCheckFunc ExecuteCallSequenceExecutionCheckFunc) (CallSequence, error)

ExecuteCallSequenceIteratively executes a CallSequence upon a provided chain iteratively. It ensures calls are included in blocks which adhere to the CallSequence properties (such as delays) as much as possible. A "fetch next call" function is provided to fetch the next element to execute. A "post element executed check" function is provided to check whether execution should stop after each element is executed. Returns the call sequence which was executed and an error if one occurs.

func (CallSequence) AttachExecutionTraces

func (cs CallSequence) AttachExecutionTraces(chain *chain.TestChain, contractDefinitions fuzzingTypes.Contracts) error

AttachExecutionTraces takes a given chain which executed the call sequence, and a list of contract definitions, and it replays each call of the sequence with an execution tracer attached to it, it then sets each CallSequenceElement.ExecutionTrace to the resulting trace. Returns an error if one occurred.

func (CallSequence) Clone

func (cs CallSequence) Clone() (CallSequence, error)

Clone creates a copy of the underlying CallSequence.

func (CallSequence) Hash

func (cs CallSequence) Hash() (common.Hash, error)

Hash calculates a unique hash which represents the uniqueness of the call sequence and each element in it. It does not hash execution/result data. Returns the calculated hash, or an error if one occurs.

func (CallSequence) Log added in v0.1.1

func (cs CallSequence) Log() *logging.LogBuffer

Log returns a logging.LogBuffer that represents this call sequence. This buffer will be passed to the underlying logger which will format it accordingly for console or file.

func (CallSequence) String

func (cs CallSequence) String() string

String returns the string representation of this call sequence

type CallSequenceElement

type CallSequenceElement struct {
	// Contract describes the contract which was targeted by a transaction.
	Contract *fuzzingTypes.Contract `json:"-"`

	// Call represents the underlying message call.
	Call *CallMessage `json:"call"`

	// BlockNumberDelay defines how much the block number should advance when executing this transaction, compared to
	// the last executed transaction. If zero, this indicates the call should be included in the current pending block.
	// This number is *suggestive*: if delay specifies we should add a tx to a block which is full, it will be added to
	// a new block instead. If BlockNumberDelay is greater than BlockTimestampDelay and both are non-zero (we want to
	// create a new block), BlockNumberDelay will be capped to BlockTimestampDelay, as each block must have a unique
	// time stamp for chain semantics.
	BlockNumberDelay uint64 `json:"blockNumberDelay"`

	// BlockTimestampDelay defines how much the block timestamp should advance when executing this transaction,
	// compared to the last executed transaction.
	// This number is *suggestive*: if BlockNumberDelay is non-zero (indicating to add to the existing block), this
	// value will not be used.
	BlockTimestampDelay uint64 `json:"blockTimestampDelay"`

	// ChainReference describes the inclusion of the Call as a transaction in a block. This block may not yet be
	// committed to its underlying chain if this is a CallSequenceElement was just executed. Additional transactions
	// may be included before the block is committed. This reference will remain compatible after the block finalizes.
	ChainReference *CallSequenceElementChainReference `json:"-"`

	// ExecutionTrace represents a verbose execution trace collected. Nil if an execution trace was not collected.
	ExecutionTrace *executiontracer.ExecutionTrace `json:"-"`
}

CallSequenceElement describes a single call in a call sequence (tx sequence) targeting a specific contract. It contains the information regarding the contract/method being called as well as the call message data itself.

func NewCallSequenceElement

func NewCallSequenceElement(contract *fuzzingTypes.Contract, call *CallMessage, blockNumberDelay uint64, blockTimestampDelay uint64) *CallSequenceElement

NewCallSequenceElement returns a new CallSequenceElement struct to track a single call made within a CallSequence.

func (*CallSequenceElement) AttachExecutionTrace

func (cse *CallSequenceElement) AttachExecutionTrace(chain *chain.TestChain, contractDefinitions fuzzingTypes.Contracts) error

AttachExecutionTrace takes a given chain which executed the call sequence element, and a list of contract definitions, and it replays the call with an execution tracer attached to it, it then sets CallSequenceElement.ExecutionTrace to the resulting trace. Returns an error if one occurred.

func (*CallSequenceElement) Clone

Clone creates a copy of the underlying CallSequenceElement.

func (*CallSequenceElement) Method

func (cse *CallSequenceElement) Method() (*abi.Method, error)

Method obtains the abi.Method targeted by the CallSequenceElement.Call, or an error if one occurred while obtaining it.

func (*CallSequenceElement) String

func (cse *CallSequenceElement) String() string

String returns a displayable string representing the CallSequenceElement.

type CallSequenceElementChainReference

type CallSequenceElementChainReference struct {
	// Block describes the block the CallSequenceElement.Call was included in as a transaction. This block may be
	// pending commitment to the chain, or already committed.
	Block *chainTypes.Block

	// TransactionIndex describes the index at which the transaction was included into the Block.
	TransactionIndex int
}

CallSequenceElementChainReference references the inclusion of a CallSequenceElement's underlying call being included in a block as a transaction.

func (*CallSequenceElementChainReference) MessageResults

MessageResults obtains the results of executing the CallSequenceElement.

type ExecuteCallSequenceExecutionCheckFunc

type ExecuteCallSequenceExecutionCheckFunc func(currentExecutedSequence CallSequence) (bool, error)

ExecuteCallSequenceExecutionCheckFunc describes a function that is called after each call is executed in a sequence. It is given the currently executed call sequence to this point. Returns a boolean indicating if the sequence execution should break, or an error if one occurs.

type ExecuteCallSequenceFetchElementFunc

type ExecuteCallSequenceFetchElementFunc func(index int) (*CallSequenceElement, error)

ExecuteCallSequenceFetchElementFunc describes a function that is called to obtain the next call sequence element to execute. It is given the current call index in the sequence. Returns the call sequence element to execute, or an error if one occurs. If the call sequence element is nil, it indicates the end of the sequence and execution breaks.

Jump to

Keyboard shortcuts

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