calls

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: AGPL-3.0 Imports: 18 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 {
	// MsgFrom represents a core.Message's from parameter (sender), indicating who sent a transaction/message to the
	// Ethereum core to apply a state update.
	MsgFrom common.Address `json:"from"`

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

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

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

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

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

	// MsgGasFeeCap 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.
	MsgGasFeeCap *big.Int `json:"gasFeeCap"`

	// MsgGasTipCap 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.
	MsgGasTipCap *big.Int `json:"gasTipCap"`

	// MsgData 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.
	MsgData []byte `json:"data,omitempty"`

	// MsgDataAbiValues 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 MsgData if it is
	// set, allowing Data to be sourced from method ABI input arguments instead.
	MsgDataAbiValues *CallMessageDataAbiValues `json:"dataAbiValues,omitempty"`
}

CallMessage implements 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, data *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) AccessList

func (m *CallMessage) AccessList() coreTypes.AccessList

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) Data

func (m *CallMessage) Data() []byte

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) From

func (m *CallMessage) From() common.Address

func (*CallMessage) Gas

func (m *CallMessage) Gas() uint64

func (*CallMessage) GasFeeCap

func (m *CallMessage) GasFeeCap() *big.Int

func (*CallMessage) GasPrice

func (m *CallMessage) GasPrice() *big.Int

func (*CallMessage) GasTipCap

func (m *CallMessage) GasTipCap() *big.Int

func (*CallMessage) IsFake

func (m *CallMessage) IsFake() bool

func (CallMessage) MarshalJSON

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

MarshalJSON marshals as JSON.

func (*CallMessage) Nonce

func (m *CallMessage) Nonce() uint64

func (*CallMessage) To

func (m *CallMessage) To() *common.Address

func (*CallMessage) UnmarshalJSON

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

UnmarshalJSON unmarshals from JSON.

func (*CallMessage) Value

func (m *CallMessage) Value() *big.Int

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) String

func (cs CallSequence) String() string

String returns a displayable string representing the CallSequence.

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