-
Notifications
You must be signed in to change notification settings - Fork 29
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
Split lib w/bytecode reduction #688
Merged
Merged
Conversation
This file contains 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
yoshiwarab
approved these changes
May 3, 2023
jakerockland
approved these changes
May 3, 2023
jakerockland
added a commit
that referenced
this pull request
May 5, 2023
* basic MVP of split library (with tests) * Adjusted tests for split library setup * minor modifier adjustment * Adjust optimizer runs * optimizer order * nit * get interface from deployed contract * get interface from deployed contract * ensure libraries are linked * library linkkinnnn * More linking fixes in tests * update Engine Flex as PoC (#688) * fix the rest of the test bindingsgit diff * OPTIMIZOOOOOR * remove unnecessary using for * Fixed comment * public constants * Update library naming convention * DEPLOYOOOOOR * DEPLOYOOOOOR * format * Address nits --------- Co-authored-by: ryley-o <30364988+ryley-o@users.noreply.github.com>
jakerockland
added a commit
that referenced
this pull request
May 5, 2023
* Support basic semantic versioning – and ensure interop with backwards compatible reads (tests added) * update the version string * minor adjustment and a song: https://www.youtube.com/watch\?v\=vOreqez4v9Y * Update to reflect better v1/v0/unknown versioning semantics * Update documentation and code structuring * Refactor size == 0 check * clean up offset checks * `STORE2`-compatible reads in `BytecodeStorage` (#681) * Update BytecodeStorage library to provide backwards-compatible reads that are compatible with SSTORE2 as the fallback read option, in advance of plans to split off reads into a shared external public utility library, in-companion to the embedded internal library for writes. * Whoops, forgot to add all the files yo * add support for manual-offset reads * SSTORE2 / explicit bytes reads restructure * Comment fix * Filename fix * Filename fix * Better typing for tests * spelling fixes * Split `BytecodeStorage` into public/internal libraries (#684) * basic MVP of split library (with tests) * Adjusted tests for split library setup * minor modifier adjustment * Adjust optimizer runs * optimizer order * nit * get interface from deployed contract * get interface from deployed contract * ensure libraries are linked * library linkkinnnn * More linking fixes in tests * update Engine Flex as PoC (#688) * fix the rest of the test bindingsgit diff * OPTIMIZOOOOOR * remove unnecessary using for * Fixed comment * public constants * Update library naming convention * DEPLOYOOOOOR * DEPLOYOOOOOR * format * Address nits --------- Co-authored-by: ryley-o <30364988+ryley-o@users.noreply.github.com> --------- Co-authored-by: ryley-o <30364988+ryley-o@users.noreply.github.com>
jakerockland
added a commit
that referenced
this pull request
May 5, 2023
* Remove all call-sites for purgeBytecode, before cleaning up library internals * Remove purge logic from library entirely * fix comment * Update to reflect TWO VERSIONS (https://www.youtube.com/watch\?v\=diIFhc_Kzng) * Update to reflect TWO VERSIONS (https://www.youtube.com/watch\?v\=diIFhc_Kzng) * Update contracts/libs/0.8.x/BytecodeStorageV1.sol Co-authored-by: ryley-o <30364988+ryley-o@users.noreply.github.com> * Update contracts/libs/0.8.x/BytecodeStorageV1.sol Co-authored-by: ryley-o <30364988+ryley-o@users.noreply.github.com> * Update contracts/libs/0.8.x/BytecodeStorageV1.sol Co-authored-by: ryley-o <30364988+ryley-o@users.noreply.github.com> * Add basic form of `BytecodeStorage` library versioning (#670) * Support basic semantic versioning – and ensure interop with backwards compatible reads (tests added) * update the version string * minor adjustment and a song: https://www.youtube.com/watch\?v\=vOreqez4v9Y * Update to reflect better v1/v0/unknown versioning semantics * Update documentation and code structuring * Refactor size == 0 check * clean up offset checks * `STORE2`-compatible reads in `BytecodeStorage` (#681) * Update BytecodeStorage library to provide backwards-compatible reads that are compatible with SSTORE2 as the fallback read option, in advance of plans to split off reads into a shared external public utility library, in-companion to the embedded internal library for writes. * Whoops, forgot to add all the files yo * add support for manual-offset reads * SSTORE2 / explicit bytes reads restructure * Comment fix * Filename fix * Filename fix * Better typing for tests * spelling fixes * Split `BytecodeStorage` into public/internal libraries (#684) * basic MVP of split library (with tests) * Adjusted tests for split library setup * minor modifier adjustment * Adjust optimizer runs * optimizer order * nit * get interface from deployed contract * get interface from deployed contract * ensure libraries are linked * library linkkinnnn * More linking fixes in tests * update Engine Flex as PoC (#688) * fix the rest of the test bindingsgit diff * OPTIMIZOOOOOR * remove unnecessary using for * Fixed comment * public constants * Update library naming convention * DEPLOYOOOOOR * DEPLOYOOOOOR * format * Address nits --------- Co-authored-by: ryley-o <30364988+ryley-o@users.noreply.github.com> --------- Co-authored-by: ryley-o <30364988+ryley-o@users.noreply.github.com> --------- Co-authored-by: ryley-o <30364988+ryley-o@users.noreply.github.com>
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.
Description of the change
PoC of V3 Engine Flex with bytecode size reduction.
It appears that Solidity doesn't do a great job of efficiently using bytecode space when doing the following for external libraries:
using X for Y
In this example, all calls to public function on bytecode storage reader library are performed in a single internal helper function, and the
using X for Y
syntax is removed for the external library.Bytecode Impacts
The result is a net-change from
24.010 bytes
(on splitLib) to23.909 bytes
on this branch, forGenArt721CoreV3_Engine_Flex.sol
(possible to get down to23.865
if we kept optimizer at 10 like it is on splitLib branch)With respect to current
main
branch, the change is23.878 bytes
(on main) to23.909 bytes
on this branch, forGenArt721CoreV3_Engine_Flex.sol
. (both have optimizer at 25)Alternate options
Also note that if we don't like this change for readability reasons, there are other ways to reduce bytecode to <24 kb. For example, changing variables from constants to non-constants reduces bytecode size a lot (e.g.
bytes32 constant FIELD_NEXT_PROJECT_ID =
->bytes32 FIELD_NEXT_PROJECT_ID =
)