Skip to content

Commit

Permalink
fix: fix katex shortcode and EC, leader election and Poisson sortitio…
Browse files Browse the repository at this point in the history
…n update (#1066)

This PR is applying all the latest changes in the Expected Consensus, Leader Election and the rationale behind Poisson Sortition of WinCount. It builds on top of the changes merged from #967

Tooling:
- katex shortcode documented and working
- markdown linter actually fails now

Co-authored-by: Hugo Dias <hugomrdias@gmail.com>
  • Loading branch information
yiannisbot and hugomrdias authored Sep 26, 2020
1 parent d2f3a5b commit 8bf3e43
Show file tree
Hide file tree
Showing 10 changed files with 304 additions and 64 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{*.yml}]
indent_style = space
indent_size = 2

[*.md]
indent_style = space
indent_size = 2
trim_trailing_whitespace = false
3 changes: 2 additions & 1 deletion .remarkrc.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins:
# make remark aware of fontmatter.
remark-frontmatter:
remark-math:
# sensible linter defaults see: https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended#rules
remark-preset-lint-recommended:
# add extra rules
Expand All @@ -12,4 +13,4 @@ plugins:
remark-lint-list-item-indent: false
remark-lint-final-newline: false
remark-lint-no-literal-urls: false
remark-lint-list-item-bullet-indent: false
remark-lint-list-item-bullet-indent: false
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,22 @@ stringit, frustra Saturnius uteroque inter! Oculis non ritibus Telethusa
{{< /hint >}}
```

### `katex`

```md

<!-- Use $$ math $$ for display mode-->
{{<katex>}}
$$SectorInitialConsensusPledge = \\[0.2cm] 30\% \times FILCirculatingSupply \times \frac{SectorQAP}{max(NetworkBaseline, NetworkQAP)}$$
{{</katex >}}


