Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Shannon Probabilistic Proofs #899

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
069851f
Probabilistic proofs doc WIP
Olshansk Oct 30, 2024
afe4c6a
Quick interim commit
Olshansk Oct 31, 2024
a015163
Checkpoint commit
Olshansk Oct 31, 2024
4b990fc
First draft complete
Olshansk Oct 31, 2024
b683816
Made docusarusu work
Olshansk Oct 31, 2024
384d796
Merge branch 'main' into probabilistic_proofs_docs
Olshansk Nov 6, 2024
a8dbec0
Merge branch 'main' into probabilistic_proofs_docs
Olshansk Nov 11, 2024
13a5f50
Merge with main
Olshansk Dec 17, 2024
c49d344
Update package log
Olshansk Dec 17, 2024
790d1e9
Apply suggestions from code review
Olshansk Dec 17, 2024
c92fc1a
A few TODOs
Olshansk Dec 17, 2024
05d7407
Update docusaurus/docs/protocol/primitives/probabilistic_proofs.md
Olshansk Dec 17, 2024
fe31c76
Update docusaurus/docs/protocol/primitives/probabilistic_proofs.md
Olshansk Dec 17, 2024
56a1276
Update docusaurus/docs/protocol/primitives/probabilistic_proofs.md
Olshansk Dec 17, 2024
b37e10f
Update docusaurus/docs/protocol/primitives/probabilistic_proofs.md
Olshansk Dec 17, 2024
0659d9b
Update docusaurus/docs/protocol/primitives/probabilistic_proofs.md
Olshansk Dec 17, 2024
a4f346c
Update docusaurus/docs/protocol/primitives/probabilistic_proofs.md
Olshansk Dec 17, 2024
e2505ba
Update docusaurus/docs/protocol/primitives/probabilistic_proofs.md
Olshansk Dec 17, 2024
8f8d320
Update docusaurus/docs/protocol/primitives/probabilistic_proofs.md
Olshansk Dec 17, 2024
f953a98
Update docusaurus/docs/protocol/primitives/probabilistic_proofs.md
Olshansk Dec 17, 2024
5f16e9c
Update docusaurus/docs/protocol/primitives/probabilistic_proofs.md
Olshansk Dec 17, 2024
24649dc
Update docusaurus/docs/protocol/primitives/probabilistic_proofs.md
Olshansk Dec 17, 2024
79580b8
Update docusaurus/docs/protocol/primitives/probabilistic_proofs.md
Olshansk Dec 17, 2024
c9c7fed
Some nits
Olshansk Dec 17, 2024
aadb39c
Update docusaurus/docs/protocol/primitives/probabilistic_proofs.md
Olshansk Dec 17, 2024
918b215
Update docusaurus/docs/protocol/primitives/probabilistic_proofs.md
Olshansk Dec 17, 2024
4b767c2
Incoporating everyone's feedback before doing the hard work
Olshansk Dec 17, 2024
f26f982
WIP
Olshansk Jan 9, 2025
8ac0867
Merge with main
Olshansk Jan 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Some nits
Olshansk committed Dec 17, 2024
commit c9c7fed5584a411778978a5e92a5b47019bd4711
37 changes: 19 additions & 18 deletions docusaurus/docs/protocol/primitives/probabilistic_proofs.md
Original file line number Diff line number Diff line change
@@ -62,32 +62,28 @@ TODO_IN_THIS_PR: Turn this into a table.

Network parameters:

- Session duration: `1` hour
- **Session duration**: `1` hour
- **Number of suppliers per session (per app)**: `20`
- **Number of services per session (per app)**: `1`

Network state:
Network state (conservative scenario):

- Median Proof Size: `1,000` bytes
- Number of services: `10,000`
- Number of applications: `100,000`
- Number of suppliers: `100,000`
- Number of suppliers per session: `10`
- Number of Proofs per session: `1`
- **Number of (active) services**: `10,000`
- **Number of (active) applications**: `100,000`
- **Number of (active) suppliers**: `100,000`

Conservative (simple) scenario:
Assumptions for the purpose of an example:

- Number of active applications: `10,000`
- Number of services used per application per session: `5`
- Number of suppliers used per application per session: `10`
- 1 Proof per (service, supplier) pair for each app
- Total time: `1` day (`24` sessions)
- **Median Proof Size**: `1,000` bytes
- **Total time**: `1` day (`24` sessions)

Total disk growth per day:

```bash
10,000 apps * 1 Proof/(service,supplier) * 10 suppliers/app * 5 services/session * 24 sessions * 1,000 bytes/Proof = 12 GB
10,000 apps * 1 Proof/(service,supplier) * 20 suppliers/app * 1 services/session * 24 sessions * 1,000 bytes/Proof = 4.8 GB ≈ 5 GB
```

A very simple (conservative) scenario would result in `12 GB` of disk growth per day, amounting to more than `4 TB` of disk growth in a year.
**CRITICAL**: A very simple (conservative) scenario would result in `5 GB` of disk growth per day, amounting to almost `2 TB` of disk growth in a year.

This discounts CPU usage needed to verify the Proofs.

@@ -180,7 +176,7 @@ to model the probability of a dishonest Supplier getting caught when submitting
- All other outcomes
- Does not include _short-circuited_ (i.e. Claim.ComputeUnits > ProofRequirementThreshold)

### Onchain Governance Parameters
### Conceptual Parameters: Onchain, Modeling, Governance, Etc

