diff --git a/apps/grpc/go.mod b/apps/grpc/go.mod index 3b738d4c91..98907d4f52 100644 --- a/apps/grpc/go.mod +++ b/apps/grpc/go.mod @@ -96,7 +96,6 @@ require ( github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect github.com/minio/sha256-simd v1.0.1 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect 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 diff --git a/apps/grpc/go.sum b/apps/grpc/go.sum index 9e92d19510..626f4a9bc8 100644 --- a/apps/grpc/go.sum +++ b/apps/grpc/go.sum @@ -740,8 +740,6 @@ github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8Ie github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= -github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= -github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= diff --git a/apps/testapp/go.mod b/apps/testapp/go.mod index a49d7e7f0c..289f97a580 100644 --- a/apps/testapp/go.mod +++ b/apps/testapp/go.mod @@ -93,7 +93,6 @@ require ( github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect github.com/minio/sha256-simd v1.0.1 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect 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 diff --git a/apps/testapp/go.sum b/apps/testapp/go.sum index 9e92d19510..626f4a9bc8 100644 --- a/apps/testapp/go.sum +++ b/apps/testapp/go.sum @@ -740,8 +740,6 @@ github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8Ie github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= -github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= -github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= diff --git a/block/internal/syncing/assert.go b/block/internal/syncing/assert.go index 02cf4040a0..7c77400571 100644 --- a/block/internal/syncing/assert.go +++ b/block/internal/syncing/assert.go @@ -1,6 +1,7 @@ package syncing import ( + "bytes" "errors" "fmt" @@ -9,7 +10,7 @@ import ( ) func assertExpectedProposer(genesis genesis.Genesis, proposerAddr []byte) error { - if string(proposerAddr) != string(genesis.ProposerAddress) { + if !bytes.Equal(proposerAddr, genesis.ProposerAddress) { return fmt.Errorf("unexpected proposer: got %x, expected %x", proposerAddr, genesis.ProposerAddress) } diff --git a/go.mod b/go.mod index b95ca3824e..6c35bfe87b 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/evstack/ev-node/core v1.0.0 github.com/filecoin-project/go-jsonrpc v0.10.1 github.com/go-kit/kit v0.13.0 + github.com/go-viper/mapstructure/v2 v2.4.0 github.com/goccy/go-yaml v1.19.2 github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/hashicorp/raft v1.7.3 @@ -24,7 +25,6 @@ require ( github.com/libp2p/go-libp2p v0.47.0 github.com/libp2p/go-libp2p-kad-dht v0.38.0 github.com/libp2p/go-libp2p-pubsub v0.15.0 - github.com/mitchellh/mapstructure v1.5.0 github.com/multiformats/go-multiaddr v0.16.1 github.com/prometheus/client_golang v1.23.2 github.com/rs/zerolog v1.34.0 @@ -64,7 +64,6 @@ require ( github.com/fsnotify/fsnotify v1.9.0 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect github.com/google/flatbuffers v25.1.24+incompatible // indirect diff --git a/go.sum b/go.sum index 10483349ba..a9b47945c0 100644 --- a/go.sum +++ b/go.sum @@ -306,8 +306,6 @@ github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8Rv github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= -github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= -github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= diff --git a/pkg/config/config.go b/pkg/config/config.go index c9f7806916..2ae3f0ff2d 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -11,7 +11,7 @@ import ( "time" "github.com/celestiaorg/go-square/v3/share" - "github.com/mitchellh/mapstructure" + "github.com/go-viper/mapstructure/v2" "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/spf13/viper" diff --git a/types/serialization_fuzz_test.go b/types/serialization_fuzz_test.go new file mode 100644 index 0000000000..8ddf84e810 --- /dev/null +++ b/types/serialization_fuzz_test.go @@ -0,0 +1,104 @@ +package types + +import ( + "testing" + + "google.golang.org/protobuf/proto" + + pb "github.com/evstack/ev-node/types/pb/evnode/v1" +) + +func FuzzHeaderUnmarshalBinary(f *testing.F) { + // Seed with a valid marshalled header + h := Header{} + h.BaseHeader.Height = 1 + h.BaseHeader.ChainID = "test" + h.BaseHeader.Time = 1000 + if data, err := h.MarshalBinary(); err == nil { + f.Add(data) + } + f.Add([]byte{}) + f.Add([]byte{0xff, 0xff, 0xff}) + + f.Fuzz(func(t *testing.T, data []byte) { + var h Header + if err := h.UnmarshalBinary(data); err != nil { + return + } + // Round-trip: if unmarshal succeeds, marshal should not panic + _, _ = h.MarshalBinary() + }) +} + +func FuzzDataUnmarshalBinary(f *testing.F) { + d := Data{Txs: Txs{[]byte("tx1"), []byte("tx2")}} + if data, err := d.MarshalBinary(); err == nil { + f.Add(data) + } + f.Add([]byte{}) + + f.Fuzz(func(t *testing.T, data []byte) { + var d Data + if err := d.UnmarshalBinary(data); err != nil { + return + } + _, _ = d.MarshalBinary() + }) +} + +func FuzzSignedHeaderUnmarshalBinary(f *testing.F) { + f.Add([]byte{}) + f.Add([]byte{0x0a, 0x00}) + + f.Fuzz(func(t *testing.T, data []byte) { + var sh SignedHeader + if err := sh.UnmarshalBinary(data); err != nil { + return + } + _, _ = sh.MarshalBinary() + }) +} + +func FuzzSignedDataUnmarshalBinary(f *testing.F) { + f.Add([]byte{}) + f.Add([]byte{0x0a, 0x00}) + + f.Fuzz(func(t *testing.T, data []byte) { + var sd SignedData + if err := sd.UnmarshalBinary(data); err != nil { + return + } + _, _ = sd.MarshalBinary() + }) +} + +func FuzzDAEnvelopeUnmarshalBinary(f *testing.F) { + f.Add([]byte{}) + + f.Fuzz(func(t *testing.T, data []byte) { + var sh SignedHeader + if _, err := sh.UnmarshalDAEnvelope(data); err != nil { + return + } + _, _ = sh.MarshalDAEnvelope(nil) + }) +} + +func FuzzStateFromProto(f *testing.F) { + s := State{ChainID: "test", LastBlockHeight: 1} + if p, err := s.ToProto(); err == nil { + if data, err := proto.Marshal(p); err == nil { + f.Add(data) + } + } + f.Add([]byte{}) + + f.Fuzz(func(t *testing.T, data []byte) { + var ps pb.State + if err := proto.Unmarshal(data, &ps); err != nil { + return + } + var s State + _ = s.FromProto(&ps) + }) +}