Skip to content

Commit

Permalink
fix: gas estimation during session validation
Browse files Browse the repository at this point in the history
Couldn't find a better way to do this and I don't know how this wasn't a
problem before?
  • Loading branch information
cpb8010 committed Dec 5, 2024
1 parent 6deee08 commit eece619
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/validators/SessionKeyValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,14 @@ contract SessionKeyValidator is IModuleValidator {
(SessionLib.SessionSpec, uint64[])
);
require(spec.signer != address(0), "Invalid signer (empty)");
(address recoveredAddress, ) = ECDSA.tryRecover(signedHash, transactionSignature);
require(recoveredAddress != address(0), "Invalid signature (empty)");
(address recoveredAddress, ECDSA.RecoverError recoverError) = ECDSA.tryRecover(signedHash, transactionSignature);

// gas estimation provides invalid custom signatures
if (recoveredAddress == address(0) && recoverError == ECDSA.RecoverError.InvalidSignature) {
// this should increase the gas estimation and shouldn't otherwise be possible
return keccak256(_signature) != keccak256(transactionSignature);
}

require(recoveredAddress == spec.signer, "Invalid signer (mismatch)");
bytes32 sessionHash = keccak256(abi.encode(spec));
sessions[sessionHash].validate(transaction, spec, periodIds);
Expand Down

0 comments on commit eece619

Please sign in to comment.