Sitelet https://github.com/ithacaxyz/account/commit/b891f19ee0f7d415dd0c5c0b32277e29bd86a08c
Skip to content

Commit b891f19

Browse files
committed
.
1 parent 3269a0b commit b891f19

5 files changed

Lines changed: 36 additions & 143 deletions

File tree

‎snapshots/BenchmarkTest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"testERC20Transfer_IthacaAccount": "112220"
2+
"testERC20Transfer_IthacaAccount": "118271"
33
}

‎src/GuardedExecutor.sol‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {ICallChecker} from "./interfaces/ICallChecker.sol";
2626
/// a key cannot spend tokens (ERC20s and native) until spend permissions have been added.
2727
/// - When a spend permission is removed and re-added, its spent amount will be reset.
2828
abstract contract GuardedExecutor is ERC7821 {
29-
3029
using LibBytes for *;
3130
using DynamicArrayLib for *;
3231
using EnumerableSetLib for *;

‎src/IthacaAccount.sol‎

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {LibNonce} from "./libraries/LibNonce.sol";
2323
import {TokenTransferLib} from "./libraries/TokenTransferLib.sol";
2424
import {LibTStack} from "./libraries/LibTStack.sol";
2525
import {IIthacaAccount} from "./interfaces/IIthacaAccount.sol";
26-
import {console} from "forge-std/console.sol";
2726

2827
/// @title Account
2928
/// @notice A account contract for EOAs with EIP7702.
@@ -619,78 +618,40 @@ contract IthacaAccount is IIthacaAccount, EIP712, GuardedExecutor {
619618
address paymentRecipient,
620619
bytes calldata paymentSignature
621620
) public virtual {
622-
console.log("=== IthacaAccount.pay() START ===");
623-
console.log("paymentAmount:", paymentAmount);
624-
console.log("keyHash:", uint256(keyHash));
625-
console.log("intentDigest:", uint256(intentDigest));
626-
console.log("eoa:", eoa);
627-
console.log("payer:", payer);
628-
console.log("paymentToken:", paymentToken);
629-
console.log("paymentRecipient:", paymentRecipient);
630-
console.log("paymentSignature length:", paymentSignature.length);
631-
console.log("msg.sender:", msg.sender);
632-
console.log("ORCHESTRATOR:", ORCHESTRATOR);
633-
console.log("address(this):", address(this));
634-
635-
console.log("Auth check - msg.sender == ORCHESTRATOR:", msg.sender == ORCHESTRATOR);
636-
console.log("Auth check - eoa == address(this):", eoa == address(this));
637-
console.log("Auth check - payer == address(this):", payer == address(this));
638-
639621
if (
640622
!LibBit.and(
641623
msg.sender == ORCHESTRATOR, LibBit.or(eoa == address(this), payer == address(this))
642624
)
643625
) {
644-
console.log("pay(): AUTHORIZATION FAILED");
645626
revert Unauthorized();
646627
}
647-
console.log("pay(): Authorization passed");
648628

649629
// If this account is the paymaster, validate the paymaster signature.
650630
if (payer == address(this)) {
651-
console.log("pay(): Payer is this account - validating paymaster signature");
652631
(bool isValid, bytes32 k) = unwrapAndValidateSignature(intentDigest, paymentSignature);
653-
console.log("pay(): Signature validation result:", isValid);
654-
console.log("pay(): Extracted keyHash:", uint256(k));
655632

656633
// Set the target key hash to the payer's.
657634
keyHash = k;
658635

659636
// If this is a simulation, signature validation errors are skipped.
660637
/// @dev to simulate a paymaster, state override the balance of the relayer
661638
/// to type(uint192).max.
662-
console.log("pay(): tx.origin.balance:", tx.origin.balance);
663639
if (tx.origin.balance >= type(uint192).max) {
664-
console.log("pay(): Simulation mode detected - forcing signature valid");
665640
isValid = true;
666641
}
667642

668643
if (!isValid) {
669-
console.log("pay(): PAYMASTER SIGNATURE VALIDATION FAILED");
670644
revert Unauthorized();
671645
}
672-
console.log("pay(): Paymaster signature validation passed");
673-
} else {
674-
console.log("pay(): Payer is not this account - skipping paymaster validation");
675646
}
676647

677-
console.log("pay(): About to transfer tokens");
678648
TokenTransferLib.safeTransfer(paymentToken, paymentRecipient, paymentAmount);
679-
console.log("pay(): Token transfer completed");
680649

681650
// Increase spend.
682-
console.log("pay(): Checking spend limits");
683-
console.log("pay(): keyHash == bytes32(0):", keyHash == bytes32(0));
684651
if (!(keyHash == bytes32(0) || _isSuperAdmin(keyHash))) {
685-
console.log("pay(): Incrementing spend for keyHash:", uint256(keyHash));
686652
SpendStorage storage spends = _getGuardedExecutorKeyStorage(keyHash).spends;
687653
_incrementSpent(spends.spends[paymentToken], paymentToken, paymentAmount);
688-
console.log("pay(): Spend incremented");
689-
} else {
690-
console.log("pay(): Skipping spend increment (super admin or zero keyHash)");
691654
}
692-
693-
console.log("=== IthacaAccount.pay() END ===");
694655
// Done to avoid compiler warnings.
695656
intentDigest = intentDigest;
696657
}

‎src/Orchestrator.sol‎

Lines changed: 3 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {IFunder} from "./interfaces/IFunder.sol";
2121
import {ISettler} from "./interfaces/ISettler.sol";
2222
import {MerkleProofLib} from "solady/utils/MerkleProofLib.sol";
2323
import {IntentHelpers} from "./libraries/IntentHelpers.sol";
24-
import {console} from "forge-std/console.sol";
2524

2625
/// @title Orchestrator
2726
/// @notice Enables atomic verification, gas compensation and execution across eoas.
@@ -419,28 +418,19 @@ contract Orchestrator is
419418
}
420419

