--- tags: Ethereum Protocol Fellowship --- # EPF update 6 ## Summary 1. Submited another pr about [bundle config](https://github.com/Vid201/aa-bundler/pull/21) for rust aa-bundler 2. Review [typescript abstract account userOpId codes](https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/interfaces/UserOperation.sol#L57-L71) along with [Vid's pr](https://github.com/Vid201/aa-bundler/pull/19) ## Rust aa-bundler bundle config Well, the [Bundle Config pr](https://github.com/Vid201/aa-bundler/pull/21) is actually a quite simple task. I spent most of the time reading the [clap documents](https://docs.rs/clap/latest/clap/) 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](https://github.com/clap-rs/clap/blob/master/examples/typed-derive.rs#L48-L59). ## 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](https://medium.com/swlh/getting-deep-into-evm-how-ethereum-works-backstage-ab6ad9c0d0bf) 2. [Storage layout](https://docs.soliditylang.org/en/v0.8.13/internals/layout_in_storage.html)