@agenticprimitives/contracts 1.0.0-alpha.4 → 1.0.0-alpha.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUDIT.md +330 -47
- package/README.md +56 -10
- package/deployments-base-sepolia.json +50 -0
- package/deployments-faithchain.json +75 -0
- package/deployments-hopechain.json +57 -0
- package/deployments-paymaster-anvil.json +1 -0
- package/deployments-registries-base-sepolia.json +1 -0
- package/deployments-registries-hopechain.json +1 -0
- package/dist/abi/AgentAccount.json +1827 -0
- package/dist/abi/AgentAccountFactory.json +545 -0
- package/dist/abi/AgentNameRegistry.json +51 -0
- package/dist/abi/AgentRegistryBase.json +652 -0
- package/dist/abi/AgenticGovernance.json +32 -0
- package/dist/abi/AgreementRegistry.json +427 -0
- package/dist/abi/ApprovedHashRegistry.json +47 -2
- package/dist/abi/AttestationRegistry.json +436 -0
- package/dist/abi/CallDataHashEnforcer.json +119 -0
- package/dist/abi/CustodyPolicy.json +1179 -0
- package/dist/abi/DelegationManager.json +656 -0
- package/dist/abi/DigestBindingEnforcer.json +251 -0
- package/dist/abi/EstateProjectionRegistry.json +293 -0
- package/dist/abi/GeoFeatureRegistry.json +625 -0
- package/dist/abi/IAgentAccount.json +262 -0
- package/dist/abi/IAgentAccountFactoryAccessor.json +15 -0
- package/dist/abi/IAgentAccountFactoryView.json +54 -0
- package/dist/abi/IAgentAccountPauseView.json +15 -0
- package/dist/abi/IAgenticPrimitivesAgentAccount.json +15 -0
- package/dist/abi/IApprovedHashRegistryView.json +26 -0
- package/dist/abi/IApprovedHashRegistryWrite.json +35 -0
- package/dist/abi/ICustodyPolicyAccountModuleView.json +31 -0
- package/dist/abi/ICustodyPolicyFactoryView.json +15 -0
- package/dist/abi/ICustodyPolicyPauseView.json +15 -0
- package/dist/abi/IDelegationManager.json +171 -0
- package/dist/abi/IERC7579HookLike.json +44 -0
- package/dist/abi/IERC7579ModuleLike.json +28 -0
- package/dist/abi/IPaymentReceiptRegistry.json +50 -0
- package/dist/abi/IRegistryMembershipPolicy.json +70 -0
- package/dist/abi/MockUSDC.json +621 -0
- package/dist/abi/PayloadClassesEnforcer.json +117 -0
- package/dist/abi/PaymentEnforcer.json +441 -0
- package/dist/abi/PaymentEscrow.json +324 -0
- package/dist/abi/PaymentReceiptRegistry.json +182 -0
- package/dist/abi/PermissionlessSubregistry.json +5 -0
- package/dist/abi/PricedSubregistry.json +869 -0
- package/dist/abi/QuorumEnforcer.json +311 -0
- package/dist/abi/ReceiptAnchorRegistry.json +153 -0
- package/dist/abi/SignatureSlotRecovery.json +88 -0
- package/dist/abi/SkillDefinitionRegistry.json +491 -0
- package/dist/abi/SmartAgentPaymaster.json +873 -0
- package/dist/abi/TreasurySpendPolicy.json +369 -0
- package/dist/abi/UniversalSignatureValidator.json +65 -0
- package/dist/abi/index.d.ts +38 -0
- package/dist/abi/index.js +38 -0
- package/dist/deployments/base-sepolia.d.ts +46 -0
- package/dist/deployments/base-sepolia.js +54 -0
- package/dist/deployments/faithchain.d.ts +55 -0
- package/dist/deployments/faithchain.js +79 -0
- package/dist/deployments/hopechain.d.ts +53 -0
- package/dist/deployments/hopechain.js +61 -0
- package/dist/deployments/index.d.ts +13 -0
- package/dist/deployments/index.js +28 -0
- package/dist/deployments/paymaster-anvil.d.ts +11 -0
- package/dist/deployments/paymaster-anvil.js +9 -0
- package/dist/deployments/registries-base-sepolia.d.ts +10 -0
- package/dist/deployments/registries-base-sepolia.js +8 -0
- package/dist/deployments/registries-hopechain.d.ts +10 -0
- package/dist/deployments/registries-hopechain.js +8 -0
- package/package.json +55 -8
- package/src/AgentAccount.sol +569 -38
- package/src/AgentAccountFactory.sol +157 -16
- package/src/ApprovedHashRegistry.sol +41 -6
- package/src/IAgentAccount.sol +23 -0
- package/src/SmartAgentPaymaster.sol +156 -12
- package/src/UniversalSignatureValidator.sol +3 -0
- package/src/agency/DelegationManager.sol +179 -0
- package/src/agency/IDelegationManager.sol +38 -0
- package/src/agreement/AgreementRegistry.sol +331 -0
- package/src/attestation/AttestationRegistry.sol +384 -0
- package/src/custody/CustodyPolicy.sol +263 -15
- package/src/custody/TreasurySpendPolicy.sol +166 -0
- package/src/enforcers/AllowedMethodsEnforcer.sol +6 -0
- package/src/enforcers/AllowedTargetsEnforcer.sol +6 -0
- package/src/enforcers/CallDataHashEnforcer.sol +61 -0
- package/src/enforcers/DigestBindingEnforcer.sol +107 -0
- package/src/enforcers/PayloadClassesEnforcer.sol +30 -0
- package/src/enforcers/PaymentEnforcer.sol +257 -0
- package/src/enforcers/QuorumEnforcer.sol +24 -1
- package/src/enforcers/TimestampEnforcer.sol +7 -0
- package/src/enforcers/ValueEnforcer.sol +6 -0
- package/src/geo/GeoFeatureRegistry.sol +197 -0
- package/src/governance/AgenticGovernance.sol +26 -4
- package/src/identity/AgentProfilePredicates.sol +23 -0
- package/src/libraries/SignatureSlotRecovery.sol +24 -7
- package/src/libraries/WebAuthnLib.sol +13 -0
- package/src/mocks/MockUSDC.sol +152 -0
- package/src/naming/AgentNamePredicates.sol +89 -0
- package/src/naming/AgentNameRegistry.sol +65 -18
- package/src/naming/AgentNameUniversalResolver.sol +1 -1
- package/src/naming/PermissionlessSubregistry.sol +19 -2
- package/src/naming/PricedSubregistry.sol +209 -0
- package/src/payments/PaymentEscrow.sol +164 -0
- package/src/payments/PaymentReceiptRegistry.sol +67 -0
- package/src/provenance/ReceiptAnchorRegistry.sol +55 -0
- package/src/registry/AgentRegistryBase.sol +313 -0
- package/src/registry/EstateProjectionRegistry.sol +109 -0
- package/src/registry/IRegistryMembershipPolicy.sol +30 -0
- package/src/relationships/AgentRelationship.sol +8 -0
- package/src/skills/SkillDefinitionRegistry.sol +187 -0
|
@@ -10,7 +10,7 @@ import "./governance/GovernanceManaged.sol";
|
|
|
10
10
|
/**
|
|
11
11
|
* @title AgentAccountFactory
|
|
12
12
|
* @notice Single-entry factory for AgentAccount proxies with
|
|
13
|
-
* deterministic CREATE2 addresses. Phase 6f.5
|
|
13
|
+
* deterministic CREATE2 addresses. Phase 6f.5 -- collapsed
|
|
14
14
|
* createPersonAgent + createMultiSigSmartAgent into one
|
|
15
15
|
* entry point so every account on chain has the same shape;
|
|
16
16
|
* the only axis is `mode` on the init params.
|
|
@@ -32,7 +32,7 @@ import "./governance/GovernanceManaged.sol";
|
|
|
32
32
|
* marker check).
|
|
33
33
|
*
|
|
34
34
|
* The canonical CustodyPolicy address is wired at construction
|
|
35
|
-
* (factory-immutable)
|
|
35
|
+
* (factory-immutable) -- there is no per-call validator
|
|
36
36
|
* override. Swapping CustodyPolicy versions means redeploying
|
|
37
37
|
* the factory, which is the same blast radius as a CREATE2
|
|
38
38
|
* salt bump.
|
|
@@ -41,7 +41,7 @@ import "./governance/GovernanceManaged.sol";
|
|
|
41
41
|
* `bundlerSigner` and `sessionIssuer` are factory-level capability
|
|
42
42
|
* addresses. They are NEVER custodians of any deployed account; each
|
|
43
43
|
* account reads them off this factory on demand. Phase A.5 made both
|
|
44
|
-
* mutable under governance
|
|
44
|
+
* mutable under governance -- rotation flows through a governance
|
|
45
45
|
* proposal + 48h timelock and propagates automatically to every
|
|
46
46
|
* existing AgentAccount.
|
|
47
47
|
*/
|
|
@@ -49,6 +49,19 @@ contract AgentAccountFactory is GovernanceManaged {
|
|
|
49
49
|
AgentAccount public immutable accountImplementation;
|
|
50
50
|
address public immutable delegationManager;
|
|
51
51
|
address public immutable custodyPolicy;
|
|
52
|
+
/// @dev Spec 253 — the ApprovedHashRegistry baked (immutable) into the
|
|
53
|
+
/// AgentAccount impl this factory deploys; surfaced here for
|
|
54
|
+
/// deploy-time auditing. The account's `isValidSignature` 0x03
|
|
55
|
+
/// sentinel consults it; it is NOT a mutable factory-view.
|
|
56
|
+
address public immutable approvedHashRegistry;
|
|
57
|
+
|
|
58
|
+
/// @notice R917-C-5 (spec 408 §1.3) — whether the T4 (admin) safety-delay floor is LIFTED to zero for
|
|
59
|
+
/// accounts this factory deploys. A DEPLOYMENT decision, stated by the deployer in the
|
|
60
|
+
/// constructor and recorded in the deployments JSON, never a `block.chainid` list in bytecode:
|
|
61
|
+
/// the previous carve-out named the estate's own chain (34348) and silently switched the
|
|
62
|
+
/// EXT-TL-FLOOR-1 invariant off where it mattered. `check:production-deploy` refuses a
|
|
63
|
+
/// production/testnet record with this `true`. T5 (24 h) / T6 (48 h) are never relaxed.
|
|
64
|
+
bool public immutable relaxedT4Floor;
|
|
52
65
|
|
|
53
66
|
address public bundlerSigner;
|
|
54
67
|
address public sessionIssuer;
|
|
@@ -72,7 +85,48 @@ contract AgentAccountFactory is GovernanceManaged {
|
|
|
72
85
|
error NoInitialSigner();
|
|
73
86
|
error InsufficientTrusteesForMode(uint8 mode, uint256 actual, uint256 required);
|
|
74
87
|
error TrusteesRequiredForRecoverableMode(uint8 mode);
|
|
88
|
+
/// @notice ACCT-M1 (spec 300): a mode-3 (org) account needs ≥2 signers so its separation-of-duties
|
|
89
|
+
/// (disjoint propose + apply quorums) is satisfiable — a 1-signer org can never split duties.
|
|
90
|
+
error InfeasibleOrgConfig(uint8 nSigners);
|
|
91
|
+
/// @notice EXT-TL-FLOOR-1 (external audit P1-2): a mode>0 timelock override is below the on-chain product
|
|
92
|
+
/// floor. Overrides may RAISE a safety delay but never LOWER it below the marketed minimum
|
|
93
|
+
/// (spec 300 — the T5/recovery guarantee is a protocol invariant, not a UI convention).
|
|
94
|
+
error TimelockBelowFloor(uint8 tier, uint32 provided, uint32 floorSecs);
|
|
75
95
|
error ZeroAddress();
|
|
96
|
+
/// @notice R9.6 / ATL-SEC-05 -- thrown when `params.custodians.length`
|
|
97
|
+
/// exceeds `MAX_INITIAL_CUSTODIANS`. Without this cap,
|
|
98
|
+
/// `_buildValidatorInitData` casts `nSigners` to `uint8`
|
|
99
|
+
/// and silently truncates at 256, computing a wrong default
|
|
100
|
+
/// threshold for a misconfigured account. A self-hurt
|
|
101
|
+
/// footgun, not a cross-account vulnerability -- capped so
|
|
102
|
+
/// the misconfiguration fails closed at construction.
|
|
103
|
+
error TooManyInitialCustodians(uint256 actual, uint256 max);
|
|
104
|
+
|
|
105
|
+
/// @notice R9.6 / ATL-SEC-05 -- upper bound on initial custodians
|
|
106
|
+
/// passed via `AgentAccountInitParams`. 32 is deliberately
|
|
107
|
+
/// generous (every smart-account substrate we surveyed
|
|
108
|
+
/// caps well below 16) but well under the `uint8` truncation
|
|
109
|
+
/// threshold at `_buildValidatorInitData:252`.
|
|
110
|
+
uint256 public constant MAX_INITIAL_CUSTODIANS = 32;
|
|
111
|
+
|
|
112
|
+
/// @notice Spec 302 W2 — trustee-slot sentinel meaning "the initial
|
|
113
|
+
/// passkey's Passkey-Identity-Address on the account being
|
|
114
|
+
/// deployed". The PIA is now account-scoped, so it CANNOT be
|
|
115
|
+
/// computed before the CREATE2 address exists — but the salt
|
|
116
|
+
/// commits to `params.trustees` (CA-F1). Clients that want the
|
|
117
|
+
/// initial passkey to be its own recovery trustee (mode>0
|
|
118
|
+
/// self-recovery bootstrap) pass this sentinel; the factory
|
|
119
|
+
/// resolves it to the real per-account PIA AFTER the deploy,
|
|
120
|
+
/// when it builds the CustodyPolicy install blob. The address
|
|
121
|
+
/// therefore commits to the INTENT ("self-passkey is a
|
|
122
|
+
/// trustee"), which is deterministic, instead of the derived
|
|
123
|
+
/// value, which is circular.
|
|
124
|
+
address public constant SELF_PASSKEY_TRUSTEE =
|
|
125
|
+
address(uint160(uint256(keccak256("ap.trustee.self-initial-passkey"))));
|
|
126
|
+
|
|
127
|
+
/// @notice Spec 302 W2 — `SELF_PASSKEY_TRUSTEE` passed without an
|
|
128
|
+
/// initial passkey to resolve it to.
|
|
129
|
+
error SelfPasskeyTrusteeWithoutPasskey();
|
|
76
130
|
|
|
77
131
|
constructor(
|
|
78
132
|
IEntryPoint entryPoint_,
|
|
@@ -80,10 +134,14 @@ contract AgentAccountFactory is GovernanceManaged {
|
|
|
80
134
|
address custodyPolicy_,
|
|
81
135
|
address bundlerSigner_,
|
|
82
136
|
address sessionIssuer_,
|
|
83
|
-
address governance_
|
|
137
|
+
address governance_,
|
|
138
|
+
address approvedHashRegistry_,
|
|
139
|
+
bool relaxedT4Floor_
|
|
84
140
|
) GovernanceManaged(governance_) {
|
|
85
141
|
if (custodyPolicy_ == address(0)) revert ZeroAddress();
|
|
86
|
-
accountImplementation = new AgentAccount(entryPoint_);
|
|
142
|
+
accountImplementation = new AgentAccount(entryPoint_, approvedHashRegistry_);
|
|
143
|
+
approvedHashRegistry = approvedHashRegistry_;
|
|
144
|
+
relaxedT4Floor = relaxedT4Floor_;
|
|
87
145
|
delegationManager = delegationManager_;
|
|
88
146
|
custodyPolicy = custodyPolicy_;
|
|
89
147
|
bundlerSigner = bundlerSigner_;
|
|
@@ -134,17 +192,20 @@ contract AgentAccountFactory is GovernanceManaged {
|
|
|
134
192
|
// timelock (see AgenticGovernance).
|
|
135
193
|
_validateInitParams(params);
|
|
136
194
|
|
|
137
|
-
|
|
195
|
+
// CA-F1 (audit 2026-06-10): derive the deploy salt from the FULL custody config so the
|
|
196
|
+
// counterfactual address commits to mode/trustees/timelocks too — not just custodians/passkey.
|
|
197
|
+
bytes32 deploySalt = _effectiveSalt(params, timelockOverrides, salt);
|
|
198
|
+
address addr = _getAddressFromSalt(params, deploySalt);
|
|
138
199
|
if (addr.code.length > 0) return AgentAccount(payable(addr));
|
|
139
200
|
|
|
140
|
-
ERC1967Proxy proxy = new ERC1967Proxy{salt:
|
|
201
|
+
ERC1967Proxy proxy = new ERC1967Proxy{salt: deploySalt}(
|
|
141
202
|
address(accountImplementation),
|
|
142
203
|
_initData(params)
|
|
143
204
|
);
|
|
144
205
|
account = AgentAccount(payable(address(proxy)));
|
|
145
206
|
|
|
146
207
|
if (params.mode > 0) {
|
|
147
|
-
bytes memory validatorInit = _buildValidatorInitData(params, timelockOverrides);
|
|
208
|
+
bytes memory validatorInit = _buildValidatorInitData(params, timelockOverrides, address(account));
|
|
148
209
|
account.installModule(2 /* MODULE_TYPE_EXECUTOR */, custodyPolicy, validatorInit);
|
|
149
210
|
}
|
|
150
211
|
|
|
@@ -159,12 +220,16 @@ contract AgentAccountFactory is GovernanceManaged {
|
|
|
159
220
|
}
|
|
160
221
|
|
|
161
222
|
/// @notice Counterfactual address for `createAgentAccount`.
|
|
223
|
+
/// @dev CA-F1: takes `timelockOverrides` because the address now commits to it. Callers MUST
|
|
224
|
+
/// predict with the SAME (params, timelockOverrides, salt) they will deploy with, else the
|
|
225
|
+
/// predicted address won't match the deployed one.
|
|
162
226
|
function getAddressForAgentAccount(
|
|
163
227
|
AgentAccountInitParams calldata params,
|
|
228
|
+
uint32[7] calldata timelockOverrides,
|
|
164
229
|
uint256 salt
|
|
165
230
|
) external view returns (address) {
|
|
166
231
|
_validateInitParams(params);
|
|
167
|
-
return
|
|
232
|
+
return _getAddressFromSalt(params, _effectiveSalt(params, timelockOverrides, salt));
|
|
168
233
|
}
|
|
169
234
|
|
|
170
235
|
// ─── Internals ──────────────────────────────────────────────────────
|
|
@@ -187,22 +252,40 @@ contract AgentAccountFactory is GovernanceManaged {
|
|
|
187
252
|
);
|
|
188
253
|
}
|
|
189
254
|
|
|
190
|
-
|
|
255
|
+
/// @dev CA-F1 (audit 2026-06-10) — the deploy salt commits to the FULL custody configuration:
|
|
256
|
+
/// mode, trustees, and per-tier timelock overrides. `_initData` already folds custodians +
|
|
257
|
+
/// the initial passkey into the proxy bytecode hash (and thus the address); those, plus the
|
|
258
|
+
/// mode/trustees/timelocks bound here, mean the canonical address IS its complete custody
|
|
259
|
+
/// config. Two `createAgentAccount` calls that differ in ANY of these resolve to DIFFERENT
|
|
260
|
+
/// addresses, so an attacker can no longer front-run a victim's counterfactual address with a
|
|
261
|
+
/// weaker mode, attacker-controlled recovery trustees, or shortened timelocks. The
|
|
262
|
+
/// occupied-address branch is consequently reachable only by an identical-config request —
|
|
263
|
+
/// which also closes CA-F2 (silent adoption of a mismatched pre-existing account) by
|
|
264
|
+
/// construction, with no separate config-equality assertion needed.
|
|
265
|
+
function _effectiveSalt(
|
|
191
266
|
AgentAccountInitParams calldata params,
|
|
267
|
+
uint32[7] calldata timelockOverrides,
|
|
192
268
|
uint256 salt
|
|
269
|
+
) internal pure returns (bytes32) {
|
|
270
|
+
return keccak256(abi.encode(salt, params.mode, params.trustees, timelockOverrides));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function _getAddressFromSalt(
|
|
274
|
+
AgentAccountInitParams calldata params,
|
|
275
|
+
bytes32 deploySalt
|
|
193
276
|
) internal view returns (address) {
|
|
194
277
|
bytes memory initData = _initData(params);
|
|
195
|
-
return _create2Address(initData,
|
|
278
|
+
return _create2Address(initData, deploySalt);
|
|
196
279
|
}
|
|
197
280
|
|
|
198
|
-
function _create2Address(bytes memory initData,
|
|
281
|
+
function _create2Address(bytes memory initData, bytes32 salt) internal view returns (address) {
|
|
199
282
|
bytes memory proxyBytecode = abi.encodePacked(
|
|
200
283
|
type(ERC1967Proxy).creationCode,
|
|
201
284
|
abi.encode(address(accountImplementation), initData)
|
|
202
285
|
);
|
|
203
286
|
bytes32 bytecodeHash = keccak256(proxyBytecode);
|
|
204
287
|
return address(uint160(uint256(keccak256(
|
|
205
|
-
abi.encodePacked(bytes1(0xff), address(this),
|
|
288
|
+
abi.encodePacked(bytes1(0xff), address(this), salt, bytecodeHash)
|
|
206
289
|
))));
|
|
207
290
|
}
|
|
208
291
|
|
|
@@ -219,6 +302,22 @@ contract AgentAccountFactory is GovernanceManaged {
|
|
|
219
302
|
|
|
220
303
|
bool hasPasskey = params.initialPasskeyX != 0 && params.initialPasskeyY != 0;
|
|
221
304
|
if (params.custodians.length == 0 && !hasPasskey) revert NoInitialSigner();
|
|
305
|
+
// R9.6 / ATL-SEC-05: cap the initial custodian set so
|
|
306
|
+
// `_buildValidatorInitData`'s `uint8(nSigners)` cast can't
|
|
307
|
+
// silently truncate. 32 is well above any rational config and
|
|
308
|
+
// well below the uint8 boundary.
|
|
309
|
+
if (params.custodians.length > MAX_INITIAL_CUSTODIANS) {
|
|
310
|
+
revert TooManyInitialCustodians(params.custodians.length, MAX_INITIAL_CUSTODIANS);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Spec 302 W2 — the self-passkey trustee sentinel is meaningless
|
|
314
|
+
// without an initial passkey to resolve it to (fail-closed at
|
|
315
|
+
// predict time too, so counterfactual and deploy agree).
|
|
316
|
+
bool hasSentinel;
|
|
317
|
+
for (uint256 i; i < params.trustees.length; i++) {
|
|
318
|
+
if (params.trustees[i] == SELF_PASSKEY_TRUSTEE) { hasSentinel = true; break; }
|
|
319
|
+
}
|
|
320
|
+
if (hasSentinel && !hasPasskey) revert SelfPasskeyTrusteeWithoutPasskey();
|
|
222
321
|
|
|
223
322
|
if (params.mode == 0) return;
|
|
224
323
|
|
|
@@ -244,7 +343,8 @@ contract AgentAccountFactory is GovernanceManaged {
|
|
|
244
343
|
/// external custodians + (1 if initial passkey, else 0).
|
|
245
344
|
function _buildValidatorInitData(
|
|
246
345
|
AgentAccountInitParams calldata params,
|
|
247
|
-
uint32[7] calldata timelockOverrides
|
|
346
|
+
uint32[7] calldata timelockOverrides,
|
|
347
|
+
address account
|
|
248
348
|
) internal view returns (bytes memory) {
|
|
249
349
|
uint256 nSigners = params.custodians.length;
|
|
250
350
|
if (params.initialPasskeyX != 0 && params.initialPasskeyY != 0) nSigners++;
|
|
@@ -254,17 +354,58 @@ contract AgentAccountFactory is GovernanceManaged {
|
|
|
254
354
|
thresholds[t] = CustodyPolicy(custodyPolicy).defaultApprovals(uint8(nSigners), t);
|
|
255
355
|
}
|
|
256
356
|
|
|
357
|
+
// ACCT-M1 (spec 300): mode-3 (org) separation-of-duties requires DISJOINT propose + apply quorums
|
|
358
|
+
// for the T4/T5 tiers, so a satisfiable config needs 2×threshold DISTINCT signers. The default
|
|
359
|
+
// matrix sets T4/T5 = N for small N (all custodians), which would demand 2N signers — making every
|
|
360
|
+
// such change permanently un-executable (the account silently locks). Cap the SoD-constrained
|
|
361
|
+
// thresholds at floor(N/2) so a disjoint quorum always exists, and require ≥2 signers (a 1-signer
|
|
362
|
+
// org can't split duties). Modes 0-2 have no SoD, so their thresholds are unchanged.
|
|
363
|
+
if (params.mode == 3) {
|
|
364
|
+
if (nSigners < 2) revert InfeasibleOrgConfig(uint8(nSigners));
|
|
365
|
+
uint8 sodCap = uint8(nSigners / 2); // ≥ 1 since nSigners ≥ 2
|
|
366
|
+
if (thresholds[4] > sodCap) thresholds[4] = sodCap;
|
|
367
|
+
if (thresholds[5] > sodCap) thresholds[5] = sodCap;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// R917-C-5 (spec 408 §1.3): the T4 floor is lifted ONLY when the deployer said so in the constructor
|
|
371
|
+
// (`relaxedT4Floor`) — a local development posture so a demo can drive an admin custody action's
|
|
372
|
+
// schedule→apply back-to-back. It is not inferred from `block.chainid`: the estate's own chain was
|
|
373
|
+
// once on that list, and the audited EXT-TL-FLOOR-1 invariant was off where it mattered. T5 (24h)
|
|
374
|
+
// and T6 (recovery, 48h) are NOT relaxed under any posture.
|
|
375
|
+
uint32 floor4 = relaxedT4Floor ? 0 : uint32(1 hours);
|
|
376
|
+
|
|
257
377
|
uint32[7] memory timelocks;
|
|
258
|
-
timelocks[4] = timelockOverrides[4] == 0 ?
|
|
378
|
+
timelocks[4] = timelockOverrides[4] == 0 ? floor4 : timelockOverrides[4];
|
|
259
379
|
timelocks[5] = timelockOverrides[5] == 0 ? uint32(24 hours) : timelockOverrides[5];
|
|
260
380
|
timelocks[6] = timelockOverrides[6] == 0 ? uint32(48 hours) : timelockOverrides[6];
|
|
261
381
|
|
|
382
|
+
// EXT-TL-FLOOR-1 (external audit P1-2): a timelock override may RAISE a safety delay but NEVER lower it
|
|
383
|
+
// below the product floor. A zero override inherits the floor default above; a non-zero override below
|
|
384
|
+
// the floor reverts, so a mode>0 (custody-governed) account can never deploy with sub-floor T4/T5/T6
|
|
385
|
+
// (recovery = T6) delays. The "T5=24h / recovery=48h" guarantee becomes a protocol invariant, not a UI
|
|
386
|
+
// convention (spec 300 — raise-only). The T4 floor is `floor4` (production value on real chains, 0 on
|
|
387
|
+
// the dev-chain carve-out); T5/T6 keep their audited floors on every chain.
|
|
388
|
+
if (timelocks[4] < floor4) revert TimelockBelowFloor(4, timelocks[4], floor4);
|
|
389
|
+
if (timelocks[5] < 24 hours) revert TimelockBelowFloor(5, timelocks[5], uint32(24 hours));
|
|
390
|
+
if (timelocks[6] < 48 hours) revert TimelockBelowFloor(6, timelocks[6], uint32(48 hours));
|
|
391
|
+
|
|
262
392
|
uint8 recThr = uint8(params.trustees.length / 2 + 1);
|
|
263
393
|
|
|
394
|
+
// Spec 302 W2 — resolve the self-passkey trustee sentinel to the
|
|
395
|
+
// account-scoped PIA. Runs AFTER the deploy (the account address —
|
|
396
|
+
// and thus the per-account PIA — exists), while the CREATE2 salt
|
|
397
|
+
// committed to the sentinel form (deterministic pre-deploy).
|
|
398
|
+
address[] memory trustees = new address[](params.trustees.length);
|
|
399
|
+
for (uint256 i; i < trustees.length; i++) {
|
|
400
|
+
trustees[i] = params.trustees[i] == SELF_PASSKEY_TRUSTEE
|
|
401
|
+
? AgentAccount(payable(account)).passkeyIdentity(params.initialPasskeyX, params.initialPasskeyY)
|
|
402
|
+
: params.trustees[i];
|
|
403
|
+
}
|
|
404
|
+
|
|
264
405
|
return abi.encode(
|
|
265
406
|
params.mode,
|
|
266
407
|
recThr,
|
|
267
|
-
|
|
408
|
+
trustees,
|
|
268
409
|
thresholds,
|
|
269
410
|
timelocks,
|
|
270
411
|
uint256(0.01 ether),
|
|
@@ -26,13 +26,26 @@ pragma solidity ^0.8.28;
|
|
|
26
26
|
* Pairs with `MultiSendCallOnly` (atomic batch) so a passkey
|
|
27
27
|
* smart account can `approveHash` + perform the delegated action
|
|
28
28
|
* in one userOp.
|
|
29
|
+
*
|
|
30
|
+
* R917-C-2 (spec 408 §1.2): an `AgentAccount`'s `0x03` sentinel does NOT approve the raw hash —
|
|
31
|
+
* it approves `AgentAccount.approvedHashKey(hash)` = `keccak256(abi.encode(hash, custodyEpoch))`,
|
|
32
|
+
* so an approval planted by a custodian who is later removed is void once the account's custody
|
|
33
|
+
* epoch moves. This registry is agnostic to that: it stores whatever 32 bytes the signer approves.
|
|
29
34
|
*/
|
|
30
35
|
contract ApprovedHashRegistry {
|
|
31
|
-
/// signer
|
|
32
|
-
|
|
36
|
+
/// @dev R917-C-2 (spec 408 §1.2): an approval is recorded with the signer's epoch at the time
|
|
37
|
+
/// (`epoch + 1`, so a set slot is never zero); `revokeAll()` bumps the epoch and voids every
|
|
38
|
+
/// approval the signer ever made in one call. `isApproved` is the ONE read: the `0x03` sentinel
|
|
39
|
+
/// and `QuorumEnforcer`'s `v == 1` slot both consult it.
|
|
40
|
+
/// signer => hash => (epoch at approval + 1), 0 = never approved
|
|
41
|
+
mapping(address => mapping(bytes32 => uint64)) private _approvedAt;
|
|
42
|
+
/// signer => current epoch
|
|
43
|
+
mapping(address => uint64) private _epoch;
|
|
33
44
|
|
|
34
45
|
event HashApproved(address indexed signer, bytes32 indexed hash);
|
|
35
46
|
event HashRevoked(address indexed signer, bytes32 indexed hash);
|
|
47
|
+
/// @dev R917-C-2 — every approval `signer` made before this event is void.
|
|
48
|
+
event AllHashesRevoked(address indexed signer, uint64 epoch);
|
|
36
49
|
|
|
37
50
|
/**
|
|
38
51
|
* @notice Pre-approve a hash. `msg.sender` is the signer; only
|
|
@@ -40,18 +53,40 @@ contract ApprovedHashRegistry {
|
|
|
40
53
|
* for this hash.
|
|
41
54
|
*/
|
|
42
55
|
function approveHash(bytes32 hash) external {
|
|
43
|
-
|
|
56
|
+
_approvedAt[msg.sender][hash] = _epoch[msg.sender] + 1;
|
|
44
57
|
emit HashApproved(msg.sender, hash);
|
|
45
58
|
}
|
|
46
59
|
|
|
47
60
|
/// @notice Revoke a previously-approved hash before redemption.
|
|
48
61
|
function revokeHash(bytes32 hash) external {
|
|
49
|
-
|
|
62
|
+
_approvedAt[msg.sender][hash] = 0;
|
|
50
63
|
emit HashRevoked(msg.sender, hash);
|
|
51
64
|
}
|
|
52
65
|
|
|
53
|
-
/// @notice
|
|
66
|
+
/// @notice R917-C-2 — revoke EVERY hash `msg.sender` ever approved, in one call. The per-hash
|
|
67
|
+
/// approvals are unenumerable on chain; this is how a signer that suspects a planted approval
|
|
68
|
+
/// voids all of them without knowing which.
|
|
69
|
+
function revokeAll() external {
|
|
70
|
+
uint64 next = _epoch[msg.sender] + 1;
|
|
71
|
+
_epoch[msg.sender] = next;
|
|
72
|
+
emit AllHashesRevoked(msg.sender, next);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/// @notice The signer's current epoch (informational; `isApproved` already accounts for it).
|
|
76
|
+
function epochOf(address signer) external view returns (uint64) {
|
|
77
|
+
return _epoch[signer];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/// @notice Whether `signer` approved `hash` under its CURRENT epoch. External view used by the
|
|
81
|
+
/// `0x03` sentinel and by `QuorumEnforcer`'s `v == 1` path.
|
|
54
82
|
function isApproved(address signer, bytes32 hash) external view returns (bool) {
|
|
55
|
-
|
|
83
|
+
uint64 at = _approvedAt[signer][hash];
|
|
84
|
+
return at != 0 && at == _epoch[signer] + 1;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/// @notice Back-compat read shape of the former public mapping: true iff currently approved.
|
|
88
|
+
function approved(address signer, bytes32 hash) external view returns (bool) {
|
|
89
|
+
uint64 at = _approvedAt[signer][hash];
|
|
90
|
+
return at != 0 && at == _epoch[signer] + 1;
|
|
56
91
|
}
|
|
57
92
|
}
|
package/src/IAgentAccount.sol
CHANGED
|
@@ -90,6 +90,29 @@ struct AgentAccountRecoveryArgs {
|
|
|
90
90
|
bytes32[] removePasskeyCredentialIdDigests;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
/**
|
|
94
|
+
* @notice Payload for `CustodyAction.RotateCredential` (T4) — spec 410 §1.2. A PLANNED rotation: the
|
|
95
|
+
* old credential is still controlled, the person (or an org's quorum) registers the new one,
|
|
96
|
+
* retires the old one, and re-approves every standing approved-digest wire under the new epoch
|
|
97
|
+
* — in ONE applied change, so no wire is dead between the retirement and the re-approval.
|
|
98
|
+
*
|
|
99
|
+
* Exactly one credential is added (`addOwner` XOR `addPasskey.x != 0`) and exactly one retired
|
|
100
|
+
* (`removeOwner` XOR `removePasskeyCredentialIdDigest != 0`). `reapprove` lists the delegation
|
|
101
|
+
* digests to approve after the retirement; the module calls `AgentAccount.approveDigest` for
|
|
102
|
+
* each, so the key is derived on chain under the post-rotation epoch.
|
|
103
|
+
*
|
|
104
|
+
* This is the ONLY custody action that carries a re-approval list. `AgentAccountRecoveryArgs`
|
|
105
|
+
* has no such field by construction: a recovery is the moment a planted grant would otherwise
|
|
106
|
+
* ride through, so recovery re-approves nothing and ends with `revokeAllApprovedDigests`.
|
|
107
|
+
*/
|
|
108
|
+
struct AgentAccountRotateCredentialArgs {
|
|
109
|
+
address addOwner;
|
|
110
|
+
AgentAccountRecoveryPasskeyAdd addPasskey;
|
|
111
|
+
address removeOwner;
|
|
112
|
+
bytes32 removePasskeyCredentialIdDigest;
|
|
113
|
+
bytes32[] reapprove;
|
|
114
|
+
}
|
|
115
|
+
|
|
93
116
|
/**
|
|
94
117
|
* @title IAgentAccount
|
|
95
118
|
* @notice Interface for an agent-native ERC-4337 smart account.
|
|
@@ -71,6 +71,20 @@ import "./governance/IGovernance.sol";
|
|
|
71
71
|
* `SenderNotAccepted` until governance explicitly opts a sender
|
|
72
72
|
* in. That is the documented safe state.
|
|
73
73
|
* 2. Monitor `getDeposit()` and alert below a runway threshold.
|
|
74
|
+
* 3. PM-2 — hand the Ownable owner to the governance TimelockController via
|
|
75
|
+
* `Ownable2Step` (`transferOwnership(governance)` then a timelocked
|
|
76
|
+
* `acceptOwnership`) once deploy-time staking/funding is done. The owner
|
|
77
|
+
* controls the INHERITED instant `withdrawTo`/stake drains; in production
|
|
78
|
+
* it MUST be the timelock, not the bootstrap deployer EOA. The
|
|
79
|
+
* governance-native, TIMELOCKED `scheduleDepositWithdrawal` /
|
|
80
|
+
* `executeDepositWithdrawal` path below is the sanctioned drain that stays
|
|
81
|
+
* coupled to governance + delayed regardless of the owner handoff state.
|
|
82
|
+
* The deployer-owned window is bootstrap-only (tracked under the
|
|
83
|
+
* governance-key custody item).
|
|
84
|
+
* 4. PM-1 — after governance pauses, call `syncPauseFromGovernance()` (or
|
|
85
|
+
* `setPauseMirror(true)` from governance) so the validation-time mirror
|
|
86
|
+
* halts sponsorship. Validation never reads governance storage directly
|
|
87
|
+
* (ERC-7562), so the mirror must be pushed/synced.
|
|
74
88
|
*
|
|
75
89
|
* @dev Inherits `addStake`, `unlockStake`, `withdrawStake`, `deposit`,
|
|
76
90
|
* and `withdrawTo` from `BasePaymaster`. Ownable owner is set in
|
|
@@ -95,19 +109,62 @@ contract SmartAgentPaymaster is BasePaymaster {
|
|
|
95
109
|
/// validation. Stored immutable.
|
|
96
110
|
address public immutable governance;
|
|
97
111
|
|
|
112
|
+
/// @notice PM-1 — local mirror of the governance pause flag. This is the
|
|
113
|
+
/// ONLY pause signal read during ERC-4337 validation. Reading the
|
|
114
|
+
/// external governance contract's storage inside
|
|
115
|
+
/// `_validatePaymasterUserOp` violates the ERC-7562 validation-scope
|
|
116
|
+
/// rules (a paymaster may touch only its own / associated storage),
|
|
117
|
+
/// so reputable bundlers (Pimlico/Stackup/Alchemy) drop the sponsored
|
|
118
|
+
/// op during simulation. We read this own-storage mirror instead;
|
|
119
|
+
/// `syncPauseFromGovernance()` — a normal call OUTSIDE validation —
|
|
120
|
+
/// refreshes it from the canonical governance flag. The mirror is a
|
|
121
|
+
/// validation-time cache of governance's pause bit, never a second
|
|
122
|
+
/// independent source (ADR-0013: cache-of-canonical, no fallback).
|
|
123
|
+
bool private _pausedMirror;
|
|
124
|
+
|
|
125
|
+
/// @notice PM-2 — a scheduled, governance-authorized EntryPoint-deposit
|
|
126
|
+
/// withdrawal. The inherited owner `withdrawTo` is an INSTANT drain
|
|
127
|
+
/// gated only by the Ownable owner; this path couples a withdrawal to
|
|
128
|
+
/// governance (`onlyGovernance`) AND a fixed timelock, so the
|
|
129
|
+
/// sponsorship treasury cannot be emptied in a single transaction.
|
|
130
|
+
struct PendingWithdrawal {
|
|
131
|
+
address payable to;
|
|
132
|
+
uint64 eta;
|
|
133
|
+
uint256 amount;
|
|
134
|
+
}
|
|
135
|
+
PendingWithdrawal private _pendingWithdrawal;
|
|
136
|
+
|
|
137
|
+
/// @notice PM-2 — delay between scheduling and executing a governance
|
|
138
|
+
/// deposit withdrawal. Gives the guardian a window to pause if a
|
|
139
|
+
/// withdrawal is unexpected (incident response).
|
|
140
|
+
uint64 public constant DEPOSIT_WITHDRAWAL_TIMELOCK = 48 hours;
|
|
141
|
+
|
|
98
142
|
error SenderNotAccepted(address sender);
|
|
99
143
|
error SystemPaused();
|
|
100
144
|
error ZeroGovernance();
|
|
101
145
|
error NotGovernance();
|
|
102
146
|
error PaymasterDataMalformed();
|
|
103
147
|
error PaymasterSignatureInvalid();
|
|
148
|
+
/// @dev PM-2 withdrawal-lifecycle errors.
|
|
149
|
+
error NoPendingWithdrawal();
|
|
150
|
+
error WithdrawalNotReady(uint64 eta);
|
|
151
|
+
error WithdrawalAmountZero();
|
|
152
|
+
error WithdrawalToZero();
|
|
104
153
|
|
|
105
154
|
event DevModeSet(bool dev);
|
|
106
155
|
event SenderAcceptedSet(address indexed sender, bool accepted);
|
|
107
156
|
event VerifyingSignerSet(address indexed oldSigner, address indexed newSigner);
|
|
157
|
+
/// @notice PM-1 — emitted whenever the local pause mirror is updated.
|
|
158
|
+
event PauseMirrorSynced(bool paused, address indexed by);
|
|
159
|
+
/// @notice PM-2 — deposit-withdrawal lifecycle.
|
|
160
|
+
event DepositWithdrawalScheduled(address indexed to, uint256 amount, uint64 eta);
|
|
161
|
+
event DepositWithdrawalExecuted(address indexed to, uint256 amount);
|
|
162
|
+
event DepositWithdrawalCancelled(address indexed to, uint256 amount);
|
|
108
163
|
|
|
109
164
|
/// @dev Storage gap reserves slots for future state. Phase A.5 §3.1.
|
|
110
|
-
|
|
165
|
+
/// PM-1/PM-2 consumed 3 slots (`_pausedMirror` packs into 1;
|
|
166
|
+
/// `PendingWithdrawal` is 2) — gap reduced 49 → 46 to preserve layout.
|
|
167
|
+
uint256[46] private __gap;
|
|
111
168
|
|
|
112
169
|
/// @dev Length of the paymaster-data tail when in verifying mode:
|
|
113
170
|
/// 6 (validUntil) + 6 (validAfter) + 65 (sig) = 77 bytes.
|
|
@@ -173,6 +230,95 @@ contract SmartAgentPaymaster is BasePaymaster {
|
|
|
173
230
|
emit VerifyingSignerSet(old, newSigner);
|
|
174
231
|
}
|
|
175
232
|
|
|
233
|
+
// ─── PM-1: pause mirror (own-storage, ERC-7562-compliant) ──────────
|
|
234
|
+
|
|
235
|
+
/// @notice PM-1 — refresh the local pause mirror from the canonical
|
|
236
|
+
/// governance flag. Permissionless ON PURPOSE: validation may not
|
|
237
|
+
/// read governance storage, so the mirror must be refreshable by
|
|
238
|
+
/// anyone (a keeper, a bundler, the guardian's incident response)
|
|
239
|
+
/// the moment governance pauses. This call is a NORMAL transaction
|
|
240
|
+
/// (not paymaster validation), so the ERC-7562 scope rules don't
|
|
241
|
+
/// apply to its cross-contract read. The mirror only ever holds the
|
|
242
|
+
/// canonical governance value — no independent pause source.
|
|
243
|
+
function syncPauseFromGovernance() external {
|
|
244
|
+
bool p = _governanceIsPaused();
|
|
245
|
+
_pausedMirror = p;
|
|
246
|
+
emit PauseMirrorSynced(p, msg.sender);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/// @notice PM-1 — direct governance push of the pause mirror, for when
|
|
250
|
+
/// governance wants to halt sponsorship without depending on a
|
|
251
|
+
/// third party to sync. `onlyGovernance` ⇒ inherits the 24h
|
|
252
|
+
/// timelock (or guardian-driven governance flow).
|
|
253
|
+
function setPauseMirror(bool paused_) external onlyGovernance {
|
|
254
|
+
_pausedMirror = paused_;
|
|
255
|
+
emit PauseMirrorSynced(paused_, msg.sender);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/// @notice The pause bit read during validation (the local mirror).
|
|
259
|
+
function paused() external view returns (bool) {
|
|
260
|
+
return _pausedMirror;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/// @dev Read the canonical governance pause flag. Used ONLY by the out-of-band sync path, never
|
|
264
|
+
/// during validation (ERC-7562 scope). L1 (seam audit): distinguish "no governance configured"
|
|
265
|
+
/// (legacy / test deploy — not paused, by design) from "governance IS configured but the read
|
|
266
|
+
/// faulted / returned malformed data" (a governance outage or non-conforming contract), which now
|
|
267
|
+
/// FAILS CLOSED — treat as paused so a sync during a governance fault halts sponsorship rather
|
|
268
|
+
/// than fail-open sponsoring. Only a clean, decodable `false` permits sponsorship.
|
|
269
|
+
function _governanceIsPaused() internal view returns (bool) {
|
|
270
|
+
// Unconfigured governance (unset, or an EOA with no code) → not paused (legacy/test path).
|
|
271
|
+
if (governance == address(0) || governance.code.length == 0) return false;
|
|
272
|
+
(bool ok, bytes memory data) = governance.staticcall(
|
|
273
|
+
abi.encodeWithSelector(IGovernanceView.isPaused.selector)
|
|
274
|
+
);
|
|
275
|
+
// Configured but faulted (call failed or undecodable) → fail closed (paused).
|
|
276
|
+
if (!ok || data.length < 32) return true;
|
|
277
|
+
return abi.decode(data, (bool));
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// ─── PM-2: governance-timelocked deposit withdrawal ────────────────
|
|
281
|
+
|
|
282
|
+
/// @notice PM-2 — schedule a governance-authorized withdrawal of the
|
|
283
|
+
/// EntryPoint deposit. Coupled to governance AND delayed by
|
|
284
|
+
/// `DEPOSIT_WITHDRAWAL_TIMELOCK`, unlike the inherited owner
|
|
285
|
+
/// `withdrawTo` (instant, owner-only). Overwrites any prior pending
|
|
286
|
+
/// withdrawal (governance is the single scheduler).
|
|
287
|
+
function scheduleDepositWithdrawal(address payable to, uint256 amount) external onlyGovernance {
|
|
288
|
+
if (to == address(0)) revert WithdrawalToZero();
|
|
289
|
+
if (amount == 0) revert WithdrawalAmountZero();
|
|
290
|
+
uint64 eta = uint64(block.timestamp) + DEPOSIT_WITHDRAWAL_TIMELOCK;
|
|
291
|
+
_pendingWithdrawal = PendingWithdrawal({to: to, eta: eta, amount: amount});
|
|
292
|
+
emit DepositWithdrawalScheduled(to, amount, eta);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/// @notice PM-2 — execute a previously-scheduled withdrawal once its
|
|
296
|
+
/// timelock has elapsed. `onlyGovernance` so the same authority
|
|
297
|
+
/// that scheduled it confirms; the delay gives the guardian time to
|
|
298
|
+
/// pause if the withdrawal is unexpected.
|
|
299
|
+
function executeDepositWithdrawal() external onlyGovernance {
|
|
300
|
+
PendingWithdrawal memory w = _pendingWithdrawal;
|
|
301
|
+
if (w.eta == 0) revert NoPendingWithdrawal();
|
|
302
|
+
if (block.timestamp < w.eta) revert WithdrawalNotReady(w.eta);
|
|
303
|
+
delete _pendingWithdrawal;
|
|
304
|
+
entryPoint().withdrawTo(w.to, w.amount);
|
|
305
|
+
emit DepositWithdrawalExecuted(w.to, w.amount);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/// @notice PM-2 — cancel a pending withdrawal (governance de-escalation).
|
|
309
|
+
function cancelDepositWithdrawal() external onlyGovernance {
|
|
310
|
+
PendingWithdrawal memory w = _pendingWithdrawal;
|
|
311
|
+
if (w.eta == 0) revert NoPendingWithdrawal();
|
|
312
|
+
delete _pendingWithdrawal;
|
|
313
|
+
emit DepositWithdrawalCancelled(w.to, w.amount);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/// @notice PM-2 — view the pending withdrawal (zero `eta` ⇒ none).
|
|
317
|
+
function pendingWithdrawal() external view returns (address to, uint256 amount, uint64 eta) {
|
|
318
|
+
PendingWithdrawal memory w = _pendingWithdrawal;
|
|
319
|
+
return (w.to, w.amount, w.eta);
|
|
320
|
+
}
|
|
321
|
+
|
|
176
322
|
// ─── Views ──────────────────────────────────────────────────────────
|
|
177
323
|
|
|
178
324
|
function devMode() external view returns (bool) {
|
|
@@ -229,17 +375,13 @@ contract SmartAgentPaymaster is BasePaymaster {
|
|
|
229
375
|
bytes32 /*userOpHash*/,
|
|
230
376
|
uint256 /*maxCost*/
|
|
231
377
|
) internal view override returns (bytes memory context, uint256 validationData) {
|
|
232
|
-
// H7-C.10 / EXT3-010: gated behind system-wide governance
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
//
|
|
236
|
-
//
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
abi.encodeWithSelector(IGovernanceView.isPaused.selector)
|
|
240
|
-
);
|
|
241
|
-
if (ok && data.length >= 32 && abi.decode(data, (bool))) revert SystemPaused();
|
|
242
|
-
}
|
|
378
|
+
// PM-1 / H7-C.10 / EXT3-010: gated behind the system-wide governance
|
|
379
|
+
// pause — but read from the LOCAL mirror (`_pausedMirror`), never the
|
|
380
|
+
// external governance contract's storage. A cross-contract staticcall
|
|
381
|
+
// here violates the ERC-7562 validation-scope rules and gets the op
|
|
382
|
+
// dropped by bundlers. The mirror is refreshed out-of-band via
|
|
383
|
+
// `syncPauseFromGovernance()` (a normal call) or `setPauseMirror()`.
|
|
384
|
+
if (_pausedMirror) revert SystemPaused();
|
|
243
385
|
|
|
244
386
|
if (_dev) {
|
|
245
387
|
// Dev mode: accept all. validationData = 0 → "valid sig,
|
|
@@ -263,6 +405,8 @@ contract SmartAgentPaymaster is BasePaymaster {
|
|
|
263
405
|
// EIP-191 wrap matches what KMS-backed `signMessage({raw})`
|
|
264
406
|
// produces via the v0.7 reference paymaster convention.
|
|
265
407
|
bytes32 ethHash = hash.toEthSignedMessageHash();
|
|
408
|
+
// R6.3: third return (sigVersion) intentionally discarded; the explicit `err` + `recovered != verifyingSigner` revert IS the auth.
|
|
409
|
+
// slither-disable-next-line unused-return
|
|
266
410
|
(address recovered, ECDSA.RecoverError err, ) = ECDSA.tryRecover(ethHash, signature);
|
|
267
411
|
if (err != ECDSA.RecoverError.NoError || recovered != verifyingSigner) {
|
|
268
412
|
// Returning sigFailed=true (per EntryPoint convention)
|
|
@@ -125,11 +125,14 @@ contract UniversalSignatureValidator {
|
|
|
125
125
|
) private pure returns (bool) {
|
|
126
126
|
if (sig.length != 65) return false;
|
|
127
127
|
// Try raw hash first.
|
|
128
|
+
// R6.3: third return (sigVersion) intentionally discarded; the `err` + `recovered == signer` is the auth.
|
|
129
|
+
// slither-disable-next-line unused-return
|
|
128
130
|
(address recovered, ECDSA.RecoverError err, ) = ECDSA.tryRecover(hash, sig);
|
|
129
131
|
if (err == ECDSA.RecoverError.NoError && recovered == signer) return true;
|
|
130
132
|
// Then try the eth-signed prefix variant — many wallets sign this
|
|
131
133
|
// form even when the caller passes a raw digest.
|
|
132
134
|
bytes32 prefixed = hash.toEthSignedMessageHash();
|
|
135
|
+
// slither-disable-next-line unused-return
|
|
133
136
|
(recovered, err, ) = ECDSA.tryRecover(prefixed, sig);
|
|
134
137
|
return err == ECDSA.RecoverError.NoError && recovered == signer;
|
|
135
138
|
}
|