Skip to content

Commit

Permalink
Updating libp2p again and bumping to v1.5.8 (#1268)
Browse files Browse the repository at this point in the history
* Updating libp2p again
* Make sure version is compat with v2

DKG refactor -> develop to unblock Florin (#1200)

- moved dkg package from core to root
- re-added demo project using the new DKG
- fixed first round of PR comments
- refactored test objects for easier readability in tests using alice, bob, carol
- extracted some action utilities and add helpful comments
- PrivateGateway now implements a DKG client for TLS
- added transition time flag to the DKG CLI
- fixed a lot of small bugs
- dkg kickoff grace period is now a daemon param and is reduced in the
test code
- added stop check to broadcaster
- moved stopped into echoBroadcast itself
- DKG requests are now sent in parallel to speed up execution
- use the internal clock correctly in the beacon handler

Final round of tests improvements (#1187)

* Test improvements
* Fix connectivity test
* Fix test after rebase
* Revert to computed round in test
* Do not use a package level variable for command output
* Allow node status to reply regardless of DKG state or params
* We expect at least the previous round to be caught up by now
* The sync mechanism will balance out and resolve the discrepancy, eventually.
* Speed up the orchestration tests shutdown
* A bit more sleep in test

test with retrive old beacon from new node (#761)

* test with retrive old beacon from new node

* Update to latest code changes

---------

Co-authored-by: Florin P膬葲an <florinpatan@gmail.com>

Handle error in test (#1212)

* Handle error in test

Fix typo in vault (#1213)

* Fix typo in vault

Allow logs to propagate to the test name (#1114)

* Make logger propagate across whole codebase
* Remove sleep in tests
* Remove deprecated sleep function
* Fix missing cancel function missing call

DKG migration tool from v1.* to v2.0.0 (#1215)

* DKG migration tool from v1.* to v2.0.0
* implemented the migration
* added a CLI command for running it automagically for each beaconID
* reload beacon upon migration
* added integration test for restoring node state from migration

run tests on develop (#1216)

improved output for DKG status command (#1218)

- fixed a bug where the transition time was 0 for initial DKG
- increased genesis time for tests due to the memdb test getting some
  weird sync deadlock

Add OpenTelemetry tracing instrumentation (#1199)

* OT tracing using a customizable endpoint

---------

Co-authored-by: Patrick McClurg <patrick.mcclurg@protocol.ai>
Co-authored-by: PM <3749956+CluEleSsUK@users.noreply.github.com>

show DKG status string instead of iota (#1221)

Removing redundant Expires header from server (#1191)

* Removing redundant Expires header from server

If there is a Cache-Control header with the max-age or s-maxage directive in the response, the Expires header is ignored.
Also reworking a few Cache-control max-age directives

Move to internal (#1214)

* Add OpenTelemetry tracing instrumentation
Initial commit for adding OT tracing using a customizable endpoint
Instrument the DKG code
Move everything to internal
Upgrade golangci-lint to 1.50.2 and correctly configure the imports linter
Allow Docker to build with the new paths
Align Go versions to 1.19.5 in both CI and Docker
Expose types to allow for Gossip client demo.
Drop WithLogger usage
More code cleanup. Stop using panic in tests
Allow clients to be built based on Lotus example and demo code
moved tracing docker-compose
* added details of tracing to the readme
* fixed import error
* extracted `crypto` module to top level
* ran GCI
---------
Co-authored-by: Patrick McClurg <patrick.mcclurg@protocol.ai>

cherry-picked commits from master (#1235)

* threshold monitoring for beacon processes (#1220)

* threshold monitoring for beacon processes

beacon processes now log some error and warning messages whenever we get
close to or cross a threshold number of failures per node

* return on finished threshold monitor

Co-authored-by: Yolan Romailler <AnomalRoil@users.noreply.github.com>

* added prometheus metric for failing to send partials (#1223)

* added prometheus metric for failing to send partials
* moved import around
* fixed tests
* made sleeps in the publicrandstream variable
- upped local sleep slightly

* aggregate prometheus partial errors by beaconID (#1232)

The additional fields in the partial error counter meant that a new
counter was created for _every_ combination. Given that they could only
be emitted for each round, a new entry was created for every partial...
which is definitely wrong

* use a gauge for counting nodes that have invalid partials (#1233)

* use a gauge for counting nodes that have invalid partials
strictly speaking this will lose sight of nodes that go down and back up
between prometheus polls; however it's much easier to handle in grafana

* combined threshold monitor and prometheus call

* return 404 when no beacon hash exists instead of 500 (#1234)

* return 404 when no beacon hash exists instead of 500
* add test for 404 on nonexistent chain

* cherry-picked master commits and fixed a few bits

---------

Co-authored-by: Yolan Romailler <AnomalRoil@users.noreply.github.com>
Co-authored-by: Houlton McGuinn <hoult.mcguinn@gmail.com>

Addressing comments for #1199 (#1236)

* fixing belated code review comments about 1199
* callback now has access to bp.log
* replacing otel.SpanContext with plain Context
* using new context for DKG update listeners
* using new context for broadcast
* using new context for sender run

Updating our dependencies to support Go 1.20 (#1238)

* Updating our dependencies to support Go 1.20

This also allows us to finally update to the latest grpc since our
blocking dependencies got updated too.

* Updating to protoc 3.20.3

* updating to golangci-lint 1.52.2

* updating to latest golangci

* Not on my watch

Automate DKG migration on startup (#1225)

* automate DKG migration on node startup
handle no such file or directory error as expected
fixed the workflow a little to ensure no nil references
check no such group file error specifically

DKG messages between participants are now signed and verified (#1229)

Miscellaneous fixes from merged reviews (#1237)

* added lots of comments to the state machine
* don't consume genesis beacon from others
* make transition time mandatory to CLI
* added a test around pretty printing
* added missing flag to demo project
* added missing tests

all DKG packets are now gossiped throughout the network (#1230)

* DKG messages between participants are now signed and verified

* all DKG packets are now gossiped throughout the network
* DKG RPCs are split into `Command`s and `GossipPacket`s
* the flow of execution is now a lot simpler and with fewer
  higher-order-function shenanigans

* remove the unnecessary (racy) brokenbroadcaster

* updated with the rebased signatures branch

* additional nil checks

* added DKG failed state in for DKGs that don't hit threshold

* use beaconID from metadata rather than passing it around

* added a timeout for the large DKG

* removed unnecessary grpc call options

* Update internal/dkg/actions.go

Co-authored-by: Yolan Romailler <AnomalRoil@users.noreply.github.com>

* use mock clock for determining all DKG timings

* fixed some references to clocks

* fixed an old test where multiple clocks were being created

---------

Co-authored-by: Yolan Romailler <AnomalRoil@users.noreply.github.com>

DKG refactor: use existing keys to generate proposal (#1253)

* use existing keys when generating proposal files
* fixed an encoding test
* copy instead of pointer to defeat the dreaded race detector
* rebase + errors.Is

Don't use more than 1 handler (#1260)

* Don't use more than 1 handler

* short tests must be quick

Cherry-pick master ontop of develop (#1256)

* added prometheus metric for failing to send partials
* moved import around
* fixed tests
* made sleeps in the publicrandstream variable
- upped local sleep slightly

aggregate prometheus partial errors by beaconID (#1232)

The additional fields in the partial error counter meant that a new
counter was created for _every_ combination. Given that they could only
be emitted for each round, a new entry was created for every partial...
which is definitely wrong

use a gauge for counting nodes that have invalid partials (#1233)

* use a gauge for counting nodes that have invalid partials
strictly speaking this will lose sight of nodes that go down and back up
between prometheus polls; however it's much easier to handle in grafana

* combined threshold monitor and prometheus call

return 404 when no beacon hash exists instead of 500 (#1234)

* return 404 when no beacon hash exists instead of 500
* add test for 404 on nonexistent chain

bumped patch version for testnet release (#1239)

fixed a bug where docker image is pushed with invalid tag (#1240)

fixed docker publish action to publish to GHCR (#1241)

* fixed docker publish action to publish to GHCR

added reference to GCHR in docker publish (#1242)

updated docker entrypoint permissions so the container starts (#1243)

Update go-libp2p to v0.27.3 (#1244)

Updating our dependencies (#1246)

* Updating our dependencies for mainnet release
* Bumping version to v1.5.6

upgrade libp2p to v0.27.5 (#1247)

Fixing wrong logging levels when checking past beacons with sync and shorter tests (#1248)

* Fixing wrong logging levels when checking past beacons with sync
* Skipping slow tests in short mode

Adding a G1 scheme that's RFC conformant (#1249)

* Adding a G1 scheme that's RFC conformant
* Using Go 1.20 in GHA
* patching GHA to support new RFC conformant scheme

added new flag for backup out with better text (#1250)

updated dockerfiles to use go 1.20 (#1255)

* updated dockerfiles to use go 1.20
- added a github action step for building the docker image on branches
to ensure compat

* renamed the docker build task
* added branches for push
* run on all pull requests

patching

updating deps and patching last details

More slow test remove from short

improving test logging to debug

improving TestBeaconSync

fixing TestDrandPublicRand

fixing test

trying to avoid unfinished sync

avoiding race in DKG

fixing weird build issue

adding TestBeaconSync to slow test

improve logging

tag slow test

removing noisy log

Adding scheme to self-signature of key

Also adding keys signature validation to DKG proposal validation

adding missing imports

using proper scheme in tests

properly close control client in cli

Hopefully avoiding the control tcp issues

avoid closing conn always

cancelling the stream ctx correctly

do not close conn

increased sleep time when waiting for clock

changed DKG runner status check to not optimistically return an error

Co-authored-by: PM <3749956+CluEleSsUK@users.noreply.github.com>

demo bug fixes; execution kickoff alignment (#1263)

* fixed error generating first proposal and panic when viewing DKG state

* all nodes now share a kickoff time set by the leader, rather than simply
waiting 5mins

parallelise state machine tests (#1269)

separate initial DKG and resharing commands (#1264)

* separate initial DKG and resharing commands

* time -> delay

Tear-out of client and relay code. (#1265)

* Initial tear-out. Working daemon, failing tests
* Removed builtin TLS
* removed unused initial stores from daemon
* exposing the time of round APIs
* Improving version handling
* migration path self-sign
* simplify version handling in v2, we keep retro-compat with 1.5.7+ and 2.x-1.y
* Fixing metrics
* Leaner logs, fixing wait in test

Cherry picking typos corrections (#1274)

* cherry picking typo corr

* Correcting comment

---------

Co-authored-by: Alejandro Criado-P茅rez <alejandro@criadoperez.com>

Properly process all beacons when self-signing (#1275)

Merging version changes from master to v2 (#1276)

migration path for pub keys (#1277)

* added a migration path for new public key format

* removed some TLS mentions

* added test for migration path and fixed some errors

* PR comments and fixed generated protobuf

* fixed some linter rules and turned off depguard

* modified catchup period (and renamed in places)

re-add tls for keys (#1281)

* re-added TLS to identities/participants

* fixed some linter complaints

* fixed some tests

* remove TLS from check and follow chains

* add TLS/insecure to remote-status stuff

* Bringing back TLS keys

* added missing TLS to TomlParticipant

* use insecure keys for more testing instances

---------

Co-authored-by: Yolan Romailler <yolan@protocol.ai>

Exposing the test/mock package (#1278)

* Exposing the test/mock package

* Making sure we are using the expected output format

More specifically chain.Beacon doesn't have the same tags for JSON formatting as client.RandomData did and so it wasn't being marshaled as it used to when we used the asRD and the RandomData struct in our client code for the HTTP server

* Updating to latest x/net dependencies

* fixing orchestrator as per review

chore(docs): update TOC

addressed merge comments from PR

readded some insecures in docker

updated some docker image versions

seal of approval
  • Loading branch information
AnomalRoil authored and CluEleSsUK committed Nov 1, 2023
1 parent c876a8f commit e52ff1e
Show file tree
Hide file tree
Showing 323 changed files with 19,916 additions and 22,816 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
- name: Build and push
uses: docker/build-push-action@v2
with:
push: false
push: false
6 changes: 3 additions & 3 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:
uses: arduino/setup-protoc@ab6203da1c3118e4406048171b09238ad31ad73e # pin@latest-16.02.2023
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: '3.19.6'
version: '3.20.3'
- name: Install Protoc-gen-go
run: |
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2.0
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30.0
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0
- name: Generate
run: go generate ./...&& go mod tidy
- name: Check
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ jobs:
- name: Install Protoc
uses: arduino/setup-protoc@149f6c87b92550901b26acd1632e11c3662e381f # pin@v1.3.0
with:
version: '3.19.6'
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: '3.20.3'

- name: Install Protoc-gen-go
run: |
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2.0
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30.0
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0
go mod tidy
- name: Get latest release version number
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
- main
- develop
- 'release/**'
pull_request:

Expand All @@ -14,6 +15,7 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v3.3.0
Expand All @@ -34,13 +36,10 @@ jobs:
run: |
export PATH=$PATH:$(go env GOPATH)/bin
make drand
make drand-client
make drand-relay-http
make drand-relay-gossip
make drand-relay-s3
test:
runs-on: ubuntu-latest
timeout-minutes: 15
continue-on-error: true
strategy:
fail-fast: false
Expand Down Expand Up @@ -70,6 +69,7 @@ jobs:

test-integration:
runs-on: ubuntu-latest
timeout-minutes: 15
continue-on-error: true
strategy:
fail-fast: false
Expand Down Expand Up @@ -99,6 +99,7 @@ jobs:

test-integration-run-demo:
runs-on: ubuntu-latest
timeout-minutes: 15
continue-on-error: true
strategy:
fail-fast: false
Expand Down Expand Up @@ -128,6 +129,7 @@ jobs:

coverage:
runs-on: ubuntu-latest
timeout-minutes: 15
continue-on-error: true
strategy:
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
CLOSING_COMMENT: "<!-- END "
TOC_TITLE: "## Table of Contents"
CREATE_PR: false
TARGET_PATHS: "README.md,cmd/relay-gossip/README.md"
TARGET_PATHS: "README.md"
37 changes: 19 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
TODO.md
test/drand
dist/
**/nohup.out
*.DS_Store
*swagger.json
demo/demo
test/full/full
gh-md-toc
web/public/
/drand
cover*
.idea
drand
drand-client
drand-relay-gossip
drand-relay-http
drand-relay-s3
test/docker/tmp
test/docker/data*
**/nohup.out
.tool-versions
datastore
/datastore
/demo/demo
/demo/group.toml
/demo/proposal.toml
/dist/
/drand
/drand-client
/drand-relay-gossip
/drand-relay-http
/drand-relay-s3
/internal/test/docker/data*
/internal/test/docker/tmp
/internal/test/drand
/internal/test/full/full
/web/public/
cover*
gh-md-toc
identity.key
TODO.md
12 changes: 8 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ issues:
- nilnil
- noctx
- revive
- depguard
- path: _test\.go
text: "SA1019" # we still want to test deprecated functions
- path: protobuf/gen.go
Expand All @@ -25,12 +26,15 @@ issues:
- path: cmd
linters:
- forbidigo # we use Println in our UX
- path: lib
- path: internal/lib
linters:
- forbidigo # we use Println in our UX
- path: drand-cli
- path: internal/drand-cli
linters:
- forbidigo # we use Println in our UX
- path: internal/metrics/threshold_monitor_test.go
linters:
- revive # we use named parameters as an example for implementer
- path: crypto/schemes.go
linters:
- dupl # we have explicit scheme instantiations
Expand All @@ -53,7 +57,7 @@ linters:
#- cyclop
#- deadcode # Deprecated
- decorder
- depguard
# - depguard
- dogsled
- dupl
- dupword
Expand Down Expand Up @@ -120,7 +124,7 @@ linters:
- predeclared
# -promlinter #TODO could be enabled
- reassign
# - revive #TODO make sure it's enabled on develop
- revive
- rowserrcheck
# - scopelint # Deprecated
- sqlclosecheck
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ builds:
- env:
- CGO_ENABLED=0
ldflags:
- -s -w -X github.com/drand/drand/cmd/drand-cli.buildDate={{.Date}} -X github.com/drand/drand/cmd/drand-cli.gitCommit={{.ShortCommit}}
- -s -w -X github.com/drand/drand/internal/drand-cli.buildDate={{.Date}} -X github.com/drand/drand/internal/drand-cli.gitCommit={{.ShortCommit}}
mod_timestamp: '{{ .CommitTimestamp }}'
checksum:
name_template: 'checksums.txt'
Expand Down
65 changes: 57 additions & 8 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ If you are reading this, it means you are about to work on the codebase.

## Table of Contents
- [Getting started](#getting-started)
- [Installing dependencies](#installing-dependencies)
- [Installing dependencies](#installing-dependencies)
- [Development flow](#development-flow)

## Getting started
Expand All @@ -13,14 +13,63 @@ If you are reading this, it means you are about to work on the codebase.

To start, you'll need to run a few commands to make sure you have the
correct development environment tools installed:

- `make install_deps_<os>` where `<os>` can be `linux` or `macos`. This will install the proto compiler under `/usr/local/bin/protoc`.
- `make install_lint`. This will install `golangci-lint` at the version used during Drand's development.
- `make build_proto`. This will compile the project's proto files.

Finally, if you ran all the above commands and `git status` does not report any changes to the repository,
then you are ready to start.

### Development environment

Certain features in Drand depend on external services.
These features are the support for running with PostgreSQL as a database backend, and observability features such as metrics, and tracing.

To keep your environment clean from any external tools required to interact with such features, you can use the
`docker-compose.yaml` file under `devenv/docker-compose.yaml`.

#### Using the devenv tools

To launch the tools, run
```shell
cd devenv
docker compose up -d
```

If you wish to stop the stack, run:
```shell
docker compose down
```

To cleanup and remove all data, run:
```shell
cd devenv
docker compose down --volumes --remove-orphans
```

#### PostgreSQL backend

To use the database instance provided with the devenv, use `127.0.0.1:5432` as the destination for PostgreSQL.

For more details, see the [testing section below](#testing-with-postgresql-as-database-backend).

#### Observability features

Drand can produce traces compatible with OpenTelemetry specification. To turn on this feature, set the `DRAND_TRACES`
environment varible to the desired destination, e.g.
```shell
export DRAND_TRACES=127.0.0.1:4317
export DRAND_TRACES_PROBABILITY=1 # This will sample all traces to the destination server
```

After that, in the same terminal, use any of the drand features, such as `make test-unit-memdb`, to start producing traces.

To explore the trace details, launch a new browser tab/window at the [Grafana instance](http://127.0.0.1:3000/explore?orgId=1),
which will allow you to explore in detail the inner workings of Drand.

For more details on how to use Grafana, you can [read the manual here](https://grafana.com/docs/grafana/v9.4/explore/trace-integration/).

### Development flow

After editing all files required by your change:
Expand All @@ -34,7 +83,7 @@ You can also run regression testing, see [the section below](#regression-testing

### Testing with Docker Compose

To test changes using Docker Compose, navigate to [Docker Readme](test/docker/README.md) and follow the steps described there.
To test changes using Docker Compose, navigate to [Docker Readme](internal/test/docker/README.md) and follow the steps described there.

#### Testing with in-memory storage as database backend

Expand All @@ -54,23 +103,23 @@ To check your code against it, run `make test-unit-postgres`.
You can also run the `make demo-postgres` command to launch the scripted demo using
PostgreSQL as a backend.

If you want to run an isolated version of Postgres, you can use the `test/docker-compose.yaml` file
If you want to run an isolated version of Postgres, you can use the `devenv/docker-compose.yaml` file
from the root of this repository to do so.

To start the database, use:
```shell
cd test/
docker-compose up -d
cd devenv/
docker compose up -d
```

To stop the database, use:
```shell
docker-compose down
docker compose down
```

If you wish to remove the database volume too, use this command instead to stop:
```shell
docker-compose down --volumes --remove-orphans
docker compose down --volumes --remove-orphans
```

## Regression testing
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ RUN \
-ldflags \
"-X github.com/drand/drand/common.COMMIT=${gitCommit} \
-X github.com/drand/drand/common.BUILDDATE=`date -u +%d/%m/%Y@%H:%M:%S` \
-X github.com/drand/drand/cmd/drand-cli.buildDate=`date -u +%d/%m/%Y@%H:%M:%S` \
-X github.com/drand/drand/cmd/drand-cli.gitCommit=${gitCommit}"
-X github.com/drand/drand/internal/drand-cli.buildDate=`date -u +%d/%m/%Y@%H:%M:%S` \
-X github.com/drand/drand/internal/drand-cli.gitCommit=${gitCommit}" \
./cmd/drand

FROM --platform=linux/amd64 busybox:1-glibc
MAINTAINER Hector Sanjuan <hector@protocol.ai>
Expand Down Expand Up @@ -65,4 +66,4 @@ VOLUME $DRAND_HOME
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/entrypoint.sh"]

# Defaults for drand go here
CMD ["start", "--tls-disable", "--control 8888", "--private-listen 0.0.0.0:4444"]
CMD ["start", "--control 8888", "--private-listen 0.0.0.0:4444"]
Loading

0 comments on commit e52ff1e

Please sign in to comment.