Skip to content

Hammer2 #180

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

Merged
merged 15 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
114 changes: 89 additions & 25 deletions Testing.ipynb

Large diffs are not rendered by default.

930 changes: 641 additions & 289 deletions reports/Basic Report.html

Large diffs are not rendered by default.

174 changes: 87 additions & 87 deletions reports/actions/Application Stake.html

Large diffs are not rendered by default.

229 changes: 229 additions & 0 deletions reports/actions/Application Unstake.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
<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"?>

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"

"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<!-- Generated by graphviz version 2.48.0 (0)

-->

<!-- Title: Application Unstake Pages: 1 -->

<svg width="468pt" height="497pt"

viewBox="0.00 0.00 467.98 497.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 493)">

<title>Application Unstake</title>

<polygon fill="white" stroke="transparent" points="-4,4 -4,-493 463.98,-493 463.98,4 -4,4"/>

<!-- Application -->

<g id="node1" class="node">

<title>Application</title>

<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"/>

<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"/>

<text text-anchor="middle" x="219.74" y="-467.3" font-family="Times,serif" font-size="14.00">Application</text>

</g>

<!-- Application Unstake -->

<g id="node2" class="node">

<title>Application Unstake</title>

<polygon fill="orange" stroke="orange" points="219.74,-416 98.58,-398 219.74,-380 340.9,-398 219.74,-416"/>

<text text-anchor="middle" x="219.74" y="-394.3" font-family="Times,serif" font-size="14.00">Application Unstake</text>

</g>

<!-- Application&#45;&gt;Application Unstake -->

<g id="edge1" class="edge">

<title>Application&#45;&gt;Application Unstake</title>

<path fill="none" stroke="black" d="M219.74,-452.81C219.74,-444.79 219.74,-435.05 219.74,-426.07"/>

<polygon fill="black" stroke="black" points="223.24,-426.03 219.74,-416.03 216.24,-426.03 223.24,-426.03"/>

</g>

<!-- Application Unstake Policy -->

<g id="node3" class="node">

<title>Application Unstake Policy</title>

<polygon fill="red" stroke="red" points="305.24,-299 134.24,-299 134.24,-263 305.24,-263 305.24,-299"/>

<text text-anchor="middle" x="219.74" y="-277.3" font-family="Times,serif" font-size="14.00">Application Unstake Policy</text>

</g>

<!-- Application Unstake&#45;&gt;Application Unstake Policy -->

<g id="edge2" class="edge">

<title>Application Unstake&#45;&gt;Application Unstake Policy</title>

<path fill="none" stroke="black" d="M219.74,-379.53C219.74,-360.94 219.74,-331.24 219.74,-309.5"/>

<polygon fill="black" stroke="black" points="223.24,-309.25 219.74,-299.25 216.24,-309.25 223.24,-309.25"/>

<text text-anchor="middle" x="253.24" y="-350.8" font-family="Times,serif" font-size="14.00">Application</text>

<text text-anchor="middle" x="253.24" y="-335.8" font-family="Times,serif" font-size="14.00">Unstake</text>

<text text-anchor="middle" x="253.24" y="-320.8" font-family="Times,serif" font-size="14.00">Space</text>

</g>

<!-- Update Application Stake Status -->

<g id="node4" class="node">

<title>Update Application Stake Status</title>

<ellipse fill="#e0eeee" stroke="#e0eeee" cx="219.74" cy="-164" rx="128.88" ry="18"/>

<text text-anchor="middle" x="219.74" y="-160.3" font-family="Times,serif" font-size="14.00">Update Application Stake Status</text>

</g>

<!-- Application Unstake Policy&#45;&gt;Update Application Stake Status -->

<g id="edge3" class="edge">

<title>Application Unstake Policy&#45;&gt;Update Application Stake Status</title>

<path fill="none" stroke="black" d="M219.74,-262.53C219.74,-243.94 219.74,-214.24 219.74,-192.5"/>

<polygon fill="black" stroke="black" points="223.24,-192.25 219.74,-182.25 216.24,-192.25 223.24,-192.25"/>

<text text-anchor="middle" x="254.24" y="-233.8" font-family="Times,serif" font-size="14.00">Application</text>

<text text-anchor="middle" x="254.24" y="-218.8" font-family="Times,serif" font-size="14.00">Stake Status</text>

<text text-anchor="middle" x="254.24" y="-203.8" font-family="Times,serif" font-size="14.00">Space</text>

</g>

<!-- Application.Stake Status -->

<g id="node6" class="node">

<title>Application.Stake Status</title>

<ellipse fill="none" stroke="black" cx="100.74" cy="-91" rx="100.98" ry="18"/>

<text text-anchor="middle" x="100.74" y="-87.3" font-family="Times,serif" font-size="14.00">Application.Stake Status</text>

</g>

<!-- Update Application Stake Status&#45;&gt;Application.Stake Status -->

<g id="edge4" class="edge">

<title>Update Application Stake Status&#45;&gt;Application.Stake Status</title>

<path fill="none" stroke="black" d="M191.84,-146.35C175.58,-136.65 154.88,-124.3 137.32,-113.83"/>

<polygon fill="black" stroke="black" points="138.85,-110.66 128.47,-108.54 135.26,-116.67 138.85,-110.66"/>

