Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 49 additions & 49 deletions snapshots/BenchmarkTest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"testERC20Transfer_AverageCost_CoinbaseSmartWallet": "685988",
"testERC20Transfer_AverageCost_CoinbaseSmartWallet_AppSponsor": "747597",
"testERC20Transfer_AverageCost_CoinbaseSmartWallet_ERC20SelfPay": "1119303",
"testERC20Transfer_AverageCost_Ithaca7702Account": "489228",
"testERC20Transfer_AverageCost_Ithaca7702Account_AppSponsor": "786741",
"testERC20Transfer_AverageCost_Ithaca7702Account_AppSponsor_ERC20": "775731",
"testERC20Transfer_AverageCost_Ithaca7702Account_ERC20SelfPay": "591298",
"testERC20Transfer_AverageCost_IthacaAccount": "528758",
"testERC20Transfer_AverageCost_IthacaAccount_AppSponsor": "821937",
"testERC20Transfer_AverageCost_IthacaAccount_AppSponsor_ERC20": "810951",
"testERC20Transfer_AverageCost_IthacaAccount_ERC20SelfPay": "630864",
"testERC20Transfer_AverageCost_Ithaca7702Account": "478920",
"testERC20Transfer_AverageCost_Ithaca7702Account_AppSponsor": "552663",
"testERC20Transfer_AverageCost_Ithaca7702Account_AppSponsor_ERC20": "541653",
"testERC20Transfer_AverageCost_Ithaca7702Account_ERC20SelfPay": "580990",
"testERC20Transfer_AverageCost_IthacaAccount": "514590",
"testERC20Transfer_AverageCost_IthacaAccount_AppSponsor": "583999",
"testERC20Transfer_AverageCost_IthacaAccount_AppSponsor_ERC20": "573013",
"testERC20Transfer_AverageCost_IthacaAccount_ERC20SelfPay": "616696",
"testERC20Transfer_AverageCost_Safe4337": "860874",
"testERC20Transfer_AverageCost_Safe4337_AppSponsor": "890102",
"testERC20Transfer_AverageCost_Safe4337_ERC20SelfPay": "1262236",
Expand All @@ -25,14 +25,14 @@
"testERC20Transfer_MaximumCost_CoinbaseSmartWallet": "177855",
"testERC20Transfer_MaximumCost_CoinbaseSmartWallet_AppSponsor": "175259",
"testERC20Transfer_MaximumCost_CoinbaseSmartWallet_ERC20SelfPay": "204919",
"testERC20Transfer_MaximumCost_Ithaca7702Account": "111840",
"testERC20Transfer_MaximumCost_Ithaca7702Account_AppSponsor": "145631",
"testERC20Transfer_MaximumCost_Ithaca7702Account_AppSponsor_ERC20": "150920",
"testERC20Transfer_MaximumCost_Ithaca7702Account_ERC20SelfPay": "112329",
"testERC20Transfer_MaximumCost_IthacaAccount": "118043",
"testERC20Transfer_MaximumCost_IthacaAccount_AppSponsor": "151415",
"testERC20Transfer_MaximumCost_IthacaAccount_AppSponsor_ERC20": "156704",
"testERC20Transfer_MaximumCost_IthacaAccount_ERC20SelfPay": "118532",
"testERC20Transfer_MaximumCost_Ithaca7702Account": "110807",
"testERC20Transfer_MaximumCost_Ithaca7702Account_AppSponsor": "122221",
"testERC20Transfer_MaximumCost_Ithaca7702Account_AppSponsor_ERC20": "127510",
"testERC20Transfer_MaximumCost_Ithaca7702Account_ERC20SelfPay": "111296",
"testERC20Transfer_MaximumCost_IthacaAccount": "116624",
"testERC20Transfer_MaximumCost_IthacaAccount_AppSponsor": "127619",
"testERC20Transfer_MaximumCost_IthacaAccount_AppSponsor_ERC20": "132908",
"testERC20Transfer_MaximumCost_IthacaAccount_ERC20SelfPay": "117113",
"testERC20Transfer_MaximumCost_Safe4337": "197561",
"testERC20Transfer_MaximumCost_Safe4337_AppSponsor": "191725",
"testERC20Transfer_MaximumCost_Safe4337_ERC20SelfPay": "221464",
Expand All @@ -45,14 +45,14 @@
"testNativeTransfer_AverageCost_CoinbaseSmartWallet": "683673",
"testNativeTransfer_AverageCost_CoinbaseSmartWallet_AppSponsor": "744894",
"testNativeTransfer_AverageCost_CoinbaseSmartWallet_ERC20SelfPay": "1049137",
"testNativeTransfer_AverageCost_Ithaca7702Account": "489813",
"testNativeTransfer_AverageCost_Ithaca7702Account_AppSponsor": "787395",
"testNativeTransfer_AverageCost_Ithaca7702Account_AppSponsor_ERC20": "778849",
"testNativeTransfer_AverageCost_Ithaca7702Account_ERC20SelfPay": "524491",
"testNativeTransfer_AverageCost_IthacaAccount": "529151",
"testNativeTransfer_AverageCost_IthacaAccount_AppSponsor": "822459",
"testNativeTransfer_AverageCost_IthacaAccount_AppSponsor_ERC20": "813961",
"testNativeTransfer_AverageCost_IthacaAccount_ERC20SelfPay": "563853",
"testNativeTransfer_AverageCost_Ithaca7702Account": "479505",
"testNativeTransfer_AverageCost_Ithaca7702Account_AppSponsor": "553317",
"testNativeTransfer_AverageCost_Ithaca7702Account_AppSponsor_ERC20": "544771",
"testNativeTransfer_AverageCost_Ithaca7702Account_ERC20SelfPay": "514183",
"testNativeTransfer_AverageCost_IthacaAccount": "514983",
"testNativeTransfer_AverageCost_IthacaAccount_AppSponsor": "584521",
"testNativeTransfer_AverageCost_IthacaAccount_AppSponsor_ERC20": "576023",
"testNativeTransfer_AverageCost_IthacaAccount_ERC20SelfPay": "549685",
"testNativeTransfer_AverageCost_Safe4337": "858120",
"testNativeTransfer_AverageCost_Safe4337_AppSponsor": "886805",
"testNativeTransfer_AverageCost_Safe4337_ERC20SelfPay": "1191736",
Expand All @@ -65,35 +65,35 @@
"testNativeTransfer_MaximumCost_CoinbaseSmartWallet": "153916",
"testNativeTransfer_MaximumCost_CoinbaseSmartWallet_AppSponsor": "151285",
"testNativeTransfer_MaximumCost_CoinbaseSmartWallet_ERC20SelfPay": "188279",
"testNativeTransfer_MaximumCost_Ithaca7702Account": "88242",
"testNativeTransfer_MaximumCost_Ithaca7702Account_AppSponsor": "122046",
"testNativeTransfer_MaximumCost_Ithaca7702Account_AppSponsor_ERC20": "129823",
"testNativeTransfer_MaximumCost_Ithaca7702Account_ERC20SelfPay": "96031",
"testNativeTransfer_MaximumCost_IthacaAccount": "94427",
"testNativeTransfer_MaximumCost_IthacaAccount_AppSponsor": "127800",
"testNativeTransfer_MaximumCost_IthacaAccount_AppSponsor_ERC20": "135589",
"testNativeTransfer_MaximumCost_IthacaAccount_ERC20SelfPay": "102216",
"testNativeTransfer_MaximumCost_Ithaca7702Account": "87209",
"testNativeTransfer_MaximumCost_Ithaca7702Account_AppSponsor": "98636",
"testNativeTransfer_MaximumCost_Ithaca7702Account_AppSponsor_ERC20": "106413",
"testNativeTransfer_MaximumCost_Ithaca7702Account_ERC20SelfPay": "94998",
"testNativeTransfer_MaximumCost_IthacaAccount": "93008",
"testNativeTransfer_MaximumCost_IthacaAccount_AppSponsor": "104004",
"testNativeTransfer_MaximumCost_IthacaAccount_AppSponsor_ERC20": "111793",
"testNativeTransfer_MaximumCost_IthacaAccount_ERC20SelfPay": "100797",
"testNativeTransfer_MaximumCost_Safe4337": "173595",
"testNativeTransfer_MaximumCost_Safe4337_AppSponsor": "167724",
"testNativeTransfer_MaximumCost_Safe4337_ERC20SelfPay": "204774",
"testNativeTransfer_MaximumCost_ZerodevKernel": "183635",
"testNativeTransfer_MaximumCost_ZerodevKernel_AppSponsor": "180611",
"testNativeTransfer_MaximumCost_ZerodevKernel_ERC20SelfPay": "219269",
"testSpendLimits_ERC20Transfer_MaximumCost_IthacaAccount": "184425",
"testSpendLimits_ERC20Transfer_MaximumCost_IthacaAccount": "183028",
"testUniswapV2Swap_AverageCost_AlchemyModularAccount": "1019693",
"testUniswapV2Swap_AverageCost_AlchemyModularAccount_AppSponsor": "1077352",
"testUniswapV2Swap_AverageCost_AlchemyModularAccount_ERC20SelfPay": "1395606",
"testUniswapV2Swap_AverageCost_CoinbaseSmartWallet": "1008244",
"testUniswapV2Swap_AverageCost_CoinbaseSmartWallet_AppSponsor": "1070443",
"testUniswapV2Swap_AverageCost_CoinbaseSmartWallet_ERC20SelfPay": "1372336",
"testUniswapV2Swap_AverageCost_Ithaca7702Account": "806302",
"testUniswapV2Swap_AverageCost_Ithaca7702Account_AppSponsor": "1103922",
"testUniswapV2Swap_AverageCost_Ithaca7702Account_AppSponsor_ERC20": "1092888",
"testUniswapV2Swap_AverageCost_Ithaca7702Account_ERC20SelfPay": "838432",
"testUniswapV2Swap_AverageCost_IthacaAccount": "846214",
"testUniswapV2Swap_AverageCost_IthacaAccount_AppSponsor": "1139524",
"testUniswapV2Swap_AverageCost_IthacaAccount_AppSponsor_ERC20": "1128418",
"testUniswapV2Swap_AverageCost_IthacaAccount_ERC20SelfPay": "878368",
"testUniswapV2Swap_AverageCost_Ithaca7702Account": "795994",
"testUniswapV2Swap_AverageCost_Ithaca7702Account_AppSponsor": "869844",
"testUniswapV2Swap_AverageCost_Ithaca7702Account_AppSponsor_ERC20": "858810",
"testUniswapV2Swap_AverageCost_Ithaca7702Account_ERC20SelfPay": "828124",
"testUniswapV2Swap_AverageCost_IthacaAccount": "832046",
"testUniswapV2Swap_AverageCost_IthacaAccount_AppSponsor": "901586",
"testUniswapV2Swap_AverageCost_IthacaAccount_AppSponsor_ERC20": "890480",
"testUniswapV2Swap_AverageCost_IthacaAccount_ERC20SelfPay": "864200",
"testUniswapV2Swap_AverageCost_Safe4337": "1184843",
"testUniswapV2Swap_AverageCost_Safe4337_AppSponsor": "1214756",
"testUniswapV2Swap_AverageCost_Safe4337_ERC20SelfPay": "1517085",
Expand All @@ -106,14 +106,14 @@
"testUniswapV2Swap_MaximumCost_CoinbaseSmartWallet": "237451",
"testUniswapV2Swap_MaximumCost_CoinbaseSmartWallet_AppSponsor": "234904",
"testUniswapV2Swap_MaximumCost_CoinbaseSmartWallet_ERC20SelfPay": "269389",
"testUniswapV2Swap_MaximumCost_Ithaca7702Account": "170891",
"testUniswapV2Swap_MaximumCost_Ithaca7702Account_AppSponsor": "204694",
"testUniswapV2Swap_MaximumCost_Ithaca7702Account_AppSponsor_ERC20": "209971",
"testUniswapV2Swap_MaximumCost_Ithaca7702Account_ERC20SelfPay": "176180",
"testUniswapV2Swap_MaximumCost_IthacaAccount": "177131",
"testUniswapV2Swap_MaximumCost_IthacaAccount_AppSponsor": "210503",
"testUniswapV2Swap_MaximumCost_IthacaAccount_AppSponsor_ERC20": "215792",
"testUniswapV2Swap_MaximumCost_IthacaAccount_ERC20SelfPay": "182420",
"testUniswapV2Swap_MaximumCost_Ithaca7702Account": "169858",
"testUniswapV2Swap_MaximumCost_Ithaca7702Account_AppSponsor": "181284",
"testUniswapV2Swap_MaximumCost_Ithaca7702Account_AppSponsor_ERC20": "186561",
"testUniswapV2Swap_MaximumCost_Ithaca7702Account_ERC20SelfPay": "175147",
"testUniswapV2Swap_MaximumCost_IthacaAccount": "175712",
"testUniswapV2Swap_MaximumCost_IthacaAccount_AppSponsor": "186707",
"testUniswapV2Swap_MaximumCost_IthacaAccount_AppSponsor_ERC20": "191996",
"testUniswapV2Swap_MaximumCost_IthacaAccount_ERC20SelfPay": "181001",
"testUniswapV2Swap_MaximumCost_Safe4337": "257333",
"testUniswapV2Swap_MaximumCost_Safe4337_AppSponsor": "251583",
"testUniswapV2Swap_MaximumCost_Safe4337_ERC20SelfPay": "286101",
Expand Down
12 changes: 1 addition & 11 deletions src/IthacaAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ contract IthacaAccount is IIthacaAccount, EIP712, GuardedExecutor {
mapping(bytes32 => LibBytes.BytesStorage) keyStorage;
/// @dev Mapping of key hash to the key's extra storage.
mapping(bytes32 => LibStorage.Bump) keyExtraStorage;
/// @dev Nonce management when porto account acts as paymaster.
mapping(bytes32 => bool) paymasterNonces;
}

