Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assess and memoize (if appropriate) VerificationKey::address_bytes #1351

Closed
Fraser999 opened this issue Aug 7, 2024 · 1 comment · Fixed by #1444
Closed

Assess and memoize (if appropriate) VerificationKey::address_bytes #1351

Fraser999 opened this issue Aug 7, 2024 · 1 comment · Fixed by #1444
Assignees
Labels

Comments

@Fraser999
Copy link
Contributor

Fraser999 commented Aug 7, 2024

We should run an ad hoc test under semi-realistic conditions which counts how many times VerificationKey::address_bytes is a repeated call on a VerificationKey instance. In other words, if we only ever call this once per instance, the total will be zero. If we call it exactly thrice per instance, the total will be twice the number of instances.

Once we have this information, we can decide whether to implement memoization of the address bytes as a field in the verification key, or leave as is.

┆Issue Number: ENG-696

@Fraser999
Copy link
Contributor Author

Having run the smoke test, the sequencer indicates that this method is called between 8 and 11 times on a given key, so it seems like memoizing is worthwhile.

github-merge-queue bot pushed a commit that referenced this issue Sep 4, 2024
## Summary
Added a lazily-initialized field `address_bytes` to `VerificationKey`.

## Background
Testing showed that `address_bytes` was called multiple times on a given
`VerificationKey` (up to 11 times in some cases). Each time the key's
bytes were being hashed, so this change ensures that hashing only
happens once for a given verification key instance.

Note that this was implemented previously in #1111 and was then reverted
in #1124. However, when reverted, the manual impls of `PartialEq`, `Eq`,
`PartialOrd`, `Ord` and `Hash` were left as-is, as were the unit tests
for these. Hence this PR doesn't need to make any changes to these trait
impls or tests.

## Changes
- Added `address_bytes: OnceLock<[u8; ADDRESS_LEN]>` to
`VerificiationKey`.

## Testing
No new tests required.  

## Related Issues
Closes #1351.
jbowen93 pushed a commit that referenced this issue Sep 6, 2024
## Summary
Added a lazily-initialized field `address_bytes` to `VerificationKey`.

## Background
Testing showed that `address_bytes` was called multiple times on a given
`VerificationKey` (up to 11 times in some cases). Each time the key's
bytes were being hashed, so this change ensures that hashing only
happens once for a given verification key instance.

Note that this was implemented previously in #1111 and was then reverted
in #1124. However, when reverted, the manual impls of `PartialEq`, `Eq`,
`PartialOrd`, `Ord` and `Hash` were left as-is, as were the unit tests
for these. Hence this PR doesn't need to make any changes to these trait
impls or tests.

## Changes
- Added `address_bytes: OnceLock<[u8; ADDRESS_LEN]>` to
`VerificiationKey`.

## Testing
No new tests required.  

## Related Issues
Closes #1351.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant