Skip to content

fix(contracts): optimize gas usage in Attestation struct#1018

Open
airope wants to merge 1 commit intoConsensys:devfrom
airope:fix/gas-optimization-attestation
Open

fix(contracts): optimize gas usage in Attestation struct#1018
airope wants to merge 1 commit intoConsensys:devfrom
airope:fix/gas-optimization-attestation

Conversation

@airope
Copy link
Copy Markdown

@airope airope commented Mar 4, 2026

Summary

This PR addresses #918 by converting all Attestation struct instantiations from positional notation to named field {} notation.

Changes

  • contracts/src/AttestationRegistry.sol: Updated attest() and massImport() functions to use named field notation for Attestation struct initialization
  • contracts/src/stdlib/IndexerModuleV2.sol: Updated _buildAttestation() to use named field notation

Why

Using named field notation (Attestation({field: value, ...})) instead of positional arguments (Attestation(value, ...)) can save gas because the Solidity compiler handles struct packing more efficiently with named initialization. It also improves readability and reduces the risk of field ordering bugs.

Testing

No logic changes — only struct initialization syntax is modified. All field values remain identical.


Note

Low Risk
Low risk: changes only switch Attestation struct construction from positional to named-field syntax, with the same values assigned. Main risk is accidental field/value mismatch, but named initialization reduces that likelihood.

Overview
Switches Attestation struct construction to named-field initialization in AttestationRegistry.attest(), AttestationRegistry.massImport(), and IndexerModuleV2._buildAttestation().

This is a syntactic refactor intended to improve readability and potentially reduce gas, without changing the data written into stored attestations.

Written by Cursor Bugbot for commit 9dca6d7. This will update automatically on new commits. Configure here.

@airope airope requested review from a team, alainncls and arthur-remy as code owners March 4, 2026 08:35
@cla-assistant
Copy link
Copy Markdown

cla-assistant Bot commented Mar 4, 2026

CLA assistant check
All committers have signed the CLA.

@alainncls alainncls changed the title fix: optimize gas usage in Attestation struct (closes #918) fix(contracts): optimize gas usage in Attestation struct Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant