Skip to content

Commit

Permalink
Merge pull request #162 from NodeFactoryIo/Release-0.4.0
Browse files Browse the repository at this point in the history
Release 0.4.0
  • Loading branch information
mpetrunic authored Jan 4, 2021
2 parents 90c80aa + 5516bed commit 7da74b2
Show file tree
Hide file tree
Showing 47 changed files with 2,526 additions and 437 deletions.
26 changes: 18 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ jobs:
version: ${{ needs.tag.outputs.tag }}
path: ./CHANGELOG.md

- name: Sign Windows Binary
uses: nodefactoryio/windows-codesign-action@master
with:
binaryPath: "build/windows/vedran.exe"
verify: "true"
keystore: ${{ secrets.WINDOWS_CODESIGN_CERT }}
password: ${{ secrets.WINDOWS_CODESIGN_PASS }}
appName: 'Vedran'
domain: 'nodefactory.io'

- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand Down Expand Up @@ -99,8 +109,8 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/linux-amd64/vedran-linux-amd64.zip
asset_name: vedran-linux-amd64
asset_content_type: application/x-binary
asset_name: vedran-linux-amd64.zip
asset_content_type: application/zip

- name: Upload Linux Arm
id: vedran-linux-arm
Expand All @@ -110,8 +120,8 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/linux-arm/vedran-linux-arm.zip
asset_name: vedran-linux-arm
asset_content_type: application/x-binary
asset_name: vedran-linux-arm.zip
asset_content_type: application/zip

- name: Upload Windows
id: vedran-windows
Expand All @@ -121,8 +131,8 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/windows/vedran-windows.zip
asset_name: vedran-windows
asset_content_type: application/x-binary
asset_name: vedran-windows.zip
asset_content_type: application/zip

- name: Upload MacOS
id: vedran-macos
Expand All @@ -132,8 +142,8 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/darwin-amd64/vedran-darwin-amd64.zip
asset_name: vedran-macos
asset_content_type: application/x-binary
asset_name: vedran-macos.zip
asset_content_type: application/zip

#in case of failure
- name: Rollback on failure
Expand Down
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.3.1
version=0.4.0
22 changes: 20 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
# Changelog

## [unreleased]((https://github.com/NodeFactoryIo/vedran/tree/HEAD))
[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.4.0...HEAD)

[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.3.1...HEAD)
### Added

### Fix

### Changed

## [v0.4.0]((https://github.com/NodeFactoryIo/vedran/tree/v0.4.0))
[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.3.1...v0.4.0)

