Skip to content

Commit

Permalink
Merge remote-tracking branch 'pokt/main' into chore/introduce-submodule
Browse files Browse the repository at this point in the history
* pokt/main:
  [P2P] Integrate background router (#732)
  Update main README.md
  [Bug] Fix CI linter errors (#885)
  [Tooling] Block `IN_THIS_*` comments from passing CI (#889)
  • Loading branch information
bryanchriswhite committed Jul 11, 2023
2 parents dd73031 + 6b875ee commit 225f889
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 30 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: golangci-lint
# Copied from https://github.com/golangci/golangci-lint-action

on:
pull_request:
types: [opened, reopened, synchronize]

permissions:
contents: read

env:
# Even though we can test against multiple versions, this one is considered a target version.
TARGET_GOLANG_VERSION: "1.19"
PROTOC_VERSION: "3.19.4"

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ env.TARGET_GOLANG_VERSION }}
cache: false
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: ${{ env.PROTOC_VERSION }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: install CI dependencies
run: make install_ci_deps
- name: generate protobufs, RPC server, RPC client and mocks
run: make protogen_clean && make protogen_local && make mockgen && make generate_rpc_openapi
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout=10m --build-tags=test
skip-cache: true
10 changes: 0 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ on:
# - "docs/**"
# - "**.md"


env:
# Even though we can test against multiple versions, this one is considered a target version.
TARGET_GOLANG_VERSION: "1.19"
Expand Down Expand Up @@ -87,14 +86,6 @@ jobs:
uses: codecov/codecov-action@v3
with:
files: ./coverage.out
- name: golangci-lint
if: ${{ always() && env.TARGET_GOLANG_VERSION == matrix.go }}
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout=10m --build-tags=test
skip-cache: true
only-new-issues: true

# TODO(@okdas): reuse artifacts built by the previous job instead
# of going through the build process in container build job again
Expand Down Expand Up @@ -153,7 +144,6 @@ jobs:
build-args: |
TARGET_GOLANG_VERSION=${{ env.TARGET_GOLANG_VERSION }}
# Run e2e tests on devnet if the PR has a label "e2e-devnet-test"
e2e-tests:
runs-on: custom-runner
Expand Down
4 changes: 1 addition & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@ linters:
- govet
- ineffassign
- staticcheck
- typecheck
- unused

# Additional linters
- gosec
- misspell
- promlinter
- unparam
- goimports

# Gocritic allows to use ruleguard; custom linting rules
- gocritic

linters-settings:
# Gocritic settings; https://go-critic.com/overview
gocritic:
Expand Down
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,17 @@ go_fmt: ## Format all the .go files in the project in place.
gofmt -w -s .

.PHONY: install_cli_deps
install_cli_deps: ## Installs `protoc-gen-go`, `mockgen`, 'protoc-go-inject-tag' and other tooling
install_cli_deps: ## Installs `helm`, `tilt` and the underlying `ci_deps`
make install_ci_deps
curl -fsSL https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.sh | bash
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

.PHONY: install_ci_deps
install_ci_deps: ## Installs `protoc-gen-go`, `mockgen`, 'protoc-go-inject-tag' and other tools necessary for CI
go install "google.golang.org/protobuf/cmd/protoc-gen-go@v1.28" && protoc-gen-go --version
go install "github.com/golang/mock/mockgen@v1.6.0" && mockgen --version
go install "github.com/favadi/protoc-go-inject-tag@latest"
go install "github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.11.0"
curl -fsSL https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.sh | bash
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

.PHONY: develop_start
develop_start: ## Run all of the make commands necessary to develop on the project
Expand Down Expand Up @@ -588,4 +592,4 @@ ggshield_secrets_scan: ## Scans the project for secrets using ggshield

.PHONY: ggshield_secrets_add
ggshield_secrets_add: ## A helper that adds the last results from `make ggshield_secrets_scan`, store in `.cache_ggshield` to `.gitguardian.yaml`. See `ggshield for more configuratiosn`
ggshield secret ignore --last-found
ggshield secret ignore --last-found
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ If you'd like to contribute to the Pocket V1 Protocol, start by:

- [Shared Architecture](shared/README.md)
- [Utility Architecture](utility/doc/README.md)
- _Coming Soon: Consensus Architecture_ // TODO(olshansky): needs a README file with proper code structure
- [Consensus Architecture](consensus/README.md)
- [Persistence Architecture](persistence/docs/README.md)
- [P2P Architecture](p2p/README.md)
- [APP Architecture](app/client/doc/README.md)
Expand Down
19 changes: 19 additions & 0 deletions build/linters/blockers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//nolint // it's not a Go code file
//go:build !codeanalysis
// +build !codeanalysis

// This file includes our custom linters.
// If you want to add/modify an existing linter, please check out ruleguard's documentation: https://github.com/quasilyte/go-ruleguard#documentation

package gorules

import (
"github.com/quasilyte/go-ruleguard/dsl"
)

// Blocks merge if IN_THIS_ comments are present
func BlockInThisCommitPRComment(m dsl.Matcher) {
m.MatchComment(`//.*IN_THIS_.*`).
Where(!m.File().Name.Matches(`Makefile`) && !m.File().Name.Matches(`blockers.go`)).
Report("'IN_THIS_' comments must be addressed before merging to main")
}
2 changes: 1 addition & 1 deletion build/linters/errs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/quasilyte/go-ruleguard/dsl"
)

// This is a custom linter that checks ensures a use of inline error checks
// This is a custom linter that ensures a use of inline error checks
func InlineErrCheck(m dsl.Matcher) {
m.Match(`$err := $x; if $err != nil { $*_ }`).
Where(m["err"].Type.Is(`error`)).
Expand Down
2 changes: 1 addition & 1 deletion build/linters/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/quasilyte/go-ruleguard/dsl"
)

// This is a custom linter that checks ensures a use of require.Equal
// This is a custom linter that ensures the use of require.Equal
func EqualInsteadOfTrue(m dsl.Matcher) {
m.Match(`require.True($t, $x == $y, $*args)`).
Suggest(`require.Equal($t, $x, $y, $args)`).
Expand Down
22 changes: 12 additions & 10 deletions p2p/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,21 @@ Depending on the necessary routing scheme (unicast / broadcast) and whether the

**Unicast**

| Sender | Receiver | Router | Example Usage |
|----------------|----------------|-----------------|------------------------------------------------------|
| Staked Actor | Staked Actor | Raintree only | Consensus (state sync) messages (to validators only) |
| Unstaked Actor | Staked Actor | Background only | Consensus (state sync) messages (to validators only) |
| Unstaked Actor | Unstaked Actor | Background only | Consensus (state sync) & Debug (CLI) messages |
| Sender | Receiver | Router | Example Usage |
|----------------|----------------|-----------------|----------------------------------------------------------------------|
| Staked Actor | Staked Actor | Raintree only | Consensus hotstuff messages (validators only) & state sync responses |
| Staked Actor | Untaked Actor | Background only | Consensus state sync responses |
| Unstaked Actor | Staked Actor | Background only | Consensus state sync responses, debug messages |
| Unstaked Actor | Unstaked Actor | Background only | Consensus state sync responses, debug messages |

**Broadcast**

| Broadcaster | Receiver | Router | Example Usage |
|----------------|----------------|-----------------------|---------------------------------------------------|
| Staked Actor | Staked Actor | Raintree + Background | Utility tx messages |
| Unstaked Actor | Staked Actor | Background only | Utility tx messages (libp2p gossipsub redundancy) |
| Unstaked Actor | Unstaked Actor | Background only | Utility tx messages |
| Broadcaster | Receiver | Router | Example Usage |
|----------------|----------------|-----------------------|-----------------------------------------------------------------|
| Staked Actor | Staked Actor | Raintree + Background | Utility tx messages, consensus state sync requests |
| Staked Actor | Untaked Actor | Background only | Utility tx messages (redundancy), consensus state sync requests |
| Unstaked Actor | Staked Actor | Background only | Utility tx messages (redundancy), consensus state sync requests |
| Unstaked Actor | Unstaked Actor | Background only | Utility tx messages, consensus state sync requests |

Both router submodule implementations embed a `UnicastRouter` which enables them to send and receive messages directly to/from a single peer.

Expand Down

0 comments on commit 225f889

Please sign in to comment.