Coming to Mainnet on Jan 15!
On Dec 13, 2023, we posted details about Starknet v0.13.0 on the community forum. The post outlined the main changes: v3 transactions and transaction fee reductions.
Over the last few weeks, internal stress-testing revealed several openings for performance improvements: some Python code begging to be replaced with Rust, an optimization of the ec_op
builtin to use projective coordinates instead of affine coordinates, and some caching.
After concentrated efforts, all of these improvements were implemented. Before diving into the results, an important schedule clarification:
- The Mainnet upgrade date of Jan 10, 2024 did not include these performance improvements. The holdup is due to our wish to run these changes a few more days on testnet.
- These performance improvements will be included in an additional Mainnet upgrade, which will take place on Jan 15, 2024.
Now here is what you all want to see: below is a table detailing the results of the various optimizations that were done. The example we choose is for erc20_transfer
.
erc20_transfer |
Cairo0 account & token contract | Cairo account & token contract |
---|---|---|
Pre-improvements | 80 TPS | 18 TPS |
Post-improvements | 150 TPS | 70 TPS |
There are several caveats to be made:
- As you can see, there is a gap in performance between Cairo0 and Cairo. The gap is due to the powerful safety properties provided by Sierra. However, as shown in the table, it can be reduced considerably by careful optimization. Following the optimizations, the gap between Cairo0 and Cairo was halved largely thanks to the
ec_op
optimization which accelerated the validate of the Cairo accounts used in our testing. Indeed the tested Cairo0 accounts used theECDSA
builtin which is illegal in Sierra (and therefore Cairo) as it can fail. - Throughput in practice depends on many factors. A major one is the % of the block using
ec_op
, which enjoys a roughly 60x speedup. This means a block with few such validate functions, or few multicalls to such accounts, will exhibit a smaller speedup compared to the erc20_transfer scenario with many separate transactions. - In particular, since the βpureβ scenario of transfers is not the standard traffic on Starknet, the practical throughput improvement on Mainnet will likely be less drastic in the average case.