Skip to content

Commit f1d044f

Browse files
authored
Merge pull request #180 from BlockScience/hammer2
Hammer2
2 parents 308f697 + 93c72c1 commit f1d044f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2945
-1458
lines changed

Testing.ipynb

Lines changed: 89 additions & 25 deletions
Large diffs are not rendered by default.

reports/Basic Report.html

Lines changed: 641 additions & 289 deletions
Large diffs are not rendered by default.

reports/actions/Application Stake.html

Lines changed: 87 additions & 87 deletions
Large diffs are not rendered by default.
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
<p>For explanations of generalized dynamical systems as well as how the mathematical specification library works in detail, please consult the documentation <a href="https://github.com/BlockScience/MSML/tree/main/docs">here</a></p>Graph Legend:<br/>Cylinder: Entity<br/>Orange Diamond: Boundary Action<br/>Red Square: Policy<br/>Blue Circle: Mechanism<br/>Transparent Circle: State Variable<h2>Action Map</h2><?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
3+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
4+
5+
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
6+
7+
<!-- Generated by graphviz version 2.48.0 (0)
8+
9+
-->
10+
11+
<!-- Title: Application Unstake Pages: 1 -->
12+
13+
<svg width="468pt" height="497pt"
14+
15+
viewBox="0.00 0.00 467.98 497.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
16+
17+
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 493)">
18+
19+
<title>Application Unstake</title>
20+
21+
<polygon fill="white" stroke="transparent" points="-4,4 -4,-493 463.98,-493 463.98,4 -4,4"/>
22+
23+
<!-- Application -->
24+
25+
<g id="node1" class="node">
26+
27+
<title>Application</title>
28+
29+
<path fill="none" stroke="black" d="M261.24,-485.73C261.24,-487.53 242.64,-489 219.74,-489 196.84,-489 178.24,-487.53 178.24,-485.73 178.24,-485.73 178.24,-456.27 178.24,-456.27 178.24,-454.47 196.84,-453 219.74,-453 242.64,-453 261.24,-454.47 261.24,-456.27 261.24,-456.27 261.24,-485.73 261.24,-485.73"/>
30+
31+
<path fill="none" stroke="black" d="M261.24,-485.73C261.24,-483.92 242.64,-482.45 219.74,-482.45 196.84,-482.45 178.24,-483.92 178.24,-485.73"/>
32+
33+
<text text-anchor="middle" x="219.74" y="-467.3" font-family="Times,serif" font-size="14.00">Application</text>
34+
35+
</g>
36+
37+
<!-- Application Unstake -->
38+
39+
<g id="node2" class="node">
40+
41+
<title>Application Unstake</title>
42+
43+
<polygon fill="orange" stroke="orange" points="219.74,-416 98.58,-398 219.74,-380 340.9,-398 219.74,-416"/>
44+
45+
<text text-anchor="middle" x="219.74" y="-394.3" font-family="Times,serif" font-size="14.00">Application Unstake</text>
46+
47+
</g>
48+
49+
<!-- Application&#45;&gt;Application Unstake -->
50+
51+
<g id="edge1" class="edge">
52+
53+
<title>Application&#45;&gt;Application Unstake</title>
54+
55+
<path fill="none" stroke="black" d="M219.74,-452.81C219.74,-444.79 219.74,-435.05 219.74,-426.07"/>
56+
57+
<polygon fill="black" stroke="black" points="223.24,-426.03 219.74,-416.03 216.24,-426.03 223.24,-426.03"/>
58+
59+
</g>
60+
61+
<!-- Application Unstake Policy -->
62+
63+
<g id="node3" class="node">
64+
65+
<title>Application Unstake Policy</title>
66+
67+
<polygon fill="red" stroke="red" points="305.24,-299 134.24,-299 134.24,-263 305.24,-263 305.24,-299"/>
68+
69+
<text text-anchor="middle" x="219.74" y="-277.3" font-family="Times,serif" font-size="14.00">Application Unstake Policy</text>
70+
71+
</g>
72+
73+
<!-- Application Unstake&#45;&gt;Application Unstake Policy -->
74+
75+
<g id="edge2" class="edge">
76+
77+
<title>Application Unstake&#45;&gt;Application Unstake Policy</title>
78+
79+
<path fill="none" stroke="black" d="M219.74,-379.53C219.74,-360.94 219.74,-331.24 219.74,-309.5"/>
80+
81+
<polygon fill="black" stroke="black" points="223.24,-309.25 219.74,-299.25 216.24,-309.25 223.24,-309.25"/>
82+
83+
<text text-anchor="middle" x="253.24" y="-350.8" font-family="Times,serif" font-size="14.00">Application</text>
84+
85+
<text text-anchor="middle" x="253.24" y="-335.8" font-family="Times,serif" font-size="14.00">Unstake</text>
86+
87+
<text text-anchor="middle" x="253.24" y="-320.8" font-family="Times,serif" font-size="14.00">Space</text>
88+
89+
</g>
90+
91+
<!-- Update Application Stake Status -->
92+
93+
<g id="node4" class="node">
94+
95+
<title>Update Application Stake Status</title>
96+
97+
<ellipse fill="#e0eeee" stroke="#e0eeee" cx="219.74" cy="-164" rx="128.88" ry="18"/>
98+
99+
<text text-anchor="middle" x="219.74" y="-160.3" font-family="Times,serif" font-size="14.00">Update Application Stake Status</text>
100+
101+
</g>
102+
103+
<!-- Application Unstake Policy&#45;&gt;Update Application Stake Status -->
104+
105+
<g id="edge3" class="edge">
106+
107+
<title>Application Unstake Policy&#45;&gt;Update Application Stake Status</title>
108+
109+
<path fill="none" stroke="black" d="M219.74,-262.53C219.74,-243.94 219.74,-214.24 219.74,-192.5"/>
110+
111+
<polygon fill="black" stroke="black" points="223.24,-192.25 219.74,-182.25 216.24,-192.25 223.24,-192.25"/>
112+
113+
<text text-anchor="middle" x="254.24" y="-233.8" font-family="Times,serif" font-size="14.00">Application</text>
114+
115+
<text text-anchor="middle" x="254.24" y="-218.8" font-family="Times,serif" font-size="14.00">Stake Status</text>
116+
117+
<text text-anchor="middle" x="254.24" y="-203.8" font-family="Times,serif" font-size="14.00">Space</text>
118+
119+
</g>
120+
121+
<!-- Application.Stake Status -->
122+
123+
<g id="node6" class="node">
124+
125+
<title>Application.Stake Status</title>
126+
127+
<ellipse fill="none" stroke="black" cx="100.74" cy="-91" rx="100.98" ry="18"/>
128+
129+
<text text-anchor="middle" x="100.74" y="-87.3" font-family="Times,serif" font-size="14.00">Application.Stake Status</text>
130+
131+
</g>
132+
133+
<!-- Update Application Stake Status&#45;&gt;Application.Stake Status -->
134+
135+
<g id="edge4" class="edge">
136+
137+
<title>Update Application Stake Status&#45;&gt;Application.Stake Status</title>
138+
139+
<path fill="none" stroke="black" d="M191.84,-146.35C175.58,-136.65 154.88,-124.3 137.32,-113.83"/>
140+
141+
<polygon fill="black" stroke="black" points="138.85,-110.66 128.47,-108.54 135.26,-116.67 138.85,-110.66"/>
142+
143+
</g>
144+
145+
<!-- Application.Unstaking Height -->
146+
147+
<g id="node7" class="node">
148+
149+
<title>Application.Unstaking Height</title>
150+
151+
<ellipse fill="none" stroke="black" cx="339.74" cy="-91" rx="120.48" ry="18"/>
152+
153+
<text text-anchor="middle" x="339.74" y="-87.3" font-family="Times,serif" font-size="14.00">Application.Unstaking Height</text>
154+
155+
</g>
156+
157+
<!-- Update Application Stake Status&#45;&gt;Application.Unstaking Height -->
158+
159+
<g id="edge5" class="edge">
160+
161+
<title>Update Application Stake Status&#45;&gt;Application.Unstaking Height</title>
162+
163+
<path fill="none" stroke="black" d="M247.88,-146.35C264.28,-136.65 285.15,-124.3 302.85,-113.83"/>
164+
165+
<polygon fill="black" stroke="black" points="304.96,-116.65 311.78,-108.54 301.39,-110.62 304.96,-116.65"/>
166+
167+
</g>
168+
169+
<!-- Application_2 -->
170+
171+
<g id="node5" class="node">
172+
173+
<title>Application_2</title>
174+
175+
<path fill="none" stroke="black" d="M261.24,-32.73C261.24,-34.53 242.64,-36 219.74,-36 196.84,-36 178.24,-34.53 178.24,-32.73 178.24,-32.73 178.24,-3.27 178.24,-3.27 178.24,-1.47 196.84,0 219.74,0 242.64,0 261.24,-1.47 261.24,-3.27 261.24,-3.27 261.24,-32.73 261.24,-32.73"/>
176+
177+
<path fill="none" stroke="black" d="M261.24,-32.73C261.24,-30.92 242.64,-29.45 219.74,-29.45 196.84,-29.45 178.24,-30.92 178.24,-32.73"/>
178+
179+
<text text-anchor="middle" x="219.74" y="-14.3" font-family="Times,serif" font-size="14.00">Application</text>
180+
181+
</g>
182+
183+
<!-- Application.Stake Status&#45;&gt;Application_2 -->
184+
185+
<g id="edge6" class="edge">
186+
187+
<title>Application.Stake Status&#45;&gt;Application_2</title>
188+
189+
<path fill="none" stroke="black" d="M128.34,-73.53C144.6,-63.83 165.36,-51.45 182.99,-40.93"/>
190+
191+
<polygon fill="black" stroke="black" points="185.08,-43.75 191.88,-35.62 181.5,-37.74 185.08,-43.75"/>
192+
193+
</g>
194+
195+
<!-- Application.Unstaking Height&#45;&gt;Application_2 -->
196+
197+
<g id="edge7" class="edge">
198+
199+
<title>Application.Unstaking Height&#45;&gt;Application_2</title>
200+
201+
<path fill="none" stroke="black" d="M311.61,-73.35C295.32,-63.72 274.63,-51.48 257.01,-41.05"/>
202+
203+
<polygon fill="black" stroke="black" points="258.5,-37.87 248.12,-35.79 254.94,-43.89 258.5,-37.87"/>
204+
205+
</g>
206+
207+
</g>
208+
209+
</svg>
210+
<h2>State</h2><h3>Local States</h3><h4>Application State</h4><table>
211+
<tr>
212+
<th>Name</th>
213+
<th>Description</th>
214+
<th>Type</th>
215+
<th>Symbol</th>
216+
<th>Domain</th>
217+
</tr><tr><td>Public key</td><td>The identifier of the application</td><td>Public Key</td><td></td><td></td></tr><tr><td>POKT Holdings</td><td>The personal holdings of the application in uPOKT</td><td>uPOKT</td><td></td><td></td></tr><tr><td>Staked POKT</td><td>The staked amount of the application in uPOKT</td><td>uPOKT</td><td></td><td></td></tr><tr><td>Services</td><td>The flavor(s) of Web3 hosted by this Servicer</td><td>List[Service]</td><td></td><td></td></tr><tr><td>GeoZone</td><td>The physical geo-location identifier this Servicer registered in</td><td>GeoZone</td><td></td><td></td></tr><tr><td>Number of Servicers</td><td>The number of servicers an application would prefer, if available, for a session.</td><td>int</td><td></td><td></td></tr><tr><td>Stake Status</td><td>The status of staking for the actor</td><td>StakeStatusType</td><td></td><td></td></tr><tr><td>Unstaking Height</td><td>The height for which a servicer has begun unstaking at or none to represent no unstaking</td><td>Block Height</td><td></td><td></td></tr></table><h2>Spaces</h2><h3>Application Unstake Space</h3><p>{actor_type: ActorType,<br/>address: Address,<br/>signer: Address}</p><h2>Behavioral Action Space</h2><h3>Application Unstake</h3><p>The action of unstaking from the network for an application</p><h4>Called By:</h4>
218+
<p>1. Application</p><h4>Constraints:</h4>
219+
<h2>Policies</h2><h3>Application Unstake Policy</h3><p>The policy for determining what happens when an application unstakes.</p><h4>Preceded By:</h4>
220+
<p>1. Application Unstake</p><h4>Domain Spaces:</h4>
221+
<p>1. Application Unstake Space</p><h4>Followed By:</h4>
222+
<p>1. Update Application Stake Status</p><h4>Codomain Spaces:</h4>
223+
<h4>Constraints:</h4>
224+
<h2>Mechanisms</h2><h3>Update Application Stake Status</h3><p>The mechanism which updates the staking status and as well the unstaking height for an application.</p><h4>Preceded By:</h4>
225+
<p>1. Application Unstake Policy</p><h4>Domain Spaces:</h4>
226+
<p>1. Application Stake Status Space</p><h4>State Updates:</h4>
227+
<p>1. Application.Stake Status</p><p>2. Application.Unstaking Height</p><h4>Constraints:</h4>
228+
<h4>Logic:</h4>
229+
<p>The application at DOMAIN[0].address has its unstaking_height variable updated to DOMAIN[0].height which will be none if it is staking. It will also have its stake status set to DOMAIN[0].status.</p><h2>Parameters</h2>

