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

Fetched v1.0.5 updates to v1.0.6 #1045

Merged
merged 10 commits into from
Dec 23, 2022
Merged
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
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ One of the quickest ways to get `razor-go` up and running on your machine is by
```
docker network create razor_network
```
2. Create user
2. Create user
```
useradd -u 82 razor
```
Expand Down Expand Up @@ -738,14 +738,14 @@ git clone https://github.com/razor-network/monitoring.git
cd monitoring
```

- If your staker is running via binary, then
- If your staker is running via binary, then

1. In `./configs/prometheus.yml`, replace `"razor-go:2112"` with `"<private/public address of host>:2112"`

- For alerting you can add webhook in `./configs/alertmanager.yml`, replace `http://127.0.0.1:5001/` with your webhook URL. This will send you an alert in every 5min if metrics stops.

- If you are running multiple stakers and want to monitor via single grafana dashboard

1. You need to update `./config/prometheus.yml`, add new target block where `job_name: "razor-go"`
```
- targets: ["<second-host-address>:2112"]
Expand All @@ -754,30 +754,30 @@ cd monitoring
```
2. Restart vmagent service `docker-compose restart vmagent`
#### Start monitoring stack
- You can spin all agents at once via
- You can spin all agents at once via

```
docker-compose up -d
```
Can check the status of each service via
Can check the status of each service via
```
docker-compose ps
```

- You can open grafana at `<private/public address of host>:3000`, and get
- You can open grafana at `<private/public address of host>:3000`, and get
1. Can checkout `Razor` dashboard to monitor your staker.
2. Insight of host metrics at `Node Exporter Full` dashboard.
3. Containers Insight at `Docker and OS metrics ( cadvisor, node_exporter )` dashboard.
4. Can monitor alerts at `Alertmanager` dashboard.

>**_NOTE:_** Configure firewall for port `3000` on your host to access grafana.

#### Troubleshoot Alerting

1. In `docker-compose.yml` uncomment ports for `alertmanager` and `vmalert`.
2. Configure firewall to allow access to ports `8880` and `9093`.

3. Check you get alerts on vmalert via `http://<host_address>:8880/vmalert/alerts`. vmalert is configured to scrap in every 2min.
3. Check you get alerts on vmalert via `http://<host_address>:8880/vmalert/alerts`. vmalert is configured to scrap in every 2min.

4. If you see alert in vmalert then look into alertmanager `http://<host_address>:9093/#/alerts?`, if you see alerts in there but you didn't get one then probably you need to check your weebhook.

Expand All @@ -792,18 +792,18 @@ cd monitoring

- If your staker is running via binary, then

1. In `./configs/prometheus.yml`, replace `"razor-go:2112"` with `"<private/public address of host>:2112"`
1. In `./configs/prometheus.yml`, replace `"razor-go:2112"` with `"<private/public address of host>:2112"`

- For alerting you can add webhook in `./configs/alertmanager.yml`, replace `http://127.0.0.1:5001/` with your webhook URL. This will send you an alert in every 5min if metrics stops.

- If you are running multiple stakers and want to monitor via single grafana dashboard
1. You need to update `./config/prometheus.yml`, add new target block where `job_name: "razor-go"`
```
- targets: ["<second-host-address>:2112"]
labels:
staker: "<staker-name>"
```
2. Restart vmagent service `docker-compose restart vmagent`
1. You need to update `./config/prometheus.yml`, add new target block where `job_name: "razor-go"`
```
- targets: ["<second-host-address>:2112"]
labels:
staker: "<staker-name>"
```
2. Restart vmagent service `docker-compose restart vmagent`

#### Start monitoring stack

Expand All @@ -820,10 +820,10 @@ cd monitoring
```

- You can open grafana at `<private/public address of host>:3000`, and get
1. Can checkout `Razor` dashboard to monitor your staker.
2. Insight of host metrics at `Node Exporter Full` dashboard.
3. Containers Insight at `Docker and OS metrics ( cadvisor, node_exporter )` dashboard.
4. Can monitor alerts at `Alertmanager` dashboard.
1. Can checkout `Razor` dashboard to monitor your staker.
2. Insight of host metrics at `Node Exporter Full` dashboard.
3. Containers Insight at `Docker and OS metrics ( cadvisor, node_exporter )` dashboard.
4. Can monitor alerts at `Alertmanager` dashboard.

> **_NOTE:_** Configure firewall for port `3000` on your host to access grafana.

Expand Down Expand Up @@ -1014,7 +1014,7 @@ $ ./razor contractAddresses

9. To Start **Voting**,

1. Provide password through **CLI**
1. Provide password through **CLI**

```bash
# Run process in foreground and provide password through cli
Expand All @@ -1040,4 +1040,4 @@ $ ./razor contractAddresses

### Contribute to razor-go

