Skip to content

Commit

Permalink
Tidy repo
Browse files Browse the repository at this point in the history
  • Loading branch information
zivkovicmilos committed Aug 1, 2024
1 parent e422d22 commit ff31d34
Show file tree
Hide file tree
Showing 24 changed files with 86 additions and 89 deletions.
8 changes: 3 additions & 5 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 @@ -41,7 +41,6 @@ linters:
- 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.19.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.19.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.19.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
14 changes: 7 additions & 7 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 Expand Up @@ -189,12 +189,12 @@ func TestConsensus_ValidFlow(t *testing.T) {
}

// Make sure the prepare message is built correctly
backend.buildPrepareMessageFn = func(proposal []byte, view *proto.View) *proto.Message {
backend.buildPrepareMessageFn = func(_ []byte, view *proto.View) *proto.Message {
return buildBasicPrepareMessage(proposalHash, nodes[nodeIndex], view)
}

// Make sure the commit message is built correctly
backend.buildCommitMessageFn = func(proposal []byte, view *proto.View) *proto.Message {
backend.buildCommitMessageFn = func(_ []byte, view *proto.View) *proto.Message {
return buildBasicCommitMessage(proposalHash, committedSeal, nodes[nodeIndex], view)
}

Expand All @@ -221,7 +221,7 @@ func TestConsensus_ValidFlow(t *testing.T) {

// Set the proposal creation method for node 0, since
// they are the proposer
backend.buildProposalFn = func(u uint64) []byte {
backend.buildProposalFn = func(_ uint64) []byte {
return proposal
}
},
Expand Down Expand Up @@ -363,12 +363,12 @@ func TestConsensus_InvalidBlock(t *testing.T) {
}

// Make sure the prepare message is built correctly
backend.buildPrepareMessageFn = func(proposal []byte, view *proto.View) *proto.Message {
backend.buildPrepareMessageFn = func(_ []byte, view *proto.View) *proto.Message {
return buildBasicPrepareMessage(proposalHashes[view.Round], nodes[nodeIndex], view)
}

// Make sure the commit message is built correctly
backend.buildCommitMessageFn = func(proposal []byte, view *proto.View) *proto.Message {
backend.buildCommitMessageFn = func(_ []byte, view *proto.View) *proto.Message {
return buildBasicCommitMessage(proposalHashes[view.Round], committedSeal, nodes[nodeIndex], view)
}

Expand Down
4 changes: 2 additions & 2 deletions core/ibft.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,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
51 changes: 28 additions & 23 deletions core/ibft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (
"testing"
"time"

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

Expand Down Expand Up @@ -260,7 +261,7 @@ func TestRunNewRound_Proposer(t *testing.T) {
cancelFn()

return &messages.Subscription{
ID: messages.SubscriptionID(1),
ID: messages.SubscriptionID(xid.New()),
SubCh: make(chan uint64),
}
},
Expand Down Expand Up @@ -356,16 +357,16 @@ func TestRunNewRound_Proposer(t *testing.T) {
messages = mockMessages{
subscribeFn: func(_ messages.SubscriptionDetails) *messages.Subscription {
return &messages.Subscription{
ID: messages.SubscriptionID(1),
ID: messages.SubscriptionID(xid.New()),
SubCh: notifyCh,
}
},
unsubscribeFn: func(_ messages.SubscriptionID) {
cancelFn()
},
getValidMessagesFn: func(
view *proto.View,
messageType proto.MessageType,
_ *proto.View,
_ proto.MessageType,
isValid func(message *proto.Message) bool,
) []*proto.Message {
return filterMessages(
Expand Down Expand Up @@ -513,16 +514,16 @@ func TestRunNewRound_Proposer(t *testing.T) {
messages = mockMessages{
subscribeFn: func(_ messages.SubscriptionDetails) *messages.Subscription {
return &messages.Subscription{
ID: messages.SubscriptionID(1),
ID: messages.SubscriptionID(xid.New()),
SubCh: notifyCh,
}
},
unsubscribeFn: func(_ messages.SubscriptionID) {
cancelFn()
},
getValidMessagesFn: func(
view *proto.View,
messageType proto.MessageType,
_ *proto.View,
_ proto.MessageType,
isValid func(message *proto.Message) bool,
) []*proto.Message {
return filterMessages(
Expand Down Expand Up @@ -591,7 +592,7 @@ func TestRunNewRound_Validator_Zero(t *testing.T) {
quorumFn: func(_ uint64) uint64 {
return 1
},
buildPrepareMessageFn: func(proposal []byte, view *proto.View) *proto.Message {
buildPrepareMessageFn: func(_ []byte, view *proto.View) *proto.Message {
return &proto.Message{
View: view,
Type: proto.MessageType_PREPARE,
Expand All @@ -612,7 +613,7 @@ func TestRunNewRound_Validator_Zero(t *testing.T) {
messages = mockMessages{
subscribeFn: func(_ messages.SubscriptionDetails) *messages.Subscription {
return &messages.Subscription{
ID: messages.SubscriptionID(1),
ID: messages.SubscriptionID(xid.New()),
SubCh: notifyCh,
}
},
Expand Down Expand Up @@ -759,7 +760,7 @@ func TestRunNewRound_Validator_NonZero(t *testing.T) {
quorumFn: func(_ uint64) uint64 {
return 1
},
buildPrepareMessageFn: func(proposal []byte, view *proto.View) *proto.Message {
buildPrepareMessageFn: func(_ []byte, view *proto.View) *proto.Message {
return &proto.Message{
View: view,
Type: proto.MessageType_PREPARE,
Expand All @@ -780,15 +781,15 @@ func TestRunNewRound_Validator_NonZero(t *testing.T) {
messages = mockMessages{
subscribeFn: func(_ messages.SubscriptionDetails) *messages.Subscription {
return &messages.Subscription{
ID: messages.SubscriptionID(1),
ID: messages.SubscriptionID(xid.New()),
SubCh: notifyCh,
}
},
unsubscribeFn: func(_ messages.SubscriptionID) {
cancelFn()
},
getValidMessagesFn: func(
view *proto.View,
_ *proto.View,
_ proto.MessageType,
isValid func(message *proto.Message) bool,
) []*proto.Message {
Expand Down Expand Up @@ -875,7 +876,7 @@ func TestRunPrepare(t *testing.T) {
messages = mockMessages{
subscribeFn: func(_ messages.SubscriptionDetails) *messages.Subscription {
return &messages.Subscription{
ID: messages.SubscriptionID(1),
ID: messages.SubscriptionID(xid.New()),
SubCh: notifyCh,
}
},
Expand Down Expand Up @@ -982,7 +983,7 @@ func TestRunCommit(t *testing.T) {
messages = mockMessages{
subscribeFn: func(_ messages.SubscriptionDetails) *messages.Subscription {
return &messages.Subscription{
ID: messages.SubscriptionID(1),
ID: messages.SubscriptionID(xid.New()),
SubCh: notifyCh,
}
},
Expand Down Expand Up @@ -1138,11 +1139,12 @@ func TestIBFT_IsAcceptableMessage(t *testing.T) {
log = mockLogger{}
transport = mockTransport{}
backend = mockBackend{
isValidSenderFn: func(message *proto.Message) bool {
isValidSenderFn: func(_ *proto.Message) bool {
return !testCase.invalidSender
},
}
)

i := NewIBFT(log, backend, transport)
i.state.view = testCase.currentView

Expand Down Expand Up @@ -1177,6 +1179,7 @@ func TestIBFT_StartRoundTimer(t *testing.T) {

wg.Add(1)
i.wg.Add(1)

go func() {
i.startRoundTimer(ctx, 0)

Expand Down Expand Up @@ -1206,6 +1209,7 @@ func TestIBFT_StartRoundTimer(t *testing.T) {
ctx, cancelFn := context.WithCancel(context.Background())

wg.Add(1)

go func() {
defer func() {
wg.Done()
Expand Down Expand Up @@ -1362,12 +1366,12 @@ func TestIBFT_FutureProposal(t *testing.T) {
mMessages = mockMessages{
subscribeFn: func(_ messages.SubscriptionDetails) *messages.Subscription {
return &messages.Subscription{
ID: messages.SubscriptionID(1),
ID: messages.SubscriptionID(xid.New()),
SubCh: notifyCh,
}
},
getValidMessagesFn: func(
view *proto.View,
_ *proto.View,
_ proto.MessageType,
isValid func(message *proto.Message) bool,
) []*proto.Message {
Expand All @@ -1385,6 +1389,7 @@ func TestIBFT_FutureProposal(t *testing.T) {
i.messages = mMessages

wg.Add(1)

go func() {
defer func() {
cancelFn()
Expand Down Expand Up @@ -1797,7 +1802,7 @@ func TestIBFT_ValidPC(t *testing.T) {
isProposerFn: func(proposer []byte, _ uint64, _ uint64) bool {
return bytes.Equal(proposer, sender)
},
isValidSenderFn: func(message *proto.Message) bool {
isValidSenderFn: func(_ *proto.Message) bool {
return true
},
}
Expand Down Expand Up @@ -2114,13 +2119,13 @@ func TestIBFT_WatchForFutureRCC(t *testing.T) {
messages = mockMessages{
subscribeFn: func(_ messages.SubscriptionDetails) *messages.Subscription {
return &messages.Subscription{
ID: messages.SubscriptionID(1),
ID: messages.SubscriptionID(xid.New()),
SubCh: notifyCh,
}
},
getValidMessagesFn: func(
view *proto.View,
messageType proto.MessageType,
_ *proto.View,
_ proto.MessageType,
isValid func(message *proto.Message) bool,
) []*proto.Message {
return filterMessages(
Expand Down
4 changes: 2 additions & 2 deletions core/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"sync/atomic"
"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"
)

// Define delegation methods
Expand Down
Loading

0 comments on commit ff31d34

Please sign in to comment.