reports/actions/Mint Block Rewards.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -513,30 +513,30 @@
513513
</g>
514514

515515
</svg>
516-
<h2>State</h2><h3>Local States</h3><h2>Spaces</h2><h3>Mint POKT Mechanism Space</h3><p>{mint_amount: uPOKT}</p><h3>Assign Servicer Salary Space</h3><p>{geo_zone: GeoZone,<br/>relay_chain: Relay Chain,<br/>height: Block Height}</p><h3>Validator Block Reward Space</h3><p>{public_key: Public Key,<br/>block_height: Block Height,<br/>reward_amount: uPOKT}</p><h3>Mint Block Rewards Space</h3><p>{current_height: Block Height,<br/>block_producer: Public Key}</p><h3>Burn POKT Mechanism Space</h3><p>{burn_amount: uPOKT}</p><h3>Modify Servicer POKT Space</h3><p>{public_key: Public Key,<br/>amount: uPOKT}</p><h2>Behavioral Action Space</h2><h2>Policies</h2><h3>Block Reward Policy Aggregate</h3><p>The aggregate policy for creating the total amount of block reward and also splitting it between different groups.
516+
<h2>State</h2><h3>Local States</h3><h2>Spaces</h2><h3>Burn POKT Mechanism Space</h3><p>{burn_amount: uPOKT}</p><h3>Validator Block Reward Space</h3><p>{public_key: Public Key,<br/>block_height: Block Height,<br/>reward_amount: uPOKT}</p><h3>Mint POKT Mechanism Space</h3><p>{mint_amount: uPOKT}</p><h3>Assign Servicer Salary Space</h3><p>{geo_zone: GeoZone,<br/>service: Service,<br/>height: Block Height}</p><h3>Modify Servicer POKT Space</h3><p>{public_key: Public Key,<br/>amount: uPOKT}</p><h3>Mint Block Rewards Space</h3><p>{current_height: Block Height,<br/>block_producer: Public Key}</p><h2>Behavioral Action Space</h2><h2>Policies</h2><h3>Block Reward Policy Aggregate</h3><p>The aggregate policy for creating the total amount of block reward and also splitting it between different groups.
517517

