feat: Fleet paymaster — gas & bond sponsorship with UUID_ONLY fleet-wide swarm registration#100
Merged
feat: Fleet paymaster — gas & bond sponsorship with UUID_ONLY fleet-wide swarm registration#100
Conversation
- Fix pragma version to ^0.8.20 for both BasePaymaster and WhitelistPaymaster - Fix CEI violation in withdraw(): emit event before external call - Add comprehensive NatSpec on _validateAndPayApprovalBasedFlow - Add ETH balance pre-check in WhitelistPaymaster._validateAndPayGeneralFlow - Document BOOTLOADER_FORMAL_ADDRESS duplicated constant with canonical source reference - Extend BasePaymaster tests: 13 tests covering validateAndPayForPaymasterTransaction (general/approval-based/unsupported flows), postTransaction, withdraw, receive, and edge cases - Extend WhitelistPaymaster tests: 1 new test for PaymasterBalanceTooLow branch - Achieve 100% coverage on WhitelistPaymaster.sol (lines, statements, branches, functions) - Achieve 100% logical coverage on BasePaymaster.sol (branches, functions; 93.94% lines due to viaIR artifact)
…elisted users - Create IBondTreasury interface for bond treasury implementations - Implement FleetTreasuryPaymaster: combined paymaster + bond treasury with QuotaControl - Gas sponsorship for FleetIdentity calls via ZkSync paymaster interface - Per-call bond approval (vs. infinite approval) for enhanced security against compromised upgrades - Whitelist-based access control with WHITELIST_ADMIN_ROLE - ERC-20 token withdrawal capability for treasury management - Add claimUuidSponsored to FleetIdentityUpgradeable: single-tx sponsored UUID claiming - User is always beneficiary (self-sovereign) - callers provide treasury address - Validates bond availability and quota before claiming - Supports operator assignment - Add comprehensive tests: 33 tests covering paymaster validation, treasury consumption, quota management, and e2e flows - Achieve >95% coverage across all metrics: - FleetTreasuryPaymaster: 96.77% lines, 97.14% branches, 100% functions - QuotaControl: 100% across all metrics - FleetIdentity sponsored claims: 100% coverage for new functions
- Implement UUID_ONLY mode for SwarmRegistryUniversalUpgradeable and SwarmRegistryL1Upgradeable - Update ISwarmRegistry and SwarmTypes interfaces to support fleet-wide registration - Add comprehensive test coverage for fleet-wide swarm operations - Both registries now support creating and managing fleet-wide swarms tied to FleetIdentity
LCOV of commit
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR delivers two interconnected features:
FleetIdentityto register swarms across both L2 (Universal) and L1 registries using a fleet-level identity, without requiredNODLtoken bonding per device.New Contracts & Interfaces
src/paymasters/FleetTreasuryPaymaster.solIBondTreasury).WHITELIST_ADMIN_ROLE; only whitelisted addresses can use the paymaster.QuotaControl(inherited) to prevent abuse.src/swarms/interfaces/IBondTreasury.solFleetTreasuryPaymasterto allow multiple treasury implementations.src/swarms/interfaces/ISwarmRegistry.sol/SwarmTypes.solUUID_ONLYregistration mode toSwarmTypes.ISwarmRegistryto expose fleet-wide registration entry points.Modified Contracts
src/swarms/FleetIdentityUpgradeable.solclaimUuidSponsored(): single-transaction sponsored UUID claiming where the user is always the beneficiary (self-sovereign). The caller supplies the treasury address; bond availability and quota are validated before the claim proceeds.setApprovedSponsor(): allows a fleet to designate a trusted paymaster/sponsor address.src/swarms/SwarmRegistryUniversalUpgradeable.sol/SwarmRegistryL1Upgradeable.solUUID_ONLYmode: fleet-wide swarm creation and management tied toFleetIdentity.src/paymasters/BasePaymaster.sol/WhitelistPaymaster.sol^0.8.20.withdraw(): event emitted before external call.WhitelistPaymaster._validateAndPayGeneralFlow._validateAndPayApprovalBasedFlow.Test Coverage
FleetTreasuryPaymasterQuotaControlFleetIdentityUpgradeable(new fns)WhitelistPaymasterBasePaymaster*viaIR artifact — logical coverage is 100%.New test files:
test/paymasters/FleetTreasuryPaymaster.t.sol— 33 tests covering paymaster validation, treasury consumption, quota management, and E2E sponsored flows.test/FleetIdentity.t.sol— sponsored UUID claiming, operator assignment, approved sponsor management.test/SwarmRegistryUniversal.t.solandtest/SwarmRegistryL1.t.solwith UUID_ONLY fleet-wide registration scenarios.test/paymasters/BasePaymaster.t.solandtest/paymasters/WhitelistPaymaster.t.sol.Security Notes
ReentrancyGuardapplied where external calls occur.