Skip to content

Commit

Permalink
Merge branch 'feat/hyperblock' into implement-blocks-pool
Browse files Browse the repository at this point in the history
  • Loading branch information
ssd04 committed Apr 1, 2024
2 parents a722602 + d480d5a commit 500d14c
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 14 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ go 1.20
require (
github.com/gogo/protobuf v1.3.2
github.com/multiversx/mx-chain-communication-go v1.0.12
github.com/multiversx/mx-chain-core-go v1.2.19-0.20240129082057-a76d0c995cf2
github.com/multiversx/mx-chain-logger-go v1.0.14-0.20240129144507-d00e967c890c
github.com/multiversx/mx-chain-storage-go v1.0.15-0.20240129144933-b1c0d642d7f8
github.com/multiversx/mx-chain-core-go v1.2.19
github.com/multiversx/mx-chain-logger-go v1.0.14
github.com/multiversx/mx-chain-storage-go v1.0.15
github.com/stretchr/testify v1.8.4
github.com/urfave/cli v1.22.14
)
Expand All @@ -23,7 +23,7 @@ require (
github.com/hashicorp/golang-lru v0.6.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiversx/concurrent-map v0.1.4 // indirect
github.com/multiversx/mx-chain-crypto-go v1.2.10-0.20231206065052-38843c1f1479 // indirect
github.com/multiversx/mx-chain-crypto-go v1.2.9 // indirect
github.com/pelletier/go-toml v1.9.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ github.com/multiversx/concurrent-map v0.1.4 h1:hdnbM8VE4b0KYJaGY5yJS2aNIW9TFFsUY
github.com/multiversx/concurrent-map v0.1.4/go.mod h1:8cWFRJDOrWHOTNSqgYCUvwT7c7eFQ4U2vKMOp4A/9+o=
github.com/multiversx/mx-chain-communication-go v1.0.12 h1:67WOaf87gpwouydD1AAOHw5LMGZh7NfITrp/KqFY3Tw=
github.com/multiversx/mx-chain-communication-go v1.0.12/go.mod h1:+oaUowpq+SqrEmAsMPGwhz44g7L81loWb6AiNQU9Ms4=
github.com/multiversx/mx-chain-core-go v1.2.19-0.20240129082057-a76d0c995cf2 h1:pFh9bwOTRgW173aHqA8Bmax+jYzLnRyXqRvi5alF7V4=
github.com/multiversx/mx-chain-core-go v1.2.19-0.20240129082057-a76d0c995cf2/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
github.com/multiversx/mx-chain-crypto-go v1.2.10-0.20231206065052-38843c1f1479 h1:beVIhs5ysylwNplQ/bZ0h5DoDlqKNWgpWE/NMHHNmAw=
github.com/multiversx/mx-chain-crypto-go v1.2.10-0.20231206065052-38843c1f1479/go.mod h1:Ap6p7QZFtwPlb++OvCG+85BfuZ+bLP/JtQp6EwjWJsI=
github.com/multiversx/mx-chain-logger-go v1.0.14-0.20240129144507-d00e967c890c h1:QIUOn8FgNRa5cir4BCWHZi/Qcr6Gg0eGNhns4+jy6+k=
github.com/multiversx/mx-chain-logger-go v1.0.14-0.20240129144507-d00e967c890c/go.mod h1:fH/fR/GEBsDjPkBoZDVJMoYo2HhlA7++DP6QfITJ1N8=
github.com/multiversx/mx-chain-storage-go v1.0.15-0.20240129144933-b1c0d642d7f8 h1:/EYv/HGX0OKbeNFt667J0yZRtuJiZH0lEK8YtobuH/c=
github.com/multiversx/mx-chain-storage-go v1.0.15-0.20240129144933-b1c0d642d7f8/go.mod h1:zl1A6teNe39T8yhdZlkX3ckm5aLYrMIJJZ6Ord1E71M=
github.com/multiversx/mx-chain-core-go v1.2.19 h1:2BaVHkB0tro3cjs5ay2pmLup1loCV0e1p9jV5QW0xqc=
github.com/multiversx/mx-chain-core-go v1.2.19/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
github.com/multiversx/mx-chain-crypto-go v1.2.9 h1:OEfF2kOQrtzUl273Z3DEcshjlTVUfPpJMd0R0SvTrlU=
github.com/multiversx/mx-chain-crypto-go v1.2.9/go.mod h1:fkaWKp1rbQN9wPKya5jeoRyC+c/SyN/NfggreyeBw+8=
github.com/multiversx/mx-chain-logger-go v1.0.14 h1:PRMpAvXE7Nec2d//QNmbYfKVHMomOKmcN4UXurQWX9o=
github.com/multiversx/mx-chain-logger-go v1.0.14/go.mod h1:bDfHSdwqIimn7Gp8w+SH5KlDuGzJ//nlyEANAaTSc3o=
github.com/multiversx/mx-chain-storage-go v1.0.15 h1:PDyP1uouAVjR32dFgM+7iaQBdReD/tKBJj10JbxXvaE=
github.com/multiversx/mx-chain-storage-go v1.0.15/go.mod h1:GZUK3sqf5onsWS/0ZPWjDCBjAL22FigQPUh252PAVk0=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
Expand Down
5 changes: 5 additions & 0 deletions process/dataAggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package process
import (
"encoding/hex"

"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/data/outport"
"github.com/multiversx/mx-chain-ws-connector-template-go/data"
Expand All @@ -28,6 +29,10 @@ func NewDataAggregator(
// ProcessHyperBlock will process meta outport block. It will try to fetch and aggregate
// notarized shards data
func (da *dataAggregator) ProcessHyperBlock(outportBlock *outport.OutportBlock) (*data.HyperOutportBlock, error) {
if outportBlock.ShardID != core.MetachainShardId {
return nil, ErrInvalidOutportBlock
}

hyperOutportBlock := &data.HyperOutportBlock{}
hyperOutportBlock.MetaOutportBlock = outportBlock

Expand Down
15 changes: 15 additions & 0 deletions process/dataAggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ func TestNewDataAggregator(t *testing.T) {
func TestDataAggregator_ProcessHyperBlock(t *testing.T) {
t.Parallel()

t.Run("invalid outport block provided", func(t *testing.T) {
t.Parallel()

blocksPoolStub := &testscommon.BlocksPoolStub{}

da, err := process.NewDataAggregator(blocksPoolStub)
require.Nil(t, err)

shardOutportBlock := createOutportBlock()

hyperOutportBlock, err := da.ProcessHyperBlock(shardOutportBlock)
require.Nil(t, hyperOutportBlock)
require.Equal(t, process.ErrInvalidOutportBlock, err)
})

headerHash := []byte("headerHash1")

shardOutportBlock := createOutportBlock()
Expand Down
2 changes: 1 addition & 1 deletion process/dataProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewDataProcessor(
dataAggregator DataAggregator,
blockCreator BlockContainerHandler,
) (DataProcessor, error) {
if publisher == nil {
if check.IfNil(publisher) {
return nil, ErrNilPublisher
}
if check.IfNil(blocksPool) {
Expand Down
2 changes: 1 addition & 1 deletion process/dataProcessor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestDataProcessor_ProcessPayload_NotImplementedTopics(t *testing.T) {
func TestDataProcessor_ProcessPayload(t *testing.T) {
t.Parallel()

t.Run("nil outport block, should return error", func(t *testing.T) {
t.Run("nil outport block data, should return error", func(t *testing.T) {
t.Parallel()

dp, _ := process.NewDataProcessor(
Expand Down
3 changes: 3 additions & 0 deletions process/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ var ErrNilPruningStorer = errors.New("nil pruning storer")

// ErrNilCacher signals that a nil cacher was provided
var ErrNilCacher = errors.New("nil cacher")

// ErrInvalidOutportBlock signals that an invalid outport block was provided
var ErrInvalidOutportBlock = errors.New("invalid outport block provided")
1 change: 1 addition & 0 deletions process/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Writer interface {
type Publisher interface {
PublishHyperBlock(hyperOutportBlock *data.HyperOutportBlock) error
Close() error
IsInterfaceNil() bool
}

// DataAggregator defines the behaviour of a component that is able to aggregate outport
Expand Down
5 changes: 5 additions & 0 deletions testscommon/publisherStub.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ func (p *PublisherStub) Close() error {

return nil
}

// IsInterfaceNil -
func (p *PublisherStub) IsInterfaceNil() bool {
return p == nil
}

0 comments on commit 500d14c

Please sign in to comment.