-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize gas usage of node and leaf hashes (#104)
## Type of change <!--Delete points that do not apply--> - Improvement (refactoring, restructuring repository, cleaning tech debt, ...) ## Changes The following changes have been made: - Refactor leaf and node hashing to improve gas usage - Added test for a complete but not full tree ## Notes - This **DOES NOT** implement a bitmask described in #95, but completes the motivation. After some thorough testing, I don't think this is necessary. Current optimizations in conjunction with changes within the compiler and the stdlib have already brought gas down SIGNIFICANTLY. Million leaf merkle trees are no longer expensive. If this is something we would like to pursue in the future we can reopen the issue. - Some testing using the Rust SDK shows that a bitmask only provides a 0.2% decrease in gas costs. - The recent bump to forc v0.35.3 decrease gas usage from 5,802,095 -> 26,076 for 1 million leaf merkle tree - Current changes reduce gas usage by another 84% from master from 26,076 -> 4,017 for 1 million leaf merkle tree - This also drop the bytecode size from 13548 bytes to 5668 bytes ## Related Issues <!--Delete everything after the "#" symbol and replace it with a number. No spaces between hash and number--> Closes #95 --------- Co-authored-by: bitzoic <[email protected]>
- Loading branch information
Showing
3 changed files
with
33 additions
and
22 deletions.
There are no files selected for viewing
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
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
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