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

Remove support for submitting with PoW #436

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
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
1 change: 0 additions & 1 deletion docs/poet_config_sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ epoch-duration=336h
phase-shift=240h
cycle-gap=12h
jsonlog=true
pow-difficulty=20
metrics-port=2222
debuglog=true
14 changes: 5 additions & 9 deletions docs/poet_operator_manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ You can think about PoET like an HTTP web service with a twist.

## PoET important endpoints

* `https://POET_URL/v1/pow_params`
nodes will query that URL to get the POW challenge parameters.
it will change every round, safe to cache in all other moments.
* `https://POET_URL/v1/info`
contains the current round id and the current round state. Nodes currently don't actively use that endpoint besides querying and checking if poet is alive. Safe to cache and invalidate when round state changes.
* `https://POET_URL/v1/submit`
nodes will submit their PoET proofs to that endpoint. *Never cache*. The POW serves as a rate-limiting factor and is meant to protect PoET from DOS.
The higher the value of `pow-difficulty`, the bigger the protection but also more burden on the nodes.
* `https://POET_UR/v1/proofs/{round_id}`
nodes will submit their PoET proofs to that endpoint. *Never cache*.
* `https://POET_URL/v1/proofs/{round_id}`
nodes will query that endpoint to get the PoET proofs for a given round. Once data is there then valid forever. Safe to cache.

PoET exposes the above API as:
Expand All @@ -23,15 +19,15 @@ PoET exposes the above API as:

The reference node implementation [go-spacemesh](https://github.com/spacemeshos/go-spacemesh) expects the REST API so it's recommended to expose it publicly. Exposing GRPC is not required.

> [!NOTE]
> [!NOTE]
> We're working to expose the cache time for all the endpoints to safely cache that on the cache servers https://github.com/spacemeshos/poet/issues/330

## PoET Overview
Poet round have two states `open` `in-progress`.
* `open` others can submit to the given round
* `in-progress` no more submissions are allowed AND PoET builds PoSW (a merkle tree)

When the round is open poet is pretty much a web application with people using `info` `pow_params` `submit` endpoints. There is a metric `grpc_server_handled_total` that will give the exact numbers etc more info in (#metrics).
When the round is open poet is pretty much a web application with people using `info`, `submit`, `proof` endpoints. There is a metric `grpc_server_handled_total` that will give the exact numbers etc more info in (#metrics).

### Config files

Expand Down Expand Up @@ -71,7 +67,7 @@ You can also use that logic to estimate needed disk performance and IOps. But HD

You *must* make sure that the data is persisted. The existence of the tree is essential to generate proof for a given round. If the tree is not there then it's not possible to generate the proof. The proof is a Merkle Proof proving selected `T` leaves from the tree and basically contains selected nodes from the tree.

> [!NOTE]
> [!NOTE]
> PoET will *not* start generating tree when it will detect that the round should be already in progress but the state of the round is empty. This is to prevent the situation when PoET is doing work for nothing

## Performance fine tunning
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/spacemeshos/poet
go 1.21.4

require (
github.com/c0mm4nd/go-ripemd v0.0.0-20200326052756-bd1759ad7d10
github.com/google/uuid v1.4.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/c0mm4nd/go-ripemd v0.0.0-20200326052756-bd1759ad7d10 h1:wJ2csnFApV9G1jgh5KmYdxVOQMi+fihIggVTjcbM7ts=
github.com/c0mm4nd/go-ripemd v0.0.0-20200326052756-bd1759ad7d10/go.mod h1:mYPR+a1fzjnHY3VFH5KL3PkEjMlVfGXP7c8rbWlkLJg=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand Down
3 changes: 0 additions & 3 deletions registration/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ func DefaultConfig() Config {
}

type Config struct {
// FIXME: remove deprecated PoW
PowDifficulty uint `long:"pow-difficulty" description:"(DEPRECATED) PoW difficulty (in the number of leading zero bits)"`

MaxRoundMembers int `long:"max-round-members" description:"the maximum number of members in a round"`
MaxSubmitBatchSize int `long:"max-submit-batch-size" description:"The maximum number of challenges to submit in a single batch"`
SubmitFlushInterval time.Duration `long:"submit-flush-interval" description:"The interval between flushes of the submit queue"`
Expand Down
51 changes: 0 additions & 51 deletions registration/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ package registration
import (
"bytes"
"context"
"errors"
"fmt"

xdr "github.com/nullstyle/go-xdr/xdr3"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/opt"
"go.uber.org/zap"

"github.com/spacemeshos/poet/logging"
"github.com/spacemeshos/poet/shared"
)

Expand Down Expand Up @@ -87,54 +84,6 @@ func (db *database) GetProof(ctx context.Context, roundID string) (*proofData, e
return proof, nil
}

func (db *database) SavePowChallenge(ctx context.Context, challenge []byte) error {
tx, err := db.db.OpenTransaction()
if err != nil {
return err
}

current, err := tx.Get([]byte("pow_challenge"), nil)
switch {
case errors.Is(err, leveldb.ErrNotFound):
// do nothing
case err != nil:
tx.Discard()
return fmt.Errorf("querying current pow challenge: %w", err)
default:
if err := tx.Put([]byte("pow_challenge_previous"), current, nil); err != nil {
logging.FromContext(ctx).Warn("failed to save previous pow challenge", zap.Error(err))
}
}
if err := tx.Put([]byte("pow_challenge"), challenge, nil); err != nil {
tx.Discard()
return fmt.Errorf("saving pow challenge: %w", err)
}
return tx.Commit()
}

func (db *database) GetPowChallenges(ctx context.Context) (current, previous []byte, err error) {
tx, err := db.db.OpenTransaction()
if err != nil {
return nil, nil, err
}

current, err = tx.Get([]byte("pow_challenge"), nil)
if err != nil {
tx.Discard()
return nil, nil, fmt.Errorf("getting current pow challenge: %w", err)
}
previous, err = tx.Get([]byte("pow_challenge_previous"), nil)
switch {
case errors.Is(err, leveldb.ErrNotFound):
previous = nil
case err != nil:
tx.Discard()
return nil, nil, fmt.Errorf("getting previous pow challenge: %w", err)
}
tx.Commit()
return current, previous, nil
}

func serializeProof(proof proofData) ([]byte, error) {
var dataBuf bytes.Buffer
_, err := xdr.Marshal(&dataBuf, proof)
Expand Down
151 changes: 0 additions & 151 deletions registration/mocks/pow_verifier.go

This file was deleted.

Loading