checks

package
v0.6.31 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: GPL-3.0 Imports: 21 Imported by: 1

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

This section is empty.

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, gs GetStakeFunc) error

ValidateInitCode checks if initCode is not empty and gets the factory address. If factory address is valid it calls a generic function that can retrieve the stake from the EntryPoint.

func ValidatePaymasterAndData added in v0.1.1

func ValidatePaymasterAndData(op *userop.UserOperation, gc GetCodeFunc, gs GetStakeFunc) 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,
	maxOpsForUnstakedSender int,
	gs GetStakeFunc,
) 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.
  3. Sender is staked and is allowed uncapped UserOperations in the pool.

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 GetStakeFunc added in v0.1.1

type GetStakeFunc = func(entity common.Address) (*entrypoint.IStakeManagerDepositInfo, error)

GetStakeFunc provides a general interface for retrieving the EntryPoint stake 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,
	maxOpsForUnstakedSender int,
) *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) 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