checks

package
v0.6.47 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package checks implements modules for running an array of standard validations for both the Client and Bundler.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReplacementOpUnderpriced = fmt.Errorf(
		"pending ops: replacement op must increase maxFeePerGas and MaxPriorityFeePerGas by >= %d%%",
		minPriceBump,
	)
)

Functions

func ValidateCallGasLimit added in v0.1.1

func ValidateCallGasLimit(op *userop.UserOperation, ov *gas.Overhead) error

ValidateCallGasLimit checks the callGasLimit is at least the cost of a CALL with non-zero value.

func ValidateFeePerGas added in v0.1.1

func ValidateFeePerGas(op *userop.UserOperation, gbf gasprice.GetBaseFeeFunc) error

ValidateFeePerGas checks the maxFeePerGas is sufficiently high to be included with the current block.basefee. Alternatively, if basefee is not supported, then check that maxPriorityFeePerGas is equal to maxFeePerGas as a fallback.

func ValidateGasAvailable added in v0.6.9

func ValidateGasAvailable(op *userop.UserOperation, maxBatchGasLimit *big.Int) error

ValidateGasAvailable checks that the max available gas is less than the batch gas limit.

func ValidateInitCode added in v0.1.1

func ValidateInitCode(op *userop.UserOperation) error

ValidateInitCode checks if initCode is not empty and has a valid factory address.

func ValidatePaymasterAndData added in v0.1.1

func ValidatePaymasterAndData(
	op *userop.UserOperation,
	dep *entrypoint.IStakeManagerDepositInfo,
	gc GetCodeFunc,
) error

ValidatePaymasterAndData checks the paymasterAndData is either zero bytes or the first 20 bytes contain an address that

  1. currently has nonempty code on chain
  2. has a sufficient deposit to pay for the UserOperation

func ValidatePendingOps added in v0.1.1

func ValidatePendingOps(
	op *userop.UserOperation,
	penOps []*userop.UserOperation,
) error

ValidatePendingOps checks the pending UserOperations by the same sender and only passes if:

  1. Sender doesn't have another UserOperation already present in the pool.
  2. It replaces an existing UserOperation with same nonce and higher fee.

func ValidateSender added in v0.1.1

func ValidateSender(op *userop.UserOperation, gc GetCodeFunc) error

ValidateSender accepts a userOp and a generic function that can retrieve the bytecode of the sender. Either the sender is deployed (non-zero length bytecode) or the initCode is not empty (but not both).

func ValidateVerificationGas added in v0.1.1

func ValidateVerificationGas(op *userop.UserOperation, ov *gas.Overhead, maxVerificationGas *big.Int) error

ValidateVerificationGas checks that the verificationGasLimit is sufficiently low (<= MAX_VERIFICATION_GAS) and the preVerificationGas is sufficiently high (enough to pay for the calldata gas cost of serializing the UserOperation plus PRE_VERIFICATION_OVERHEAD_GAS).

Types

type GetCodeFunc added in v0.1.1

type GetCodeFunc = func(addr common.Address) ([]byte, error)

GetCodeFunc provides a general interface for retrieving the bytecode for a given address.

type Standalone

type Standalone struct {
	// contains filtered or unexported fields
}

Standalone exposes modules to perform basic Client and Bundler checks as specified in EIP-4337. It is intended for bundlers that are independent of an Ethereum node and hence relies on a given ethClient to query blockchain state.

func New

func New(
	db *badger.DB,
	rpc *rpc.Client,
	ov *gas.Overhead,
	alt *altmempools.Directory,
	maxVerificationGas *big.Int,
	maxBatchGasLimit *big.Int,
	isRIP7212Supported bool,
	tracer string,
	repConst *entities.ReputationConstants,
) *Standalone

New returns a Standalone instance with methods that can be used in Client and Bundler modules to perform standard checks as specified in EIP-4337.

func (*Standalone) Clean added in v0.4.0

func (s *Standalone) Clean() modules.BatchHandlerFunc

Clean returns a BatchHandler that clears the DB of data that is no longer required. This should be one of the last modules executed by the Bundler.

func (*Standalone) CodeHashes added in v0.4.0

func (s *Standalone) CodeHashes() modules.BatchHandlerFunc

CodeHashes returns a BatchHandler that verifies the code for any interacted contracts has not changed since the first simulation.

func (*Standalone) PaymasterDeposit

func (s *Standalone) PaymasterDeposit() modules.BatchHandlerFunc

PaymasterDeposit returns a BatchHandler that tracks each paymaster in the batch and ensures it has enough deposit to pay for all the UserOps that use it.

func (*Standalone) SimulateBatch added in v0.6.33

func (s *Standalone) SimulateBatch() modules.BatchHandlerFunc

TODO: Implement

func (*Standalone) SimulateOp

func (s *Standalone) SimulateOp() modules.UserOpHandlerFunc

SimulateOp returns a UserOpHandler that runs through simulation of new UserOps with the EntryPoint.

func (*Standalone) ValidateOpValues

func (s *Standalone) ValidateOpValues() modules.UserOpHandlerFunc

ValidateOpValues returns a UserOpHandler that runs through some first line sanity checks for new UserOps received by the Client. This should be one of the first modules executed by the Client.

Jump to

Keyboard shortcuts

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