EPF update 6

Summary

  1. Submited another pr about bundle config for rust aa-bundler
  2. Review typescript abstract account userOpId codes along with Vid's pr

Rust aa-bundler bundle config

Well, the Bundle Config pr is actually a quite simple task. I spent most of the time reading the clap documents and find a custom way to parse the input integer into U256 in rust and and hex string like 0x122321.... into Address type in rust.

The Clap-rs repo gives a very good example for how to write a custom parser for custom type.

UserOperationHash

I was also reviewing Vid's pr on generating UserOperationHash. I came accross the yul code which I don't have good understanding the yul codes. The UserOperationHash is generated by the codes below


    function pack(UserOperation calldata userOp) internal pure returns (bytes memory ret) {
        //lighter signature scheme. must match UserOp.ts#packUserOp
        bytes calldata sig = userOp.signature;
        // copy directly the userOp from calldata up to (but not including) the signature.
        // this encoding depends on the ABI encoding of calldata, but is much lighter to copy
        // than referencing each field separately.
        assembly {
            let ofs := userOp
            let len := sub(sub(sig.offset, ofs), 32)
            ret := mload(0x40)
            mstore(0x40, add(ret, add(len, 32)))
            mstore(ret, len)
            calldatacopy(add(ret, 32), ofs, len)
        }
    }

The yul codes is operating on the stack level.Let's give a review of the codes.

ofs is the userOp position in the calldata. len is the length from the userOp head to the signature field head.

0x40 is the default free memory pointer. Store a new free memory pointer add(ret, add(len, 32)) which is the new memory free pointer.

mstore(ret, len) store the length of the data in the free pointer position and calldatacopy(add(ret, 32), ofs, len) copy the userOp up before signature into memory.

Reading List

  1. Memory Layout in EVM
  2. Storage layout