### Added
- Provide LB fee information [#\158](https://github.com/NodeFactoryIo/vedran/pull/158) ([MakMuftic](https://github.com/MakMuftic))

### Fix
- Metrics endpoint and grafana dashboard example [#\138](https://github.com/NodeFactoryIo/vedran/pull/138) ([mpetrun5](https://github.com/mpetrun5))
- Fix next payout date prometheus value [#\161](https://github.com/NodeFactoryIo/vedran/pull/161) ([mpetrun5](https://github.com/mpetrun5))

### Changed

## [v0.3.1]((https://github.com/NodeFactoryIo/vedran/tree/v0.3.1))
[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.3.0...v0.3.1)

### Added

Expand All @@ -13,7 +31,6 @@

### Changed

[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.3.0...HEAD)
## [v0.3.0]((https://github.com/NodeFactoryIo/vedran/tree/v0.3.0))

[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.2.0...v0.3.0)
Expand All @@ -29,6 +46,7 @@
- Execute payout transactions [\#127](https://github.com/NodeFactoryIo/vedran/pull/127) ([MakMuftic](https://github.com/MakMuftic))
- Sign stats request [\#143](https://github.com/NodeFactoryIo/vedran/pull/143) ([MakMuftic](https://github.com/MakMuftic))
- Send all funds on payout [\#153](https://github.com/NodeFactoryIo/vedran/pull/153) ([MakMuftic](https://github.com/MakMuftic))
- Metrics endpoint and grafana dashboard example [#\138](https://github.com/NodeFactoryIo/vedran/pull/138) ([mpetrun5](https://github.com/mpetrun5))

### Fix
- Fix payout [\#148](https://github.com/NodeFactoryIo/vedran/pull/148) ([MakMuftic](https://github.com/MakMuftic))
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN go mod download
COPY . .

# Build the application
RUN go build -o vedran .
RUN go build -ldflags "-X 'github.com/NodeFactoryIo/vedran/pkg/version.Version=$(sed -n 's/version=//p' .version)'" -o vedran .

# Move to /dist directory as the place for resulting binary folder
WORKDIR /dist
Expand All @@ -32,4 +32,4 @@ FROM scratch
COPY --from=builder /dist/vedran /

# Command to run
ENTRYPOINT ["/vedran"]
ENTRYPOINT ["/vedran"]
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ lint:
clean:
rm vedran 2> /dev/null || exit 0

build:
go build

install:
make clean
make build
Expand All @@ -35,12 +32,17 @@ PLATFORMS := linux/amd64 windows/amd64 darwin/amd64 linux/arm
temp = $(subst /, ,$@)
os = $(word 1, $(temp))
arch = $(word 2, $(temp))
version = $(shell sed -n 's/version=//p' .version)
version_flag = -ldflags "-X github.com/NodeFactoryIo/vedran/pkg/version.Version=$(version)"

$(PLATFORMS):
@if [ "$(os)" = "windows" ]; then \
GOOS=$(os) GOARCH=$(arch) go build -o 'build/windows/vedran.exe'; \
GOOS=$(os) GOARCH=$(arch) go build ${version_flag} -o 'build/windows/vedran.exe'; \
else \
GOOS=$(os) GOARCH=$(arch) go build -o 'build/${os}-${arch}/vedran'; \
GOOS=$(os) GOARCH=$(arch) go build ${version_flag} -o 'build/${os}-${arch}/vedran'; \
fi

buildAll: $(PLATFORMS)

build:
go build ${version_flag}
49 changes: 36 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
### Architecture

_Vedran loadbalancer_ is used in conjunction with [Vedran daemon](https://github.com/NodeFactoryIo/vedran-daemon).
Suppose the node owner wants to register to loadbalancer, than it is required to install and run _Vedran daemon_.
Daemon executes the registration process and starts providing all relevant information (ping, metrics) to the _Vedran loadbalancer_.
_Vedran loadbalancer_ is used in conjunction with [Vedran daemon](https://github.com/NodeFactoryIo/vedran-daemon).
Suppose the node owner wants to register to loadbalancer, than it is required to install and run _Vedran daemon_.
Daemon executes the registration process and starts providing all relevant information (ping, metrics) to the _Vedran loadbalancer_.
Please check [Vedran daemon repo](https://github.com/NodeFactoryIo/vedran-daemon) for more details on the daemon itself.

![Image of vedran architecture](./assets/vedran-arch.png)
Expand All @@ -22,19 +22,21 @@ _This is dockerized demo of entire setup with loadbalancer, node and daemon_

**Run demo with `docker-compose up`**

_After all components have been started and node has sent first valid metrics report (after 30 seconds),
_After all components have been started and node has sent first valid metrics report (after 30 seconds),
you can invoke RPC methods on `localhost:4000` using HTTP requests or on `localhost:4000/ws` using WebSocket request_
Metrics can be seen on `localhost:3000` hosted grafana under `vedran-dashboard`

You can check available rpc methods with:

```bash
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "rpc_methods"}' http://localhost:4000
```

This demo starts three separate dockerized components:
This demo starts five separate dockerized components:
- _Polkadot node_ ([repository](https://github.com/paritytech/polkadot))
- _Vedran daemon_ ([repository](https://github.com/NodeFactoryIo/vedran-daemon))
- _Vedran loadbalancer_
- _Vedran loadbalancer_ (port: 4000)
- _Prometheus server_ (port: 9090) - scrapes metrics from vedran's `/metrics` endpoint
- _Grafana_ (port: 3000) - Visualizes metrics

### Trigger Manual Payout

Expand All @@ -49,11 +51,11 @@ docker run --network vedran_default nodefactory/vedran:v0.3.0 payout --private-k

## Get **vedran** binary releases

Download prebuild binary from [releases](https://github.com/NodeFactoryIo/vedran/releases).
Be careful to chose appropriate binary depending on your OS. For more details on how to run _vedran loadbalancer_ see [Starting loadbalancer](#starting-loadbalancer) part.
Download prebuild binary from [releases](https://github.com/NodeFactoryIo/vedran/releases).
Be careful to chose appropriate binary depending on your OS. For more details on how to run _vedran loadbalancer_ see [Starting loadbalancer](#starting-loadbalancer) part.

## Get **vedran** package
Alternatively, it is possible to get _vedran_ golang package:
Alternatively, it is possible to get _vedran_ golang package:
1. Install [Golang](https://golang.org/doc/install) **1.15 or greater**
2. Run the command below
```
Expand All @@ -74,12 +76,12 @@ Load balancer is started by invoking **start** command.

For example `./vedran start --auth-secret=supersecret --private-key=lb-wallet-private-key`.

For more information you can always run vedran with `--help` flag.
For more information you can always run vedran with `--help` flag.
For list of all commands run `vedran --help` or for list of all options for specific command run `vedran start --help`.

**Load balancer will expose Polkadot RPC API on port 80 by default (can be changed using flag `--server-port`)**

Vedran loadbalancer supports both **HTTP** and **Websockets** protocols for Polkadot RPC API.
Vedran loadbalancer supports both **HTTP** and **Websockets** protocols for Polkadot RPC API.

- **HTTP - available on root path** `/`
- **WS - available on separate path** `/ws`
Expand Down Expand Up @@ -162,7 +164,7 @@ Additionally, it is possible to change URL on which payout script will connect w
### Get private key
You can use [subkey](https://substrate.dev/docs/en/knowledgebase/integrate/subkey) tool to get private key for your wallet.

After installing subkey tool call `subkey inspect "insert your mnemonic here"`.
After installing subkey tool call `subkey inspect "insert your mnemonic here"`.
You can find private key as _Secreet seed_. See example output of subkey command:

```
Expand All @@ -172,6 +174,27 @@ You can find private key as _Secreet seed_. See example output of subkey command
SS58 Address: 5FnAq6wrMzri5V6jLfKgBkbR2rSAMkVAHVYWa3eU7TAV5rv9
```

## Monitoring

Monitoring is done via grafana and prometheus which are expected to be installed.

### Installation
- [Grafana installation](https://grafana.com/docs/grafana/latest/installation/)
- [Prometheus installation](https://prometheus.io/docs/prometheus/latest/installation/)

### Configuration

- ### Grafana
Should be configured to fetch data from prometheus server as data source [Tutorial](https://prometheus.io/docs/visualization/grafana/).

Should have a dashboard that visualizes data scraped from prometheus server. Example configuration can be found [here](./infra/grafana/provisioning/dashboards/vedran-dashboard.json) and can be imported like [this](https://grafana.com/docs/grafana/latest/dashboards/export-import/#importing-a-dashboard).


- ### Prometheus
Prometheus should be configured to scrape metrics from vedran's `/metrics` endpoint
via prometheus .yml configuration. Example of which can be found [here](./infra/prometheus/prometheus.yml)


## Vedran loadbalancer API

`POST api/v1/nodes`
Expand Down
7 changes: 3 additions & 4 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"errors"
"fmt"
schedulepayout "github.com/NodeFactoryIo/vedran/internal/schedule/payout"
"net/url"
"strconv"
"strings"
Expand Down Expand Up @@ -281,10 +280,10 @@ func startCommand(_ *cobra.Command, _ []string) {
}
log.Debugf("Whitelisting set to: %t", whitelistEnabled)

var payoutConfiguration *schedulepayout.PayoutConfiguration
var payoutConfiguration *configuration.PayoutConfiguration
if !autoPayoutDisabled {
lbUrl, _ := url.Parse("http://" + publicIP + ":" + string(serverPort))
payoutConfiguration = &schedulepayout.PayoutConfiguration{
payoutConfiguration = &configuration.PayoutConfiguration{
PayoutNumberOfDays: int(payoutNumberOfDays),
PayoutTotalReward: payoutTotalRewardAsFloat64,
LbFeeAddress: payoutFeeAddress,
Expand All @@ -306,8 +305,8 @@ func startCommand(_ *cobra.Command, _ []string) {
TunnelServerAddress: tunnelServerAddress,
PortPool: pPool,
WhitelistEnabled: whitelistEnabled,
PayoutConfiguration: payoutConfiguration,
},
payoutConfiguration,
payoutPrivateKey,
)
}
40 changes: 32 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ services:
command: |
--dev --rpc-external --rpc-methods Unsafe --ws-external --prometheus-external --log error --rpc-cors=all
client:
container_name: "vedran_user_curl"
image: curlimages/curl:latest
command: |
sh -c "while sleep 15; do curl --silent -H Content-Type: application/json -d '{\"id\":1, \"jsonrpc\":\"2.0\", \"method\": \"chain_getBlock\"}' http://vedran:4000; done"
vedran:
command: start --auth-secret=test-secret --log-level debug --public-ip vedran --server-port 4000 --private-key ${VEDRAN_LB_PK:-0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a} --payout-interval 1 --payout-reward ${VEDRAN_LB_REWARD_POOL:-10}
image: nodefactory/vedran:v0.3.1
image: nodefactory/vedran:v0.4.0
ports:
- "4000:4000"
container_name: "vedran"
Expand All @@ -20,15 +27,32 @@ services:
depends_on:
- vedran
- polkadot
command: --id test-id --lb http://vedran:4000 --node-rpc http://polkadot:9933 --node-ws http://polkadot:9944 --node-metrics http://polkadot:9615 --payout-address 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty --log-level info

client:
container_name: "vedran_user_curl"
image: curlimages/curl:latest
command: |
sh -c "while sleep 15; do curl --silent -H Content-Type: application/json -d '{\"id\":1, \"jsonrpc\":\"2.0\", \"method\": \"chain_getBlock\"}' http://vedran:4000; done"
command: --id test-id --lb http://vedran:4000 --node-rpc http://polkadot:9933 --node-ws http://polkadot:9944 --node-metrics http://polkadot:9615 --payout-address 1Z4GTfUN2QHkSeHqdBUDawgbEWzqtfRG8ouJZ26z3cm7ePN --log-level info

prometheus:
image: prom/prometheus
volumes:
- ./infra/prometheus/:/etc/prometheus/
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention=20d'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
ports:
- 9090:9090

grafana:
image: grafana/grafana
volumes:
- grafana_data:/var/lib/grafana
- ./infra/grafana/provisioning:/etc/grafana/provisioning
environment:
- GF_AUTH_ANONYMOUS_ENABLED=true
ports:
- 3000:3000
user: "104"

volumes:
polkadot-data:
grafana_data:
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ require (
github.com/inconshreveable/go-vhost v0.0.0-20160627193104-06d84117953b
github.com/manifoldco/promptui v0.8.0
github.com/pkg/errors v0.8.1
github.com/prometheus/client_golang v1.7.1
github.com/sirupsen/logrus v1.6.0
github.com/slok/go-http-metrics v0.9.0
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.6.1
golang.org/x/net v0.0.0-20200822124328-c89045814202
Expand Down
Loading

0 comments on commit 7da74b2

Please sign in to comment.