Skip to content

Commit a21482a

Browse files
authored
Use calldata ECDSA recovery variants to avoid memory copies (#6048)
1 parent f28883a commit a21482a

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

contracts/metatx/ERC2771Forwarder.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {Errors} from "../utils/Errors.sol";
1919
* * `to`: The address that should be called.
2020
* * `value`: The amount of native token to attach with the requested call.
2121
* * `gas`: The amount of gas limit that will be forwarded with the requested call.
22-
* * `nonce`: A unique transaction ordering identifier to avoid replayability and request invalidation.
22+
* * `nonce` (implicit): Taken from {Nonces} for `from` and included in the signed typed data.
2323
* * `deadline`: A timestamp after which the request is not executable anymore.
2424
* * `data`: Encoded `msg.data` to send with the requested call.
2525
*
@@ -195,7 +195,7 @@ contract ERC2771Forwarder is EIP712, Nonces {
195195

196196
/**
197197
* @dev Validates if the provided request can be executed at current block timestamp with
198-
* the given `request.signature` on behalf of `request.signer`.
198+
* the given `request.signature` on behalf of `request.from`.
199199
*/
200200
function _validate(
201201
ForwardRequestData calldata request
@@ -232,7 +232,7 @@ contract ERC2771Forwarder is EIP712, Nonces {
232232
keccak256(request.data)
233233
)
234234
)
235-
).tryRecover(request.signature);
235+
).tryRecoverCalldata(request.signature);
236236

237237
return (err == ECDSA.RecoverError.NoError, recovered);
238238
}

contracts/utils/cryptography/signers/SignerECDSA.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ abstract contract SignerECDSA is AbstractSigner {
5050
bytes32 hash,
5151
bytes calldata signature
5252
) internal view virtual override returns (bool) {
53-
(address recovered, ECDSA.RecoverError err, ) = ECDSA.tryRecover(hash, signature);
53+
(address recovered, ECDSA.RecoverError err, ) = ECDSA.tryRecoverCalldata(hash, signature);
5454
return signer() == recovered && err == ECDSA.RecoverError.NoError;
5555
}
5656
}

contracts/utils/cryptography/signers/SignerEIP7702.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ abstract contract SignerEIP7702 is AbstractSigner {
1919
bytes32 hash,
2020
bytes calldata signature
2121
) internal view virtual override returns (bool) {
22-
(address recovered, ECDSA.RecoverError err, ) = ECDSA.tryRecover(hash, signature);
22+
(address recovered, ECDSA.RecoverError err, ) = ECDSA.tryRecoverCalldata(hash, signature);
2323
return address(this) == recovered && err == ECDSA.RecoverError.NoError;
2424
}
2525
}

0 commit comments

Comments
 (0)