Skip to content

Commit

Permalink
Merge branch 'dev' into fix-leftover-error-check
Browse files Browse the repository at this point in the history
  • Loading branch information
MatheusFranco99 committed Aug 20, 2024
2 parents fce9169 + 9abeeec commit e86fc23
Show file tree
Hide file tree
Showing 104 changed files with 62,078 additions and 102,313 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
go-version: 1.22.x

- name: Get Dependencies
run: go get -v -t -d ./...
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
go-version: 1.22.x

- name: Get Dependencies
run: go get -v -t -d ./...
Expand Down
46 changes: 23 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
module github.com/ssvlabs/ssv-spec

go 1.20
go 1.22

require (
github.com/attestantio/go-eth2-client v0.21.3
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
github.com/ethereum/go-ethereum v1.12.0
github.com/ethereum/go-ethereum v1.14.8
github.com/ferranbt/fastssz v0.1.3
github.com/goccy/go-yaml v1.11.3 // indirect
github.com/google/go-cmp v0.6.0
github.com/herumi/bls-eth-go-binary v1.29.1
github.com/libp2p/go-libp2p v0.27.4
github.com/libp2p/go-libp2p-pubsub v0.9.3
github.com/libp2p/go-libp2p v0.36.1
github.com/libp2p/go-libp2p-pubsub v0.11.0
github.com/pkg/errors v0.9.1
github.com/prysmaticlabs/go-bitfield v0.0.0-20240328144219-a1caa50c3a1e
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
)

require github.com/google/go-cmp v0.5.9

require (
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/goccy/go-yaml v1.11.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.2 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/holiman/uint256 v1.3.1 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/libp2p/go-msgio v0.3.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
Expand All @@ -37,22 +36,23 @@ require (
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.2.0 // indirect
github.com/multiformats/go-multiaddr v0.9.0 // indirect
github.com/multiformats/go-multiaddr v0.13.0 // indirect
github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect
github.com/multiformats/go-multibase v0.2.0 // indirect
github.com/multiformats/go-multicodec v0.8.1 // indirect
github.com/multiformats/go-multihash v0.2.1 // indirect
github.com/multiformats/go-multistream v0.4.1 // indirect
github.com/multiformats/go-multicodec v0.9.0 // indirect
github.com/multiformats/go-multihash v0.2.3 // indirect
github.com/multiformats/go-multistream v0.5.0 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/sys v0.19.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.1.7 // indirect
lukechampine.com/blake3 v1.3.0 // indirect
)
268 changes: 185 additions & 83 deletions go.sum

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions qbft/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package qbft

import (
"bytes"
"sort"

"github.com/pkg/errors"
"github.com/ssvlabs/ssv-spec/types"
Expand Down Expand Up @@ -58,6 +59,32 @@ func aggregateCommitMsgs(msgs []*ProcessingMessage, fullData []byte) (*types.Sig
}
}
ret.FullData = fullData

// Sort the OperatorIDs and Signatures in the SignedSSVMessage

pairs := make([]struct {
OpID types.OperatorID
Sig types.Signature
}, len(ret.OperatorIDs))

for i, id := range ret.OperatorIDs {
pairs[i] = struct {
OpID types.OperatorID
Sig types.Signature
}{OpID: id, Sig: ret.Signatures[i]}
}

// Sort the slice of pairs
sort.Slice(pairs, func(i, j int) bool {
return pairs[i].OpID < pairs[j].OpID
})

// Extract the sorted IDs and Signatures back into separate slices
for i, pair := range pairs {
ret.OperatorIDs[i] = pair.OpID
ret.Signatures[i] = pair.Sig
}

return ret, nil
}

Expand Down
10 changes: 5 additions & 5 deletions qbft/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ func (c *Controller) UponExistingInstanceMsg(msg *ProcessingMessage) (*types.Sig

prevDecided, _ := inst.IsDecided()

// if previously decided, we don't process more messages
if prevDecided {
return nil, errors.New("not processing consensus message since instance is already decided")
}

decided, _, decidedMsg, err := inst.ProcessMsg(msg)
if err != nil {
return nil, errors.Wrap(err, "could not process msg")
}

// if previously Decided we do not return Decided true again
if prevDecided {
return nil, err
}

// save the highest Decided
if !decided {
return nil, nil
Expand Down
8 changes: 0 additions & 8 deletions qbft/decided.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,10 @@ func ValidateDecided(
return errors.New("not a decided msg")
}

if err := msg.Validate(); err != nil {
return errors.Wrap(err, "invalid decided msg")
}

if err := baseCommitValidationVerifySignature(msg, msg.QBFTMessage.Height, committeeMember.Committee); err != nil {
return errors.Wrap(err, "invalid decided msg")
}

if err := msg.Validate(); err != nil {
return errors.Wrap(err, "invalid decided")
}

r, err := HashDataRoot(msg.SignedMessage.FullData)
if err != nil {
return errors.Wrap(err, "could not hash input data")
Expand Down
2 changes: 0 additions & 2 deletions qbft/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,9 @@ func (i *Instance) Start(value []byte, height Height) {
// propose if this node is the proposer
if proposer(i.State, i.GetConfig(), FirstRound) == i.State.CommitteeMember.OperatorID {
proposal, err := CreateProposal(i.State, i.signer, i.StartValue, nil, nil)
// nolint
if err != nil {
fmt.Printf("%s\n", err.Error())
}
// nolint
if err := i.Broadcast(proposal); err != nil {
fmt.Printf("%s\n", err.Error())
}
Expand Down
1 change: 1 addition & 0 deletions qbft/spectest/all_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ var AllTests = []tests.TestF{
commit.NoCommitQuorum,
commit.ForceStop,
commit.PostCutoff,
commit.SortedDecided,

roundchange.HappyFlow,
roundchange.WrongHeight,
Expand Down
11 changes: 6 additions & 5 deletions qbft/spectest/generate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ package main
import (
"encoding/json"
"fmt"
"github.com/pkg/errors"
"github.com/ssvlabs/ssv-spec/qbft/spectest/tests"
comparable2 "github.com/ssvlabs/ssv-spec/types/testingutils/comparable"
"log"
"os"
"path/filepath"
"reflect"
"runtime"
"strings"

"github.com/pkg/errors"
"github.com/ssvlabs/ssv-spec/qbft/spectest/tests"
comparable2 "github.com/ssvlabs/ssv-spec/types/testingutils/comparable"

"github.com/ssvlabs/ssv-spec/qbft/spectest"
)

Expand Down Expand Up @@ -92,7 +93,7 @@ func writeJsonStateComparison(name, testType string, post interface{}) {

file := filepath.Join(scDir, fmt.Sprintf("%s.json", name))
log.Printf("writing state comparison json: %s\n", file)
if err := os.WriteFile(file, byts, 0644); err != nil {
if err := os.WriteFile(file, byts, 0400); err != nil {
panic(err.Error())
}
}
Expand All @@ -119,7 +120,7 @@ func writeJson(data []byte) {

file := filepath.Join(basedir, "tests.json")
log.Printf("writing spec tests json to: %s\n", file)
if err := os.WriteFile(file, data, 0644); err != nil {
if err := os.WriteFile(file, data, 0400); err != nil {
panic(err.Error())
}
}
Loading

0 comments on commit e86fc23

Please sign in to comment.