Skip to content

Commit 0d0f7fd

Browse files
committed
Optimize calculation of ledger hashes
Problem: when performing transaction application, all merkle ledger hashes are recomputed for every account update. This is wasteful for a number of reasons: 1. Transactions normally contain more than one account update and hashes computed by an account update are overwritten by a subsequent account update 2. Ledger's depth is 35, whereas only around 2^18 are actually populated. This means that each account update induces a wasteful overhead of at least 17 hashes Solution: defer computation of hashes in mask. When an account is added, it's stacked in a list `unhashed_accounts` of masks which is processed at the time of next access to hashes. This fix improved performance of handling 9-account-update transactions by ~60% (measured on a laptop).
1 parent 85757df commit 0d0f7fd

File tree

1 file changed

+205
-140
lines changed

1 file changed

+205
-140
lines changed

0 commit comments

Comments
 (0)