Skip to content

perf: defer signer() read in SignerECDSA#6211

Merged
Amxx merged 1 commit intoOpenZeppelin:typo-fixesfrom
Azzurra88:defer-signer
Dec 19, 2025
Merged

perf: defer signer() read in SignerECDSA#6211
Amxx merged 1 commit intoOpenZeppelin:typo-fixesfrom
Azzurra88:defer-signer

Conversation

@Azzurra88
Copy link

Checks recovery error before reading signer().

@Azzurra88 Azzurra88 requested a review from a team as a code owner December 16, 2025 13:27
@changeset-bot
Copy link

changeset-bot bot commented Dec 16, 2025

⚠️ No Changeset found

Latest commit: 32a6140

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 16, 2025

Walkthrough

The pull request modifies the _rawSignatureValidation function in SignerECDSA.sol by reordering the operands in a boolean conjunction. The check is changed from signer() == recovered && err == ECDSA.RecoverError.NoError to err == ECDSA.RecoverError.NoError && signer() == recovered. This alteration preserves the logical outcome while changing the left-to-right evaluation sequence.

Possibly related PRs

Suggested labels

gas optimization

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: deferring the signer() read by reordering operands to check recovery error first, which is a performance optimization.
Description check ✅ Passed The description is directly related to the changeset, clearly stating the optimization: checking recovery error before reading signer().
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 353f564 and 32a6140.

📒 Files selected for processing (1)
  • contracts/utils/cryptography/signers/SignerECDSA.sol (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Redirect rules - solidity-contracts
  • GitHub Check: Header rules - solidity-contracts
  • GitHub Check: Pages changed - solidity-contracts
  • GitHub Check: tests
  • GitHub Check: slither
  • GitHub Check: tests-foundry
  • GitHub Check: tests-upgradeable
  • GitHub Check: halmos
  • GitHub Check: coverage
🔇 Additional comments (1)
contracts/utils/cryptography/signers/SignerECDSA.sol (1)

54-54: LGTM! Valid gas optimization.

Checking the error condition before calling signer() leverages short-circuit evaluation to avoid a storage read (SLOAD) when signature recovery fails. This is a correct and efficient optimization.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gonzaotc
Copy link
Contributor

Please add a changeset

@Amxx Amxx changed the base branch from master to typo-fixes December 19, 2025 15:45
@Amxx Amxx merged commit 220d8fd into OpenZeppelin:typo-fixes Dec 19, 2025
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants