Skip to content

Commit

Permalink
Merge branch 'main' into fix/audit
Browse files Browse the repository at this point in the history
  • Loading branch information
zivkovicmilos committed Dec 27, 2024
2 parents a03cc81 + ff31d34 commit e8bfa76
Show file tree
Hide file tree
Showing 24 changed files with 75 additions and 126 deletions.
10 changes: 4 additions & 6 deletions .golangci.yaml → .github/golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ issues:
- path: (.+)_test.go
linters:
- nilnil
- unused
- errcheck
- gosec
- lll

linters:
fast: false
Expand All @@ -34,14 +34,13 @@ linters:
- bidichk # Checks for dangerous unicode character sequences
- durationcheck # Check for two durations multiplied together
- errcheck # Forces to not skip error check
- exportloopref # Checks for pointers to enclosing loop variables
- copyloopvar # Checks for pointers to enclosing loop variables
- gocritic # Bundles different linting checks
- godot # Checks for periods at the end of comments
- gomoddirectives # Allow or ban replace directives in go.mod
- gosimple # Code simplification
- govet # Official Go tool
- ineffassign # Detects when assignments to existing variables are not used
- interfacer # Top-level interface suggestions
- nakedret # Finds naked/bare returns and requires change them
- nilerr # Requires explicit returns
- nilnil # Requires explicit returns
Expand Down Expand Up @@ -78,7 +77,6 @@ linters:
- gofumpt # Stricter gofmt
- goimports # Unused imports
- goconst # Repeated strings that could be replaced by a constant
- forcetypeassert # Finds forced type assertions
- dogsled # Checks assignments with too many blank identifiers (e.g. x, , , _, := f())
- dupl # Code clone detection
- errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
Expand All @@ -100,7 +98,7 @@ linters-settings:
- importShadow
- unnamedResult
errcheck:
check-type-assertions: true
check-type-assertions: false
check-blank: true
exclude-functions:
- io/ioutil.ReadFile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.21.x
go-version: 1.22.x

- name: Checkout code
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.21.x
go-version: 1.22.x

- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -23,7 +23,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.21.x
go-version: 1.22.x

- name: Checkout code
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: lint
lint:
golangci-lint run --config .golangci.yaml
golangci-lint run --config .github/golangci.yaml

.PHONY: gofumpt
gofumpt:
Expand Down
2 changes: 1 addition & 1 deletion NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ https://github.com/0xPolygon/go-ibft