421420
address eoa = _getEoa();
422-
console.log("selfCall: EOA address:", eoa);
423421

424422
// Start a calldata pointer, each operation points the calldata pointer to the next dynamic bytes.
425423
// Using memory might be slightly less efficient, but lets us modify in-place, resulting in cleaner top-level code.
426424
CalldataPointer memory ptr;
427425
bytes32 digest = _computeDigest(ptr);
428-
console.log("selfCall: Computed digest:", uint256(digest));
429426

430427
bytes calldata fundData = _getNextBytes(ptr);
431-
console.log("selfCall: Fund data length:", fundData.length);
432428

433429
if (fundData.length > 0) {
434-
console.log("selfCall: Starting fund phase");
435430
(address funder, bytes calldata sig, bytes[] calldata transfers) =
436431
_parseFundData(fundData);
437-
console.log("selfCall: Funder address:", funder);
438-
console.log("selfCall: Transfers length:", transfers.length);
439432
_fund(_getEoa(), funder, digest, transfers, sig);
440-
console.log("selfCall: Fund phase completed");
441-
} else {
442-
console.log("selfCall: No funding data");
443-
}
433+
} else {}
444434

445435
// The chicken and egg problem:
446436
// A off-chain simulation of a successful Intent may not guarantee on-chain success.
@@ -458,14 +448,9 @@ contract Orchestrator is
458448

459449
// Handle the sub Intents after initialize (if any), and before the `_verify`.
460450
bytes calldata preCallsBytes = _getNextBytes(ptr);
461-
console.log("selfCall: Pre-calls data length:", preCallsBytes.length);
462451
if (preCallsBytes.length > 0) {
463-
console.log("selfCall: Starting pre-calls phase");
464452
_handlePreCalls(eoa, flags, preCallsBytes);
465-
console.log("selfCall: Pre-calls completed");
466-
} else {
467-
console.log("selfCall: No pre-calls data");
468-
}
453+
} else {}
469454

470455
// If `_verify` is invalid, just revert.
471456
// The verification gas is determined by `executionData` and the account logic.
@@ -474,56 +459,37 @@ contract Orchestrator is
474459
// in the window between off-chain simulation and on-chain execution.
475460
bytes32 keyHash;
476461
{
477-
console.log("selfCall: Starting verification phase");
478462
bool isValid;
479463
bytes calldata signature = _getNextBytes(ptr);
480-
console.log("selfCall: Signature length:", signature.length);
481464

482465
uint256 nonce = _getNonce();
483-
console.log("selfCall: Nonce:", nonce);
484466

485467
if (nonce >> 240 == MERKLE_VERIFICATION) {
486-
console.log("selfCall: Using Merkle verification");
487468
// For multi chain intents, we have to verify using merkle sigs.
488469
(isValid, keyHash) = _verifyMerkleSig(digest, eoa, signature);
489470
bytes calldata settlerData = _getNextBytes(ptr);
490-
console.log("selfCall: Settler data length:", settlerData.length);
491471

492472
// If this is an output intent, then send the digest as the settlementId
493473
// on all input chains.
494474
if (settlerData.length > 0) {
495-
console.log("selfCall: Processing output intent");
496475
// Output intent - first 20 bytes of settler data is the settler addr
497476
ISettler(address(bytes20(bytes32(settlerData[:32])))).send(
498477
digest, settlerData[32:]
499478
);
500479
}
501480
} else {
502-
console.log("selfCall: Using standard verification");
503-
console.log("selfCall: Digest:", uint256(digest));
504-
console.log("selfCall: EOA:", eoa);
505-
console.log("selfCall: Signature bytes:");
506-
console.logBytes(signature);
507481
(isValid, keyHash) = _verify(digest, eoa, signature);
508482
}
509483

510-
console.log("selfCall: Verification result:", isValid);
511-
console.log("selfCall: KeyHash:", uint256(keyHash));
512-
console.log("selfCall: Flags:", flags);
513-
514484
if (flags == _SIMULATION_MODE_FLAG) {
515-
console.log("selfCall: Simulation mode - forcing valid");
516485
isValid = true;
517486
}
518487

519488
if (!isValid) {
520-
console.log("selfCall: VERIFICATION FAILED");
521489
revert VerificationError();
522490
}
523491

524-
console.log("selfCall: Checking and incrementing nonce");
525492
_checkAndIncrementNonce(eoa, nonce);
526-
console.log("selfCall: Nonce check completed");
527493
}
528494

