fix(contracts): optimize gas usage in Attestation struct#1018
Open
airope wants to merge 1 commit intoConsensys:devfrom
Open
fix(contracts): optimize gas usage in Attestation struct#1018airope wants to merge 1 commit intoConsensys:devfrom
airope wants to merge 1 commit intoConsensys:devfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses #918 by converting all
Attestationstruct instantiations from positional notation to named field{}notation.Changes
contracts/src/AttestationRegistry.sol: Updatedattest()andmassImport()functions to use named field notation forAttestationstruct initializationcontracts/src/stdlib/IndexerModuleV2.sol: Updated_buildAttestation()to use named field notationWhy
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
Attestationstruct 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
Attestationstruct construction to named-field initialization inAttestationRegistry.attest(),AttestationRegistry.massImport(), andIndexerModuleV2._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.