Skip to content

Commit d8d6c02

Browse files
authored
Merge pull request #22 from AAStarCommunity/chore/m7-r4-address-sync
chore(airaccount): sync M7 module addresses to r4 audit-final + postOp gas floor
2 parents a9b63f2 + fcabd1a commit d8d6c02

5 files changed

Lines changed: 57 additions & 25 deletions

File tree

packages/airaccount/src/server/config.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,34 @@ export interface ServerConfig {
5353
logger?: ILogger;
5454
}
5555

56-
/** AirAccount contract version selection. */
57-
export type AirAccountVersion = "M5" | "M7";
56+
/** AirAccount contract version selection.
57+
* - "M7" — r4 audit-final (default). Use for all new account creation.
58+
* - "M7r6" — r6 deployment (2026-03-29, superseded). Use ONLY to recover existing r6-deployed accounts.
59+
* - "M5" — legacy 6-field InitConfig deployment.
60+
*/
61+
export type AirAccountVersion = "M5" | "M7" | "M7r6";
5862

5963
/**
6064
* Build a pre-configured EntryPointVersionConfig for Sepolia using a known AirAccount deployment.
6165
* Eliminates the need to look up contract addresses manually.
6266
*
6367
* @example
64-
* // Use M7 (default)
68+
* // Use M7 r4 audit-final (default)
6569
* const config = { entryPoints: { v07: sepoliaV07Config() }, ... };
6670
*
71+
* // Recover an existing r6-deployed account (do NOT use for new accounts)
72+
* const config = { entryPoints: { v07: sepoliaV07Config("M7r6") }, ... };
73+
*
6774
* // Use M5 legacy
6875
* const config = { entryPoints: { v07: sepoliaV07Config("M5") }, ... };
6976
*/
7077
export function sepoliaV07Config(version: AirAccountVersion = "M7"): EntryPointVersionConfig {
7178
const factoryAddress =
7279
version === "M5"
7380
? AIRACCOUNT_ADDRESSES.sepolia.factoryM5
74-
: AIRACCOUNT_ADDRESSES.sepolia.factory;
81+
: version === "M7r6"
82+
? AIRACCOUNT_ADDRESSES.sepolia.factoryM7r6
83+
: AIRACCOUNT_ADDRESSES.sepolia.factory; // "M7" = r4 audit-final (default)
7584

7685
return {
7786
entryPointAddress: ENTRYPOINT_ADDRESSES[EntryPointVersion.V0_7].sepolia,

packages/airaccount/src/server/constants/entrypoint.ts

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,37 @@ export const AIRACCOUNT_ADDRESSES = {
7070
factoryM4: "0x914db0a849f55e68a726c72fd02b7114b1176d88",
7171
// M5 factory r5 — 6-field InitConfig, guardian acceptance sigs required
7272
factoryM5: "0xd72a236d84be6c388a8bc7deb64afd54704ae385",
73-
// M7 factory r5 (prev) — defaultCommunityGuardian was address(0), do not use for new accounts
74-
factoryM7r5Prev: "0xa0007c5db27548d8c1582773856db1d123107383",
75-
// M7 factory r6 — defaultCommunityGuardian = team Safe 0x51eD...E114 (deployed 2026-03-29)
76-
// BREAKING CHANGE: `.factory` now points to r6. Accounts created here have a new CREATE2 address.
77-
factory: "0x42f82d77f9cf940686b6a64a369245cb563e0e85",
78-
// M7 factory alias — use this to be explicit about targeting M7
79-
factoryM7: "0x42f82d77f9cf940686b6a64a369245cb563e0e85",
80-
// M7 account implementation r6 (shared by all clone proxies)
81-
accountImpl: "0x2F1B4EB63143D338bE78d0AF878B806f075080c1",
73+
/** @deprecated defaultCommunityGuardian was address(0); superseded by r6 and r4. Do not use for new accounts. */
74+
factoryM7r5Prev: "0xa0007c5dB27548D8c1582773856dB1D123107383",
75+
76+
// ── Deprecated: r6 addresses (2026-03-29 deployment, superseded by r4 audit-final) ──────────
77+
// Retain for legacy account lookups and historical event indexing ONLY.
78+
// DO NOT use for new account creation — CREATE2 address will differ from r4.
79+
/** @deprecated Use {@link factory} (r4 audit-final) for new accounts. */
80+
factoryM7r6: "0x42f82d77f9cf940686b6a64a369245cb563e0e85",
81+
/** @deprecated Use {@link accountImpl} (r4 audit-final). */
82+
accountImplM7r6: "0x2F1B4EB63143D338bE78d0AF878B806f075080c1",
83+
/** @deprecated Use {@link compositeValidator} (r4 audit-final). */
84+
compositeValidatorM7r6: "0x4135c539fec5e200fe9762b721f6829b2315cbe1",
85+
/** @deprecated Use {@link tierGuardHook} (r4 audit-final). */
86+
tierGuardHookM7r6: "0x73572e9e6138fd53465ee243e2fb4842cf86a787",
87+
/** @deprecated Use {@link agentSessionKeyValidator} (r4 audit-final). */
88+
agentSessionKeyValidatorM7r6: "0xa3e52db4b6e0a9d7cd5dd1414a90eedcf950e029",
89+
90+
// ── Current: r4 audit-final (freeze/m7-v0.16.0, 660 tests, all audit findings resolved) ─────
91+
// M7 factory r4 — EIP-1167 clone factory, full audit-final release
92+
factory: "0x61bBAf9E1b8Fd78fF874776cFa50497dB9d43C3F",
93+
factoryM7: "0x61bBAf9E1b8Fd78fF874776cFa50497dB9d43C3F",
94+
// M7 account implementation r4 (shared by all clone proxies, 23,847B EIP-170 compliant)
95+
accountImpl: "0xA674D308ce22230B70412b20Ee5a66fC6B24F49c",
8296
validatorRouter: "0x730a162Ce3202b94cC5B74181B75b11eBB3045B1",
8397
blsAlgorithm: "0xc2096E8D04beb3C337bb388F5352710d62De0287",
8498
blsAggregator: "0x7700aec8a15a94db5697c581de8c88ecf83b59ff",
8599
superPaymaster: "0x16cE0c7d846f9446bbBeb9C5a84A4D140fAeD94A",
86-
// M7 r5 ERC-7579 modules (pre-installed by factory on every new account)
87-
compositeValidator: "0x4135c539fec5e200fe9762b721f6829b2315cbe1",
88-
tierGuardHook: "0x73572e9e6138fd53465ee243e2fb4842cf86a787",
89-
agentSessionKeyValidator: "0xa3e52db4b6e0a9d7cd5dd1414a90eedcf950e029",
100+
// M7 r4 ERC-7579 modules (pre-installed by factory on every new account)
101+
compositeValidator: "0xB65569950C48AA56dbe876915ca3605fD6FF2980",
102+
tierGuardHook: "0x67f878295cFF7451CBD2A775C4490607AF1b07d7",
103+
agentSessionKeyValidator: "0x1F06961e133217801F92e1CF552187F594a32873",
90104
// M6 继承合约(M7 factory 仍可配合使用)
91105
sessionKeyValidator: "0xcaba5a18e46f728b5330ea33bd099693a1b76217",
92106
calldataParserRegistry: "0x7099eb39fbab795e66dd71fbeaace150edf1b3c3",

packages/enduser/src/UserClient.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,10 @@ export class UserClient extends BaseClient {
498498
const SAFETY_PAD = 80000n;
499499
verificationGasLimit = est.verificationGasLimit + SAFETY_PAD;
500500

501-
// PostOp Tuning
502-
paymasterPostOpGasLimit = est.paymasterPostOpGasLimit + 10000n;
501+
// SuperPaymaster postOp calls burnFromWithOpHash (~40k gas) + storage writes.
502+
// Add 100k buffer; floor at 200k to prevent OOG. Pure BigInt to avoid Number precision loss.
503+
const _postOpBase = est.paymasterPostOpGasLimit + 100_000n;
504+
paymasterPostOpGasLimit = _postOpBase > 200_000n ? _postOpBase : 200_000n;
503505

504506
autoEstimate = false; // logic handled
505507
}

packages/paymaster/src/V4/PaymasterClient.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,13 @@ export class PaymasterClient {
336336
verificationGasLimit: options?.verificationGasLimit,
337337
callGasLimit: options?.callGasLimit,
338338
paymasterVerificationGasLimit: options?.paymasterVerificationGasLimit,
339-
paymasterPostOpGasLimit: options?.paymasterPostOpGasLimit ?? 150000n
339+
paymasterPostOpGasLimit: options?.paymasterPostOpGasLimit ?? 200_000n
340340
};
341341

342342
if (options?.autoEstimate !== false && (!gasLimits.verificationGasLimit || !gasLimits.callGasLimit)) {
343343
const est = await this.estimateUserOperationGas(
344-
client, wallet, aaAddress, entryPoint, paymasterAddress, token, bundlerUrl, callData,
345-
{
344+
client, wallet, aaAddress, entryPoint, paymasterAddress, token, bundlerUrl, callData,
345+
{
346346
validityWindow: options?.validityWindow,
347347
operator: options?.operator,
348348
factory: options?.factory,
@@ -353,7 +353,12 @@ export class PaymasterClient {
353353
gasLimits.verificationGasLimit = options?.verificationGasLimit ?? est.verificationGasLimit;
354354
gasLimits.callGasLimit = options?.callGasLimit ?? est.callGasLimit;
355355
gasLimits.paymasterVerificationGasLimit = options?.paymasterVerificationGasLimit ?? est.paymasterVerificationGasLimit;
356-
gasLimits.paymasterPostOpGasLimit = options?.paymasterPostOpGasLimit ?? est.paymasterPostOpGasLimit;
356+
// SuperPaymaster postOp calls burnFromWithOpHash (~40k) + storage writes.
357+
// Apply 100k buffer with 200k floor. Pure BigInt to avoid Number precision loss.
358+
if (!options?.paymasterPostOpGasLimit) {
359+
const _base = est.paymasterPostOpGasLimit + 100_000n;
360+
gasLimits.paymasterPostOpGasLimit = _base > 200_000n ? _base : 200_000n;
361+
}
357362
}
358363

359364
// 1. Get Nonce

packages/paymaster/src/V4/SuperPaymasterClient.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ export class SuperPaymasterClient {
113113
const bundlerEstimateVGL = est.paymasterVerificationGasLimit || 100000n;
114114
const tunedPMVerificationGas = tuneGasLimit(bundlerEstimateVGL, 60_000n, 0.45);
115115

116-
// Same for PostOp
117-
const tunedPostOp = est.paymasterPostOpGasLimit + 10000n;
116+
// SuperPaymaster postOp calls burnFromWithOpHash (~40k gas) + storage writes.
117+
// Add 100k buffer; floor at 200k to prevent OOG. Pure BigInt to avoid Number precision loss.
118+
const _postOpBase = est.paymasterPostOpGasLimit + 100_000n;
119+
const tunedPostOp = _postOpBase > 200_000n ? _postOpBase : 200_000n;
118120

119121
console.log(`[SuperPaymasterClient] 🔧 Tuned Limits: VGL=${tunedVGL}, PMVGL=${tunedPMVerificationGas}, PostOp=${tunedPostOp}`);
120122

0 commit comments

Comments
 (0)