Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/github.com/rollkit/go-…
Browse files Browse the repository at this point in the history
…da-0.5.0
  • Loading branch information
Wondertan authored May 28, 2024
2 parents cc72348 + 563ba0a commit 0e0d255
Show file tree
Hide file tree
Showing 153 changed files with 2,101 additions and 1,228 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
# global owners are only requested if there isn't a more specific
# codeowner specified below. For this reason, the global codeowners
# are often repeated in package-level definitions.
* @renaynay @Wondertan @vgonkivs @distractedm1nd @walldiss @ramin
* @renaynay @Wondertan @vgonkivs @distractedm1nd @walldiss @ramin @cristaloleg

docs/adr @adlerjohn @liamsi
23 changes: 19 additions & 4 deletions .github/workflows/ci_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ jobs:
# Dockerfile Linting
hadolint:
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_lint.yml@v0.3.2 # yamllint disable-line rule:line-length
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_lint.yml@v0.4.1 # yamllint disable-line rule:line-length
with:
dockerfile: Dockerfile

yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: celestiaorg/.github/.github/actions/yamllint@v0.2.8
- uses: celestiaorg/.github/.github/actions/yamllint@v0.4.1

markdown-lint:
name: Markdown Lint
Expand All @@ -85,7 +85,7 @@ jobs:
# If this was a workflow dispatch event, we need to generate and push a tag
# for goreleaser to grab
version_bump:
needs: [hadolint, yamllint, markdown-lint, go-ci]
needs: [hadolint, yamllint, markdown-lint, go-ci, setup]
runs-on: ubuntu-latest
permissions: "write-all"
steps:
Expand All @@ -106,7 +106,7 @@ jobs:

# Generate the release with goreleaser to include pre-built binaries
goreleaser:
needs: version_bump
needs: [version_bump, setup]
runs-on: ubuntu-latest
if: |
github.event_name == 'workflow_dispatch' ||
Expand Down Expand Up @@ -137,3 +137,18 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

upload-docs:
needs: goreleaser
if: github.event_name == 'release'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- run: |
make openrpc-gen > openrpc.json
gh release upload ${{github.event.release.tag_name}} openrpc.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/create_release_tracking_epic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Create Release Tracking Epic
# on slack for tracking the deployment of a release to testnets and mainnet.
on:
release:
types: [published]
types: [released]
jobs:
trigger_issue:
uses: celestiaorg/.github/.github/workflows/reusable_create_release_tracking_epic.yml@v0.4.1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
permissions:
contents: write
packages: write
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_pipeline.yml@v0.3.2 # yamllint disable-line rule:line-length
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_pipeline.yml@v0.4.1 # yamllint disable-line rule:line-length
with:
dockerfile: Dockerfile
secrets: inherit
4 changes: 2 additions & 2 deletions .github/workflows/github_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v4

- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
uses: peaceiris/actions-mdbook@v2
with:
mdbook-version: "latest"

Expand All @@ -30,7 +30,7 @@ jobs:

- name: Deploy main
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./specs/book
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_call:
inputs:
go-version:
description: 'Go version'
description: "Go version"
required: true
type: string

Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
go-version: ${{ inputs.go-version }}

- name: golangci-lint
uses: golangci/golangci-lint-action@v4.0.0
uses: golangci/golangci-lint-action@v6.0.1
with:
args: --timeout 10m
version: v1.56
Expand All @@ -66,7 +66,7 @@ jobs:
run: git diff --exit-code

test_coverage:
needs: [lint, go_mod_tidy_check]
needs: [lint, go_mod_tidy_check, setup]
name: Unit Tests Coverage
strategy:
fail-fast: false
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
retention-days: 5

- name: upload coverage
uses: codecov/codecov-action@v4.1.0
uses: codecov/codecov-action@v4.4.1
with:
env_vars: OS
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
15 changes: 15 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ run:

linters:
enable:
- bidichk
- bodyclose
# - depguard as of v1.54.2, the default config throws errors on our repo
- dogsled
- dupl
- errcheck
- errorlint
# - funlen
# - gochecknoglobals
# - gochecknoinits
- exportloopref
- gocheckcompilerdirectives
- goconst
- gocritic
# - gocyclo
# - godox
- gofmt
- gofumpt
- goimports
# - golint - deprecated since v1.41. revive will be used instead
- revive
Expand All @@ -25,10 +30,15 @@ linters:
- ineffassign
# - interfacer
- lll
- loggercheck
- misspell
# - maligned
- nakedret
- nilerr
- nilnil
- nolintlint
- prealloc
- protogetter
# - scopelint - deprecated since v1.39. exportloopref will be used instead
- exportloopref
- staticcheck
Expand All @@ -40,8 +50,11 @@ linters:
# - whitespace
# - wsl
# - gocognit
- wastedassign
- whitespace
- nolintlint
- asciicheck
- dupword

