Skip to content
Draft
44 changes: 44 additions & 0 deletions src/Batcher.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import {IOrchestrator} from "./interfaces/IOrchestrator.sol";

/// @title Batcher
/// @notice Contract for executing multiple intents through the orchestrator in a single transaction
/// @dev Individual intent failures do not revert the entire batch
contract Batcher {
/// @notice Emitted when an intent execution fails
event IntentFailed(uint256 indexed index, bytes reason);

error InvalidArrayLength();
error ArrayLengthMismatch();

/// @notice Execute multiple intents through the orchestrator
/// @param orchestrator The orchestrator contract address
/// @param encodedIntents Array of encoded intents
/// @param intentGas Array of gas amounts for each intent
function batchExecute(
address orchestrator,
bytes[] calldata encodedIntents,
uint256[] calldata intentGas
) external {
uint256 length = encodedIntents.length;

if (length == 0) revert InvalidArrayLength();
if (length != intentGas.length) revert ArrayLengthMismatch();

// Execute each intent
for (uint256 i = 0; i < length; ++i) {
// Encode the function call
bytes memory data =
abi.encodeWithSelector(IOrchestrator.execute.selector, encodedIntents[i]);

// Make the call with specified gas
(bool success, bytes memory returnData) = orchestrator.call{gas: intentGas[i]}(data);

if (!success) {
emit IntentFailed(i, returnData);
}
}
}
}
7 changes: 0 additions & 7 deletions src/IthacaAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -627,13 +627,6 @@ contract IthacaAccount is IIthacaAccount, EIP712, GuardedExecutor {
// Set the target key hash to the payer's.
keyHash = k;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simulation Logic Removal - Security Improvement

Excellent removal of simulation-specific logic from production contract!

Security benefits:

  1. Eliminates attack surface: Removes special-case logic that could be exploited
  2. Cleaner audit trail: Production contract behavior is now deterministic
  3. Separation of concerns: Simulation logic moved to dedicated simulation contracts

The removal of the address(ORCHESTRATOR).balance == type(uint256).max check is particularly good - this was a hacky way to detect simulation mode that could potentially be gamed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like this removal. now the simulation functionality is more isolated.

// If this is a simulation, signature validation errors are skipped.
/// @dev to simulate a paymaster, state override the balance of the msg.sender
/// to type(uint256).max. In this case, the msg.sender is the ORCHESTRATOR.
if (address(ORCHESTRATOR).balance == type(uint256).max) {
isValid = true;
}

if (!isValid) {
revert Unauthorized();
}
Expand Down
293 changes: 56 additions & 237 deletions src/Orchestrator.sol

Large diffs are not rendered by default.

Loading
Loading