/// @dev Returns the storage pointer.
Expand Down Expand Up @@ -136,9 +134,6 @@ contract IthacaAccount is IIthacaAccount, EIP712, GuardedExecutor {
/// use `address(0xdeaDDeADDEaDdeaDdEAddEADDEAdDeadDEADDEaD)`.
error NewImplementationIsZero();

/// @dev The paymaster nonce has already been used.
error PaymasterNonceError();

////////////////////////////////////////////////////////////////////////
// Events
////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -617,11 +612,6 @@ contract IthacaAccount is IIthacaAccount, EIP712, GuardedExecutor {

// If this account is the paymaster, validate the paymaster signature.
if (payer == address(this)) {
if (_getAccountStorage().paymasterNonces[intentDigest]) {
revert PaymasterNonceError();
}
_getAccountStorage().paymasterNonces[intentDigest] = true;

(bool isValid, bytes32 k) = unwrapAndValidateSignature(intentDigest, paymentSignature);

// Set the target key hash to the payer's.
Expand Down Expand Up @@ -732,6 +722,6 @@ contract IthacaAccount is IIthacaAccount, EIP712, GuardedExecutor {
returns (string memory name, string memory version)
{
name = "IthacaAccount";
version = "0.5.10";
version = "0.5.11";
}
}
32 changes: 29 additions & 3 deletions src/Orchestrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {IFunder} from "./interfaces/IFunder.sol";
import {ISettler} from "./interfaces/ISettler.sol";
import {MerkleProofLib} from "solady/utils/MerkleProofLib.sol";
import {IntentHelpers} from "./libraries/IntentHelpers.sol";
import {LibNonce} from "./libraries/LibNonce.sol";

/// @title Orchestrator
/// @notice Enables atomic verification, gas compensation and execution across eoas.
Expand Down Expand Up @@ -52,6 +53,13 @@ contract Orchestrator is
using LibERC7579 for bytes32[];
using EfficientHashLib for bytes32[];
using LibBitmap for LibBitmap.Bitmap;
using LibNonce for mapping(uint192 => LibStorage.Ref);

////////////////////////////////////////////////////////////////////////
// State
////////////////////////////////////////////////////////////////////////

mapping(address => mapping(uint192 => LibStorage.Ref)) nonceSeqs;

////////////////////////////////////////////////////////////////////////
// Errors
Expand Down Expand Up @@ -111,6 +119,13 @@ contract Orchestrator is
/// For PreCalls where the nonce is skipped, this event will NOT be emitted..
event IntentExecuted(address indexed eoa, uint256 indexed nonce, bool incremented, bytes4 err);

/// @dev The nonce sequence of is invalidated up to (inclusive) of `nonce`.
/// The new available nonce will be `nonce + 1`.
/// This event is emitted in the `invalidateNonce` function,
/// as well as the `execute` function when an execution is performed directly
/// on the Account with a `keyHash`, bypassing the Orchestrator.
event NonceInvalidated(uint256 nonce);

////////////////////////////////////////////////////////////////////////
// Constants
////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -515,7 +530,7 @@ contract Orchestrator is
revert VerificationError();
}

_checkAndIncrementNonce(eoa, nonce);
nonceSeqs[eoa].checkAndIncrement(nonce);
}

