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

Remove lists from Chits messages #1412

Merged
merged 29 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5a1bdb3
If the network is not fuji or mainnet linearize on init
StephenButtolph Mar 20, 2023
f6d6d18
Loop until stop vertex is accepted
StephenButtolph Mar 20, 2023
3c96f9b
If the stop vertex is accepted, transition to snowman bootstrapping
StephenButtolph Mar 20, 2023
9f1f252
merged
StephenButtolph Mar 20, 2023
af9460a
merged
StephenButtolph Apr 13, 2023
75f42a5
wip removing avalanche consensus engine
StephenButtolph Apr 13, 2023
1be3d27
Use require in Avalanche bootstrapping tests
StephenButtolph Apr 13, 2023
9614cec
Merge branch 'cleanup-avalanche-bootstrap-tests' into linearize-on-start
StephenButtolph Apr 13, 2023
853a70c
merged
StephenButtolph Apr 13, 2023
dd8c14f
remove bootstrapping tests from the consensus engine
StephenButtolph Apr 13, 2023
fff4c15
lint
StephenButtolph Apr 13, 2023
83cb219
wip fix tests
StephenButtolph Apr 14, 2023
c56755a
fix tests
StephenButtolph Apr 14, 2023
395e510
Merge branch 'dev' into cleanup-avalanche-bootstrap-tests
StephenButtolph Apr 14, 2023
1d8904b
Merge branch 'cleanup-avalanche-bootstrap-tests' into linearize-on-start
StephenButtolph Apr 14, 2023
50e9ebd
Update metrics
StephenButtolph Apr 14, 2023
ad9b139
Merge branch 'linearize-on-start' of github.com:ava-labs/avalanchego …
StephenButtolph Apr 14, 2023
708b260
remove whitelist vtx tests
StephenButtolph Apr 14, 2023
caa60ba
Remove avalanche consensus
StephenButtolph Apr 15, 2023
5b8ae87
Remove whitelist interface
StephenButtolph Apr 15, 2023
798d62b
Remove more dead code
StephenButtolph Apr 15, 2023
d56f8da
deadcode
StephenButtolph Apr 15, 2023
b113a2b
merged
StephenButtolph Apr 24, 2023
87d0f99
merged
StephenButtolph Apr 24, 2023
06ee7bf
Remove lists from Chits messages
StephenButtolph Apr 24, 2023
869a04a
merged
StephenButtolph Apr 25, 2023
0abb509
Merge branch 'remove-avalanche-consensus' into simplify-chits-message
StephenButtolph Apr 25, 2023
4991f15
merged
StephenButtolph Jun 1, 2023
c824df4
remove old comment
StephenButtolph Jun 1, 2023
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
28 changes: 18 additions & 10 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ linters:
- depguard
- errcheck
- exportloopref
- forbidigo
- goconst
- gocritic
- gofmt
Expand Down Expand Up @@ -49,11 +50,28 @@ linters:
# - lll

linters-settings:
depguard:
list-type: blacklist
packages-with-error-message:
- io/ioutil: 'io/ioutil is deprecated. Use package io or os instead.'
- github.com/stretchr/testify/assert: 'github.com/stretchr/testify/require should be used instead.'
include-go-root: true
errorlint:
# Check for plain type assertions and type switches.
asserts: false
# Check for plain error comparisons.
comparison: false
# https://golangci-lint.run/usage/linters/#forbidigo
forbidigo:
# Forbid the following identifiers (list of regexp).
forbid:
- 'require\.Error$(# ErrorIs should be used instead)?'
- 'require\.ErrorContains$(# ErrorIs should be used instead)?'
exclude_godoc_examples: false
# https://golangci-lint.run/usage/linters#gosec
gosec:
excludes:
- G107 # https://securego.io/docs/rules/g107.html
revive:
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
Expand Down Expand Up @@ -103,13 +121,3 @@ linters-settings:
- "all"
- "-SA6002" # argument should be pointer-like to avoid allocation, for sync.Pool
- "-SA1019" # deprecated packages e.g., golang.org/x/crypto/ripemd160
# https://golangci-lint.run/usage/linters#gosec
gosec:
excludes:
- G107 # https://securego.io/docs/rules/g107.html
depguard:
list-type: blacklist
packages-with-error-message:
- io/ioutil: 'io/ioutil is deprecated. Use package io or os instead.'
- github.com/stretchr/testify/assert: 'github.com/stretchr/testify/require should be used instead.'
include-go-root: true
88 changes: 88 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# How to Contribute to Avalanche

## Setup

To start developing on AvalancheGo, you'll need a few things installed.