We would really appreciate your contribution. To see our [contribution guideline](https://github.com/razor-network/razor-go/blob/main/.github/CONTRIBUTING.md)
We would really appreciate your contribution. To see our [contribution guideline](https://github.com/razor-network/razor-go/blob/main/.github/CONTRIBUTING.md)
11 changes: 9 additions & 2 deletions block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,28 @@ package block

import (
"context"
"razor/core"
"sync"
"time"

"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/sirupsen/logrus"
"razor/core"
"time"
)

var latestBlock *types.Header
var mu = sync.Mutex{}

func GetLatestBlock() *types.Header {
mu.Lock()
defer mu.Unlock()
return latestBlock
}

func SetLatestBlock(block *types.Header) {
mu.Lock()
latestBlock = block
mu.Unlock()
}

func CalculateLatestBlock(client *ethclient.Client) {
Expand Down
26 changes: 21 additions & 5 deletions cmd/addStake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ import (
"crypto/elliptic"
"crypto/rand"
"errors"
"math/big"
"razor/core"
"razor/core/types"
"razor/pkg/bindings"
"testing"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Types "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/spf13/pflag"
"github.com/stretchr/testify/mock"
"math/big"
"razor/core"
"razor/core/types"
"razor/pkg/bindings"
"testing"
)

func TestStakeCoins(t *testing.T) {
Expand Down Expand Up @@ -301,6 +302,21 @@ func TestExecuteStake(t *testing.T) {
},
expectedFatal: true,
},
{
name: "Test 9: When stake value is less than minSafeRazor and staker's stake is more than the minSafeRazor already",
args: args{
config: config,
password: "test",
address: "0x000000000000000000000000000000000000dead",
amount: big.NewInt(20),
balance: big.NewInt(10000),
minSafeRazor: big.NewInt(100),
stakerId: 1,
approveTxn: common.BigToHash(big.NewInt(1)),
stakeTxn: common.BigToHash(big.NewInt(2)),
},
expectedFatal: false,
},
}

defer func() { log.ExitFunc = nil }()
Expand Down
13 changes: 7 additions & 6 deletions cmd/claimBounty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ import (
"crypto/elliptic"
"crypto/rand"
"errors"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Types "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/spf13/pflag"
"github.com/stretchr/testify/mock"
"io/fs"
"math/big"
"razor/cmd/mocks"
"razor/core"
"razor/core/types"
utilsPkgMocks "razor/utils/mocks"
"testing"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Types "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/spf13/pflag"
"github.com/stretchr/testify/mock"
)

func TestExecuteClaimBounty(t *testing.T) {
Expand Down
7 changes: 4 additions & 3 deletions cmd/claimCommission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import (
"crypto/elliptic"
"crypto/rand"
"errors"
"math/big"
"razor/core/types"
"testing"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Types "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/spf13/pflag"
"github.com/stretchr/testify/mock"
"math/big"
"razor/core/types"
"testing"
)

func TestClaimCommission(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion cmd/config-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
package cmd

import (
"github.com/spf13/viper"
"razor/core"
"razor/core/types"
"razor/utils"
"strings"

"github.com/spf13/viper"
)

//This function returns the config data
Expand Down
9 changes: 5 additions & 4 deletions cmd/createCollection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ import (
"crypto/elliptic"
"crypto/rand"
"errors"
"math/big"
"razor/core"
"razor/core/types"
"testing"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Types "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/spf13/pflag"
"github.com/stretchr/testify/mock"
"math/big"
"razor/core"
"razor/core/types"
"testing"
)

func TestCreateCollection(t *testing.T) {
Expand Down
9 changes: 5 additions & 4 deletions cmd/createJob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ import (
"crypto/elliptic"
"crypto/rand"
"errors"
"math/big"
"razor/core"
"razor/core/types"
"testing"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Types "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/spf13/pflag"
"github.com/stretchr/testify/mock"
"math/big"
"razor/core"
"razor/core/types"
"testing"
)

func TestCreateJob(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions cmd/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package cmd

import (
"errors"
"razor/core/types"
"testing"

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/spf13/pflag"
"github.com/stretchr/testify/mock"
"razor/core/types"
"testing"
)

func TestCreate(t *testing.T) {
Expand Down
13 changes: 7 additions & 6 deletions cmd/dispute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ import (
"crypto/rand"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Types "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/stretchr/testify/mock"
"io/fs"
"math/big"
"razor/core/types"
"razor/pkg/bindings"
"reflect"
"testing"

"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Types "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/stretchr/testify/mock"
)

func TestDispute(t *testing.T) {
Expand Down
9 changes: 5 additions & 4 deletions cmd/modifyCollectionStatus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ import (
"crypto/elliptic"
"crypto/rand"
"errors"
"math/big"
"razor/core"
"razor/core/types"
"testing"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Types "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/spf13/pflag"
"github.com/stretchr/testify/mock"
"math/big"
"razor/core"
"razor/core/types"
"testing"
)

func TestCheckCurrentStatus(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion cmd/propose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import (
"crypto/rand"
"errors"
"fmt"
"github.com/stretchr/testify/mock"
"math/big"
"razor/core/types"
"razor/pkg/bindings"
"reflect"
"testing"

"github.com/stretchr/testify/mock"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Types "github.com/ethereum/go-ethereum/core/types"
Expand Down
Loading