issues:
exclude-rules:
Expand All @@ -67,3 +80,5 @@ linters-settings:
local-prefixes: github.com/celestiaorg/celestia-node
dupl:
threshold: 200
gofumpt:
extra-rules: true
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ else
endif
.PHONY: install

## install-global: Install the celestia-node binary (only for systems that support GNU coreutils, i.e. Linux).
install-global:
@echo "--> Installing Celestia"
@install -v ./build/* -t ${PREFIX}/bin/
@install -v ./build/* -t ${PREFIX}/bin
.PHONY: install-global

## go-install: Build and install the celestia-node binary into the GOBIN directory.
Expand Down Expand Up @@ -111,9 +112,9 @@ install-key:
## fmt: Formats only *.go (excluding *.pb.go *pb_test.go). Runs `gofmt & goimports` internally.
fmt: sort-imports
@find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs gofmt -w -s
@find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs goimports -w -local github.com/celestiaorg
@go mod tidy -compat=1.20
@cfmt -w -m=100 ./...
@gofumpt -w -extra .
@markdownlint --fix --quiet --config .markdownlint.yaml .
.PHONY: fmt

Expand Down Expand Up @@ -174,8 +175,7 @@ pb-gen:

## openrpc-gen: Generate OpenRPC spec for Celestia-Node's RPC api
openrpc-gen:
@echo "--> Generating OpenRPC spec"
@go run ./cmd/docgen fraud header state share das p2p node blob da
@go run ${LDFLAGS} ./cmd/celestia docgen
.PHONY: openrpc-gen

## lint-imports: Lint only Go imports.
Expand Down
1 change: 0 additions & 1 deletion api/docgen/examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ func ExampleValue(t, parent reflect.Type) (interface{}, error) {
case reflect.Interface:
return struct{}{}, nil
}

return nil, fmt.Errorf("failed to retrieve example value for type: %s on parent '%s')", t, parent)
}

Expand Down
12 changes: 5 additions & 7 deletions api/docgen/openrpc.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Package docgen generates an OpenRPC spec for the Celestia Node. It has been inspired by and
// adapted from Filecoin's Lotus API implementation.

//nolint:revive
package docgen

import (
Expand Down Expand Up @@ -92,7 +90,7 @@ func ParseCommentsFromNodebuilderModules(moduleNames ...string) (Comments, Comme
return nodeComments, permComments
}

func NewOpenRPCDocument(comments Comments, permissions Comments) *go_openrpc_reflect.Document {
func NewOpenRPCDocument(comments, permissions Comments) *go_openrpc_reflect.Document {
d := &go_openrpc_reflect.Document{}

d.WithMeta(&go_openrpc_reflect.MetaT{
Expand Down Expand Up @@ -163,7 +161,7 @@ func NewOpenRPCDocument(comments Comments, permissions Comments) *go_openrpc_ref
}

// remove the default implementation from the method descriptions
appReflector.FnGetMethodDescription = func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (string, error) {
appReflector.FnGetMethodDescription = func(_ reflect.Value, m reflect.Method, _ *ast.FuncDecl) (string, error) {
if v, ok := permissions[m.Name]; ok {
return "Auth level: " + v, nil
}
Expand All @@ -172,14 +170,14 @@ func NewOpenRPCDocument(comments Comments, permissions Comments) *go_openrpc_ref

appReflector.FnGetMethodName = func(
moduleName string,
r reflect.Value,
_ reflect.Value,
m reflect.Method,
funcDecl *ast.FuncDecl,
_ *ast.FuncDecl,
) (string, error) {
return moduleName + "." + m.Name, nil
}

appReflector.FnGetMethodSummary = func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (string, error) {
appReflector.FnGetMethodSummary = func(_ reflect.Value, m reflect.Method, _ *ast.FuncDecl) (string, error) {
if v, ok := comments[extractPackageNameFromAPIMethod(m)+m.Name]; ok {
return v, nil
}
Expand Down
7 changes: 4 additions & 3 deletions api/gateway/availability.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gateway

import (
"encoding/json"
"errors"
"net/http"
"strconv"

Expand Down Expand Up @@ -33,8 +34,8 @@ func (h *Handler) handleHeightAvailabilityRequest(w http.ResponseWriter, r *http
}

err = h.share.SharesAvailable(r.Context(), header)
switch err {
case nil:
switch {
case err == nil:
resp, err := json.Marshal(&AvailabilityResponse{Available: true})
if err != nil {
writeError(w, http.StatusInternalServerError, heightAvailabilityEndpoint, err)
Expand All @@ -44,7 +45,7 @@ func (h *Handler) handleHeightAvailabilityRequest(w http.ResponseWriter, r *http
if werr != nil {
log.Errorw("serving request", "endpoint", heightAvailabilityEndpoint, "err", err)
}
case share.ErrNotAvailable:
case errors.Is(err, share.ErrNotAvailable):
resp, err := json.Marshal(&AvailabilityResponse{Available: false})
if err != nil {
writeError(w, http.StatusInternalServerError, heightAvailabilityEndpoint, err)
Expand Down
3 changes: 1 addition & 2 deletions api/gateway/bindings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestRegisterEndpoints(t *testing.T) {
}
}

func hasEndpointRegistered(router *mux.Router, path string, method string) bool {
func hasEndpointRegistered(router *mux.Router, path, method string) bool {
var registered bool
err := router.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error {
template, err := route.GetPathTemplate()
Expand All @@ -109,7 +109,6 @@ func hasEndpointRegistered(router *mux.Router, path string, method string) bool
}
return nil
})

if err != nil {
fmt.Println("Error walking through routes:", err)
return false
Expand Down
4 changes: 1 addition & 3 deletions api/gateway/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ const (
headerByHeightEndpoint = "/header"
)

var (
heightKey = "height"
)
var heightKey = "height"

func (h *Handler) handleHeadRequest(w http.ResponseWriter, r *http.Request) {
head, err := h.header.LocalHead(r.Context())
Expand Down
2 changes: 1 addition & 1 deletion api/rpc/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (c *Client) Close() {

// NewClient creates a new Client with one connection per namespace with the
// given token as the authorization token.
func NewClient(ctx context.Context, addr string, token string) (*Client, error) {
func NewClient(ctx context.Context, addr, token string) (*Client, error) {
authHeader := http.Header{perms.AuthKey: []string{fmt.Sprintf("Bearer %s", token)}}
return newClient(ctx, addr, authHeader)
}
Expand Down
2 changes: 1 addition & 1 deletion api/rpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (s *Server) verifyAuth(_ context.Context, token string) ([]auth.Permission,

// RegisterService registers a service onto the RPC server. All methods on the service will then be
// exposed over the RPC.
func (s *Server) RegisterService(namespace string, service interface{}, out interface{}) {
func (s *Server) RegisterService(namespace string, service, out interface{}) {
if s.authDisabled {
s.rpc.Register(namespace, service)
return
Expand Down
3 changes: 1 addition & 2 deletions api/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func TestAuthedRPC(t *testing.T) {
adminToken, err := perms.NewTokenWithPerms(signer, perms.AllPerms)
require.NoError(t, err)

var tests = []struct {
tests := []struct {
perm int
token string
}{
Expand Down Expand Up @@ -280,7 +280,6 @@ func implementsMarshaler(t *testing.T, typ reflect.Type) {
default:
return
}

}

// setupNodeWithAuthedRPC sets up a node and overrides its JWT
Expand Down
6 changes: 3 additions & 3 deletions blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ func (com Commitment) Equal(c Commitment) bool {
return bytes.Equal(com, c)
}

// Proof is a collection of nmt.Proofs that verifies the inclusion of the data.
// Proof proves the WHOLE namespaced data for the particular row.
// The Proof is a set of nmt proofs that can be verified only through
// the included method (due to limitation of the nmt https://github.com/celestiaorg/nmt/issues/218).
// Proof proves the WHOLE namespaced data to the row roots.
// TODO (@vgonkivs): rework `Proof` in order to prove a particular blob.
// https://github.com/celestiaorg/celestia-node/issues/2303
type Proof []*nmt.Proof
Expand Down Expand Up @@ -62,7 +63,6 @@ func (p Proof) equal(input Proof) error {
if !bytes.Equal(proof.LeafHash(), input[i].LeafHash()) {
return ErrInvalidProof
}

}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion blob/blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestBlob(t *testing.T) {
blob, err := convertBlobs(appBlobs...)
require.NoError(t, err)

var test = []struct {
test := []struct {
name string
expectedRes func(t *testing.T)
}{
Expand Down
Loading

0 comments on commit 0e0d255

Please sign in to comment.