Skip to content

Commit

Permalink
Remove support for submitting with PoW
Browse files Browse the repository at this point in the history
  • Loading branch information
poszu committed Nov 27, 2023
1 parent ba98c66 commit f7afc10
Show file tree
Hide file tree
Showing 16 changed files with 146 additions and 914 deletions.
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
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

0 comments on commit f7afc10

Please sign in to comment.