<!-- Use $ math $ for inline mode-->
{{<katex>}}
$SectorInitialConsensusPledge = \\[0.2cm] 30\% \times FILCirculatingSupply \times \frac{SectorQAP}{max(NetworkBaseline, NetworkQAP)}$
{{</katex >}}
```

## Math mode

For short snippets of math text you can just use the `{{<katex>}}` shortcode, but if you need to write lots of math in a page you can just use `math-mode` and avoid writting the katex shortcode everywhere.
Expand Down Expand Up @@ -380,4 +396,4 @@ hugo mod get github.com/filecoin-project/specs-actors@v0.7.2
- [config](https://github.com/mermaid-js/mermaid/blob/master/docs/mermaidAPI.md#mermaidapi-configuration-defaults)
- [editor](https://mermaid-js.github.io/mermaid-live-editor)
- [Pan/Zoom for SVG](https://github.com/anvaka/panzoom)
- [Icons](https://css.gg/)
- [Icons](https://css.gg/)
302 changes: 259 additions & 43 deletions content/algorithms/expected_consensus/_index.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion content/systems/filecoin_files/piece/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ dashboardTests: 0
---

# The Filecoin Piece
---

The _Filecoin Piece_ is the main _unit of negotiation_ for data that users store on the Filecoin network. The Filecoin Piece is _not a unit of storage_, it is not of a specific size, but is upper-bounded by the size of the _Sector_. A Filecoin Piece can be of any size, but if a Piece is larger than the size of a Sector that the miner supports it has to be split into more Pieces so that each Piece fits into a Sector.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ This collateral is returned to the storage provider when all deals in the sector


{{<katex>}}
MinimumProviderDealCollateral = \\[0.2cm] \ \ \ \ \ \ \ \ 5\% \times FILCirculatingSupply \times \frac{DealRawByte}{max(NetworkBaseline, NetworkRawBytePower)}
$MinimumProviderDealCollateral = \\[0.2cm] \ \ \ \ \ \ \ \ 5\% \times FILCirculatingSupply \times \frac{DealRawByte}{max(NetworkBaseline, NetworkRawBytePower)}$
{{</katex>}}
8 changes: 4 additions & 4 deletions content/systems/filecoin_mining/miner_collaterals.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ Hence, the initial pledge function consists of two components: a _storage pledge

{{<katex>}}

SectorInitialPledge = SectorInitialStoragePledge + SectorInitialConsensusPledge \\[0.3cm]
$$SectorInitialPledge = SectorInitialStoragePledge + SectorInitialConsensusPledge \\[0.3cm]$$

{{</katex>}}

The storage pledge protects the networkʼs quality-of-service for clients by providing starting collateral for the sector in the event of slashing. The storage pledge must be small enough to be feasible for miners joining the network, and large enough to collateralize storage against early faults, penalties, and fees. The vesting of block rewards and the use of unvested rewards as additional collateral reduces initial storage pledge without compromising the incentive alignment of the network. This is discussed in more depth in the following subsection. A balance is achieved by using an initial storage pledge amount approximately sufficient to cover 7 days worth of Sector fault fee and 1 Sector fault detection fee. This is denominated in the number of days of future rewards that a sector is expected to earn.

{{<katex>}}

SectorInitialStoragePledge = Estimated20DaysSectorBlockReward \\[0.3cm]
$$SectorInitialStoragePledge = Estimated20DaysSectorBlockReward \\[0.3cm]$$

{{</katex>}}

Since the storage pledge per sector is based on the expected block reward that sector will win, the storage pledge is independent of the networkʼs total storage. As a result, the total network storage pledge depends solely on future block reward. Thus, while the storage pledge provides a clean way to reason about the rationality of adding a sector, it does not provide sufficient long-term security guarantees to the network, making consensus takeovers less costly as the block reward decreases. As such, the second half of the initial pledge function, the consensus pledge, depends on both the amount of quality-adjusted power (QAP) added by the sector and the network circulating supply. The network targets approximately 30% of the network's circulating supply locked up in initial consensus pledge when it is at or above the baseline. This is achieved with a small pledge share allocated to sectors based on their share of the networkʼs quality-adjusted power. Given an exponentially growing baseline, initial pledge per unit QAP should decrease over time, as should other mining costs.

{{<katex>}}

SectorInitialConsensusPledge = \\[0.2cm] 30\% \times FILCirculatingSupply \times \frac{SectorQAP}{max(NetworkBaseline, NetworkQAP)}
$$SectorInitialConsensusPledge = \\[0.2cm] 30\% \times FILCirculatingSupply \times \frac{SectorQAP}{max(NetworkBaseline, NetworkQAP)}$$

{{</katex>}}

Expand All @@ -56,4 +56,4 @@ In general, fault fees are slashed first from the soonest-to-vest unvested block

## Storage Deal Collateral

The third form of collateral is provided by the storage provider to collateralize deals. See the [Storage Market Actor](storage_market_actor) for further details on the Storage Deal Collateral.
The third form of collateral is provided by the storage provider to collateralize deals. See the [Storage Market Actor](storage_market_actor) for further details on the Storage Deal Collateral.
1 change: 0 additions & 1 deletion content/systems/filecoin_mining/sector/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ dashboardTests: 0
---

# Sector
---

Sectors are the basic units of storage on Filecoin. They have standard sizes, as well as well-defined time-increments for commitments. The size of a sector balances security concerns against usability. A sectorʼs lifetime is determined in the storage market, and sets the promised duration of the sector.

Expand Down
12 changes: 1 addition & 11 deletions layouts/shortcodes/katex.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
{{- if not (.Page.Scratch.Get "katex") -}}
<!-- Include katext only first time -->
<link rel="stylesheet" href="{{ "katex/katex.min.css" | relURL }}" />
<script defer src="{{ "katex/katex.min.js" | relURL }}"></script>
<script defer src="{{ "katex/auto-render.min.js" | relURL }}" onload="renderMathInElement(document.body);"></script>
{{- .Page.Scratch.Set "katex" true -}}
{{- end -}}

<span {{- with .Get "class" }} class="{{ . }}"{{ end }}>
{{ cond (in .Params "display") "\\[" "\\(" -}}
<span class="math-mode">
{{- trim .Inner "\n" -}}
{{- cond (in .Params "display") "\\]" "\\)" }}
</span>
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "The Filecoin protocol specification",
"main": "index.js",
"scripts": {
"test": "remark content --quiet",
"test": "remark content --frail --quiet",
"start": "concurrently npm:watch-*",
"serve": "npm start",
"watch-hugo": "npm run build-diagrams && hugo server --bind=0.0.0.0 --disableFastRender --renderToDisk",
Expand Down Expand Up @@ -44,6 +44,7 @@
"remark-lint-heading-increment": "^2.0.1",
"remark-lint-no-hr-after-heading": "^1.0.0",
"remark-lint-no-multiple-toplevel-headings": "^2.0.1",
"remark-math": "^3.0.1",
"remark-preset-lint-recommended": "^4.0.1",
"remark-toc": "^7.0.0",
"to-vfile": "^6.1.0"
Expand Down

0 comments on commit 8bf3e43

Please sign in to comment.