mina
mina copied to clipboard
Memorize transaction-related hashes
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:
- Derive token id (
derive_token_id
inAccount_id
) - Events-related hashing (
Zkapp_account.Event.hash
andZkapp_account.Make_events.push_hash
) - Hashing of zkapp URI (
hash_zkapp_uri
inZkapp_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.