Starknet v0.13.0: Performance Improvement

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:

  1. 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 the ECDSA builtin which is illegal in Sierra (and therefore Cairo) as it can fail.
  2. 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.
  3. 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.

Hi, thanks for the update.
Hope you can clarify a few things:
Does it mean that today the fees are calculated as described in this document Gas and transaction fees (Prior to Starknet 0.13.0) :: Starknet documentation

Also, what are the numbers in the table above?

Hey @sgc-code thanks for the quick reply!

  • No - the correct reference is now after v0.13.0.
  • The numbers are erc-20 transfers per second. I clarified this in the table now.

Great to hear many optimizations are already in place.
So if the new step/builtin costs are already included, and the L1 DA optimization is also available now. Can you clarify what are the improvements that will take effect on Jan 15th?

is this upgrade V0.13.1?