529495
// Payment
@@ -532,12 +498,8 @@ contract Orchestrator is
532498
// provided that the token balance does not decrease in the window between
533499
// off-chain simulation and on-chain execution.
534500
{
535-
console.log("selfCall: Starting payment phase");
536501
uint256 paymentAmount = _getPaymentAmount();
537-
console.log("selfCall: Payment amount:", paymentAmount);
538502
if (paymentAmount != 0) {
539-
console.log("selfCall: Payment token:", _getPaymentToken());
540-
console.log("selfCall: Payment recipient:", _getPaymentRecipient());
541503
_pay(
542504
paymentAmount,
543505
keyHash,
@@ -548,26 +510,16 @@ contract Orchestrator is
548510
_getPaymentRecipient(),
549511
_getPaymentSignature()
550512
);
551-
console.log("selfCall: Payment completed");
552-
} else {
553-
console.log("selfCall: No payment required");
554-
}
513+
} else {}
555514
}
556515
// This re-encodes the ERC7579 `executionData` with the optional `opData`.
557516
// We expect that the account supports ERC7821
558517
// (an extension of ERC7579 tailored for 7702 accounts).
559-
console.log("selfCall: Starting execution phase");
560-
console.log("execution data is:");
561-
console.logBytes(_getExecutionData());
562518
bytes memory executeData = LibERC7579.reencodeBatchAsExecuteCalldata(
563519
hex"01000000000078210001", // ERC7821 batch execution mode.
564520
_getExecutionData(),
565521
abi.encode(keyHash) // `opData`.
566522
);
567-
console.log("selfCall: Execute data length:", executeData.length);
568-
console.log("selfCall: Calling EOA with execute data");
569-
console.log("execution data wrapped is:");
570-
console.logBytes(executeData);
571523

572524
assembly ("memory-safe") {
573525
mstore(0x00, 0) // Zeroize the return slot.
@@ -580,7 +532,6 @@ contract Orchestrator is
580532
return(0x00, 0x20)
581533
}
582534
}
583-
console.log("selfCall: Execution completed successfully");
584535
}
585536

586537
/// @dev Loops over the `encodedPreCalls` and does the following for each:
@@ -733,29 +684,15 @@ contract Orchestrator is
733684
address paymentRecipient,
734685
bytes calldata paymentSignature
735686
) internal virtual {
736-
console.log("=== Orchestrator._pay() START ===");
737-
console.log("_pay: paymentAmount:", paymentAmount);
738-
console.log("_pay: keyHash:", uint256(keyHash));
739-
console.log("_pay: intentDigest:", uint256(intentDigest));
740-
console.log("_pay: eoa:", eoa);
741-
console.log("_pay: payer:", payer);
742-
console.log("_pay: paymentToken:", paymentToken);
743-
console.log("_pay: paymentRecipient:", paymentRecipient);
744-
console.log("_pay: paymentSignature length:", paymentSignature.length);
745-
746687
uint256 currentBalance = TokenTransferLib.balanceOf(paymentToken, paymentRecipient);
747-
console.log("_pay: Recipient current balance:", currentBalance);
748688

749689
uint256 requiredBalanceAfter = Math.saturatingAdd(currentBalance, paymentAmount);
750-
console.log("_pay: Required balance after:", requiredBalanceAfter);
751690

752691
// Call the pay function on the account contract
753692
// Equivalent Solidity code:
754693
// IIthacaAccount(payer).pay(paymentAmount, keyHash, digest, abi.encode(i));
755694
// Gas Savings:
756695
// Saves ~2k gas for normal use cases, by avoiding abi.encode and solidity external call overhead
757-
console.log("_pay: About to call pay() on payer account");
758-
console.log("_pay: Calling address:", payer);
759696
address callee = Math.coalesce(payer, eoa);
760697

761698
bool payCallSuccess;
@@ -792,21 +729,11 @@ contract Orchestrator is
792729
if iszero(payCallSuccess) { revert(0x00, 0x20) }
793730
}
794731

795-
console.log("_pay: Pay call completed successfully");
796-
797732
uint256 actualBalanceAfter = TokenTransferLib.balanceOf(paymentToken, paymentRecipient);
798-
console.log("_pay: Recipient actual balance after:", actualBalanceAfter);
799-
console.log("_pay: Required balance after:", requiredBalanceAfter);
800733

801734
if (actualBalanceAfter < requiredBalanceAfter) {
802-
console.log("_pay: PAYMENT VERIFICATION FAILED - Insufficient balance increase");
803-
console.log("_pay: Expected increase:", paymentAmount);
804-
console.log("_pay: Actual increase:", actualBalanceAfter - currentBalance);
805735
revert PaymentError();
806736
}
807-
808-
console.log("_pay: Payment verification passed");
809-
console.log("=== Orchestrator._pay() END ===");
810737
}
811738

812739
/// @dev Calls `unwrapAndValidateSignature` on the `eoa`.

0 commit comments

Comments
 (0)