</g>

<!-- Application.Unstaking Height -->

<g id="node7" class="node">

<title>Application.Unstaking Height</title>

<ellipse fill="none" stroke="black" cx="339.74" cy="-91" rx="120.48" ry="18"/>

<text text-anchor="middle" x="339.74" y="-87.3" font-family="Times,serif" font-size="14.00">Application.Unstaking Height</text>

</g>

<!-- Update Application Stake Status&#45;&gt;Application.Unstaking Height -->

<g id="edge5" class="edge">

<title>Update Application Stake Status&#45;&gt;Application.Unstaking Height</title>

<path fill="none" stroke="black" d="M247.88,-146.35C264.28,-136.65 285.15,-124.3 302.85,-113.83"/>

<polygon fill="black" stroke="black" points="304.96,-116.65 311.78,-108.54 301.39,-110.62 304.96,-116.65"/>

</g>

<!-- Application_2 -->

<g id="node5" class="node">

<title>Application_2</title>

<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"/>

<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"/>

<text text-anchor="middle" x="219.74" y="-14.3" font-family="Times,serif" font-size="14.00">Application</text>

</g>

<!-- Application.Stake Status&#45;&gt;Application_2 -->

<g id="edge6" class="edge">

<title>Application.Stake Status&#45;&gt;Application_2</title>

<path fill="none" stroke="black" d="M128.34,-73.53C144.6,-63.83 165.36,-51.45 182.99,-40.93"/>

<polygon fill="black" stroke="black" points="185.08,-43.75 191.88,-35.62 181.5,-37.74 185.08,-43.75"/>

</g>

<!-- Application.Unstaking Height&#45;&gt;Application_2 -->

<g id="edge7" class="edge">

<title>Application.Unstaking Height&#45;&gt;Application_2</title>

<path fill="none" stroke="black" d="M311.61,-73.35C295.32,-63.72 274.63,-51.48 257.01,-41.05"/>

<polygon fill="black" stroke="black" points="258.5,-37.87 248.12,-35.79 254.94,-43.89 258.5,-37.87"/>

</g>

</g>

</svg>
<h2>State</h2><h3>Local States</h3><h4>Application State</h4><table>
<tr>
<th>Name</th>
<th>Description</th>
<th>Type</th>
<th>Symbol</th>
<th>Domain</th>
</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>
<p>1. Application</p><h4>Constraints:</h4>
<h2>Policies</h2><h3>Application Unstake Policy</h3><p>The policy for determining what happens when an application unstakes.</p><h4>Preceded By:</h4>
<p>1. Application Unstake</p><h4>Domain Spaces:</h4>
<p>1. Application Unstake Space</p><h4>Followed By:</h4>
<p>1. Update Application Stake Status</p><h4>Codomain Spaces:</h4>
<h4>Constraints:</h4>
<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>
<p>1. Application Unstake Policy</p><h4>Domain Spaces:</h4>
<p>1. Application Stake Status Space</p><h4>State Updates:</h4>
<p>1. Application.Stake Status</p><p>2. Application.Unstaking Height</p><h4>Constraints:</h4>
<h4>Logic:</h4>
<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>
18 changes: 9 additions & 9 deletions reports/actions/Mint Block Rewards.html
Original file line number Diff line number Diff line change
Expand Up @@ -513,30 +513,30 @@
</g>

</svg>
<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.
<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.

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>
<p>1. Mint Block Rewards</p><h4>Domain Spaces:</h4>
<p>1. Mint Block Rewards Space</p><h4>Followed By:</h4>
<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>
<p>1. Mint POKT Mechanism Space</p><p>2. Assign Servicer Salary Space</p><p>3. Validator Block Reward Space</p><h4>Constraints:</h4>
<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.
<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.

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`.

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.
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.

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.

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

```go
// Called for each (relayChain, geoZone) pair every SessionBlockFrequency
func DistributeRewards(relayChain, geoZone, height):
totalVolumeUsage = WorldState.RetrieveTotalVolumeEstimate(relayChain, geoZone, height)
// Called for each (Service, geoZone) pair every SessionBlockFrequency
func DistributeRewards(Service, geoZone, height):
totalVolumeUsage = WorldState.RetrieveTotalVolumeEstimate(Service, geoZone, height)
totalAvailableReward = totalVolumeUsage * GovParams.UsageToRewardCoefficient(height)

allServicers = WorldState.RetrieveEligibleServicers(relayChain, geoZone, height)
allServicers = WorldState.RetrieveEligibleServicers(Service, geoZone, height)
eligibleServicers = filterServicers(allServicers, GovParams.MinimumTestScoreThreshold(height))

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

awardTokens(servicers, maxServicerReward - burnAmount)
burnTokens(relayChain, geoZone, burnAmount)
burnTokens(Service, geoZone, burnAmount)
}
```</p><h4>Preceded By:</h4>
<p>1. Block Reward Policy Aggregate</p><h4>Domain Spaces:</h4>
Expand Down Expand Up @@ -591,4 +591,4 @@ <h4>Logic:</h4>
<p>1. Modify DAO POKT Space</p><h4>State Updates:</h4>
<p>1. DAO.POKT Holdings</p><h4>Constraints:</h4>
<h4>Logic:</h4>
<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>
<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>
Loading