Content pfp
Content
@
https://opensea.io/collection/evm-6
0 reply
0 recast
2 reactions

horsefacts πŸš‚ pfp
horsefacts πŸš‚
@horsefacts.eth
Optimizing my first serious L2 contracts has been a journey: 1) Dev: your intuitions are all wrong now. 2) Testnet: cheap L2 gas, cheap L1 calldata. Many tools overestimate L2 gas and it can outweigh calldata unlike IRL. 3) Mainnet: cheap L2 gas, L1 calldata is 20-100x testnet cost. Calldata costs dominate everything.
5 replies
6 recasts
22 reactions

timdaub pfp
timdaub
@timdaub.eth
what did u have to change specifically to make the biggest optimization gains?
1 reply
0 recast
0 reaction

horsefacts πŸš‚ pfp
horsefacts πŸš‚
@horsefacts.eth
Anything that reduces nonzero calldata bytes will have the biggest impact. The techniques in @msolomon.eth's repo here are all good: https://github.com/ScopeLift/l2-optimizoooors Make assumptions that avoid passing args like reading defaults or values from storage, use packed encodings, use custom selectors.
2 replies
0 recast
7 reactions

horsefacts πŸš‚ pfp
horsefacts πŸš‚
@horsefacts.eth
But you're also able to make reasonable tradeoffs that aren't quite as possible on mainnet, like "maybe we don't need a custom encoding scheme to save 2 cents per call." Lots of things will still be cheap out of the box and you can profile to figure out where it's worth optimizing.
1 reply
0 recast
0 reaction

timdaub pfp
timdaub
@timdaub.eth
β€žnon-zero calldata bytesβ€œ on L2 or do you mean resulting non-zero call data bytes on L1? amazing resource
1 reply
0 recast
0 reaction

timdaub pfp
timdaub
@timdaub.eth
@horsefacts.eth resulting L1 call data is my understanding
1 reply
0 recast
0 reaction

Matt Solomon pfp
Matt Solomon
@msolomon.eth
Right. The full tx data (to, data, gas, etc) for each L2 tx is posted to L1 in batches. Optimism/arbitrum use calldata compression to reduce costs, and this is great at reducing the number of zeros. But compression algos can't compress non-zero data as well, so it's more important for you to optimize that yourself
1 reply
0 recast
1 reaction

Matt Solomon pfp
Matt Solomon
@msolomon.eth
Different context but here's a related diagram that I like (source: https://twitter.com/VitalikButerin/status/1554983955182809088). We're talking about shrinking the "transaction calldata" box here
1 reply
0 recast
0 reaction