From 1facfb726830b48186ab7a44ab66caabb07ab2bc Mon Sep 17 00:00:00 2001 From: Fedor Partanskiy Date: Mon, 16 Sep 2024 19:49:09 +0300 Subject: [PATCH] bump smartbft Signed-off-by: Fedor Partanskiy --- go.mod | 2 +- go.sum | 4 +- .../SmartBFT/internal/bft/controller.go | 2 +- .../SmartBFT/internal/bft/state.go | 2 +- .../SmartBFT/internal/bft/util.go | 2 +- .../SmartBFT/internal/bft/view.go | 2 +- .../SmartBFT/internal/bft/viewchanger.go | 2 +- .../SmartBFT/pkg/consensus/consensus.go | 2 +- .../SmartBFT/pkg/wal/reader.go | 2 +- .../SmartBFT/pkg/wal/writeaheadlog.go | 72 ++++++++++--------- vendor/modules.txt | 2 +- 11 files changed, 50 insertions(+), 44 deletions(-) diff --git a/go.mod b/go.mod index 2e2f6b66c8b..12284840bc3 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/gorilla/handlers v1.5.1 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 - github.com/hyperledger-labs/SmartBFT v0.0.0-20240616160543-3f61a410b8c1 + github.com/hyperledger-labs/SmartBFT v0.0.0-20240916013553-852e5be5889b github.com/hyperledger/fabric-chaincode-go/v2 v2.0.0 github.com/hyperledger/fabric-config v0.3.0 github.com/hyperledger/fabric-lib-go v1.1.3-0.20240523144151-25edd1eaf5f5 diff --git a/go.sum b/go.sum index 0965a0860aa..0dadd7f5e54 100644 --- a/go.sum +++ b/go.sum @@ -290,8 +290,8 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= -github.com/hyperledger-labs/SmartBFT v0.0.0-20240616160543-3f61a410b8c1 h1:0a9x5r4mymcBM+EHRuOB34AcehrCbZvdDokA/zMNw9o= -github.com/hyperledger-labs/SmartBFT v0.0.0-20240616160543-3f61a410b8c1/go.mod h1:bY4EAvtsXf132ySoNJncMUOyBcGEQL3MXVtavRNFia4= +github.com/hyperledger-labs/SmartBFT v0.0.0-20240916013553-852e5be5889b h1:HihCDs7Hy69lykrPJP7Uc54DIWlTCYg4m/+kHRqxUk0= +github.com/hyperledger-labs/SmartBFT v0.0.0-20240916013553-852e5be5889b/go.mod h1:54hysiDJViMzhT0mJIqt8aUvkQ+yHj4RIdiGZzuosQs= github.com/hyperledger/aries-bbs-go v0.0.0-20240528084656-761671ea73bc h1:3Ykk6MtyfnlzMOQry9zkxsoLWpCWZwDPqehO/BJwArM= github.com/hyperledger/aries-bbs-go v0.0.0-20240528084656-761671ea73bc/go.mod h1:Kofn6A6WWea1ZM8Rys5aBW9dszwJ7Ywa0kyyYL0TPYw= github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2 h1:B1Nt8hKb//KvgGRprk0h1t4lCnwhE9/ryb1WqfZbV+M= diff --git a/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/controller.go b/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/controller.go index 19cb5e0b826..9ced3bb4ec0 100644 --- a/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/controller.go +++ b/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/controller.go @@ -10,10 +10,10 @@ import ( "sync/atomic" "time" - "github.com/golang/protobuf/proto" "github.com/hyperledger-labs/SmartBFT/pkg/api" "github.com/hyperledger-labs/SmartBFT/pkg/types" protos "github.com/hyperledger-labs/SmartBFT/smartbftprotos" + "google.golang.org/protobuf/proto" ) // Decider delivers the proposal with signatures to the application diff --git a/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/state.go b/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/state.go index b45d9347fd2..8b8659a3018 100644 --- a/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/state.go +++ b/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/state.go @@ -9,10 +9,10 @@ import ( "errors" "fmt" - "github.com/golang/protobuf/proto" "github.com/hyperledger-labs/SmartBFT/pkg/api" "github.com/hyperledger-labs/SmartBFT/pkg/types" protos "github.com/hyperledger-labs/SmartBFT/smartbftprotos" + "google.golang.org/protobuf/proto" ) type StateRecorder struct { diff --git a/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/util.go b/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/util.go index e1b7b027af8..195b7f4289d 100644 --- a/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/util.go +++ b/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/util.go @@ -16,10 +16,10 @@ import ( "sync" "sync/atomic" - "github.com/golang/protobuf/proto" "github.com/hyperledger-labs/SmartBFT/pkg/api" "github.com/hyperledger-labs/SmartBFT/pkg/types" protos "github.com/hyperledger-labs/SmartBFT/smartbftprotos" + "google.golang.org/protobuf/proto" ) type proposalInfo struct { diff --git a/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/view.go b/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/view.go index 234cbcdd476..76477d86740 100644 --- a/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/view.go +++ b/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/view.go @@ -13,10 +13,10 @@ import ( "sync/atomic" "time" - "github.com/golang/protobuf/proto" "github.com/hyperledger-labs/SmartBFT/pkg/api" "github.com/hyperledger-labs/SmartBFT/pkg/types" protos "github.com/hyperledger-labs/SmartBFT/smartbftprotos" + "google.golang.org/protobuf/proto" ) // Phase indicates the status of the view diff --git a/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/viewchanger.go b/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/viewchanger.go index ca9ca33d0e6..0e16f7e759c 100644 --- a/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/viewchanger.go +++ b/vendor/github.com/hyperledger-labs/SmartBFT/internal/bft/viewchanger.go @@ -12,11 +12,11 @@ import ( "sync/atomic" "time" - "github.com/golang/protobuf/proto" "github.com/hyperledger-labs/SmartBFT/pkg/api" "github.com/hyperledger-labs/SmartBFT/pkg/metrics/disabled" "github.com/hyperledger-labs/SmartBFT/pkg/types" protos "github.com/hyperledger-labs/SmartBFT/smartbftprotos" + "google.golang.org/protobuf/proto" ) // ViewController controls the view diff --git a/vendor/github.com/hyperledger-labs/SmartBFT/pkg/consensus/consensus.go b/vendor/github.com/hyperledger-labs/SmartBFT/pkg/consensus/consensus.go index 20e77e77ecc..56191e5d135 100644 --- a/vendor/github.com/hyperledger-labs/SmartBFT/pkg/consensus/consensus.go +++ b/vendor/github.com/hyperledger-labs/SmartBFT/pkg/consensus/consensus.go @@ -14,12 +14,12 @@ import ( "sync/atomic" "time" - "github.com/golang/protobuf/proto" algorithm "github.com/hyperledger-labs/SmartBFT/internal/bft" bft "github.com/hyperledger-labs/SmartBFT/pkg/api" "github.com/hyperledger-labs/SmartBFT/pkg/metrics/disabled" "github.com/hyperledger-labs/SmartBFT/pkg/types" protos "github.com/hyperledger-labs/SmartBFT/smartbftprotos" + "google.golang.org/protobuf/proto" ) // Consensus submits requests to be total ordered, diff --git a/vendor/github.com/hyperledger-labs/SmartBFT/pkg/wal/reader.go b/vendor/github.com/hyperledger-labs/SmartBFT/pkg/wal/reader.go index b2294f08a73..185cda769b4 100644 --- a/vendor/github.com/hyperledger-labs/SmartBFT/pkg/wal/reader.go +++ b/vendor/github.com/hyperledger-labs/SmartBFT/pkg/wal/reader.go @@ -13,9 +13,9 @@ import ( "io" "os" - "github.com/golang/protobuf/proto" "github.com/hyperledger-labs/SmartBFT/pkg/api" protos "github.com/hyperledger-labs/SmartBFT/smartbftprotos" + "google.golang.org/protobuf/proto" ) type LogRecordReader struct { diff --git a/vendor/github.com/hyperledger-labs/SmartBFT/pkg/wal/writeaheadlog.go b/vendor/github.com/hyperledger-labs/SmartBFT/pkg/wal/writeaheadlog.go index d7d0b86eb52..2aafdda917c 100644 --- a/vendor/github.com/hyperledger-labs/SmartBFT/pkg/wal/writeaheadlog.go +++ b/vendor/github.com/hyperledger-labs/SmartBFT/pkg/wal/writeaheadlog.go @@ -16,10 +16,10 @@ import ( "strings" "sync" - "github.com/golang/protobuf/proto" "github.com/hyperledger-labs/SmartBFT/pkg/api" "github.com/hyperledger-labs/SmartBFT/pkg/metrics/disabled" protos "github.com/hyperledger-labs/SmartBFT/smartbftprotos" + "google.golang.org/protobuf/proto" ) const ( @@ -84,16 +84,16 @@ type WriteAheadLogFile struct { logger api.Logger metrics *Metrics - mutex sync.Mutex - dirFile *os.File - index uint64 - logFile *os.File - headerBuff []byte - dataBuff *proto.Buffer - crc uint32 - readMode bool - truncateIndex uint64 - activeIndexes []uint64 + mutex sync.Mutex + dirFile *os.File + index uint64 + logFile *os.File + headerBuff []byte + crc uint32 + readMode bool + truncateIndex uint64 + activeIndexes []uint64 + bufferSizeBytes int64 } type Options struct { @@ -154,16 +154,16 @@ func Create(logger api.Logger, dirPath string, options *Options) (*WriteAheadLog } wal := &WriteAheadLogFile{ - dirName: cleanDirName, - options: opt, - logger: logger, - metrics: opt.Metrics, - index: 1, - headerBuff: make([]byte, 8), - dataBuff: proto.NewBuffer(make([]byte, opt.BufferSizeBytes)), - crc: walCRCSeed, - truncateIndex: 1, - activeIndexes: []uint64{1}, + dirName: cleanDirName, + options: opt, + logger: logger, + metrics: opt.Metrics, + index: 1, + headerBuff: make([]byte, 8), + crc: walCRCSeed, + truncateIndex: 1, + activeIndexes: []uint64{1}, + bufferSizeBytes: opt.BufferSizeBytes, } wal.metrics.CountOfFiles.Set(float64(len(wal.activeIndexes))) @@ -237,13 +237,13 @@ func Open(logger api.Logger, dirPath string, options *Options) (*WriteAheadLogFi cleanDirName := filepath.Clean(dirPath) wal := &WriteAheadLogFile{ - dirName: cleanDirName, - options: opt, - logger: logger, - metrics: opt.Metrics, - headerBuff: make([]byte, 8), - dataBuff: proto.NewBuffer(make([]byte, opt.BufferSizeBytes)), - readMode: true, + dirName: cleanDirName, + options: opt, + logger: logger, + metrics: opt.Metrics, + headerBuff: make([]byte, 8), + readMode: true, + bufferSizeBytes: opt.BufferSizeBytes, } wal.dirFile, err = os.Open(cleanDirName) @@ -351,7 +351,6 @@ func (w *WriteAheadLogFile) Close() error { w.logFile = nil } - w.dataBuff = nil w.headerBuff = nil if w.dirFile != nil { @@ -426,14 +425,21 @@ func (w *WriteAheadLogFile) append(record *protos.LogRecord) error { return ErrReadOnly } - w.dataBuff.Reset() - - err := w.dataBuff.Marshal(record) + buf := make([]byte, 0, w.bufferSizeBytes) + nbuf, err := proto.MarshalOptions{ + Deterministic: false, + AllowPartial: true, + }.MarshalAppend(buf, record) if err != nil { return fmt.Errorf("wal: failed to marshal to data buffer: %w", err) } + if len(buf) == len(nbuf) { + if !record.ProtoReflect().IsValid() { + return fmt.Errorf("wal: failed to marshal to data buffer: %w", errors.New("proto: Marshal called with nil")) + } + } - payloadBuff := w.dataBuff.Bytes() + payloadBuff := nbuf recordLength := len(payloadBuff) if (uint64(recordLength) & recordCRCMask) != 0 { diff --git a/vendor/modules.txt b/vendor/modules.txt index 90b6135e66c..bc1fa48dddb 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -201,7 +201,7 @@ github.com/gorilla/mux # github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 ## explicit; go 1.14 github.com/grpc-ecosystem/go-grpc-middleware -# github.com/hyperledger-labs/SmartBFT v0.0.0-20240616160543-3f61a410b8c1 +# github.com/hyperledger-labs/SmartBFT v0.0.0-20240916013553-852e5be5889b ## explicit; go 1.22 github.com/hyperledger-labs/SmartBFT/internal/bft github.com/hyperledger-labs/SmartBFT/pkg/api