|
| 1 | +--- |
| 2 | +simd: '0110' |
| 3 | +title: Exponential fee for write lock accounts |
| 4 | +authors: |
| 5 | + - Anatoly Yakovenko, Tao Zhu |
| 6 | +category: Standard/Meta |
| 7 | +type: Core/Networking/Interface/Meta |
| 8 | +status: Draft |
| 9 | +created: 2024-01-18 |
| 10 | +feature: (fill in with feature tracking issues once accepted) |
| 11 | +supersedes: (optional - fill this in if the SIMD supersedes a previous SIMD) |
| 12 | +extends: (optional - fill this in if the SIMD extends the design of a previous |
| 13 | + SIMD) |
| 14 | +--- |
| 15 | + |
| 16 | +## Summary: |
| 17 | + |
| 18 | +In a permissionless environment with low fees, users often submit transactions |
| 19 | +for opportunistic trades without considering the success probability. Almost |
| 20 | +half of the Compute Units (CUs) in a block are allocated to failed transactions, |
| 21 | +leading to undesirable scenario where large portion of compute powers primarily |
| 22 | +serving failed DeFi arbitrage transactions. To address this, the proposed |
| 23 | +feature introduces economic back pressure, discouraging spam activities and |
| 24 | +ensuring efficient network resource utilization. It suggests tracking the |
| 25 | +Exponential Moving Average (EMA) of contentious accounts' CU utilization |
| 26 | +per block and exponentially increasing the cost to write-lock these accounts |
| 27 | +if their utilization remains high. |
| 28 | + |
| 29 | +## Motivation: |
| 30 | + |
| 31 | +The motivation behind this feature is to introduce economic back pressure, |
| 32 | +dissuading DeFi spammers from overwhelming the network. DeFi spam, defined as |
| 33 | +opportunistic trades with a positive return on investment, currently occupies |
| 34 | +almost half of the CUs in a block as failed transactions. Economic back |
| 35 | +pressure aims to create a deterrent for such spam activities, ensuring network |
| 36 | +resources are efficiently utilized and preventing continuous block congestion |
| 37 | +caused by failed DeFi spam transactions. |
| 38 | + |
| 39 | +## Alternatives Considered |
| 40 | + |
| 41 | +While the priority fee serves to mitigate low-cost spams by decreasing the |
| 42 | +likelihood of less prioritized transactions being included, it cannot entirely |
| 43 | +eliminate the inclusion of spam transactions in a block. As long as there |
| 44 | +remains a chance, no matter how small, to inexpensively include transactions, |
| 45 | +the incentive for spamming persists. The proposed feature recognizes that the |
| 46 | +current mechanisms have limitations in fully addressing the spam issue, and |
| 47 | +thus, seeks to introduce a more robust solution to discourage opportunistic |
| 48 | +trades and ensure a more secure and efficient network environment. |
| 49 | + |
| 50 | +## New Terminology |
| 51 | + |
| 52 | +- *compute-unit utilization*: denominated in `cu`, it represents total |
| 53 | + compute-units applied to a given resource. |
| 54 | +- *cost rate*: denominated in `lamport/cu`, it represents the cost per |
| 55 | +compute-unit at a given condition. |
| 56 | +- *compute unit pricer*: a componenet tracks Exponential Moving Average of |
| 57 | +*compute-unit utilization*, applies a # algorithm to provide current |
| 58 | +*cost rate*. |
| 59 | +- *write lock fee*: denominated in `lamport`, it is fee dedicated for write |
| 60 | +lock an account, calculated as `compute-unit-pricer.cost-rate() * transaction.requested_cu()`. |
| 61 | + |
| 62 | +## Design Highlights: |
| 63 | + |
| 64 | +- Account Association with Compute Unit Pricer: |
| 65 | + - Accounts are associated with a *compute unit pricer*, and the *runtime* |
| 66 | + maintains an LRU cache of actively contentious accounts' public keys and |
| 67 | + their *compute unit pricers*. |
| 68 | + - Alternatively, each account can have its *compute unit pricer* stored |
| 69 | + onchain, which would require modifying accounts. |
| 70 | +- Compute Unit Pricer: |
| 71 | + - Tracks an account's EMA *compute-unit utilization*, updated after the |
| 72 | + current bank is frozen. |
| 73 | + - Provides the current *cost rate* when queried. |
| 74 | +- EMA of Compute-Unit Utilization: |
| 75 | + - Uses 150 slots for EMA calculation. |
| 76 | + - EMA Alpha, representing the degree of weighting decrease, is calculated as |
| 77 | + `alpha = 2 / (N+1)`. |
| 78 | +- # Algorithm: |
| 79 | + - Adjusts write-lock *cost rate* based on an account's EMA *compute-unit |
| 80 | + utilization*. Initial write-lock cost rate is `1000 lamport/CU`. |
| 81 | + - 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 | +- Calculate *Write Lock Fee*: |
| 85 | + - Fee required to write-lock an account is calculated by multiplying the |
| 86 | + write-lock *cost rate* by the transaction's requested CU. |
| 87 | + |
| 88 | +## Detailed Design: |
| 89 | + |
| 90 | +- Initialization and Inheritance: |
| 91 | + - Bank initializes an empty account_write_lock_fee_cache, an LRU Cache of |
| 92 | + {account_pubkey, compute-unit-pricer}. |
| 93 | + - Child banks inherit the parent's cache. |
| 94 | +- Transaction Fee Calculation: |
| 95 | + - Calculate write-lock fee for each account a transaction needs to write, |
| 96 | + summing up to be its *write lock fee*. This, along with signature fee and |
| 97 | + priority fee, constitutes the total fee for the transaction. |
| 98 | + - Leader checks fee payer's balance before scheduling the transaction. |
| 99 | +- Cost Tracking: |
| 100 | + - Cost_tracker tracks CUs for the current block and each write-locked accounti |
| 101 | + as-is; |
| 102 | + - Ensuring cost tracking is enabled at the replay stage. |
| 103 | +- End of Block Processing: |
| 104 | + - Identify write-locked accounts with *compute-unit utilization* > half of |
| 105 | + 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 1024, which should be large enough for hot accounts |
| 108 | + in 150 slots. |
| 109 | +- Fee Handling: |
| 110 | + - Collected write-lock fees are 100% burnt. |
| 111 | + - Collected priority fees are 100% rewarded. |
| 112 | + - Collected signature fees are 50% burnt, 50% rewarded. |
| 113 | + |
| 114 | +## Impact: |
| 115 | + |
| 116 | +- Rate of successful CU inclusion in a block is expected to increase, reducing |
| 117 | +failed transactions. |
| 118 | +- Transactions writing to contentious accounts will experience increased fees, |
| 119 | +particularly during congestion. |
| 120 | +- DeFi arbitrage traders will need to adjust strategies to account for the |
| 121 | +heightened fees. |
| 122 | + |
| 123 | + |
| 124 | +## Other Considerations: |
| 125 | + |
| 126 | +- Users may need new instruction to set a maximum write-lock fee for transaction |
| 127 | +- Consider tooling for wallets/simulators to query "min/max write lock fee." |
| 128 | +- Acknowledge read lock contention, deferring EMA fee implementation for read locks. |
| 129 | +- In the future, a percentage of collected write-lock-fee could be deposited |
| 130 | +to an account, allowing dApps to refund cranks and other service providers. |
| 131 | +This decision should be done via a governance vote. |
| 132 | + |
| 133 | + |
| 134 | +## Security Considerations |
| 135 | + |
| 136 | +n/a |
| 137 | + |
| 138 | + |
| 139 | +## Backwards Compatibility |
| 140 | + |
| 141 | +Needs feature gate. |
0 commit comments