- **ProofRequestProbability (p)**: The probability that a Claim will require a Proof.
- **Penalty (S)**: The amount of stake slashed when a Supplier fails to provide a required Proof.
@@ -230,7 +226,7 @@ is penalized. This can be modeled using a Geometric PDF (Probability Distributio
In practice, we need to track the likelihood of `k or less` failures `Pr(X<=k)`,
until a single success. This can be modeled using a Geometric CDF.

TODO_IN_THIS_PR: Remove the paragraph below.
TODO_IN_THIS_PR: Remove the paragraph below. From Bryan: `This paragraph confuses me a bit. The previous paragraph says that we need to use a CDF but then this paragraph seems to turn around and say that this actually don't? I feel like this and the above paragraph should be combined and rephrased a bit.`

To simplify the math, we'll be using the Expected Value of a Geometric PDF
due to its [simpler proof formulation](https://en.wikipedia.org/wiki/Geometric_distribution#Proof_of_expected_value), guaranteeing the results be **AT LEAST**
@@ -342,6 +338,8 @@ While the expected profit is `0`, the variance in the number of successful false
Claims can make dishonest behavior risky. The Supplier might get caught earlier than expected,
leading to a net loss.

TODO_IN_THIS_PR: Incorporate this from Ramiro: `Variance works both ways, hence my previous comment. This can be a justification for changing the calculation of S as I suggest. This is because the attacker might not be caught until much later and result in a net profit.`

## Crypto-economic Analysis & Incentives

### Impact on Honest Suppliers
@@ -395,6 +393,8 @@ By tweaking `p` and `S`, the network can:
- **Lower `p`** reduces the number of Proofs required --> improves scalability --> requires higher penalties.
- **Higher `S`** increases the risk for dishonest Suppliers --> lead to social adversity from network participants.

TODO_IN_THIS_PR: Explain how `How does a high slashing penalty increase the risk of dishonest suppliers?`

#### Selecting Optimal `p` and `S`

To select appropriate values:
@@ -518,6 +518,7 @@ $$ S = R \cdot E[K] = 20 \cdot 99 = 1980 ≈ 2,000 $$

- The number of sessions a supplier is in will need to be limited
- The minimum stake amount will need to be significantly higher than the penalty to enable slashing across multiple sessions at once
- It could be a multiple of its provided services count.

2. **Optimal Reward Value**: Evaluating onchain Shannon data to determine the optimal value for `R`
3. **Closed Feedback Loop**: Having `p` dynamically adjust onchain as a function of onchain data without intervention from the DAO / PNF.

Unchanged files with check annotations Beta

- `k` (num failures) = `16`; computed using a cumulative geometric probability distribution
- `ProofRequestProbability` = `0.25`; selected manually to scale the network by 4x
- `ProofRequirementThreshold` = `20 POKT`; selected to a value that is above p95 of all POKT claims
- `ProofMissingPenalty` = `320 POKT`; calculated via `ProofRequirementThreshold * k` to deter malicious behaviour

Check warning on line 21 in docusaurus/docs/protocol/primitives/probabilistic_proofs_morse.md

GitHub Actions / misspell

[misspell] docusaurus/docs/protocol/primitives/probabilistic_proofs_morse.md#L21

"behaviour" is a misspelling of "behavior"
Raw output
./docusaurus/docs/protocol/primitives/probabilistic_proofs_morse.md:21:104: "behaviour" is a misspelling of "behavior"
**The question being answered by the distribution**: What is the probability of the protocol trusting (i.e. failing) `k` Claims or less (i.e. handling a normal claim or not catching an attacker) until a single penalty enforcement (i.e. successfully catching an attacker).
### Approach
An _attack by example_ approach is used determining the appropriate values for `ProofRequestProbability`, `ProofRequirementThreshold` and `ProofMissingPenalty`. This will demonstrate the optimal malicious behaviour an attacker should follow and tend to that case.

Check warning on line 145 in docusaurus/docs/protocol/primitives/probabilistic_proofs_morse.md

GitHub Actions / misspell

[misspell] docusaurus/docs/protocol/primitives/probabilistic_proofs_morse.md#L145

"behaviour" is a misspelling of "behavior"
Raw output
./docusaurus/docs/protocol/primitives/probabilistic_proofs_morse.md:145:205: "behaviour" is a misspelling of "behavior"
### Definitions
"source": [
"# Get successful and failed claims\n",
"failed_claims_df = claims_df.loc[claims_df['result_code'] != 0].copy()\n",
"successfull_claims_df = claims_df.loc[claims_df['result_code'] == 0].copy()"

Check warning on line 58 in docusaurus/docs/protocol/primitives/Pocket_Network_Morse_Probabilistic_Proofs.ipynb

GitHub Actions / misspell

[misspell] docusaurus/docs/protocol/primitives/Pocket_Network_Morse_Probabilistic_Proofs.ipynb#L58

"successfull" is a misspelling of "successful"
Raw output
./docusaurus/docs/protocol/primitives/Pocket_Network_Morse_Probabilistic_Proofs.ipynb:58:5: "successfull" is a misspelling of "successful"
]
},
{
}
],
"source": [
"print('Percentage of failed claims: %0.2f%%' % ((len(failed_claims_df)/(len(successfull_claims_df)+len(failed_claims_df))) * 100.))"

Check warning on line 75 in docusaurus/docs/protocol/primitives/Pocket_Network_Morse_Probabilistic_Proofs.ipynb

GitHub Actions / misspell

[misspell] docusaurus/docs/protocol/primitives/Pocket_Network_Morse_Probabilistic_Proofs.ipynb#L75

"successfull" is a misspelling of "successful"
Raw output
./docusaurus/docs/protocol/primitives/Pocket_Network_Morse_Probabilistic_Proofs.ipynb:75:81: "successfull" is a misspelling of "successful"
]
},
{
" '''\n",
" Numeber of relays to proof size approximation\n",
"\n",
" We expect the size of the proof to scale in O(long(r)) whith respect to the\n",

Check warning on line 336 in docusaurus/docs/protocol/primitives/Pocket_Network_Morse_Probabilistic_Proofs.ipynb

GitHub Actions / misspell

[misspell] docusaurus/docs/protocol/primitives/Pocket_Network_Morse_Probabilistic_Proofs.ipynb#L336

"whith" is a misspelling of "with"
Raw output
./docusaurus/docs/protocol/primitives/Pocket_Network_Morse_Probabilistic_Proofs.ipynb:336:64: "whith" is a misspelling of "with"
" number of relays (r). \n",
" If we know the size of the proof for 1e6 relays (proof_1M_r), we can scale \n",
" down/up from there. \n",