// Payment
Expand Down Expand Up @@ -624,7 +639,7 @@ contract Orchestrator is
}

////////////////////////////////////////////////////////////////////////
// Account Implementation
// Account-Related Helpers
////////////////////////////////////////////////////////////////////////

/// @dev Returns the implementation of the EOA.
Expand All @@ -634,6 +649,17 @@ contract Orchestrator is
(, result) = LibEIP7702.delegationAndImplementationOf(eoa);
}

/// @dev Return current nonce with sequence key.
function getNonce(address account, uint192 seqKey) public view virtual returns (uint256) {
return nonceSeqs[account].get(seqKey);
}

/// @dev Invalidates current nonce with sequence key.
function invalidateNonce(uint256 nonce) public {
nonceSeqs[msg.sender].invalidate(nonce);
emit NonceInvalidated(nonce);
}

////////////////////////////////////////////////////////////////////////
// Multi Chain Functions
////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -885,7 +911,7 @@ contract Orchestrator is
returns (string memory name, string memory version)
{
name = "Orchestrator";
version = "0.5.5";
version = "0.5.6";
}

////////////////////////////////////////////////////////////////////////
Expand Down
8 changes: 1 addition & 7 deletions src/SimpleFunder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ contract SimpleFunder is EIP712, Ownable, IFunder {
error InvalidWithdrawalSignature();
error InvalidNonce();
error DeadlineExpired();
error DigestUsed();

address public funder;

mapping(address => bool) public gasWallets;
mapping(uint256 => bool) public nonces;
mapping(address => bool) public orchestrators;
mapping(bytes32 => bool) public usedDigests;

bytes32 constant WITHDRAWAL_TYPE_HASH = keccak256(
"Withdrawal(address token,address recipient,uint256 amount,uint256 deadline,uint256 nonce)"
Expand All @@ -58,7 +56,7 @@ contract SimpleFunder is EIP712, Ownable, IFunder {
returns (string memory name, string memory version)
{
name = "SimpleFunder";
version = "0.1.8";
version = "0.1.9";
}

////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -141,10 +139,6 @@ contract SimpleFunder is EIP712, Ownable, IFunder {
if (!orchestrators[msg.sender]) {
revert OnlyOrchestrator();
}
if (usedDigests[digest]) {
revert DigestUsed();
}
usedDigests[digest] = true;

bool isValid = SignatureCheckerLib.isValidSignatureNow(funder, digest, funderSignature);

Expand Down
15 changes: 10 additions & 5 deletions test/Benchmark.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3674,7 +3674,7 @@ contract BenchmarkTest is BaseTest {
PaymentType _paymentType
) internal view returns (bytes[] memory) {
bytes[] memory encodedIntents = new bytes[](delegatedEoas.length);
uint256 nonce = IthacaAccount(payable(delegatedEoas[0].eoa)).getNonce(0);
uint256 nonce = oc.getNonce(delegatedEoas[0].eoa, 0);
for (uint256 i = 0; i < delegatedEoas.length; i++) {
Intent memory u;
u.eoa = delegatedEoas[i].eoa;
Expand Down Expand Up @@ -3759,11 +3759,16 @@ contract BenchmarkTest is BaseTest {
vm.startPrank(d.eoa);
d.d.authorize(k.k);
d.d
.setCanExecute(
k.keyHash, address(paymentToken), bytes4(keccak256("transfer(address,uint256)")), true
);
.setCanExecute(
k.keyHash,
address(paymentToken),
bytes4(keccak256("transfer(address,uint256)")),
true
);
d.d
.setSpendLimit(k.keyHash, address(paymentToken), GuardedExecutor.SpendPeriod.Hour, 1 ether);
.setSpendLimit(
k.keyHash, address(paymentToken), GuardedExecutor.SpendPeriod.Hour, 1 ether
);
d.d.setSpendLimit(k.keyHash, address(0), GuardedExecutor.SpendPeriod.Hour, 1 ether);
vm.stopPrank();

Expand Down
Loading