518518
There are two components that are aggregated here, one for fees and one for general block rewards. Based upon the numerous parameters, the total reward for each group is determined. For a more detailed version of the policy, one can look here: https://docs.google.com/spreadsheets/d/1QYe6NzuiyimsXs5cT1BSM-UT1DtX_K38cOZsEFJOtdA/edit#gid=242780369</p><h4>Preceded By:</h4>
519519
<p>1. Mint Block Rewards</p><h4>Domain Spaces:</h4>
520520
<p>1. Mint Block Rewards Space</p><h4>Followed By:</h4>
521521
<p>1. Mint POKT Mechanism</p><p>2. Assign Servicer Salary Policy</p><p>3. Validator Block Reward Policy</p><p>4. DAO Block Reward Policy</p><h4>Codomain Spaces:</h4>
522522
<p>1. Mint POKT Mechanism Space</p><p>2. Assign Servicer Salary Space</p><p>3. Validator Block Reward Space</p><h4>Constraints:</h4>
523-
<h3>Assign Servicer Salary Policy</h3><p>A `ServicerSalary` is assigned to each individual Servicer based on their specific `ReportCard`, and is distributed every `SalaryBlockFrequency`. Salaries are distributed from the `TotalAvailableReward` pool, whose inflation is governed by Application volume of each `(RelayChain, GeoZone)` pair and scaled by the `UsageToRewardCoefficient` governance parameter.
523+
<h3>Assign Servicer Salary Policy</h3><p>A `ServicerSalary` is assigned to each individual Servicer based on their specific `ReportCard`, and is distributed every `SalaryBlockFrequency`. Salaries are distributed from the `TotalAvailableReward` pool, whose inflation is governed by Application volume of each `(Service, GeoZone)` pair and scaled by the `UsageToRewardCoefficient` governance parameter.
524524

