-
Notifications
You must be signed in to change notification settings - Fork 2
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
Gas optimisation - Improve storage of info objects in InstanceStore #660
Comments
Gas comsumption table for test
|
doerfli
added a commit
that referenced
this issue
Sep 13, 2024
doerfli
added a commit
that referenced
this issue
Sep 16, 2024
doerfli
added a commit
that referenced
this issue
Sep 16, 2024
Gas consumption after storing
|
doerfli
added a commit
that referenced
this issue
Sep 16, 2024
doerfli
added a commit
that referenced
this issue
Sep 16, 2024
doerfli
added a commit
that referenced
this issue
Sep 16, 2024
doerfli
added a commit
that referenced
this issue
Sep 16, 2024
doerfli
added a commit
that referenced
this issue
Sep 17, 2024
doerfli
added a commit
that referenced
this issue
Sep 17, 2024
doerfli
added a commit
that referenced
this issue
Sep 17, 2024
doerfli
added a commit
that referenced
this issue
Sep 17, 2024
doerfli
added a commit
that referenced
this issue
Sep 17, 2024
doerfli
added a commit
that referenced
this issue
Sep 17, 2024
doerfli
added a commit
that referenced
this issue
Sep 17, 2024
doerfli
added a commit
that referenced
this issue
Sep 17, 2024
migrate product related infos to ProductStore (#660)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently all info objects are stored in generic encoded bytes for in the
KeyValueStore
. But this is bad as usingabi.encode
will use one slot per field of the struct (even if the struct is slot optimized).To improve gas usage, the InstanceStore needs to be refactored to store the structs plain instead of as encoded bytes. A quick hack test resultes in reduction of the gas consumption by over 50% to store PolicyInfo, FeeInfo and RiskInfo objects. This results from reduced storage costs as well has not having to encode to bytes. Reading will also get cheaper, but will have less overall impact as read costs are really in the overall picture (but it could sum up in a complex process).
Some background in
abi.encode
can be found here https://medium.com/@scourgedev/deep-dive-into-abi-encode-types-padding-and-disassembly-84472f1b4543Example tx: https://amoy.polygonscan.com/tx/0xc85256c6980d7c30ec633892906c51d38d800e24b18a1c7704cc63b2f9e25cd5
Screenshot from tenderly for a
createApplication
call in the InstanceStoreThe text was updated successfully, but these errors were encountered: