2
function numberMarker() internal view {
    assembly {mstore(0, number())}
}

I'm studying about Account Abstraction, and exploring through the implementation code of EntryPoint.sol by Infinitism. Link is here.

However, I'm stuck in the function numberMarker()...

It seems to store NUMBER opcode in the 0x00 part of memory, but they are saying that it can be used as marker for banned opcode.

Is it used as a marker for bundlers to verify if banned opcodes are used? How does this code work?

I've seen the full code of EntryPoint.sol, but can't find any clues for its usage. It is only called inside some functions...

1 Answer 1

1

From the eip-4337: https://eips.ethereum.org/EIPS/eip-4337#simulation

The client(or bundler) simulated call performs the full validation before submitting on-chain, by calling:

  1. If initCode is present, factory.createSender()
  2. account.validateUserOp()
  3. If paymaster is present, paymaster.validatePaymasterUserOp()

These calls differ in their banned OpCodes and policies.

For example:

The CREATE2 opcode is banned for validateUserOp() and validatePaymasterUserOp() but allows to call for factory.createSender().

To enable a client to distinguish opcodes between them, within contracts, there is a call to the NUMBER opcode (block.number), used as a delimiter between the 3 functions. While simulating userOp validation.

You can see the numberMarker calling within

EntryPoint: https://github.com/eth-infinitism/account-abstraction/blob/465f22310fcc639964e6ab5f8aa648770c6d8981/contracts/core/EntryPoint.sol

From EntryPoint, the numberMarker will be called 2 times sequentially to separate the 3 opcodes sections.


Most important, currently, the bundler uses top-level calls instead of this approach to scan banned OpCodes: https://github.com/eth-infinitism/bundler/pull/116

Can find the example of how the bundler scans banned OpCodes from: https://github.com/eth-infinitism/bundler/blob/65f56cfc9c739b594279469de924730517209244/packages/bundler/src/parseScannerResult.ts#L172

1
  • 1
    Thanks, it helped a lot :)
    – sm-stack
    Commented Sep 30, 2023 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.