-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat(registry): cheaper on-chain batch opt-in (48k gas) #336
feat(registry): cheaper on-chain batch opt-in (48k gas) #336
Conversation
d8fca6e
to
bec46ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First review, will continue tmr!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commenting it here but applies a bit everywhere: wdyt of having a type CompressedHash
(or similar name) alias to bytes20
? I found it really counter-intuitive to read bytes20 pubkeyHash
etc
error OperatorAlreadyRegistered(); | ||
error OperatorNotRegistered(); | ||
error UnauthorizedMiddleware(); | ||
error InactiveOperator(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By grepping over the codebase I've seen InactiveOperator
is unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn missed this - added a TODO comment
Overview
This PR introduces a slightly more optimized version of
BoltValidators
that uses an internal libraryValidatorsLib
.The main gain in efficiency is due to the new
_Validator
struct that tightly packs necessary info in a single slot, containing pointers to other mappings, offloading the majority of storage costs when batch registering.The optimizations performed are geared toward storage costs rather than runtime costs.
In particular the loops, variables, event emission, and other runtime checks haven't been optimized/removed.
Gas usage
We benchmarked
BoltValidatorsV2
(new implementation) vsBoltValidatorsV1
(old implementation).The image below shows the efficiency curve of batch registration costs:
Meta