Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AA-340: Update the RIP-7560 with the EIP-7702 transaction type fields #7

Merged
merged 4 commits into from
Oct 20, 2024
Merged
Changes from 2 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
36 changes: 27 additions & 9 deletions RIPS/rip-7560.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status: Draft
type: Standards Track
category: Core
created: 2023-09-01
requires: 4337, 6780
requires: 7702
---

## Abstract
Expand Down Expand Up @@ -61,7 +61,7 @@ smart contracts. This, however, is impossible without an addition of Native Acco
| Name | Value |
|-----------------------|---------------------------------------------------------------------------------|
| FORK_BLOCK | TBD |
| AA_TX_TYPE | 4 |
| AA_TX_TYPE | 126 |
Copy link

@sm-stack sm-stack Jun 10, 2024

Choose a reason for hiding this comment

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

I'm afraid that 126 is a deposit tx type at Optimism. Relative docs at optimism specs here.

| AA_ENTRY_POINT | `address(7560)` |
| AA_SENDER_CREATOR | `address(ffff7560)` |
| AA_BASE_GAS_COST | 15000 |
Expand Down Expand Up @@ -90,14 +90,22 @@ A new [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) transaction with type
validationGasLimit, paymasterValidationGasLimit, paymasterPostOpGasLimit
callGasLimit,
accessList,
authorizationList,
signature
])

```

The base gas cost of this transaction is set to AA_BASE_GAS_COST instead of 21000 to reflect the lack of “intrinsic”
```
authorizationList = [[chain_id, address, nonce, y_parity, r, s], ...]
```

The base gas cost of this transaction is set to `AA_BASE_GAS_COST` instead of 21000 to reflect the lack of "intrinsic"
ECDSA signature verification.

The `authorizationList` parameter has the exact same behaviour as defined by the
[EIP-7702](https://eips.ethereum.org/EIPS/eip-7702).

### Gas fees are charged directly from the contract balance

The maximum gas cost of the AA_TX_TYPE transaction is defined as:
Expand Down Expand Up @@ -201,7 +209,7 @@ We define the following Solidity struct to represent the AA transaction on-chain

```solidity

struct TransactionType4 {
struct TransactionTypeRIP7560 {
address sender;
address deployer;
address paymaster;
Expand All @@ -217,10 +225,20 @@ struct TransactionType4 {
bytes paymasterData;
bytes callData;
bytes signature;
address[] authorizationList;
bool[] authorizationListStatus;

Choose a reason for hiding this comment

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

maybe better to provide authorizedList and failedAuthorizationList (which is expected to be empty)

Copy link
Author

Choose a reason for hiding this comment

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

Just talked to @shahafn about that - we could not see how would it make it better? Appears to provide the exact same information (except, maybe, losing the ordering - which might even be a downside in some edge-cases) and not improving anything.
I prefer the bool[] approach.

}

```

Note that the `authorizationList` struct parameter only includes the list of addresses recovered from each element
of the RLP-encoded transaction payload.

As there is a gas cost associated with providing any element of the `authorizationList` regardless of its validity,
and in order to avoid repeated `ecrecover` executions in on-chain validation,
we introduce the `authorizationListStatus` struct parameter.
Its elements contain `true` for entries that did result in setting the EOA code, and `false` otherwise.

We then define the following Solidity method and the `sender` of the transaction is invoked with the corresponding data:

```solidity
Expand All @@ -230,7 +248,7 @@ function validateTransaction(uint256 version, bytes32 txHash, bytes transaction)
```

The gas limit of this frame is set to `validationGasLimit - senderCreationGasUsed - calldataGasUsed`.\
The `transaction` parameter is interpreted as an ABI encoding of `TransactionType4`.\
The `transaction` parameter is interpreted as an ABI encoding of `TransactionTypeRIP7560`.\
The `txHash` parameter represents the hash of the AA_TX_TYPE transaction with empty signature, as defined in section
[Calculation of Transaction Type AA_TX_TYPE hash](#calculation-of-transaction-type-aatxtype-hash).\
The `version` parameter is added in order to maintain the Solidity method ID in case of changes to this struct
Expand Down Expand Up @@ -269,7 +287,7 @@ The gas limit of this frame is set to `paymasterValidationGasLimit`.

The amount of gas used by this frame is referred to as `paymasterValidationGasUsed`.

The `transaction` parameter is interpreted as an ABI encoding of `TransactionType4`.\
The `transaction` parameter is interpreted as an ABI encoding of `TransactionTypeRIP7560`.\
The `txHash` parameter represents the hash of the AA_TX_TYPE transaction with empty signature, as defined in section
[Calculation of Transaction Type AA_TX_TYPE hash](#calculation-of-transaction-type-aatxtype-hash).

Expand Down Expand Up @@ -420,8 +438,8 @@ keccak256(AA_TX_TYPE || 0x00 || rlp(transaction_payload)

```

Note that the `chainId` and `accessList` parameters are included in the transaction hash calculation but are not
available on-chain as part of the `TransactionType4` struct.
Note that the `chainId`, `accessList` and `authorizationList` parameters are included in the transaction hash
calculation but are not available on-chain as part of the `TransactionTypeRIP7560` struct.

In order to calculate the transaction hash that will be used during the signing of the transaction and validation of
the transaction signature by the `sender`, the value of the `signature` parameter is considered to be an empty
Expand Down Expand Up @@ -544,7 +562,7 @@ The full mitigation may be achieved by separating the validation from into a sep
### Size of the `nonce` parameter

Note that the `nonce` transaction parameter is defined as a 64-bit integer by the Ethereum protocol,
however in the `TransactionType4` struct it is defined as `uint256 nonce`.
however in the `TransactionTypeRIP7560` struct it is defined as `uint256 nonce`.

We will propose a mechanism that uses the higher 192 bits of the `nonce` field in a separate RIP.
In the meanwhile it is strictly recommended that the wallets use `require(nonce < type(uint64).max)` check.
Expand Down