Skip to content

Commit 787deb8

Browse files
committed
Updates for juice costs in CAD007
1 parent 77e381c commit 787deb8

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

cad/007_juice/README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Overview
44

5-
Juice accounting refers to the system of accounting and pricing for immediate processing costs on the Convex network (CPU and networking).
5+
Juice accounting refers to the system of accounting and pricing for transaction processing costs on the Convex network (CPU and networking). We need this system for cryptoeconomic security: without it an attacker could cause the network to execute large amount of pointless work at zero cost and deny service to others.
66

77
The CVM implements a system of Juice with the following reasons:
88

@@ -30,23 +30,25 @@ Transaction Size Cost = TRANSACTION_PER_BYTE * Storage Size of Transaction
3030

3131
## Juice Allowance
3232

33-
Each Transaction MUST have a Juice Allowance
33+
Each Transaction MUST have a **juice allowance**
3434

35-
The Juice Allowance MAY by specified by the User in the Transaction, otherwise a default Juice Allowance MUST be used.
35+
The juice allowance MAY by specified by the user in the transaction, otherwise the maximum juice allowance shall be assumed (subject to available coins).
3636

37-
The Juice Allowance MUST NOT exceed the ability of the Transaction Origin Account to pay the Juice Fees for the Transaction
37+
The juice allowance MUST NOT exceed the ability of the transaction origin account to pay the juice fees for the transaction
3838

39-
The Juice Allowance MUST be limited to a maximum value in order to place an upper bound on computation costs for any single Transaction (currently `1,000,000`)
39+
The juice allowance MUST be limited to a maximum value in order to place an upper bound on computation costs for any single Transaction (currently `10,000,000`)
4040

4141
## Juice Consumed
4242

43-
During CVM execution of a Transaction, the CVM MUST track Juice Consumed, by incrementally adding a Juice Cost for each CVM Op or Runtime Function executed.
43+
During CVM execution of a transaction, the CVM MUST track juice consumed, by incrementally adding juice cost for each CVM op or runtime function executed.
4444

45-
Execution of any CVM OP or Runtime Function MUST have a fixed positive Juice Cost.
45+
Execution of any CVM OP or runtime function MUST have a fixed positive Juice Cost.
4646

47-
Execution of certain CVM Ops or Runtime Functions MAY additionally have a variable Juice Cost, where the cost is scaled by the size or the computation requested (typically the size of the largest data structure(s) used in the computation).
47+
Execution of certain CVM ops or Runtime Functions MAY additionally have a variable Juice Cost, where the cost is scaled by the size or the computation requested (typically the size of the largest data structure(s) used in the computation).
4848

49-
Juice Cost SHOULD be scaled according to the estimated upper bound of computation time required to execute the corresponding CVM code on a typicaly Peer. However this will not be precise, as real world execution times may vary based on different Peer technology and operational enviornments.
49+
Juice cost SHOULD be scaled according to the estimated computation time required to execute the corresponding CVM code on a typical Peer. This is not expected to be precise, as real world execution times may vary based on different Peer technology and operational environments.
50+
51+
Juice cost MUST be scaled according to an upper bound on the maximum of compute time, storage size or bandwidth cost. This is essentially to ensure that an attacker with `O(n)` resources cannot consume a higher level of resources e.g. `O(n^2)` (which would enable a DoS attack given sufficient scale in terms of `n`).
5052

5153
## Juice Constraints
5254

@@ -59,31 +61,33 @@ If a `:JUICE` Error occurs in a Transaction:
5961

6062
## Juice Price calculation
6163

62-
The Network MUST define a Governance Constant INITIAL_JUICE_PRICE as a Long value (currently `2`), which is used as the Juice Price in the Genesis State
64+
The network MUST define a governance constant INITIAL_JUICE_PRICE as a Long value (currently `2`), which is used as the juice price in the genesis state
6365

64-
The Network MUST define a Governance Constant JUICE_SCALE_FACTOR as a Double value (currently `1.125`)
66+
The network MUST define a governance constant JUICE_SCALE_FACTOR as a Double value (currently `1.125`)
6567

66-
The Network MUST define a Governance Constant JUICE_PER_SECOND as a Long value (currently `100,000,000`, calculated according to a reasonable lower bound estimate of steady-state CVM execution speed for an average Peer)
68+
The network MUST define a governance constant JUICE_PER_SECOND as a Long value (currently `100,000,000`, calculated according to a reasonable lower bound estimate of steady-state CVM execution speed for an average peer). This typically translates to between 10-100,000 transactions per second, depending on transaction complexity, which is comfortable given that the CVM has been benchmarked processing over 1 million TPS.
6769

68-
The Network MAY update JUICE_SCALE_FACTOR and JUICE_PER_SECOND as part of a Governance Update, in which case Peers MUST utilise the new values for any State updates on or after the Governence Update Timestamp.
70+
The Network MAY update JUICE_SCALE_FACTOR and JUICE_PER_SECOND as part of a governance update, in which case peers MUST utilise the new values for any State updates on or after the governance update timestamp.
6971

70-
Juice Price MUST be updated after every Block of transactions. Combined with the bounded size of Blocks and bounded execution costs on transactions, this ensure a bounded amount of computation can occur between Juice Price updates.
72+
Juice price MUST be updated after every block of transactions. Combined with the bounded size of blocks and bounded execution costs on transactions, this ensure a bounded amount of computation can occur between juice price updates.
7173

72-
For every `JUICE_PER_SECOND` amount of total Juice Consumed, the Juice update MUST increase the Juice Price according to `Juice Price = Juice Price / JUICE_SCALE_FACTOR (rounded up)`
74+
For every `JUICE_PER_SECOND` amount of total juice consumed, the update MUST increase the juice price according to `Juice Price = Juice Price / JUICE_SCALE_FACTOR (rounded up)`
7375

7476
For every `1000ms` elapsed the juice update MUST reduce Juice Price according to `Juice Price = Juice Price / JUICE_SCALE_FACTOR (rounded down)`
7577

7678
Juice Price MUST have a minimum value of `1`, i.e. Juice consumption is never free.
7779

7880
## Cryptoeconomics
7981

80-
The variation of Juice Prices implies:
82+
The juice accounting system is designed to give effective cryptoeconomics for transaction costs, where the cost of transactions is proportional to the amount of network resources consumed (compute, bandwidth and storage).
83+
84+
The variation of juice prices implies:
8185
- Juice Price will increase if the network is loaded by more than JUICE_PER_SECOND worth of transactions, which will increasingly discourage Users from submitting lower value transactions
8286
- Juice Price will decrease if the network is loaded by less than JUICE_PER_SECOND worth of transactions
8387
- An equilibrium level of JUICE_PER_SECOND amount of Juice Consumed per second may be reached, where the Juice Price remains stable.
8488
- If the Network has zero load, the Juice Price will decline exponentially towards `1` (with a "half life" of around 6 seconds)
8589

86-
Since we assume Good Peers are able to handle over JUICE_PER_SECOND worth of computation, an attacker would be unable to put excessive load on the network for long periods of time without incurring exponentially rising costs, which makes such sustained attacks infeasible.
90+
Since we assume good peers are able to handle over JUICE_PER_SECOND worth of computation, an attacker would be unable to put excessive load on the network for long periods of time without incurring exponentially rising costs, which makes such sustained attacks infeasible.
8791

8892
Alternatively, an attacker could attempt temporary DoS attacks when the Juice Price is low. However, since these cannot be sustained, they would only cause temporary delays to confirmation of final State updates, and would not stop legitimate Transactions from being included in consensus and ultimately executed.
8993

0 commit comments

Comments
 (0)