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

display embedded mainnet_rules article on reward system UI front page #1890

Merged
merged 1 commit into from
Oct 24, 2024
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
30 changes: 30 additions & 0 deletions cmd/skywire-cli/commands/reward/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,55 @@
package clireward

import (
"bytes"
"fmt"
"os"
"regexp"

markdown "github.com/MichaelMure/go-term-markdown"
"github.com/spf13/cobra"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
"github.com/yuin/goldmark/renderer/html"
"golang.org/x/term"

"github.com/skycoin/skywire"
)

var asHTML bool
var rawFile bool

func init() {
rewardCmd.AddCommand(rulesCmd)
rulesCmd.Flags().BoolVarP(&asHTML, "html", "l", false, "render html from markdown")
rulesCmd.Flags().BoolVarP(&rawFile, "raw", "r", false, "print raw the embedded file")
}

var rulesCmd = &cobra.Command{
Use: "rules",
Short: "display the mainnet rules",
Long: "display the mainnet rules",
Run: func(_ *cobra.Command, _ []string) {
if rawFile {
fmt.Println(skywire.MainnetRules)
os.Exit(0)
}
if asHTML {
// Preprocess to replace ~text~ with ~~text~~ for strikethrough
re := regexp.MustCompile(`~(.*?)~`)
rules := re.ReplaceAllString(skywire.MainnetRules, "~~$1~~")
var buf bytes.Buffer
md := goldmark.New(
goldmark.WithExtensions(extension.Strikethrough),
goldmark.WithRendererOptions(html.WithXHTML()), // Optional: add XHTML compatibility
)
if err := md.Convert([]byte(rules), &buf); err != nil {
fmt.Println("Error rendering markdown as HTML:", err)
os.Exit(1)
}
fmt.Println(buf.String())
os.Exit(0)
}
terminalWidth, _, err := term.GetSize(int(os.Stdout.Fd()))
if err != nil {
terminalWidth = 80
Expand Down
11 changes: 10 additions & 1 deletion cmd/skywire-cli/commands/rewards/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,11 @@ func mainPage(c *gin.Context) {
fmt.Println("Error parsing Front Page template:", err1)
}
tmpl := tmpl0

mainnetRulesHtml, _ := script.Exec(`skywire cli reward rules -l`).String() //nolint
skywireVersion, _ := script.Exec(`skywire -v`).Replace("skywire version ", "").String() //nolint
htmlPageTemplateData1 := htmlPageTemplateData
htmlPageTemplateData1.Content = htmpl.HTML(skycoinlogohtml) //nolint
htmlPageTemplateData1.Content = htmpl.HTML(skywireVersion + "<br>" + skycoinlogohtml + "<br>" + mainnetRulesHtml) //nolint
tmplData := map[string]interface{}{
"Page": htmlPageTemplateData1,
}
Expand Down Expand Up @@ -1540,6 +1543,12 @@ var htmlHeadTemplate = `<head>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=4.9,'>
<title title='{{.Page.Title}}'>{{.Page.Title}}</title>
<style type='text/css'>
a {
color: #3399FF;
}
a:visited {
color: #FF00FF;
}
pre {
font-family:mononokiregular;
font-size:10pt;
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ require (
github.com/tidwall/pretty v1.2.1
github.com/toqueteos/webbrowser v1.2.0
github.com/xtaci/kcp-go v5.4.20+incompatible
github.com/yuin/goldmark v1.4.13
github.com/zcalusic/sysinfo v1.1.2
go.etcd.io/bbolt v1.3.11
golang.org/x/net v0.30.0
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,7 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zcalusic/sysinfo v1.1.2 h1:38KUgZQmCxlN9vUTt4miis4rU5ISJXGXOJ2rY7bMC8g=
github.com/zcalusic/sysinfo v1.1.2/go.mod h1:NX+qYnWGtJVPV0yWldff9uppNKU4h40hJIRPf/pGLv4=
Expand Down
51 changes: 26 additions & 25 deletions mainnet_rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,15 @@

The required minimum Skywire version will be incremented periodically.

#### Table of Contents
* [Introduction](#introduction)
* [Uptime Reward Pool](#uptime-reward-pool)
* [Rules & Requirements](#rules--requirements)
* [Exceptions](#exceptions-for-deployment-changes-with-dmsghttp-config-chinese-users)
* [Verifying Requirements & Eligibility](#verifying-requirements--eligibility)
* [Version](#version)
* [Deployment](#deployment)
* [Uptime](#uptime)
* [Deployment](#deployment)
* [Skycoin Address](#skycoin-address)
* [Connection to DMSG network](#connection-to-dmsg-network)
* [Verifying other requirements](#verifying-other-requirements)
* [Reward System Overview](#reward-system-overview)
* ~~[Hardware](#hardware)~~

## Introduction

<div align="center"><em> Updates to this article will be followed by a notification via the <a href="https://t.me/SkywirePSA">official Skywire PSA channel</a> on Telegram.</em>
</div>
<br>

All information about rewards will be published here. Please ask for clarification in the [@skywire](https://t.me/skywire) Telegram channel if some things appear to not be covered. Please join [@SkywirePSA](https://t.me/SkywirePSA) for public service announcements (PSA) regarding the skywire network, update notices, changes to this article, etc.
All information about rewards will be published here. Please ask for clarification in the [@skywire](https://t.me/skywire) Telegram channel if some things appear to not be covered.

Please join [@SkywirePSA](https://t.me/SkywirePSA) for public service announcements (PSA) regarding the skywire network, update notices, changes to this article, etc.

Reward distribution notifications are on telegram [@skywire_reward](https://t.me/skywire_reward).

Expand Down Expand Up @@ -95,13 +81,17 @@ to circumvent ISP blocking of http requests.

In order to bootstrap the visor's to connection to the dmsg network (via TCP connection to an individual dmsg server) the [dmsghttp-config.json](/dmsghttp-config.json) is provided with the skywire binary release.

In the instance that the skywire production deployment changes - specifically the dmsg servers - it will be necessary to update to the next version or package release which fixes the dmsg servers - or else to manually update the [dmsghttp-config.json](/dmsghttp-config.json) which is provided by your skywire installation.
In the instance that the skywire production deployment changes - specifically the dmsg servers:
* it will be necessary to update to the next version or package release which fixes the dmsg servers.
OR
* it will be necessary to manually update the [dmsghttp-config.json](/dmsghttp-config.json) which is provided by your skywire installation.

Currently, **there is no mechanism for updating the dmsghttp-config.json which does not require an http request** ; a request which may be blocked depending on region.

In this instance, the visor will not connect to any service because it is not connected to the dmsg network, so it will not be possible for the visor to accumulate uptime or for the reward system to collect the survey, which are prerequisites for reward eligibility.

As a consequence of this; any visors running a dmsghttp-config, and hence any visors running in regions such as China, the minimum version requirement for obtaining rewards is not only the latest available version, but __the latest release of the package__ unless the dmsghttp-config.json is updated manually within your installation.
As a consequence of this; any visors running a dmsghttp-config, and hence any visors running in regions such as China, the minimum version requirement for obtaining rewards is not only the latest available version,
but __the latest release of the package__ unless the dmsghttp-config.json is updated manually within your installation.

## Verifying Requirements & Eligibility

Expand Down Expand Up @@ -140,7 +130,9 @@ The service configuration will be automatically updated any time a config is gen

For those visors in china or those running a dmsghttp-config, compare the dmsghttp-config of your current installation with the dmsghttp-config on the develop branch of [github.com/skycoin/skywire](https://github.com/skycoin/skywire)

The same data in a different format should be displayed in the [dmsg-discovery all_servers](https://dmsgd.skywire.skycoin.com/dmsg-discovery/all_servers) page. Ensure that the dmsghttp-config.json in your installation has the same ip addresses and ports for the dmsg server keys. The data from the dmsg discovery should be considered authoritative or current.
The same data in a different format should be displayed in the [dmsg-discovery all_servers](https://dmsgd.skywire.skycoin.com/dmsg-discovery/all_servers) page. Ensure that the dmsghttp-config.json in your installation has the same ip addresses and ports for the dmsg server keys.

The data from the dmsg discovery should be considered authoritative or current.

### Uptime

Expand Down Expand Up @@ -282,11 +274,16 @@ If your visor is not generating such logging or errors are indicated, please rea

### Transportability

It is not required that a visor run any service, such as a vpn or socks5 proxy server, whichpermitsdirect access tothe internet from yor ip address. However, it is required that the visor is able to act as a hop along a route. A module is active at runtime which checks that transports may be established to that visor - the visor crates a dmsg transport to itself every few minutes to ensure transportability. If it's not possible to create a dmsg transport to the same visor after three attempts,the visor will shut down automatically. **It is expected that the visor will be restarted by a process control mechanism if the visor shuts down for any reason.** In the officially supported linux packages, systemd will restart the visor if it stops; regardless of the exit status of the process.
It is not required that a visor run any service, such as a vpn or socks5 proxy server, which permits direct access to the internet from your ip address.
However, it is required that the visor is able to act as a hop along a route.
A module is active at runtime which checks that transports may be established to that visor - the visor creates a dmsg transport to itself every few minutes to ensure transportability.
If it's not possible to create a dmsg transport to the same visor after three attempts,the visor will shut down automatically.
**It is expected that the visor will be restarted by a process control mechanism if the visor shuts down for any reason.** In the officially supported linux packages, systemd will restart the visor if it stops; regardless of the exit status of the process.

### Transport setup node

Previously, the transport setup node was run continuously as part of the reward system to ensure that visors were responding as expected to transport setup-node requests. However, there were intermittent issues with reliability of the results ; because there is no caching mechanism for responsiveness to transport setup-node requests as there exists for uptime.
Previously, the transport setup node was run continuously as part of the reward system to ensure that visors were responding as expected to transport setup-node requests.
However, there were intermittent issues with reliability of the results ; because there is no caching mechanism for responsiveness to transport setup-node requests as there exists for uptime.

Currently, the transport setup-nodes which are configured for the visor are included in the survey and verified as an eligibility requirement for rewards by the reward system.

Expand Down Expand Up @@ -335,8 +332,6 @@ skywire cli log
```
along with transport bandwidth logs.

~~A survey of transports which have been set by transport setup-nodes are also collected hourly, from all visors which have had surveys collected~~

The index of the collected files may be viewed at [fiber.skywire.dev/log-collection/tree](https://fiber.skywire.dev/log-collection/tree)

Once collected from the nodes, the surveys for those visors which met uptime are checked to verify hardware and other requirements, etc.
Expand All @@ -349,7 +344,11 @@ The public keys which require to be whitelisted in order to collect the surveys,

## Reward System Funding & Distributions

The reward system is funded on a monthly basis. **Sometimes there are unexpected or unavoidable delays in the funding.** In these instances, rewards will be distributed based on the data generated when the system is funded. In some instances, it's necessary to discard previous reward data and do multiple distributions to handle backlog of reward system funds. We do our best to ensure fair reward distribution, but the system itself is not infinitely flexible. If there is no good way to rectify historical or undistributed rewards backlog, it will be distributed going forward as multiple distributions on the same day.
The reward system is funded on a monthly basis. **Sometimes there are unexpected or unavoidable delays in the funding.** In these instances, rewards will be distributed based on the data generated when the system is funded.
In some instances, it's necessary to discard previous reward data and do multiple distributions to handle backlog of reward system funds.

**We do our best to ensure fair reward distribution** - but the system itself is not infinitely flexible.
If there is no good way to rectify historical or undistributed rewards backlog, it will be distributed going forward as multiple distributions on the same day to those current active participants in the network.

## Deployment Outages

Expand All @@ -360,3 +359,5 @@ The policy for handling rewards in the instance of a deployment outage is to rep
## Hardware

As of November 2024, skywire rewards are open to all computer hardware and architectures.

If there is not a release for your desired architecture, we can attempt to add it, on request.
19 changes: 19 additions & 0 deletions vendor/github.com/yuin/goldmark/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions vendor/github.com/yuin/goldmark/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions vendor/github.com/yuin/goldmark/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading