Skip to content

Commit

Permalink
Merge branch 'master' into removeSnowball
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Jan 13, 2025
2 parents 90fd999 + e973af8 commit 7d41d89
Show file tree
Hide file tree
Showing 518 changed files with 25,890 additions and 10,767 deletions.
10 changes: 8 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-syntax

# Code owners are the final gate for PR approval to their named section of code.
# If a single PR involves multiple code owners, every code owner should approve
# a PR prior to merging.
# If a single PR modifies multiple files with different code owner groups, at
# least one code owner of the touched file should approve the PR prior to
# merging.

* @StephenButtolph
*.md @meaghanfitzgerald @StephenButtolph
/.github/ @marun
/.github/*.md @marun @meaghanfitzgerald
/network/p2p/ @joshua-kim
/network/p2p/*.md @joshua-kim @meaghanfitzgerald
/scripts/ @marun
/scripts/*.md @marun @meaghanfitzgerald
/tests/ @marun
/tests/*.md @marun @meaghanfitzgerald
2 changes: 1 addition & 1 deletion .github/actions/run-monitored-tmpnet-cmd/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ inputs:
required: true
# The following inputs need never be provided by the caller. They
# default to context values that the action's steps are unable to
# acccess directly.
# access directly.
repository_owner:
default: ${{ github.repository_owner }}
repository_name:
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/set-go-version-in-env/go_version_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ set -euo pipefail
# 3 directories above this script
AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd ../../.. && pwd )

echo GO_VERSION="~$(sed -n -e 's/^go //p' "${AVALANCHE_PATH}"/go.mod)"
echo GO_VERSION="$(sed -n -e 's/^go //p' "${AVALANCHE_PATH}"/go.mod)"
3 changes: 1 addition & 2 deletions .github/actions/setup-go-for-project/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This action targets the project default version of setup-go. For
# workers with old NodeJS incompabible with newer versions of
# workers with old NodeJS incompatible with newer versions of
# setup-go, try setup-go-for-project-v3.
#
# Since github actions do not support dynamically configuring the
Expand All @@ -22,4 +22,3 @@ runs:
uses: actions/setup-go@v5
with:
go-version: '${{ env.GO_VERSION }}'
check-latest: true
108 changes: 108 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Lifecycle labels
- name: "DO NOT MERGE"
color: "ba1b48"
description: "This PR must not be merged in its current state"
- name: "lifecycle/frozen"
color: "2476B2"
- name: "lifecycle/stale"
color: "ededed"

# General category labels
- name: "bug"
color: "d73a4a"
description: "Something isn't working"
- name: "documentation"
color: "0075ca"
description: "Improvements or additions to documentation or examples"
- name: "enhancement"
color: "a2eeef"
description: "New feature or request"
- name: "needs information"
color: "d876e3"
description: "Further information is needed"
- name: "needs investigation"
color: "147F45"
description: "It is currently unclear if there is an issue"
- name: "good first issue"
color: "7057ff"
description: "Good for newcomers"
- name: "help wanted"
color: "008672"
description: "Looking for someone to address this"
- name: "ci"
color: "e99695"
description: "This focuses on changes to the CI process"
- name: "cleanup"
color: "BFD4F2"
description: "Code quality improvement"
- name: "dependencies"
color: "0366d6"
description: "This primarily focuses on changing a dependency"
- name: "testing"
color: "220233"
description: "This primarily focuses on testing"
- name: "monitoring"
color: "97450A"
description: "This primarily focuses on logs, metrics, and/or tracing"
- name: "incident response"
color: "BE3D15"
- name: "github_actions"
color: "000000"
description: "Pull requests that update GitHub Actions code"
- name: "go"
color: "16e2e2"
description: "Pull requests that update Go code"
- name: "needs Go upgrade"
color: "16e2e2"
description: "This requires a minor upgrade of Go to be supported"

# Avalanchego specific labels
- name: "antithesis"
color: "1d76db"
description: "Related to an issue reported by Antithesis"
- name: "bubble votes"
color: "3C9CDD"
- name: "consensus"
color: "4444ff"
description: "This involves consensus"
- name: "continuous staking"
color: "f9d0c4"
- name: "Durango"
color: "DAF894"
description: "durango fork"
- name: "gossiping upgrade"
color: "c2e0c6"
- name: "merkledb"
color: "0e8a16"
- name: "networking"
color: "88E841"
description: "This involves networking"
- name: "sdk"
color: "72ED25"
description: "This involves SDK tooling or frameworks"
- name: "storage"
color: "3F2A70"
description: "This involves storage primitives"
- name: "Uptime Tracking"
color: "d4c5f9"
- name: "vm"
color: "d1f7a0"
description: "This involves virtual machines"
- name: "warp"
color: "4FC611"
- name: "Warp Signature API"
color: "68A7EA"

# ACP labels
- name: "acp103"
color: "AB2C58"
- name: "acp113"
color: "3359BA"
- name: "acp118"
color: "DFC715"
- name: "acp125"
color: "bfdadc"
- name: "acp20"
color: "DB7D37"
- name: "acp77"
color: "45CDF2"
2 changes: 2 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
## How this works

## How this was tested

## Need to be documented in RELEASES.md?
6 changes: 3 additions & 3 deletions .github/workflows/buf-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/[email protected]
- uses: bufbuild/buf-push-action@v1
- uses: bufbuild/buf-action@v1
with:
input: "proto"
buf_token: ${{ secrets.BUF_TOKEN }}
token: ${{ secrets.BUF_TOKEN }}
version: 1.35.0
48 changes: 16 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: fuzz_test
shell: bash
run: ./scripts/build_fuzz.sh 10 # Run each fuzz test 10 seconds
e2e_pre_etna:
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -66,28 +66,7 @@ jobs:
uses: ./.github/actions/upload-tmpnet-artifact
if: always()
with:
name: e2e-pre-etna-tmpnet-data
e2e_post_etna:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- name: Build AvalancheGo Binary
shell: bash
run: ./scripts/build.sh -r
- name: Run e2e tests
uses: ./.github/actions/run-monitored-tmpnet-cmd
with:
run: E2E_SERIAL=1 ./scripts/tests.e2e.sh --delay-network-shutdown --activate-etna
prometheus_id: ${{ secrets.PROMETHEUS_ID || '' }}
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
loki_id: ${{ secrets.LOKI_ID || '' }}
loki_password: ${{ secrets.LOKI_PASSWORD || '' }}
- name: Upload tmpnet network dir
uses: ./.github/actions/upload-tmpnet-artifact
if: always()
with:
name: e2e-post-etna-tmpnet-data
name: e2e-tmpnet-data
e2e_existing_network:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -150,21 +129,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/[email protected]
with:
github_token: ${{ github.token }}
- uses: bufbuild/buf-lint-action@v1
- uses: bufbuild/buf-action@v1
with:
input: "proto"
pr_comment: false
# buf-action defaults to pushing on non-fork branch pushes
# which is never desirable for this job. The buf-push job is
# responsible for pushes.
push: false
version: 1.35.0
check_generated_protobuf:
name: Up-to-date protobuf
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- uses: bufbuild/buf-setup-action@v1.31.0
- uses: bufbuild/buf-action@v1
with:
github_token: ${{ github.token }}
setup_only: true
version: 1.35.0
- shell: bash
run: scripts/protobuf_codegen.sh
- shell: bash
Expand All @@ -176,9 +159,10 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- shell: bash
run: scripts/mock.gen.sh
- shell: bash
run: .github/workflows/check-clean-branch.sh
run: |
grep -lr -E '^// Code generated by MockGen\. DO NOT EDIT\.$' . | xargs -r rm
go generate -run "go.uber.org/mock/mockgen" ./...
.github/workflows/check-clean-branch.sh
go_mod_tidy:
name: Up-to-date go.mod and go.sum
runs-on: ubuntu-latest
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: labels
on:
push:
branches:
- master
paths:
- .github/labels.yml
- .github/workflows/labels.yml
pull_request: # dry run only
paths:
- .github/labels.yml
- .github/workflows/labels.yml

jobs:
labeler:
permissions:
contents: read
issues: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crazy-max/ghaction-github-labeler@v5
with:
dry-run: ${{ github.event_name == 'pull_request' }}
4 changes: 2 additions & 2 deletions .github/workflows/trigger-antithesis-avalanchego.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
required: true
type: string
recipients:
description: 'Comma-seperated email addresses to send the test report to'
description: 'Comma-separated email addresses to send the test report to'
required: true
type: string
image_tag:
Expand All @@ -25,7 +25,7 @@ jobs:
name: Run Antithesis Avalanchego Test Setup
runs-on: ubuntu-latest
steps:
- uses: antithesishq/antithesis-trigger-action@v0.5
- uses: antithesishq/antithesis-trigger-action@v0.6
with:
notebook_name: avalanche
tenant: avalanche
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/trigger-antithesis-xsvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
required: true
type: string
recipients:
description: 'Comma-seperated email addresses to send the test report to'
description: 'Comma-separated email addresses to send the test report to'
required: true
type: string
image_tag:
Expand All @@ -25,7 +25,7 @@ jobs:
name: Run Antithesis XSVM Test Setup
runs-on: ubuntu-latest
steps:
- uses: antithesishq/antithesis-trigger-action@v0.5
- uses: antithesishq/antithesis-trigger-action@v0.6
with:
notebook_name: avalanche
tenant: avalanche
Expand Down
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ linters:
enable:
- asciicheck
- bodyclose
- copyloopvar
- depguard
- dupword
- errcheck
- errorlint
- exportloopref
- forbidigo
- gci
- goconst
Expand Down Expand Up @@ -128,6 +128,7 @@ linters-settings:
gosec:
excludes:
- G107 # Url provided to HTTP request as taint input https://securego.io/docs/rules/g107
- G115 # TODO(marun) Enable this ruleset in a follow-up PR
importas:
# Do not allow unaliased imports of aliased packages.
no-unaliased: false
Expand Down
38 changes: 34 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,41 @@ To start developing on AvalancheGo, you'll need a few things installed.
./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.
#### Autogenerated mocks

```sh
./scripts/mock.gen.sh
```
💁 The general direction is to **reduce** usage of mocks, so use the following with moderation.

Mocks are auto-generated using [mockgen](https://pkg.go.dev/go.uber.org/mock/mockgen) and `//go:generate` commands in the code.

- To **re-generate all mocks**, use the command below from the root of the project:

```sh
go generate -run "go.uber.org/mock/mockgen" ./...
```

- To **add** an interface that needs a corresponding mock generated:
- if the file `mocks_generate_test.go` exists in the package where the interface is located, either:
- modify its `//go:generate go run go.uber.org/mock/mockgen` to generate a mock for your interface (preferred); or
- add another `//go:generate go run go.uber.org/mock/mockgen` to generate a mock for your interface according to specific mock generation settings
- if the file `mocks_generate_test.go` does not exist in the package where the interface is located, create it with content (adapt as needed):

```go
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package mypackage
//go:generate go run go.uber.org/mock/mockgen -package=${GOPACKAGE} -destination=mocks_test.go . YourInterface
```

Notes:
1. Ideally generate all mocks to `mocks_test.go` for the package you need to use the mocks for and do not export mocks to other packages. This reduces package dependencies, reduces production code pollution and forces to have locally defined narrow interfaces.
1. Prefer using reflect mode to generate mocks than source mode, unless you need a mock for an unexported interface, which should be rare.
- To **remove** an interface from having a corresponding mock generated:
1. Edit the `mocks_generate_test.go` file in the directory where the interface is defined
1. If the `//go:generate` mockgen command line:
- generates a mock file for multiple interfaces, remove your interface from the line
- generates a mock file only for the interface, remove the entire line. If the file is empty, remove `mocks_generate_test.go` as well.

### Testing

Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ For more information, refer to the [GRPC Golang Quick Start Guide](https://grpc.

### Running mock codegen

To regenerate the [gomock](https://github.com/uber-go/mock) code, run `scripts/mock.gen.sh` from the root of the repo.

This should only be necessary when modifying exported interfaces or after modifying `scripts/mock.mockgen.txt`.
See [the Contributing document autogenerated mocks section](CONTRIBUTING.md#Autogenerated-mocks).

## Versioning

Expand Down
Loading

0 comments on commit 7d41d89

Please sign in to comment.