bcnmy / bcnmy/userop-debugger-backend
Enhance Paymaster Info Decoder from PaymasterAndData
- Dominant language
- TypeScript
- Stars
- 7
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
## Background
PaymasterAndData from input param of UserOps is decoded in to PaymasterInfo
Struct for PaymasterInfo is:
```js
export interface PaymasterInfo {
name: string;
version: string;
provider: PaymasterProvider;
paymasterAddress: string;
type: PaymasterType;
gasPaymentToken?: TokenInfo;
exchangeRate?: string;
error?: DecodedError;
moreInfo?: {};
}
```
## Proposed Enhancement
Enhance the PaymasterInfo Decoder to accomodate the decoded values of `paymasterAndData`
such as:
1. paymasterVerificationGasLimit
2. paymasterPostOpGasLimit
At moment parsing is done only to extract the paymasterAddress which is 0:42 slicing
The data after 42 ie [42:] contains `paymasterVerificationGasLimit` and `paymasterPostOpGasLimit`
Add a new function:
```js
unpackPaymasterDataFields(paymasterAndData: string): [string, bigint, bigint] {
let paymasterAddress = ethers.getAddress(paymasterAndData.slice(0, 42));
let paymasterVerificationGasLimit = BigInt('0x' + paymasterAndData.slice(42, 66));
let paymasterPostOpGasLimit = BigInt('0x' + paymasterAndData.slice(66, 90));
return [paymasterAddress, paymasterVerificationGasLimit, paymasterPostOpGasLimit];
}
```
these can be set to PaymasterInfo Struct
## Usage of new proposed properties in struct
1. AA93
- check to verify for the Error AA94Decoder and use the length of `paymasterAndData` in errorString
```js
paymasterAndData.length >= UserOperationLib.PAYMASTER_DATA_OFFSET
```
here PAYMASTER_DATA_OFFSET is 52
```js
uint256 public constant PAYMASTER_VALIDATION_GAS_OFFSET = 20;
uint256 public constant PAYMASTER_POSTOP_GAS_OFFSET = 36;
uint256 public constant PAYMASTER_DATA_OFFSET = 52;
```
------
2. AA40
```js
if (mUserOp.verificationGasLimit + mUserOp.paymasterVerificationGasLimit < gasUsed) {
revert FailedOp(opIndex, "AA40 over verificationGasLimit");
}
```
here we need to generate ErrorString which contain the verificationGasLimit & paymasterVerificationGasLimit and their sum
to make the display on UI more detailed
Contributor guide
No contributing guide indexed for this repository
Research direction
Locate the PaymasterInfo decoder and the AA93 and AA40 error-handling paths mentioned in the issue. Check the documented PaymasterAndData offsets first; done means the decoder exposes both gas limits and the relevant error strings include the requested length and gas-limit details.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100