- Golang version >= 1.19.6
- gcc
- g++

## Issues

### Security

- Do not open up a GitHub issue if it relates to a security vulnerability in AvalancheGo, and instead refer to our [security policy](./SECURITY.md).

### Did you fix whitespace, format code, or make a purely cosmetic patch?

- Changes from the community that are cosmetic in nature and do not add anything substantial to the stability, functionality, or testability of `avalanchego` will generally not be accepted.

### Making an Issue

- Check that the issue you're filing doesn't already exist by searching under [issues](https://github.com/ava-labs/avalanchego/issues).
- If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/ava-labs/avalanchego/issues/new/choose). Be sure to include a *title and clear description* with as much relevant information as possible.

## Features

- If you want to start a discussion about the development of a new feature or the modfiication of an existing one, start a thread under GitHub [discussions](https://github.com/ava-labs/avalanchego/discussions/categories/ideas).
- Post a thread about your idea and why it should be added to AvalancheGo.
- Don't start working on a pull request until you've received positive feedback from the maintainers.

## Pull Request Guidelines

- Open a new GitHub pull request containing your changes.
- Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
- The PR should be opened against the `dev` branch.
- If your PR isn't ready to be reviewed just yet, you can open it as a draft to collect early feedback on your changes.
- Once the PR is ready for review, mark it as ready-for-review and request review from one of the maintainers.

### Autogenerated code

- Any changes to protobuf message types require that protobuf files are regenerated.

```sh
./scripts/protobuf_codegen.sh
```

- To add or remove an interface that needs a corresponding mock generated, add it to the mock file [here](./scripts/mocks.mockgen.txt). You can regenerate the mocks by running the following script.

```sh
./scripts/mock.gen.sh
```

### Testing

#### Local

- Build the avalanchego binary

```sh
./scripts/build.sh
```

- Run unit tests

```sh
./scripts/build_test.sh
```

- Run the linter

```sh
./scripts/lint.sh
```

### Continuous Integration (CI)

- Pull requests will generally not be approved or merged unless they pass CI.

## Other

### Do you have questions about the source code?

- Ask any question about AvalancheGo under GitHub [discussions](https://github.com/ava-labs/avalanchego/discussions/categories/q-a).

### Do you want to contribute to the Avalanche documentation?

- Please check out the `avalanche-docs` repository [here](https://github.com/ava-labs/avalanche-docs).
5 changes: 2 additions & 3 deletions api/admin/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package admin

import (
"context"
"fmt"

"github.com/ava-labs/avalanchego/api"
"github.com/ava-labs/avalanchego/ids"
Expand Down Expand Up @@ -106,13 +105,13 @@ func (c *client) SetLoggerLevel(
if len(logLevel) > 0 {
logLevelArg, err = logging.ToLevel(logLevel)
if err != nil {
return fmt.Errorf("couldn't parse %q to log level", logLevel)
return err
}
}
if len(displayLevel) > 0 {
displayLevelArg, err = logging.ToLevel(displayLevel)
if err != nil {
return fmt.Errorf("couldn't parse %q to log level", displayLevel)
return err
}
}
return c.requester.SendRequest(ctx, "admin.setLoggerLevel", &SetLoggerLevelArgs{
Expand Down
128 changes: 61 additions & 67 deletions api/admin/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,61 +240,56 @@ func TestReloadInstalledVMs(t *testing.T) {

func TestSetLoggerLevel(t *testing.T) {
type test struct {
name string
logLevel string
displayLevel string
serviceErr bool
clientShouldErr bool
name string
logLevel string
displayLevel string
serviceErr error
clientErr error
}
tests := []test{
{
name: "Happy path",
logLevel: "INFO",
displayLevel: "INFO",
serviceErr: false,
clientShouldErr: false,
name: "Happy path",
logLevel: "INFO",
displayLevel: "INFO",
serviceErr: nil,
clientErr: nil,
},
{
name: "Service errors",
logLevel: "INFO",
displayLevel: "INFO",
serviceErr: true,
clientShouldErr: true,
name: "Service errors",
logLevel: "INFO",
displayLevel: "INFO",
serviceErr: errTest,
clientErr: errTest,
},
{
name: "Invalid log level",
logLevel: "invalid",
displayLevel: "INFO",
serviceErr: false,
clientShouldErr: true,
name: "Invalid log level",
logLevel: "invalid",
displayLevel: "INFO",
serviceErr: nil,
clientErr: logging.ErrUnknownLevel,
},
{
name: "Invalid display level",
logLevel: "INFO",
displayLevel: "invalid",
serviceErr: false,
clientShouldErr: true,
name: "Invalid display level",
logLevel: "INFO",
displayLevel: "invalid",
serviceErr: nil,
clientErr: logging.ErrUnknownLevel,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require := require.New(t)
var err error
if tt.serviceErr {
err = errTest

c := client{
requester: NewMockClient(&api.EmptyReply{}, tt.serviceErr),
}
mockClient := client{requester: NewMockClient(&api.EmptyReply{}, err)}
err = mockClient.SetLoggerLevel(
err := c.SetLoggerLevel(
context.Background(),
"",
tt.logLevel,
tt.displayLevel,
)
if tt.clientShouldErr {
require.Error(err)
} else {
require.NoError(err)
}
require.ErrorIs(err, tt.clientErr)
})
}
}
Expand All @@ -304,8 +299,8 @@ func TestGetLoggerLevel(t *testing.T) {
name string
loggerName string
serviceResponse map[string]LogAndDisplayLevels
serviceErr bool
clientShouldErr bool
serviceErr error
clientErr error
}
tests := []test{
{
Expand All @@ -314,76 +309,75 @@ func TestGetLoggerLevel(t *testing.T) {
serviceResponse: map[string]LogAndDisplayLevels{
"foo": {LogLevel: logging.Info, DisplayLevel: logging.Info},
},
serviceErr: false,
clientShouldErr: false,
serviceErr: nil,
clientErr: nil,
},
{
name: "service errors",
loggerName: "foo",
serviceResponse: nil,
serviceErr: true,
clientShouldErr: true,
serviceErr: errTest,
clientErr: errTest,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require := require.New(t)
var err error
if tt.serviceErr {
err = errTest

c := client{
requester: NewMockClient(
&GetLoggerLevelReply{
LoggerLevels: tt.serviceResponse,
},
tt.serviceErr,
),
}
mockClient := client{requester: NewMockClient(&GetLoggerLevelReply{LoggerLevels: tt.serviceResponse}, err)}
res, err := mockClient.GetLoggerLevel(
res, err := c.GetLoggerLevel(
context.Background(),
tt.loggerName,
)
if tt.clientShouldErr {
require.Error(err)
return
require.ErrorIs(err, tt.clientErr)
if tt.clientErr == nil {
require.EqualValues(tt.serviceResponse, res)
}
require.NoError(err)
require.EqualValues(tt.serviceResponse, res)
})
}
}

func TestGetConfig(t *testing.T) {
type test struct {
name string
serviceErr bool
clientShouldErr bool
serviceErr error
clientErr error
expectedResponse interface{}
}
var resp interface{} = "response"
tests := []test{
{
name: "Happy path",
serviceErr: false,
clientShouldErr: false,
serviceErr: nil,
clientErr: nil,
expectedResponse: &resp,
},
{
name: "service errors",
serviceErr: true,
clientShouldErr: true,
serviceErr: errTest,
clientErr: errTest,
expectedResponse: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require := require.New(t)
var err error
if tt.serviceErr {
err = errTest

c := client{
requester: NewMockClient(tt.expectedResponse, tt.serviceErr),
}
mockClient := client{requester: NewMockClient(tt.expectedResponse, err)}
res, err := mockClient.GetConfig(context.Background())
if tt.clientShouldErr {
require.Error(err)
return
res, err := c.GetConfig(context.Background())
require.ErrorIs(err, tt.clientErr)
if tt.clientErr == nil {
require.Equal(resp, res)
}
require.NoError(err)
require.EqualValues("response", res)
})
}
}
8 changes: 3 additions & 5 deletions api/admin/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestLoadVMsSuccess(t *testing.T) {
err := resources.admin.LoadVMs(&http.Request{}, nil, &reply)

require.Equal(t, expectedVMRegistry, reply.NewVMs)
require.Equal(t, err, nil)
require.NoError(t, err)
}

// Tests behavior for LoadVMs if we fail to reload vms.
Expand All @@ -90,8 +90,7 @@ func TestLoadVMsReloadFails(t *testing.T) {

reply := LoadVMsReply{}
err := resources.admin.LoadVMs(&http.Request{}, nil, &reply)

require.Equal(t, err, errTest)
require.ErrorIs(t, err, errTest)
}

// Tests behavior for LoadVMs if we fail to fetch our aliases
Expand All @@ -115,6 +114,5 @@ func TestLoadVMsGetAliasesFails(t *testing.T) {

reply := LoadVMsReply{}
err := resources.admin.LoadVMs(&http.Request{}, nil, &reply)

require.Equal(t, err, errTest)
require.ErrorIs(t, err, errTest)
}
Loading