The original and sole authors of this source code ([@zivkovicmilos](https://github.com/zivkovicmilos)
and [@dbrajovic](https://github.com/dbrajovic)) have decided to
continue maintaining this project under the [madz-lab](https://github.com/madz-lab) organization and have continued
continue maintaining this project under the [sig-0](https://github.com/sig-0) organization and have continued
licensing this work under the Apache 2 license.

The work contained in this repository is a continuation of work from commit
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ transaction execution or block building mechanics. That responsibility is left t

To get up and running with the `go-ibft` package, you can pull it into your project using:

`go get github.com/madz-lab/go-ibft`
`go get github.com/sig-0/go-ibft`

Currently, the minimum required go version is `go 1.19`.

Expand All @@ -25,7 +25,7 @@ Currently, the minimum required go version is `go 1.19`.
```go
package main

import "github.com/madz-lab/go-ibft"
import "github.com/sig-0/go-ibft"

// IBFTBackend is the structure that implements all required
// go-ibft Backend interfaces
Expand Down
4 changes: 2 additions & 2 deletions core/backend.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package core

import (
"github.com/madz-lab/go-ibft/messages"
"github.com/madz-lab/go-ibft/messages/proto"
"github.com/sig-0/go-ibft/messages"
"github.com/sig-0/go-ibft/messages/proto"
)

// MessageConstructor defines a message constructor interface
Expand Down
4 changes: 2 additions & 2 deletions core/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"testing"
"time"

"github.com/madz-lab/go-ibft/messages"
"github.com/madz-lab/go-ibft/messages/proto"
"github.com/sig-0/go-ibft/messages"
"github.com/sig-0/go-ibft/messages/proto"
"github.com/stretchr/testify/assert"
)

Expand Down
21 changes: 11 additions & 10 deletions core/ibft.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"sync"
"time"

"github.com/madz-lab/go-ibft/messages"
"github.com/madz-lab/go-ibft/messages/proto"
"github.com/sig-0/go-ibft/messages"
"github.com/sig-0/go-ibft/messages/proto"
)

type Logger interface {
Expand Down Expand Up @@ -409,7 +409,7 @@ func (i *IBFT) waitForRCC(
messages.SubscriptionDetails{
MessageType: proto.MessageType_ROUND_CHANGE,
View: view,
MinNumMessages: int(quorum),
MinNumMessages: int(quorum), //nolint:gosec // Quorum cannot exceed int limits
},
)
)
Expand Down Expand Up @@ -461,7 +461,7 @@ func (i *IBFT) handleRoundChangeMessage(view *proto.View, quorum uint64) *proto.
isValidFn,
)

if len(msgs) < int(quorum) {
if len(msgs) < int(quorum) { //nolint:gosec // Quorum cannot exceed int limits
return nil
}

Expand Down Expand Up @@ -696,10 +696,11 @@ func (i *IBFT) validateRoundChangeCertificate(
}

// Make sure there are Quorum RCC
//nolint:gosec // Quorum cannot exceed int limits
if len(certificate.RoundChangeMessages) < int(i.backend.Quorum(view.Height)) {
return fmt.Errorf("no quorum round change messages in certificate: expected=%d actual=%d",
len(certificate.RoundChangeMessages),
int(i.backend.Quorum(view.Height)),
int(i.backend.Quorum(view.Height)), //nolint:gosec // Quorum cannot exceed int limits
)
}

Expand Down Expand Up @@ -796,7 +797,7 @@ func (i *IBFT) runPrepare(ctx context.Context) error {
messages.SubscriptionDetails{
MessageType: proto.MessageType_PREPARE,
View: view,
MinNumMessages: int(quorum) - 1,
MinNumMessages: int(quorum) - 1, //nolint:gosec // Quorum cannot exceed int limits
},
)
)
Expand Down Expand Up @@ -838,7 +839,7 @@ func (i *IBFT) handlePrepare(view *proto.View, quorum uint64) bool {
isValidPrepare,
)

if len(prepareMessages) < int(quorum)-1 {
if len(prepareMessages) < int(quorum)-1 { //nolint:gosec // Quorum cannot exceed int limits
// quorum not reached, keep polling
return false
}
Expand Down Expand Up @@ -876,7 +877,7 @@ func (i *IBFT) runCommit(ctx context.Context) error {
messages.SubscriptionDetails{
MessageType: proto.MessageType_COMMIT,
View: view,
MinNumMessages: int(quorum),
MinNumMessages: int(quorum), //nolint:gosec // Quorum cannot exceed int limits
},
)
)
Expand Down Expand Up @@ -919,7 +920,7 @@ func (i *IBFT) handleCommit(view *proto.View, quorum uint64) bool {
}

commitMessages := i.messages.GetValidMessages(view, proto.MessageType_COMMIT, isValidCommit)
if len(commitMessages) < int(quorum) {
if len(commitMessages) < int(quorum) { //nolint:gosec // Quorum cannot exceed int limits
// quorum not reached, keep polling
return false
}
Expand Down Expand Up @@ -1118,7 +1119,7 @@ func (i *IBFT) validPC(
)

// Make sure there are at least Quorum (PP + P) messages
if len(allMessages) < int(i.backend.Quorum(i.state.getHeight())) {
if len(allMessages) < int(i.backend.Quorum(i.state.getHeight())) { //nolint:gosec // Quorum cannot exceed int limits
return false
}

Expand Down
Loading

0 comments on commit e8bfa76

Please sign in to comment.