Skip to content

Commit

Permalink
added docker usage documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
0xluk committed Feb 19, 2024
1 parent f24d6ce commit 64e0118
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ COPY fourq_verify /app/fourq_verify
RUN chmod +x /app/go-archiver
RUN chmod +x /app/fourq_verify

EXPOSE 21841
EXPOSE 21842
EXPOSE 8000
EXPOSE 8001

WORKDIR /app

Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# go-archiver
# docker run -v /root/store:/app/store --name qubic-archiver --restart=always -d ghcr.io/qubic/qubic-archiver

## Docker usage:
When running the docker container, you need to specify the following environment variables:
- `QUBIC_ARCHIVER_QUBIC_NODE_IP` - the IP address of the Qubic node that archiver will connect to
- `QUBIC_ARCHIVER_QUBIC_FALLBACK_TICK` - the start tick for the archiver to start archiving from (needs to be from current epoch)
```bash
$ docker run -p 8000:8000 -p 8001:8001 -e QUBIC_ARCHIVER_QUBIC_NODE_IP="212.51.150.253" -e QUBIC_ARCHIVER_QUBIC_FALLBACK_TICK=12543674 -v /root/store:/app/store --name qubic-archiver -d ghcr.io/qubic/qubic-archiver
```
8 changes: 3 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ func main() {
func run() error {
var cfg struct {
Server struct {
GrpcHost string `conf:"default:0.0.0.0:21841"`
HttpHost string `conf:"default:0.0.0.0:21842"`
ReadTimeout time.Duration `conf:"default:5s"`
WriteTimeout time.Duration `conf:"default:5s"`
ShutdownTimeout time.Duration `conf:"default:5s"`
Expand All @@ -39,7 +37,7 @@ func run() error {
NodeIp string `conf:"default:212.51.150.253"`
NodePort string `conf:"default:21841"`
FallbackTick uint64 `conf:"default:12543674"`
BatchSize uint64 `conf:"default:500"`
BatchSize uint64 `conf:"default:500"`
}
}

Expand Down Expand Up @@ -69,15 +67,15 @@ func run() error {
}
log.Printf("main: Config :\n%v\n", out)

db, err := pebble.Open("demo", &pebble.Options{})
db, err := pebble.Open("store", &pebble.Options{})
if err != nil {
log.Fatalf("err opening pebble: %s", err.Error())
}
defer db.Close()

ps := store.NewPebbleStore(db, nil)

rpcServer := rpc.NewServer("0.0.0.0:21841", "0.0.0.0:21842", ps, nil)
rpcServer := rpc.NewServer("0.0.0.0:80001", "0.0.0.0:8000", ps, nil)
rpcServer.Start()

shutdown := make(chan os.Signal, 1)
Expand Down
22 changes: 15 additions & 7 deletions validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

type Validator struct {
qu *qubic.Connection
qu *qubic.Connection
store *store.PebbleStore
}

Expand All @@ -24,18 +24,20 @@ func NewValidator(qu *qubic.Connection, store *store.PebbleStore) *Validator {
}

func (v *Validator) ValidateTick(ctx context.Context, tickNumber uint64) error {
ctx, cancel := context.WithTimeout(context.Background(), 5 * time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

quorumVotes, err := v.qu.GetQuorumVotes(ctx, uint32(tickNumber))
if err != nil {
return errors.Wrap(err, "getting quorum tick data")
}

//
if len(quorumVotes) == 0 {
return errors.New("not quorum votes fetched")
}

//getting computors from storage, otherwise get it from a node
epoch := quorumVotes[0].Epoch
var comps types.Computors
comps, err = computors.Get(ctx, v.store, uint64(epoch))
Expand All @@ -48,24 +50,29 @@ func (v *Validator) ValidateTick(ctx context.Context, tickNumber uint64) error {
if err != nil {
return errors.Wrap(err, "getting computors from qubic")
}

err = computors.Store(ctx, v.store, comps)
if err != nil {
return errors.Wrap(err, "storing computors")
}
}

err = computors.Validate(ctx, comps)
if err != nil {
return errors.Wrap(err, "validating comps")
}
//log.Println("Computors validated")
err = computors.Store(ctx, v.store, comps)
if err != nil {
return errors.Wrap(err, "storing computors")
}

err = quorum.Validate(ctx, quorumVotes, comps)
if err != nil {
return errors.Wrap(err, "validating quorum")
}

// if the quorum votes have an empty tick data, it means that POTENTIALLY there is no tick data, it doesn't for
// validation, but we may need to fetch it in the future ?!
if quorumVotes[0].TxDigest == [32]byte{} {
return nil
}

log.Println("Quorum validated")

tickData, err := v.qu.GetTickData(ctx, uint32(tickNumber))
Expand Down Expand Up @@ -95,6 +102,7 @@ func (v *Validator) ValidateTick(ctx context.Context, tickNumber uint64) error {

log.Printf("Validated %d transactions\n", len(validTxs))

// proceed to storing tick information
err = quorum.Store(ctx, v.store, quorumVotes)
if err != nil {
return errors.Wrap(err, "storing quorum votes")
Expand Down

0 comments on commit 64e0118

Please sign in to comment.