525525
A Servicer must accumulate `MinimumTestScoreThreshold` TestScores before it is eligible for salary distribution. A ReportCard can be viewed as a rolling average of the Servicer's performance, where TestScores are removed when either `TestScoreExpiration` is passed or the TestScore FIFO queue exceeds `MaxTestScores`.
526526

527-
Salary distribution is accomplished by aggregating the total volume estimated (see above) for a specific `(RelayChain, GeoZone)` pair (i.e. `TotalVolumeUsage`), multiplied by `UsageToRewardCoefficient`, and evenly divided into buckets per Servicer that exceed the minimum threshold (i.e. the `MinimumReportCardThreshold`). Each Servicer's reward is scaled proportionally to both their stake and their ReportCard. Tokens that are not allocated to a servicer are burnt.
527+
Salary distribution is accomplished by aggregating the total volume estimated (see above) for a specific `(Service, GeoZone)` pair (i.e. `TotalVolumeUsage`), multiplied by `UsageToRewardCoefficient`, and evenly divided into buckets per Servicer that exceed the minimum threshold (i.e. the `MinimumReportCardThreshold`). Each Servicer's reward is scaled proportionally to both their stake and their ReportCard. Tokens that are not allocated to a servicer are burnt.
528528

529529
For example, a 100% ReportCard results in zero burning of the `maxServicerReward`, while a 80% ReportCard results in 20% burning of the maxServicerReward. The rate of decrease continues linearly until the `MinimumReportCardThreshold` is reached. Below the MinimumReportCardThreshold no reward is given to prevent cheap Sybil attacks and freeloading nodes. Unstaking causes the Servicer's ReportCard to be cleared and start from scratch.
530530

