Skip to content

Commit 678d5db

Browse files
committed
clarify eviction, set initial cache size
1 parent 0617e70 commit 678d5db

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

proposals/0110-exponential-fee-for-write-lock-accounts.md

+17-8
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ compute-unit at a given condition.
5959
- *write lock fee*: denominated in `lamport`, it is fee dedicated for write
6060
lock an account, calculated as `compute-unit-pricer.cost-rate() * transaction.requested_cu()`.
6161

62-
## Design Highlights
62+
## Detailed Design
63+
64+
### Design Highlights
6365

6466
- Account Association with Compute Unit Pricer:
6567
- Accounts are associated with a *compute unit pricer*, and the *runtime*
@@ -77,15 +79,17 @@ lock an account, calculated as `compute-unit-pricer.cost-rate() * transaction.re
7779
`alpha = 2 / (N+1)`.
7880
- # Algorithm:
7981
- Adjusts write-lock *cost rate* based on an account's EMA *compute-unit
80-
utilization*. Initial write-lock cost rate is `1000 micro-lamport/CU`.
82+
utilization*.
8183
- For each block, if an account's EMA *compute-unit utilization* is more than
82-
half of its max limit, its write-lock *cost rate* increases by 1%. If it's
83-
below half, the *cost rate* decreases by 1%.
84+
half of its max limit, its write-lock *cost rate* increases by X%. If it's
85+
below half, the *cost rate* decreases by X%.
86+
- For V0, Initial write-lock cost rate is `1000 micro-lamport/CU`; and cost
87+
rate set to 1%.
8488
- Calculate *Write Lock Fee*:
8589
- Fee required to write-lock an account is calculated by multiplying the
8690
write-lock *cost rate* by the transaction's requested CU.
8791

88-
## Detailed Design
92+
### Detailed Design
8993

9094
- Initialization and Inheritance:
9195
- Bank initializes an empty account_write_lock_fee_cache, an LRU Cache of
@@ -103,9 +107,14 @@ lock an account, calculated as `compute-unit-pricer.cost-rate() * transaction.re
103107
- End of Block Processing:
104108
- Identify write-locked accounts with *compute-unit utilization* > half of
105109
account max CU limit. Add/update bank's account_write_lock_fee_cache.
106-
- Adding new account into LRU cache could push out eldest account;
107-
- LRU cache has capacity of 2048, which is 2* worst case block, should
108-
be enough to prevent cache attack.
110+
- Evicting cheapest account before add new "hot" accounts into LRU cach;
111+
- LRU cache has capacity set to 2* worst case eviction per block to prevent
112+
cache attack.
113+
- For v0, cache capacity set to 2048, as:
114+
- Max number of tansactions with account 6M CU = 48M/6M = 8;
115+
- Max number of accounts per tx: 128;
116+
- worst case per block: 128 * 8 = 1024;
117+
- 2 times worst case: 2048;
109118
- Fee Handling:
110119
- Collected write-lock fees are 100% burnt.
111120
- Collected priority fees are 100% rewarded.

0 commit comments

Comments
 (0)