diff --git a/script/README.md b/script/README.md index a96e1b6..acc2da7 100644 --- a/script/README.md +++ b/script/README.md @@ -385,6 +385,98 @@ reachable functions must retain their own authorization because `multicall` does `tryMulticall` does not change worker behavior; worker integration must be performed separately. +### One-signature proposal batches + +`proposeBatch(BatchProposal[] proposals, address proposer, PermitTransferFrom permit, bytes signature, uint256[] payments)` executes a partial-success batch for **one signer and one collateral token**. Unlike `tryMulticall`, it uses one Permit2 signature, one nonce, and one upfront token transfer for the entire batch. It adds no persistent batch state or initializer changes. + +```solidity +struct BatchProposal { + Proposal proposal; // Existing fields, including maxPayment. + uint256 maxAmount; // This item's maximum bond + payment spend. +} +``` + +The signed witness is `BatchWitness(BatchProposal[] proposals)`. Each array item binds all existing proposal fields and its own `maxAmount`, and the array order is signed. The sum of `maxAmount` values must equal `permit.permitted.amount`. The batch must be nonempty and `payments.length` must match `proposals.length`. Actual `payments` are selected by the relayer and capped by each signed `proposal.maxPayment`; payments also consume that item's budget. + +The contract pulls the full budget once, verifies the exact token receipt, and attempts each item in an external self-call. That helper is callable only by the contract itself; the outer reentrancy guard remains active. Each oracle receives an allowance bounded by its item's budget minus payment, and any remaining allowance is revoked. A failed item rolls back all of its effects, including token movement and temporary whitelist changes. An item whose request currency does not match the permit token fails individually. The final refund is: + +```text +permit.permitted.amount - sum(successful actual bonds + successful payments) +``` + +Previously retained payments are excluded from the refund. Successful items emit `ProposalExecuted`; failed items emit `BatchProposalFailed(index, proposalHash, errorSelector, revertDataHash)`, where `proposalHash` is the EIP-712 struct hash of the signed `BatchProposal` item. The function returns a matching `bool[]`, and `BatchExecuted(proposer, token, nonce, spent, refund)` summarizes the batch. Full signatures and ancillary data are not logged by these batch events. `BatchProposalFailed.revertDataHash` hashes at most the first 256 bytes of child revert data, matching the bounded-copy policy of `tryMulticall`. Longer payloads are truncated before copying and hashing in the parent; errors shorter than four bytes have a zero error selector. This bounds failure-metadata processing, but does not cap child execution gas. + +A completed outer transaction consumes the Permit2 nonce **even when every item fails**. Refunds do not restore it: retry failed items using a fresh batch signature and unused nonce. Invalid signatures, malformed batch shape/budgets, a failed Permit2 transfer, or a failed final refund revert the whole transaction, including nonce consumption and any successful proposals. This is a one-shot batch authorization, not an authorization that can be filled over multiple transactions. + +Like `tryMulticall`, this method has no per-child gas cap or batch-size constant. An out-of-gas child can starve later items or prevent the outer transaction from finishing; an outer revert rolls everything back. Clients must estimate gas and check calldata size for the actual batch. + +For **8,139 bytes of ancillary data per proposal** and a standard **65-byte EOA Permit2 signature**, `proposeBatch` fits **15 proposals** within Polygon Bor's 131,072-byte transaction-size limit: + +| Proposals | Outer calldata bytes | Result | +|-----------|----------------------|--------| +| 15 | 128,612 | Fits, with 2,460 bytes left for the transaction envelope | +| 16 | 137,156 | Exceeds the limit before adding the envelope | + +The encoding is `452 + 8,544 × proposals` bytes at this ancillary-data/signature size. The capacity test reserves another 512 bytes for an ordinary signed legacy/type-2 transaction without an access list. Larger contract-wallet signatures or access lists require their own size check. Shorter ancillary data allows larger batches. + +`test_proposeBatch_maxAncillaryData_polygonCapacity` uses maximum-length, all-nonzero ancillary data, real Permit2 bytecode, the upgradeable relay, Managed OO, and temporary whitelist insertion/removal for every proposal. All 15 proposals succeed within the repository's 53,902,641 Polygon block gas reference limit (block `81,683,818`), after reserving intrinsic calldata gas. The test also passes with Foundry `--isolate` for separate transaction contexts. This is a local execution/capacity test, not a live Polygon submission or a guarantee of current RPC acceptance. The older `tryMulticall` encoding fits 14 proposals at the same maximum ancillary size because it carries a separate permit and signature for each proposal. + +#### Constructing the signature in a UI + +Use the existing `Proposal` fields as typed data rather than ABI-encoded arbitrary calls. With `@uniswap/permit2-sdk` and an ethers v6 signer, the following constructs one signature. `proposals` is the ordered array of `{ proposal: { oracle, requester, identifier, timestamp, ancillaryData, proposedPrice, maxPayment }, maxAmount }` objects. `ancillaryData` is a hex-encoded byte string, and large integers should use decimal strings or bigint rather than JavaScript numbers. + +```typescript +import { SignatureTransfer } from '@uniswap/permit2-sdk' + +const permit = { + permitted: { + token: collateralToken, + amount: proposals.reduce((sum, item) => sum + BigInt(item.maxAmount), 0n).toString(), + }, + spender: signedProposerProxy, // The proxy, not the implementation or relayer. + nonce, // Unused Permit2 unordered nonce for this signer. + deadline, +} + +const { domain, types, values } = SignatureTransfer.getPermitData( + permit, + permit2Address, + chainId, + { + witness: { proposals }, + witnessTypeName: 'BatchWitness', + witnessType: { + BatchWitness: [{ name: 'proposals', type: 'BatchProposal[]' }], + BatchProposal: [ + { name: 'proposal', type: 'Proposal' }, + { name: 'maxAmount', type: 'uint256' }, + ], + Proposal: [ + { name: 'oracle', type: 'address' }, + { name: 'requester', type: 'address' }, + { name: 'identifier', type: 'bytes32' }, + { name: 'timestamp', type: 'uint256' }, + { name: 'ancillaryData', type: 'bytes' }, + { name: 'proposedPrice', type: 'int256' }, + { name: 'maxPayment', type: 'uint256' }, + ], + }, + }, +) +const signature = await signer.signTypedData(domain, types, values) + +// Submit via an account holding DELEGATED_PROPOSER_ROLE. +await relayContract.proposeBatch( + proposals, + await signer.getAddress(), + { permitted: permit.permitted, nonce: permit.nonce, deadline: permit.deadline }, + signature, + payments, +) +``` + +The wallet must already have sufficient ERC20 allowance to Permit2; a first-time token approval is separate from this one batch signature. The UI should show every proposal and its spend/payment caps, verify intended oracle addresses, and identify failed items for a fresh signature. Wallet rendering of nested typed-data arrays varies. The existing single-proposal witness remains unchanged, and `tryMulticall` still accepts only `propose` calls; use `proposeBatch` directly for this flow. + ### Verification Verify the implementation with no constructor arguments. Verify the ERC1967 proxy separately using its implementation address and encoded `initialize(permit2, admin)` calldata as constructor arguments. diff --git a/src/optimistic-oracle-v2/implementation/SignedProposer.sol b/src/optimistic-oracle-v2/implementation/SignedProposer.sol index 1e8184c..1e9173b 100644 --- a/src/optimistic-oracle-v2/implementation/SignedProposer.sol +++ b/src/optimistic-oracle-v2/implementation/SignedProposer.sol @@ -19,7 +19,7 @@ import {TryMulticall} from "../../common/implementation/TryMulticall.sol"; * @custom:security-contact bugs@umaproject.org * @notice Allows proposers to sign Permit2 witness proposals off-chain and have them submitted by * a delegated relayer. The proposal parameters are embedded as the Permit2 witness so a single - * signature authorises both the token transfer and the specific proposal. + * signature authorises both the token transfer and a specific proposal or ordered proposal batch. * * The signer is set as the proposer (receiving rewards on settlement). * @@ -38,14 +38,19 @@ import {TryMulticall} from "../../common/implementation/TryMulticall.sol"; * * The contract is permissioned: * - `DEFAULT_ADMIN_ROLE` — manages roles, payments, whitelist ownership, and upgrades. - * - `DELEGATED_PROPOSER_ROLE` — may call `propose` and `tryMulticall`. + * - `DELEGATED_PROPOSER_ROLE` — fully trusted, company-controlled relayers that may call + * `propose`, `proposeBatch`, and `tryMulticall`. * - `WHITELIST_ADMIN_ROLE` — may directly add/remove entries on whitelists owned by this contract. * * @dev Inherited `multicall` deliberately accepts any caller and selector and executes atomically. Self-delegatecall * preserves `msg.sender`, so every externally reachable function must enforce its own authorization, including functions - * added in future versions. The batching entry point does not provide a reentrancy guard; functions that need one must + * added in future versions. The `multicall` entry point does not provide a reentrancy guard; functions that need one must * apply their own. `tryMulticall` instead restricts the caller to delegated proposers, accepts only `propose`, and rejects - * nested partial-success batches. These restrictions do not apply to the atomic `multicall` entry point. + * nested partial-success batches. Each `tryMulticall` child uses its own permit and nonce; failed children preserve their + * permits. `proposeBatch` restricts the caller to delegated proposers and holds a reentrancy guard across an ordered, + * same-token batch for one signer. It funds the batch with one Permit2 signature and nonce, isolates child failures, and + * refunds unused funds at completion. A completed batch consumes the shared nonce even if every child fails; retries + * require a fresh signature. These restrictions do not apply to the atomic `multicall` entry point. */ contract SignedProposer is AccessControlUpgradeable, @@ -58,7 +63,7 @@ contract SignedProposer is // ─── Structs ────────────────────────────────────────────────────────────────── - /// @notice Proposal witness — token amount, nonce & deadline live in the Permit2 permit. + /// @notice Proposal witness fields shared by individual permits and batch items. struct Proposal { address oracle; address requester; @@ -69,6 +74,12 @@ contract SignedProposer is uint256 maxPayment; } + /// @notice One signed batch item; maxAmount covers this proposal's bond and payment. + struct BatchProposal { + Proposal proposal; + uint256 maxAmount; + } + // ─── Roles ───────────────────────────────────────────────────────────────────── bytes32 public constant DELEGATED_PROPOSER_ROLE = keccak256("DELEGATED_PROPOSER_ROLE"); @@ -76,6 +87,8 @@ contract SignedProposer is // ─── Constants ──────────────────────────────────────────────────────────────── + uint256 private constant MAX_BATCH_REVERT_DATA_SIZE = 256; + bytes32 public constant PROPOSAL_TYPEHASH = keccak256( "Proposal(address oracle,address requester,bytes32 identifier,uint256 timestamp,bytes ancillaryData,int256 proposedPrice,uint256 maxPayment)" ); @@ -84,6 +97,15 @@ contract SignedProposer is string public constant WITNESS_TYPE_STRING = "Proposal witness)Proposal(address oracle,address requester,bytes32 identifier,uint256 timestamp,bytes ancillaryData,int256 proposedPrice,uint256 maxPayment)TokenPermissions(address token,uint256 amount)"; + bytes32 public constant BATCH_PROPOSAL_TYPEHASH = keccak256( + "BatchProposal(Proposal proposal,uint256 maxAmount)Proposal(address oracle,address requester,bytes32 identifier,uint256 timestamp,bytes ancillaryData,int256 proposedPrice,uint256 maxPayment)" + ); + bytes32 public constant BATCH_WITNESS_TYPEHASH = keccak256( + "BatchWitness(BatchProposal[] proposals)BatchProposal(Proposal proposal,uint256 maxAmount)Proposal(address oracle,address requester,bytes32 identifier,uint256 timestamp,bytes ancillaryData,int256 proposedPrice,uint256 maxPayment)" + ); + string public constant BATCH_WITNESS_TYPE_STRING = + "BatchWitness witness)BatchProposal(Proposal proposal,uint256 maxAmount)BatchWitness(BatchProposal[] proposals)Proposal(address oracle,address requester,bytes32 identifier,uint256 timestamp,bytes ancillaryData,int256 proposedPrice,uint256 maxPayment)TokenPermissions(address token,uint256 amount)"; + // ─── Storage ─────────────────────────────────────────────────────────────── ISignatureTransfer public permit2; @@ -103,6 +125,18 @@ contract SignedProposer is event PaymentWithdrawn(address indexed token, address indexed to, uint256 amount); + /// @dev revertDataHash hashes at most the first 256 bytes of child revert data. + event BatchProposalFailed( + uint256 indexed index, bytes32 indexed proposalHash, bytes4 errorSelector, bytes32 revertDataHash + ); + event BatchExecuted( + address indexed proposer, address indexed token, uint256 indexed nonce, uint256 spent, uint256 refund + ); + + error EmptyBatch(); + error BatchLengthMismatch(); + error BatchAmountMismatch(uint256 totalBudget, uint256 permitAmount); + error OnlySelf(); error ZeroAddress(); error PaymentExceedsMaxPayment(); error PermitTransferAmountMismatch(uint256 expectedAmount, uint256 receivedAmount); @@ -170,8 +204,111 @@ contract SignedProposer is if (address(currency) != permit.permitted.token) { revert PermitTokenMismatch(address(currency), permit.permitted.token); } - _permit2Transfer(proposal, permit, proposer, signature); - totalBond = _executeProposal(proposal, proposer, currency, permit.permitted.amount, payment); + _permit2Transfer(permit, proposer, signature, _hashProposal(proposal), WITNESS_TYPE_STRING); + totalBond = _executeProposal(proposal, proposer, currency, permit.permitted.amount, payment, true); + } + + /** + * @notice Execute a same-token batch for one signer using one Permit2 witness signature. + * @dev The ordered proposals and their individual budgets are signed. Their budgets must sum + * exactly to permit.permitted.amount. Each child rolls back independently on failure; only + * successful bonds/payments are charged, and all unused funds are refunded once at the end. + * A completed batch consumes its nonce even if every child fails. Invalid signatures, invalid + * batch shape/funding, a failed final refund, or insufficient outer gas revert the whole batch. + * Delegated relayers are fully trusted to select per-item payments and supply sufficient gas. + * A payment above maxPayment, or one leaving insufficient budget for the bond, fails that item + * without reverting the batch. Such failures, including relayer mistakes, consume the shared + * nonce on batch completion; unused funds are refunded and retries require a fresh signature. + * As with tryMulticall, there is no per-child gas cap or guarantee against gas starvation. + * @param proposals Signed proposal fields and bond-plus-payment budgets, in execution order. + * @param proposer Signer, token owner, and refund recipient for the entire batch. + * @param permit Single-token Permit2 authorization covering the sum of all item budgets. + * @param signature One signature over the permit and BatchWitness. + * @param payments Actual per-item payments, bounded by each signed proposal.maxPayment. + * @return successes Per-item execution results. Failed items require a fresh signed batch to retry. + */ + function proposeBatch( + BatchProposal[] calldata proposals, + address proposer, + ISignatureTransfer.PermitTransferFrom calldata permit, + bytes calldata signature, + uint256[] calldata payments + ) external onlyRole(DELEGATED_PROPOSER_ROLE) nonReentrant returns (bool[] memory successes) { + uint256 length = proposals.length; + if (length == 0) revert EmptyBatch(); + if (length != payments.length) revert BatchLengthMismatch(); + + // Permit2 needs the full ordered witness before it can authenticate and fund the batch. + // This first pass hashes each item once and checks the total budget; the second executes + // the funded items. A permissioned relayer must still prove the signer's exact authorization. + bytes32[] memory hashes = new bytes32[](length); + uint256 totalBudget; + for (uint256 i; i < length; ++i) { + hashes[i] = _hashBatchProposal(proposals[i]); + totalBudget += proposals[i].maxAmount; + } + if (totalBudget != permit.permitted.amount) { + revert BatchAmountMismatch(totalBudget, permit.permitted.amount); + } + bytes32 witness = keccak256(abi.encode(BATCH_WITNESS_TYPEHASH, keccak256(abi.encodePacked(hashes)))); + _permit2Transfer(permit, proposer, signature, witness, BATCH_WITNESS_TYPE_STRING); + + IERC20 currency = IERC20(permit.permitted.token); + // Deduct only successful bond + payment spends; failed budgets remain refundable. + uint256 refund = permit.permitted.amount; + successes = new bool[](length); + for (uint256 i; i < length; ++i) { + bytes memory callData = + abi.encodeCall(this.executeBatchProposal, (proposals[i], proposer, currency, payments[i])); + bool success; + uint256 spent; + bytes4 errorSelector; + bytes32 revertDataHash; + // Avoid allocating the complete child revert payload in the parent frame. + assembly ("memory-safe") { + success := call(gas(), address(), 0, add(callData, 0x20), mload(callData), 0, 0) + switch success + case 1 { + // The self-only helper returns exactly one uint256; never accept a missing spend value. + if iszero(eq(returndatasize(), 0x20)) { revert(0, 0) } + returndatacopy(0, 0, 0x20) + spent := mload(0) + } + default { + let size := returndatasize() + if gt(size, MAX_BATCH_REVERT_DATA_SIZE) { size := MAX_BATCH_REVERT_DATA_SIZE } + let data := mload(0x40) + returndatacopy(data, 0, size) + if iszero(lt(size, 4)) { errorSelector := mload(data) } + revertDataHash := keccak256(data, size) + } + } + successes[i] = success; + if (success) { + refund -= spent; + } else { + emit BatchProposalFailed(i, hashes[i], errorSelector, revertDataHash); + } + } + if (refund > 0) currency.safeTransfer(proposer, refund); + emit BatchExecuted(proposer, address(currency), permit.nonce, permit.permitted.amount - refund, refund); + } + + /// @dev Only the funded batch may enter this call boundary. The outer nonReentrant guard stays + /// active throughout child execution; token/oracle callbacks cannot enter propose or proposeBatch. + /// An external self-call lets the parent catch failures and roll back every effect of this child. + function executeBatchProposal(BatchProposal calldata item, address proposer, IERC20 currency, uint256 payment) + external + returns (uint256 spent) + { + if (msg.sender != address(this)) revert OnlySelf(); + if (payment > item.proposal.maxPayment) revert PaymentExceedsMaxPayment(); + IERC20 requestCurrency = _getRequestCurrency(item.proposal); + if (requestCurrency != currency) { + revert PermitTokenMismatch(address(requestCurrency), address(currency)); + } + // Defer refunds to the outer batch; the individual cap still bounds this oracle's allowance. + spent = _executeProposal(item.proposal, proposer, currency, item.maxAmount, payment, false) + payment; } // ─── Internals ──────────────────────────────────────────────────────────────── @@ -191,16 +328,8 @@ contract SignedProposer is return request.currency; } - function _permit2Transfer( - Proposal calldata proposal, - ISignatureTransfer.PermitTransferFrom calldata permit, - address proposer, - bytes calldata signature - ) internal { - IERC20 currency = IERC20(permit.permitted.token); - uint256 balanceBefore = currency.balanceOf(address(this)); - - bytes32 witness = keccak256( + function _hashProposal(Proposal calldata proposal) internal pure returns (bytes32) { + return keccak256( abi.encode( PROPOSAL_TYPEHASH, proposal.oracle, @@ -212,13 +341,28 @@ contract SignedProposer is proposal.maxPayment ) ); + } + + function _hashBatchProposal(BatchProposal calldata item) internal pure returns (bytes32) { + return keccak256(abi.encode(BATCH_PROPOSAL_TYPEHASH, _hashProposal(item.proposal), item.maxAmount)); + } + + function _permit2Transfer( + ISignatureTransfer.PermitTransferFrom calldata permit, + address proposer, + bytes calldata signature, + bytes32 witness, + string memory witnessTypeString + ) internal { + IERC20 currency = IERC20(permit.permitted.token); + uint256 balanceBefore = currency.balanceOf(address(this)); permit2.permitWitnessTransferFrom( permit, ISignatureTransfer.SignatureTransferDetails({to: address(this), requestedAmount: permit.permitted.amount}), proposer, witness, - WITNESS_TYPE_STRING, + witnessTypeString, signature ); @@ -234,7 +378,8 @@ contract SignedProposer is address proposer, IERC20 currency, uint256 maxAmount, - uint256 payment + uint256 payment, + bool refundExcess ) internal returns (uint256 totalBond) { AddressWhitelistInterface whitelist = _getEffectiveProposerWhitelist(proposal); bool addedToWhitelist; @@ -251,7 +396,7 @@ contract SignedProposer is if (addedToWhitelist) whitelist.removeFromWhitelist(proposer); uint256 excess = maxAmount - totalBond - payment; - if (excess > 0) currency.safeTransfer(proposer, excess); + if (refundExcess && excess > 0) currency.safeTransfer(proposer, excess); emit ProposalExecuted( proposer, diff --git a/test/SignedProposer.t.sol b/test/SignedProposer.t.sol index 31b0d01..876d460 100644 --- a/test/SignedProposer.t.sol +++ b/test/SignedProposer.t.sol @@ -61,6 +61,10 @@ contract SignedProposerTest is Test { uint256 indexed index, bytes32 indexed callHash, bytes4 errorSelector, bytes32 revertDataHash ); + event BatchProposalFailed( + uint256 indexed index, bytes32 indexed proposalHash, bytes4 errorSelector, bytes32 revertDataHash + ); + SignedProposer internal signedProposer; ManagedOptimisticOracleV2 internal moo; MockPermit2 internal mockPermit2; @@ -263,6 +267,175 @@ contract SignedProposerTest is Test { test_tryMulticall_allSuccess_preservesProposalEventsAndAccounting(); } + function test_proposeBatch_rejectsEmptyMismatchedAndIncorrectlyFundedBatches() public { + SignedProposer.BatchProposal[] memory items = new SignedProposer.BatchProposal[](0); + uint256[] memory payments = new uint256[](0); + ISignatureTransfer.PermitTransferFrom memory permit = _buildPermit(1 ether, 0, block.timestamp + 1 hours); + vm.expectRevert(SignedProposer.EmptyBatch.selector); + vm.prank(relayer); + signedProposer.proposeBatch(items, proposer, permit, "", payments); + + items = new SignedProposer.BatchProposal[](1); + items[0] = SignedProposer.BatchProposal(_buildProposal(block.timestamp, 1 ether), 2 ether); + vm.expectRevert(SignedProposer.BatchLengthMismatch.selector); + vm.prank(relayer); + signedProposer.proposeBatch(items, proposer, permit, "", payments); + + payments = new uint256[](1); + vm.expectRevert(abi.encodeWithSelector(SignedProposer.BatchAmountMismatch.selector, 2 ether, 1 ether)); + vm.prank(relayer); + signedProposer.proposeBatch(items, proposer, permit, "", payments); + } + + function test_proposeBatch_onlyDelegatedRelayers() public { + SignedProposer.BatchProposal[] memory items = new SignedProposer.BatchProposal[](0); + uint256[] memory payments = new uint256[](0); + ISignatureTransfer.PermitTransferFrom memory permit = _buildPermit(0, 0, block.timestamp + 1 hours); + vm.expectRevert( + abi.encodeWithSelector( + IAccessControl.AccessControlUnauthorizedAccount.selector, admin, DELEGATED_PROPOSER_ROLE + ) + ); + vm.prank(admin); + signedProposer.proposeBatch(items, proposer, permit, "", payments); + } + + function test_executeBatchProposal_cannotBypassFundingThroughPublicEntryPoints() public { + SignedProposer.BatchProposal memory item = + SignedProposer.BatchProposal(_buildProposal(block.timestamp, 1 ether), TOTAL_BOND); + bytes[] memory calls = new bytes[](1); + calls[0] = abi.encodeCall(SignedProposer.executeBatchProposal, (item, proposer, IERC20(address(currency)), 0)); + vm.expectRevert(SignedProposer.OnlySelf.selector); + vm.prank(relayer); + signedProposer.executeBatchProposal(item, proposer, IERC20(address(currency)), 0); + vm.expectRevert(SignedProposer.OnlySelf.selector); + vm.prank(admin); + signedProposer.multicall(calls); + vm.expectRevert( + abi.encodeWithSelector( + TryMulticall.TryMulticallInvalidSelector.selector, 0, SignedProposer.executeBatchProposal.selector + ) + ); + vm.prank(relayer); + signedProposer.tryMulticall(calls); + } + + function test_proposeBatch_rejectsShortPermit2Receipt() public { + ShortTransferERC20Mock shortToken = new ShortTransferERC20Mock(); + SignedProposer.BatchProposal[] memory items = new SignedProposer.BatchProposal[](1); + items[0] = SignedProposer.BatchProposal(_buildProposal(block.timestamp, 1 ether), 100 ether); + uint256[] memory payments = new uint256[](1); + ISignatureTransfer.PermitTransferFrom memory permit = + _buildPermitForToken(address(shortToken), 100 ether, 0, block.timestamp + 1 hours); + shortToken.mint(proposer, 100 ether); + vm.prank(proposer); + shortToken.approve(address(mockPermit2), 100 ether); + vm.expectRevert( + abi.encodeWithSelector(SignedProposer.PermitTransferAmountMismatch.selector, 100 ether, 90 ether) + ); + vm.prank(relayer); + signedProposer.proposeBatch(items, proposer, permit, "", payments); + assertEq(shortToken.balanceOf(proposer), 100 ether); + } + + function test_proposeBatch_boundsRevertDataAndPreservesSiblings() public { + uint256[6] memory sizes = [uint256(0), 3, 4, 256, 257, 512 * 1024]; + for (uint256 i; i < sizes.length; ++i) { + _batchWithRevertData(sizes[i]); + } + } + + function _batchWithRevertData(uint256 revertDataSize) internal { + vm.warp(block.timestamp + 2); + uint256 firstTimestamp = block.timestamp - 1; + uint256 lastTimestamp = block.timestamp; + _makeRequest(firstTimestamp, 0); + _makeRequest(lastTimestamp, 0); + _setBond(); + _fundAndApproveProposer(TOTAL_BOND * 3); + uint256 proposerBalanceBefore = currency.balanceOf(proposer); + currency.mint(address(signedProposer), 7 ether); + uint256 retainedBalanceBefore = currency.balanceOf(address(signedProposer)); + + SignedProposer.BatchProposal[] memory items = new SignedProposer.BatchProposal[](3); + items[0] = SignedProposer.BatchProposal(_buildProposal(firstTimestamp, 1 ether), TOTAL_BOND); + items[1] = SignedProposer.BatchProposal( + _buildRevertingProposal(false, revertDataSize, firstTimestamp, 9 ether), TOTAL_BOND + ); + items[2] = SignedProposer.BatchProposal(_buildProposal(lastTimestamp, 2 ether), TOTAL_BOND); + ISignatureTransfer.PermitTransferFrom memory permit = _buildPermit(TOTAL_BOND * 3, 0, block.timestamp + 1 hours); + bytes memory prefix = new bytes(revertDataSize > 256 ? 256 : revertDataSize); + for (uint256 i; i < prefix.length; ++i) { + prefix[i] = bytes1(uint8(i % 251 + 1)); + } + SignedProposer.Proposal memory proposal = items[1].proposal; + bytes32 proposalHash = keccak256( + abi.encode( + signedProposer.PROPOSAL_TYPEHASH(), + proposal.oracle, + proposal.requester, + proposal.identifier, + proposal.timestamp, + keccak256(proposal.ancillaryData), + proposal.proposedPrice, + proposal.maxPayment + ) + ); + bytes32 itemHash = keccak256(abi.encode(signedProposer.BATCH_PROPOSAL_TYPEHASH(), proposalHash, TOTAL_BOND)); + vm.expectEmit(true, true, false, true, address(signedProposer)); + emit BatchProposalFailed(1, itemHash, revertDataSize >= 4 ? bytes4(0x01020304) : bytes4(0), keccak256(prefix)); + vm.prank(relayer); + bool[] memory successes = signedProposer.proposeBatch(items, proposer, permit, "", new uint256[](3)); + assertTrue(successes[0]); + assertFalse(successes[1]); + assertTrue(successes[2]); + assertEq(moo.getRequest(requester, IDENTIFIER, firstTimestamp, ANCILLARY).proposedPrice, 1 ether); + assertEq(moo.getRequest(requester, IDENTIFIER, lastTimestamp, ANCILLARY).proposedPrice, 2 ether); + assertEq(currency.balanceOf(proposer), proposerBalanceBefore - 2 * TOTAL_BOND); + assertEq(currency.balanceOf(address(signedProposer)), retainedBalanceBefore); + assertEq(currency.allowance(address(signedProposer), address(moo)), 0); + } + + function test_proposeBatch_blocksReentrantSingleProposal() public { + _batchWithReentrantCallback(false); + } + + function test_proposeBatch_blocksReentrantBatch() public { + _batchWithReentrantCallback(true); + } + + function _batchWithReentrantCallback(bool nestedBatch) internal { + ReentrantSignedProposerRequester callbackRequester = + new ReentrantSignedProposerRequester(moo, signedProposer, IERC20(address(currency))); + requester = address(callbackRequester); + requesterWhitelist.addToWhitelist(requester); + vm.prank(admin); + signedProposer.addDelegatedProposer(requester); + callbackRequester.requestWithProposalCallback(IDENTIFIER, block.timestamp, ANCILLARY); + _setBond(); + SignedProposer.BatchProposal[] memory items = new SignedProposer.BatchProposal[](1); + items[0] = SignedProposer.BatchProposal(_buildProposal(block.timestamp, 1 ether), TOTAL_BOND); + uint256[] memory payments = new uint256[](1); + ISignatureTransfer.PermitTransferFrom memory permit = _buildPermit(TOTAL_BOND, 0, block.timestamp + 1 hours); + if (nestedBatch) { + callbackRequester.setReentrantBatchCall( + abi.encodeCall(SignedProposer.proposeBatch, (items, proposer, permit, bytes(""), payments)) + ); + } else { + callbackRequester.setReentrantProposal(items[0].proposal, proposer, permit, "", 0); + } + _fundAndApproveProposer(TOTAL_BOND); + vm.prank(relayer); + bool[] memory successes = signedProposer.proposeBatch(items, proposer, permit, "", payments); + assertTrue(successes[0]); + assertTrue(callbackRequester.attemptedReentrantPropose()); + assertFalse(callbackRequester.reentrantProposeSucceeded()); + assertEq( + callbackRequester.reentrantRevertData(), + abi.encodeWithSelector(ReentrancyGuardUpgradeable.ReentrancyGuardReentrantCall.selector) + ); + } + // ─── Helpers ────────────────────────────────────────────────────────────────── function _makeRequest(uint256 timestamp, uint256 reward) internal returns (uint256 totalBond) { @@ -1594,6 +1767,7 @@ contract ReentrantSignedProposerRequester { ISignatureTransfer.PermitTransferFrom internal reentrantPermit; address internal reentrantProposer; bytes internal reentrantSignature; + bytes internal reentrantBatchCall; uint256 internal reentrantPayment; bool public attemptedReentrantPropose; @@ -1611,6 +1785,10 @@ contract ReentrantSignedProposerRequester { oracle.setCallbacks(identifier, timestamp, ancillaryData, true, false, false); } + function setReentrantBatchCall(bytes calldata callData) external { + reentrantBatchCall = callData; + } + function setReentrantProposal( SignedProposer.Proposal calldata proposal, address proposer, @@ -1629,6 +1807,10 @@ contract ReentrantSignedProposerRequester { require(msg.sender == address(oracle), "ReentrantRequester: unauthorized"); attemptedReentrantPropose = true; + if (reentrantBatchCall.length > 0) { + (reentrantProposeSucceeded, reentrantRevertData) = address(signedProposer).call(reentrantBatchCall); + return; + } try signedProposer.propose( reentrantProposal, reentrantProposer, reentrantPermit, reentrantSignature, reentrantPayment ) returns (uint256) { diff --git a/test/SignedProposerPermit2.t.sol b/test/SignedProposerPermit2.t.sol index 377fca1..b950807 100644 --- a/test/SignedProposerPermit2.t.sol +++ b/test/SignedProposerPermit2.t.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.27; +import {Vm} from "forge-std/Vm.sol"; import {Test} from "forge-std/Test.sol"; import {DeployPermit2} from "permit2/test/utils/DeployPermit2.sol"; @@ -239,7 +240,13 @@ contract SignedProposerPermit2Test is Test, DeployPermit2 { internal returns (bool transactionSucceeded, bool[] memory successes) { - bytes memory transactionData = abi.encodeCall(TryMulticall.tryMulticall, (calls)); + return _executeWithinPolygonBlock(abi.encodeCall(TryMulticall.tryMulticall, (calls))); + } + + function _executeWithinPolygonBlock(bytes memory transactionData) + internal + returns (bool transactionSucceeded, bool[] memory successes) + { uint256 intrinsicGas = _transactionIntrinsicGas(transactionData); if (intrinsicGas >= POLYGON_BLOCK_GAS_LIMIT) return (false, successes); @@ -357,6 +364,285 @@ contract SignedProposerPermit2Test is Test, DeployPermit2 { return abi.encodePacked(r, s, v); } + function _prepareSignedBatch() + internal + returns ( + SignedProposer.BatchProposal[] memory items, + ISignatureTransfer.PermitTransferFrom memory permit, + uint256[] memory payments + ) + { + vm.warp(block.timestamp + 3); + items = new SignedProposer.BatchProposal[](3); + payments = new uint256[](3); + for (uint256 i; i < 3; ++i) { + uint256 timestamp = block.timestamp - i; + _makeRequest(timestamp, 0); + items[i] = SignedProposer.BatchProposal({ + proposal: _buildProposal(timestamp, int256(i + 1), 5 ether), + maxAmount: TOTAL_BOND + 10 ether + }); + payments[i] = 1 ether; + } + _setBond(); + permit = _buildPermit(3 * (TOTAL_BOND + 10 ether), 42, block.timestamp + 1 hours); + _fundAndApproveProposer(permit.permitted.amount); + } + + function _batchSignature( + SignedProposer.BatchProposal[] memory items, + ISignatureTransfer.PermitTransferFrom memory permit, + address spender + ) internal view returns (bytes memory) { + // Independently encode the typed array and its nested dependencies, as a wallet would. + bytes32 itemTypeHash = keccak256( + "BatchProposal(Proposal proposal,uint256 maxAmount)Proposal(address oracle,address requester,bytes32 identifier,uint256 timestamp,bytes ancillaryData,int256 proposedPrice,uint256 maxPayment)" + ); + bytes32 batchTypeHash = keccak256( + "BatchWitness(BatchProposal[] proposals)BatchProposal(Proposal proposal,uint256 maxAmount)Proposal(address oracle,address requester,bytes32 identifier,uint256 timestamp,bytes ancillaryData,int256 proposedPrice,uint256 maxPayment)" + ); + bytes32[] memory hashes = new bytes32[](items.length); + for (uint256 i; i < items.length; ++i) { + hashes[i] = keccak256(abi.encode(itemTypeHash, _computeWitnessHash(items[i].proposal), items[i].maxAmount)); + } + bytes32 witness = keccak256(abi.encode(batchTypeHash, keccak256(abi.encodePacked(hashes)))); + bytes32 permitTypeHash = keccak256( + "PermitWitnessTransferFrom(TokenPermissions permitted,address spender,uint256 nonce,uint256 deadline,BatchWitness witness)BatchProposal(Proposal proposal,uint256 maxAmount)BatchWitness(BatchProposal[] proposals)Proposal(address oracle,address requester,bytes32 identifier,uint256 timestamp,bytes ancillaryData,int256 proposedPrice,uint256 maxPayment)TokenPermissions(address token,uint256 amount)" + ); + bytes32 structHash = keccak256( + abi.encode( + permitTypeHash, + keccak256(abi.encode(TOKEN_PERMISSIONS_TYPEHASH, permit.permitted)), + spender, + permit.nonce, + permit.deadline, + witness + ) + ); + bytes32 digest = keccak256(abi.encodePacked("\x19\x01", IEIP712(permit2Address).DOMAIN_SEPARATOR(), structHash)); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(proposerKey, digest); + return abi.encodePacked(r, s, v); + } + + function test_proposeBatch_oneSignatureAllSuccessAndRefund() public { + ( + SignedProposer.BatchProposal[] memory items, + ISignatureTransfer.PermitTransferFrom memory permit, + uint256[] memory payments + ) = _prepareSignedBatch(); + currency.mint(address(signedProposer), 7 ether); // Existing payments must not fund or be refunded by this batch. + bytes memory signature = _batchSignature(items, permit, address(signedProposer)); + vm.prank(relayer); + bool[] memory successes = signedProposer.proposeBatch(items, proposer, permit, signature, payments); + assertEq(successes.length, 3); + for (uint256 i; i < 3; ++i) { + assertTrue(successes[i]); + assertEq(moo.getRequest(requester, IDENTIFIER, items[i].proposal.timestamp, ANCILLARY).proposer, proposer); + } + assertEq(currency.balanceOf(proposer), 27 ether); + assertEq(currency.balanceOf(address(signedProposer)), 10 ether); + assertEq(currency.allowance(address(signedProposer), address(moo)), 0); + assertEq(ISignatureTransfer(permit2Address).nonceBitmap(proposer, 0), 1 << 42); + vm.expectRevert(bytes4(keccak256("InvalidNonce()"))); + vm.prank(relayer); + signedProposer.proposeBatch(items, proposer, permit, signature, payments); + } + + function test_proposeBatch_collisionRefundsFailedBudgetAndContinues() public { + ( + SignedProposer.BatchProposal[] memory items, + ISignatureTransfer.PermitTransferFrom memory permit, + uint256[] memory payments + ) = _prepareSignedBatch(); + defaultProposerWhitelist.removeFromWhitelist(proposer); + defaultProposerWhitelist.transferOwnership(address(signedProposer)); + items[1].proposal = items[0].proposal; + bytes memory signature = _batchSignature(items, permit, address(signedProposer)); + vm.recordLogs(); + vm.prank(relayer); + bool[] memory successes = signedProposer.proposeBatch(items, proposer, permit, signature, payments); + assertTrue(successes[0]); + assertFalse(successes[1]); + assertTrue(successes[2]); + assertEq(currency.balanceOf(proposer), permit.permitted.amount - 2 * (TOTAL_BOND + 1 ether)); + assertEq(currency.balanceOf(address(signedProposer)), 2 ether); + assertFalse(defaultProposerWhitelist.isOnWhitelist(proposer)); + assertTrue(defaultProposerWhitelist.isOnWhitelist(address(signedProposer))); + assertEq(currency.allowance(address(signedProposer), address(moo)), 0); + Vm.Log[] memory logs = vm.getRecordedLogs(); + uint256 failures; + for (uint256 i; i < logs.length; ++i) { + if ( + logs[i].emitter == address(signedProposer) + && logs[i].topics[0] == keccak256("BatchProposalFailed(uint256,bytes32,bytes4,bytes32)") + ) { + ++failures; + assertEq(uint256(logs[i].topics[1]), 1); + } + } + assertEq(failures, 1); + } + + function test_proposeBatch_allFailRefundsEverythingButConsumesNonce() public { + ( + SignedProposer.BatchProposal[] memory items, + ISignatureTransfer.PermitTransferFrom memory permit, + uint256[] memory payments + ) = _prepareSignedBatch(); + for (uint256 i; i < 3; ++i) { + payments[i] = 6 ether; + } // Above signed maxPayment. + bytes memory signature = _batchSignature(items, permit, address(signedProposer)); + vm.prank(relayer); + bool[] memory successes = signedProposer.proposeBatch(items, proposer, permit, signature, payments); + for (uint256 i; i < 3; ++i) { + assertFalse(successes[i]); + } + assertEq(currency.balanceOf(proposer), permit.permitted.amount); + assertEq(currency.balanceOf(address(signedProposer)), 0); + assertEq(ISignatureTransfer(permit2Address).nonceBitmap(proposer, 0), 1 << 42); + } + + function test_proposeBatch_individualBudgetCannotBorrowFromSibling() public { + ( + SignedProposer.BatchProposal[] memory items, + ISignatureTransfer.PermitTransferFrom memory permit, + uint256[] memory payments + ) = _prepareSignedBatch(); + // Keep the aggregate budget unchanged while making the first item unable to fund its bond. + items[0].maxAmount -= 20 ether; + items[1].maxAmount += 20 ether; + bytes memory signature = _batchSignature(items, permit, address(signedProposer)); + vm.prank(relayer); + bool[] memory successes = signedProposer.proposeBatch(items, proposer, permit, signature, payments); + assertFalse(successes[0]); + assertTrue(successes[1]); + assertTrue(successes[2]); + assertEq(currency.balanceOf(proposer), permit.permitted.amount - 2 * (TOTAL_BOND + 1 ether)); + assertEq(currency.balanceOf(address(signedProposer)), 2 ether); + } + + function test_proposeBatch_wrongCurrencyOnlyFailsThatItem() public { + ( + SignedProposer.BatchProposal[] memory items, + ISignatureTransfer.PermitTransferFrom memory permit, + uint256[] memory payments + ) = _prepareSignedBatch(); + ERC20Mock otherCurrency = new ERC20Mock(); + items[1].proposal.oracle = address( + new MaliciousSignedProposerOracle(IERC20(address(otherCurrency)), address(signedProposer), address(this)) + ); + bytes memory signature = _batchSignature(items, permit, address(signedProposer)); + vm.prank(relayer); + bool[] memory successes = signedProposer.proposeBatch(items, proposer, permit, signature, payments); + assertTrue(successes[0]); + assertFalse(successes[1]); + assertTrue(successes[2]); + assertEq(currency.balanceOf(proposer), permit.permitted.amount - 2 * (TOTAL_BOND + 1 ether)); + } + + function testFuzz_proposeBatch_rejectsSignedItemTampering(uint8 mutation) public { + ( + SignedProposer.BatchProposal[] memory items, + ISignatureTransfer.PermitTransferFrom memory permit, + uint256[] memory payments + ) = _prepareSignedBatch(); + bytes memory signature = _batchSignature(items, permit, address(signedProposer)); + mutation = uint8(bound(mutation, 0, 8)); + if (mutation == 0) { + items[0].proposal.oracle = address(1); + } else if (mutation == 1) { + items[0].proposal.requester = address(1); + } else if (mutation == 2) { + items[0].proposal.identifier = bytes32(uint256(1)); + } else if (mutation == 3) { + items[0].proposal.timestamp += 1; + } else if (mutation == 4) { + items[0].proposal.ancillaryData = hex"1234"; + } else if (mutation == 5) { + items[0].proposal.proposedPrice += 1; + } else if (mutation == 6) { + items[0].proposal.maxPayment += 1; + } else if (mutation == 7) { + items[0].maxAmount += 1; + items[1].maxAmount -= 1; + } else { + SignedProposer.BatchProposal memory first = items[0]; + items[0] = items[1]; + items[1] = first; + } + vm.expectRevert(SignatureVerification.InvalidSigner.selector); + vm.prank(relayer); + signedProposer.proposeBatch(items, proposer, permit, signature, payments); + assertEq(ISignatureTransfer(permit2Address).nonceBitmap(proposer, 0), 0); + assertEq(currency.balanceOf(proposer), permit.permitted.amount); + } + + function test_proposeBatch_rejectsSignatureForDifferentSpender() public { + ( + SignedProposer.BatchProposal[] memory items, + ISignatureTransfer.PermitTransferFrom memory permit, + uint256[] memory payments + ) = _prepareSignedBatch(); + bytes memory signature = _batchSignature(items, permit, address(123)); + vm.expectRevert(SignatureVerification.InvalidSigner.selector); + vm.prank(relayer); + signedProposer.proposeBatch(items, proposer, permit, signature, payments); + } + + function test_proposeBatch_refundFailureRevertsFundingNonceAndSuccessfulProposals() public { + ( + SignedProposer.BatchProposal[] memory items, + ISignatureTransfer.PermitTransferFrom memory permit, + uint256[] memory payments + ) = _prepareSignedBatch(); + bytes memory signature = _batchSignature(items, permit, address(signedProposer)); + vm.mockCallRevert(address(currency), abi.encodeCall(IERC20.transfer, (proposer, 27 ether)), hex"1234"); + vm.expectRevert(bytes(hex"1234")); + vm.prank(relayer); + signedProposer.proposeBatch(items, proposer, permit, signature, payments); + assertEq(ISignatureTransfer(permit2Address).nonceBitmap(proposer, 0), 0); + assertEq(currency.balanceOf(proposer), permit.permitted.amount); + assertEq(currency.balanceOf(address(signedProposer)), 0); + for (uint256 i; i < 3; ++i) { + assertEq(moo.getRequest(requester, IDENTIFIER, items[i].proposal.timestamp, ANCILLARY).proposer, address(0)); + } + vm.clearMockedCalls(); + vm.prank(relayer); + bool[] memory successes = signedProposer.proposeBatch(items, proposer, permit, signature, payments); + for (uint256 i; i < 3; ++i) { + assertTrue(successes[i]); + } + } + + function test_proposeBatch_gasExhaustingLastChildRollsBackItsTokenPull() public { + ( + SignedProposer.BatchProposal[] memory items, + ISignatureTransfer.PermitTransferFrom memory permit, + uint256[] memory payments + ) = _prepareSignedBatch(); + MaliciousSignedProposerOracle gasOracle = + new MaliciousSignedProposerOracle(IERC20(address(currency)), address(signedProposer), address(this)); + gasOracle.setBondAmount(TOTAL_BOND); + gasOracle.setExhaustGasAfterTransfer(true); + items[2].proposal.oracle = address(gasOracle); + bytes memory signature = _batchSignature(items, permit, address(signedProposer)); + vm.prank(relayer); + (bool outerSuccess, bytes memory result) = address(signedProposer).call{gas: 30_000_000}( + abi.encodeCall(SignedProposer.proposeBatch, (items, proposer, permit, signature, payments)) + ); + assertTrue(outerSuccess); + bool[] memory successes = abi.decode(result, (bool[])); + assertTrue(successes[0]); + assertTrue(successes[1]); + assertFalse(successes[2]); + assertEq(currency.balanceOf(address(gasOracle)), 0); + assertEq(currency.allowance(address(signedProposer), address(gasOracle)), 0); + assertFalse(gasOracle.whitelist().isOnWhitelist(proposer)); + assertEq(currency.balanceOf(proposer), permit.permitted.amount - 2 * (TOTAL_BOND + 1 ether)); + assertEq(currency.balanceOf(address(signedProposer)), 2 ether); + } + function test_propose_realPermit2Signature() public { uint256 timestamp = block.timestamp; _makeRequest(timestamp, 0); @@ -606,6 +892,74 @@ contract SignedProposerPermit2Test is Test, DeployPermit2 { assertEq(moo.getRequest(requester, IDENTIFIER, timestamp, ANCILLARY).proposedPrice, 2 ether); } + function test_proposeBatch_maxAncillaryData_polygonCapacity() public { + uint256 maxBatch = 15; + bytes memory ancillaryData = _maximallyPricedAncillaryData(); + assertEq(ancillaryData.length, 8_139); + vm.warp(block.timestamp + maxBatch + 1); + SignedProposer.BatchProposal[] memory boundary = new SignedProposer.BatchProposal[](maxBatch); + SignedProposer.BatchProposal[] memory oversized = new SignedProposer.BatchProposal[](maxBatch + 1); + for (uint256 i; i < oversized.length; ++i) { + uint256 timestamp = block.timestamp - i; + _makeRequest(timestamp, 0, ancillaryData); + oversized[i] = + SignedProposer.BatchProposal(_buildProposal(timestamp, int256(i + 1), 0, ancillaryData), TOTAL_BOND); + if (i < maxBatch) boundary[i] = oversized[i]; + } + _setBond(ancillaryData); + _fundAndApproveProposer(TOTAL_BOND * maxBatch); + // Include temporary whitelist insertion/removal for every successful item. + defaultProposerWhitelist.removeFromWhitelist(proposer); + defaultProposerWhitelist.transferOwnership(address(signedProposer)); + + ISignatureTransfer.PermitTransferFrom memory permit = + _buildPermit(TOTAL_BOND * maxBatch, 43, block.timestamp + 1 hours); + bytes memory boundaryData = abi.encodeCall( + SignedProposer.proposeBatch, + ( + boundary, + proposer, + permit, + _batchSignature(boundary, permit, address(signedProposer)), + new uint256[](maxBatch) + ) + ); + permit.permitted.amount += TOTAL_BOND; + bytes memory oversizedData = abi.encodeCall( + SignedProposer.proposeBatch, + ( + oversized, + proposer, + permit, + _batchSignature(oversized, permit, address(signedProposer)), + new uint256[](maxBatch + 1) + ) + ); + + // For 65-byte EOA signatures: 452 fixed bytes + 8,544 bytes per maximum-sized item. + assertEq(boundaryData.length, 128_612); + assertEq(oversizedData.length, 137_156); + // Leave ample room for an ordinary signed legacy/type-2 envelope without an access list. + assertLt(boundaryData.length + 512, BOR_MAX_TRANSACTION_BYTES); + // The next batch already exceeds Bor's 128 KiB limit before adding the transaction envelope. + assertGt(oversizedData.length, BOR_MAX_TRANSACTION_BYTES); + (bool outerSuccess, bool[] memory successes) = _executeWithinPolygonBlock(boundaryData); + uint256 executionGas = vm.lastCallGas().gasTotalUsed; + assertTrue(_allSucceeded(outerSuccess, successes, maxBatch)); + assertEq(currency.balanceOf(proposer), 0); + assertEq(currency.balanceOf(address(signedProposer)), 0); + assertEq(currency.allowance(address(signedProposer), address(moo)), 0); + assertFalse(defaultProposerWhitelist.isOnWhitelist(proposer)); + assertEq(ISignatureTransfer(permit2Address).nonceBitmap(proposer, 0), 1 << 43); + + emit log_named_uint("max ancillary bytes per proposal", ancillaryData.length); + emit log_named_uint("largest successful proposal batch", maxBatch); + emit log_named_uint("15 proposal calldata bytes", boundaryData.length); + emit log_named_uint("batch execution gas (excluding intrinsic gas)", executionGas); + emit log_named_uint("16 proposal calldata bytes", oversizedData.length); + emit log_named_uint("Polygon block gas limit", POLYGON_BLOCK_GAS_LIMIT); + } + function test_tryMulticall_maxAncillaryData_polygonBlockCapacity() public { bytes memory ancillaryData = _maximallyPricedAncillaryData(); assertEq(ancillaryData.length, moo.OO_ANCILLARY_DATA_LIMIT());