531531
The following is pseudo-code to illustrate this business logic:
532532

533533
```go
534-
// Called for each (relayChain, geoZone) pair every SessionBlockFrequency
535-
func DistributeRewards(relayChain, geoZone, height):
536-
totalVolumeUsage = WorldState.RetrieveTotalVolumeEstimate(relayChain, geoZone, height)
534+
// Called for each (Service, geoZone) pair every SessionBlockFrequency
535+
func DistributeRewards(Service, geoZone, height):
536+
totalVolumeUsage = WorldState.RetrieveTotalVolumeEstimate(Service, geoZone, height)
537537
totalAvailableReward = totalVolumeUsage * GovParams.UsageToRewardCoefficient(height)
538538

539-
allServicers = WorldState.RetrieveEligibleServicers(relayChain, geoZone, height)
539+
allServicers = WorldState.RetrieveEligibleServicers(Service, geoZone, height)
540540
eligibleServicers = filterServicers(allServicers, GovParams.MinimumTestScoreThreshold(height))
541541

542542
maxServicerReward = totalAvailableReward / len(eligibleServicers)
@@ -549,7 +549,7 @@ <h3>Assign Servicer Salary Policy</h3><p>A `ServicerSalary` is assigned to each
549549
burnAmount = burnPercent * maxServicerReward
550550

551551
awardTokens(servicers, maxServicerReward - burnAmount)
552-
burnTokens(relayChain, geoZone, burnAmount)
552+
burnTokens(Service, geoZone, burnAmount)
553553
}
554554
```</p><h4>Preceded By:</h4>
555555
<p>1. Block Reward Policy Aggregate</p><h4>Domain Spaces:</h4>
@@ -591,4 +591,4 @@ <h4>Logic:</h4>
591591
<p>1. Modify DAO POKT Space</p><h4>State Updates:</h4>
592592
<p>1. DAO.POKT Holdings</p><h4>Constraints:</h4>
593593
<h4>Logic:</h4>
594-
<p>The DAO has its holdings increased by the value</p><h2>Parameters</h2><p>minimum_test_score_threshold</p><p>validator_fee_percentage</p><p>max_bootstrap_servicer_cost_per_relay</p><p>dao_fee_percentage</p><p>block_proposer_allocation</p><p>maturity_relay_charge</p><p>gateway_bootstrap_unwind_end</p><p>application_fee_per_relay</p><p>minimum_report_card_threshold</p><p>portal_fee_per_relay</p><p>min_bootstrap_gateway_fee_per_relay</p><p>gateway_bootstrap_unwind_start</p><p>relays_to_tokens_multiplier</p><p>maturity_relay_cost</p><p>servicer_bootstrap_unwind_start</p><p>servicer_bootstrap_end</p><p>transaction_fee</p>
594+
<p>The DAO has its holdings increased by the value</p><h2>Parameters</h2><p>maturity_relay_cost</p><p>gateway_bootstrap_unwind_end</p><p>validator_fee_percentage</p><p>transaction_fee</p><p>block_proposer_allocation</p><p>servicer_bootstrap_unwind_start</p><p>gateway_bootstrap_unwind_start</p><p>minimum_test_score_threshold</p><p>dao_fee_percentage</p><p>portal_fee_per_relay</p><p>servicer_bootstrap_end</p><p>minimum_report_card_threshold</p><p>relays_to_tokens_multiplier</p><p>min_bootstrap_gateway_fee_per_relay</p><p>application_fee_per_relay</p><p>max_bootstrap_servicer_cost_per_relay</p><p>maturity_relay_charge</p>

0 commit comments

Comments
 (0)