mina icon indicating copy to clipboard operation
mina copied to clipboard

Memorize transaction-related hashes

Open georgeee opened this issue 1 year ago • 1 comments

While examining the performance of Staged_ledger.update_coinbase_stack_and_get_data, I noticed that even after optimizations culminated by PR #14643, up to 50% of time is being spent in first and send passes of transaction application.

This was measured on blocks of 128 txs each being a 9-account-update zkapp (deploying 8 new accounts). No events or memo were used, this might have affected the results.

When I tried to make a breakdown of cost-centers I noticed the following pieces to take significant part of the costs:

  1. Derive token id (derive_token_id in Account_id)
  2. Events-related hashing (Zkapp_account.Event.hash and Zkapp_account.Make_events.push_hash)
  3. Hashing of zkapp URI (hash_zkapp_uri in Zkapp_account)

These hashing routines (unlike account hash and merge hash used in merkle tree building) are solely dependent on a transaction in question, hence can be performed before block creation (and hashes memorized).

This would reduce the demand of block window duration, hopefully reducing time of update_coinbase_stack_and_get_data two-fold.

georgeee avatar Dec 20 '23 18:12 georgeee