diff --git a/client/elasticClientCommon.go b/client/elasticClientCommon.go index 553ca048..94b81f50 100644 --- a/client/elasticClientCommon.go +++ b/client/elasticClientCommon.go @@ -46,7 +46,7 @@ func loadResponseBody(body io.ReadCloser, dest interface{}) error { return nil } if dest == nil { - _, err := io.Copy(ioutil.Discard, body) + _, err := io.Copy(io.Discard, body) return err } @@ -56,7 +56,7 @@ func loadResponseBody(body io.ReadCloser, dest interface{}) error { func elasticDefaultErrorResponseHandler(res *esapi.Response) error { responseBody := map[string]interface{}{} - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { return fmt.Errorf("%w cannot read elastic response body bytes", err) } diff --git a/client/elasticClientScroll.go b/client/elasticClientScroll.go index 1e1c5037..5448e16c 100644 --- a/client/elasticClientScroll.go +++ b/client/elasticClientScroll.go @@ -4,7 +4,7 @@ import ( "bytes" "context" "fmt" - "io/ioutil" + "io" "net/http" "strconv" "time" @@ -23,9 +23,6 @@ func (ec *elasticClient) DoCountRequest(ctx context.Context, index string, body if err != nil { return 0, err } - if err != nil { - return 0, err - } bodyBytes, err := getBytesFromResponse(res) if err != nil { @@ -139,7 +136,7 @@ func getBytesFromResponse(res *esapi.Response) ([]byte, error) { } defer closeBody(res) - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { return nil, err } diff --git a/client/elasticClientScroll_test.go b/client/elasticClientScroll_test.go index b0fe3d7b..ab61898d 100644 --- a/client/elasticClientScroll_test.go +++ b/client/elasticClientScroll_test.go @@ -2,7 +2,7 @@ package client import ( "context" - "io/ioutil" + "io" "net/http" "net/http/httptest" "os" @@ -24,7 +24,7 @@ func TestElasticClient_DoCountRequest(t *testing.T) { jsonFile, err := os.Open("./testsData/response-count-request.json") require.Nil(t, err) - byteValue, _ := ioutil.ReadAll(jsonFile) + byteValue, _ := io.ReadAll(jsonFile) _, _ = w.Write(byteValue) } diff --git a/client/logging/customLogger.go b/client/logging/customLogger.go index a42eecdf..aa3547fb 100644 --- a/client/logging/customLogger.go +++ b/client/logging/customLogger.go @@ -2,7 +2,6 @@ package logging import ( "io" - "io/ioutil" "net/http" "time" @@ -28,10 +27,10 @@ func (cl *CustomLogger) LogRoundTrip( ) if req != nil && req.Body != nil && req.Body != http.NoBody { - reqSize, _ = io.Copy(ioutil.Discard, req.Body) + reqSize, _ = io.Copy(io.Discard, req.Body) } if res != nil && res.Body != nil && res.Body != http.NoBody { - resSize, _ = io.Copy(ioutil.Discard, res.Body) + resSize, _ = io.Copy(io.Discard, res.Body) } if err != nil { diff --git a/data/block.go b/data/block.go index 73409f75..e8720aa4 100644 --- a/data/block.go +++ b/data/block.go @@ -2,6 +2,8 @@ package data import ( "time" + + "github.com/multiversx/mx-chain-core-go/data/api" ) // Block is a structure containing all the fields that need @@ -18,7 +20,7 @@ type Block struct { MiniBlocksDetails []*MiniBlocksDetails `json:"miniBlocksDetails,omitempty"` NotarizedBlocksHashes []string `json:"notarizedBlocksHashes"` Proposer uint64 `json:"proposer"` - Validators []uint64 `json:"validators"` + Validators []uint64 `json:"validators,omitempty"` PubKeyBitmap string `json:"pubKeyBitmap"` Size int64 `json:"size"` SizeTxs int64 `json:"sizeTxs"` @@ -39,6 +41,7 @@ type Block struct { MaxGasLimit uint64 `json:"maxGasLimit"` ScheduledData *ScheduledData `json:"scheduledData,omitempty"` EpochStartShardsData []*EpochStartShardData `json:"epochStartShardsData,omitempty"` + Proof *api.HeaderProof `json:"proof,omitempty"` RandSeed string `json:"randSeed,omitempty"` PrevRandSeed string `json:"prevRandSeed,omitempty"` Signature string `json:"signature,omitempty"` @@ -47,6 +50,7 @@ type Block struct { SoftwareVersion string `json:"softwareVersion,omitempty"` ReceiptsHash string `json:"receiptsHash,omitempty"` Reserved []byte `json:"reserved,omitempty"` + ProposerBlsKey string `json:"proposerBlsKey,omitempty"` } // MiniBlocksDetails is a structure that hold information about mini-blocks execution details diff --git a/go.mod b/go.mod index 4747b259..e1a24574 100644 --- a/go.mod +++ b/go.mod @@ -7,8 +7,8 @@ require ( github.com/gin-contrib/cors v1.4.0 github.com/gin-gonic/gin v1.10.0 github.com/google/uuid v1.6.0 - github.com/multiversx/mx-chain-communication-go v1.1.1 - github.com/multiversx/mx-chain-core-go v1.2.24 + github.com/multiversx/mx-chain-communication-go v1.2.0 + github.com/multiversx/mx-chain-core-go v1.3.1 github.com/multiversx/mx-chain-logger-go v1.0.15 github.com/multiversx/mx-chain-vm-common-go v1.5.16 github.com/prometheus/client_model v0.4.0 diff --git a/go.sum b/go.sum index 16275e8e..a5313de0 100644 --- a/go.sum +++ b/go.sum @@ -251,10 +251,10 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= -github.com/multiversx/mx-chain-communication-go v1.1.1 h1:y4DoQeQOJTaSUsRzczQFazf8JYQmInddypApqA3AkwM= -github.com/multiversx/mx-chain-communication-go v1.1.1/go.mod h1:WK6bP4pGEHGDDna/AYRIMtl6G9OA0NByI1Lw8PmOnRM= -github.com/multiversx/mx-chain-core-go v1.2.24 h1:O0X7N9GfNVUCE9fukXA+dvfCRRjViYn88zOaE7feUog= -github.com/multiversx/mx-chain-core-go v1.2.24/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE= +github.com/multiversx/mx-chain-communication-go v1.2.0 h1:0wOoLldiRbvaOPxwICbnRCqCpLqPewg8M/FMbC/0OXY= +github.com/multiversx/mx-chain-communication-go v1.2.0/go.mod h1:wS3aAwkmHbC9mlzQdvL6p7l8Rqw3vmzhj7WZW1dTveA= +github.com/multiversx/mx-chain-core-go v1.3.1 h1:r8DAkl9a9t6z38jjbtGNrz295pBeM6fwTq91TP8xX6U= +github.com/multiversx/mx-chain-core-go v1.3.1/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE= github.com/multiversx/mx-chain-crypto-go v1.2.12 h1:zWip7rpUS4CGthJxfKn5MZfMfYPjVjIiCID6uX5BSOk= github.com/multiversx/mx-chain-logger-go v1.0.15 h1:HlNdK8etyJyL9NQ+6mIXyKPEBo+wRqOwi3n+m2QIHXc= github.com/multiversx/mx-chain-logger-go v1.0.15/go.mod h1:t3PRKaWB1M+i6gUfD27KXgzLJJC+mAQiN+FLlL1yoGQ= diff --git a/integrationtests/utils.go b/integrationtests/utils.go index 5fe2aaf8..39baab5e 100644 --- a/integrationtests/utils.go +++ b/integrationtests/utils.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "os" @@ -22,6 +21,7 @@ import ( ) var ( + // nolint log = logger.GetOrCreate("integration-tests") pubKeyConverter, _ = pubkeyConverter.NewBech32PubkeyConverter(32, addressPrefix) ) @@ -93,7 +93,7 @@ func getIndexMappings(index string) (string, error) { return "", err } - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) if err != nil { return "", err } diff --git a/process/elasticproc/block/blockProcessor.go b/process/elasticproc/block/blockProcessor.go index ca74af4b..5b9cbb93 100644 --- a/process/elasticproc/block/blockProcessor.go +++ b/process/elasticproc/block/blockProcessor.go @@ -4,6 +4,7 @@ import ( "encoding/hex" "errors" "fmt" + "github.com/multiversx/mx-chain-core-go/data/api" "strconv" "time" @@ -33,22 +34,27 @@ var ( ) type blockProcessor struct { - hasher hashing.Hasher - marshalizer marshal.Marshalizer + hasher hashing.Hasher + marshalizer marshal.Marshalizer + validatorsPubKeyConverter core.PubkeyConverter } // NewBlockProcessor will create a new instance of block processor -func NewBlockProcessor(hasher hashing.Hasher, marshalizer marshal.Marshalizer) (*blockProcessor, error) { +func NewBlockProcessor(hasher hashing.Hasher, marshalizer marshal.Marshalizer, validatorsPubKeyConverter core.PubkeyConverter) (*blockProcessor, error) { if check.IfNil(hasher) { return nil, indexer.ErrNilHasher } if check.IfNil(marshalizer) { return nil, indexer.ErrNilMarshalizer } + if check.IfNil(validatorsPubKeyConverter) { + return nil, indexer.ErrNilPubkeyConverter + } return &blockProcessor{ - hasher: hasher, - marshalizer: marshalizer, + hasher: hasher, + marshalizer: marshalizer, + validatorsPubKeyConverter: validatorsPubKeyConverter, }, nil } @@ -74,7 +80,6 @@ func (bp *blockProcessor) PrepareBlockForDB(obh *outport.OutportBlockWithHeader) sizeTxs := computeSizeOfTransactions(obh.TransactionPool) miniblocksHashes := bp.getEncodedMBSHashes(obh.BlockData.Body, obh.BlockData.IntraShardMiniBlocks) - leaderIndex := bp.getLeaderIndex(obh.SignersIndexes) numTxs, notarizedTxs := getTxsCount(obh.Header) elasticBlock := &data.Block{ @@ -85,7 +90,8 @@ func (bp *blockProcessor) PrepareBlockForDB(obh *outport.OutportBlockWithHeader) Hash: hex.EncodeToString(obh.BlockData.HeaderHash), MiniBlocksHashes: miniblocksHashes, NotarizedBlocksHashes: obh.NotarizedHeadersHashes, - Proposer: leaderIndex, + Proposer: obh.LeaderIndex, + ProposerBlsKey: hex.EncodeToString(obh.LeaderBLSKey), Validators: obh.SignersIndexes, PubKeyBitmap: hex.EncodeToString(obh.Header.GetPubKeysBitmap()), Size: int64(blockSizeInBytes), @@ -131,9 +137,31 @@ func (bp *blockProcessor) PrepareBlockForDB(obh *outport.OutportBlockWithHeader) appendBlockDetailsFromHeaders(elasticBlock, obh.Header, obh.BlockData.Body, obh.TransactionPool) appendBlockDetailsFromIntraShardMbs(elasticBlock, obh.BlockData.IntraShardMiniBlocks, obh.TransactionPool, len(obh.Header.GetMiniBlockHeaderHandlers())) + addProofs(elasticBlock, obh) + return elasticBlock, nil } +func addProofs(elasticBlock *data.Block, obh *outport.OutportBlockWithHeader) { + if obh.BlockData.HeaderProof != nil { + elasticBlock.Proof = proofToAPIProof(obh.BlockData.HeaderProof) + elasticBlock.PubKeyBitmap = elasticBlock.Proof.PubKeysBitmap + } +} + +func proofToAPIProof(headerProof coreData.HeaderProofHandler) *api.HeaderProof { + return &api.HeaderProof{ + PubKeysBitmap: hex.EncodeToString(headerProof.GetPubKeysBitmap()), + AggregatedSignature: hex.EncodeToString(headerProof.GetAggregatedSignature()), + HeaderHash: hex.EncodeToString(headerProof.GetHeaderHash()), + HeaderEpoch: headerProof.GetHeaderEpoch(), + HeaderNonce: headerProof.GetHeaderNonce(), + HeaderShardId: headerProof.GetHeaderShardId(), + HeaderRound: headerProof.GetHeaderRound(), + IsStartOfEpoch: headerProof.GetIsStartOfEpoch(), + } +} + func getTxsCount(header coreData.HeaderHandler) (numTxs, notarizedTxs uint32) { numTxs = header.GetTxCount() @@ -368,14 +396,6 @@ func (bp *blockProcessor) computeBlockSize(headerBytes []byte, body *block.Body) return blockSize, nil } -func (bp *blockProcessor) getLeaderIndex(signersIndexes []uint64) uint64 { - if len(signersIndexes) > 0 { - return signersIndexes[0] - } - - return 0 -} - func computeBlockSearchOrder(header coreData.HeaderHandler) uint64 { shardIdentifier := createShardIdentifier(header.GetShardID()) stringOrder := fmt.Sprintf("1%02d%d", shardIdentifier, header.GetNonce()) diff --git a/process/elasticproc/block/blockProcessor_test.go b/process/elasticproc/block/blockProcessor_test.go index fe568236..a4ca8a81 100644 --- a/process/elasticproc/block/blockProcessor_test.go +++ b/process/elasticproc/block/blockProcessor_test.go @@ -3,6 +3,7 @@ package block import ( "encoding/hex" "errors" + "github.com/multiversx/mx-chain-core-go/data/api" "math/big" "testing" @@ -25,27 +26,34 @@ func TestNewBlockProcessor(t *testing.T) { tests := []struct { name string - argsFunc func() (hashing.Hasher, marshal.Marshalizer) + argsFunc func() (hashing.Hasher, marshal.Marshalizer, core.PubkeyConverter) exErr error }{ { name: "NilMarshalizer", - argsFunc: func() (hashing.Hasher, marshal.Marshalizer) { - return &mock.HasherMock{}, nil + argsFunc: func() (hashing.Hasher, marshal.Marshalizer, core.PubkeyConverter) { + return &mock.HasherMock{}, nil, nil }, exErr: indexer.ErrNilMarshalizer, }, { name: "NilHasher", - argsFunc: func() (hashing.Hasher, marshal.Marshalizer) { - return nil, &mock.MarshalizerMock{} + argsFunc: func() (hashing.Hasher, marshal.Marshalizer, core.PubkeyConverter) { + return nil, &mock.MarshalizerMock{}, nil }, exErr: indexer.ErrNilHasher, }, + { + name: "NilValidatorPubKeyConverter", + argsFunc: func() (hashing.Hasher, marshal.Marshalizer, core.PubkeyConverter) { + return &mock.HasherMock{}, &mock.MarshalizerMock{}, nil + }, + exErr: indexer.ErrNilPubkeyConverter, + }, { name: "ShouldWork", - argsFunc: func() (hashing.Hasher, marshal.Marshalizer) { - return &mock.HasherMock{}, &mock.MarshalizerMock{} + argsFunc: func() (hashing.Hasher, marshal.Marshalizer, core.PubkeyConverter) { + return &mock.HasherMock{}, &mock.MarshalizerMock{}, &mock.PubkeyConverterMock{} }, exErr: nil, }, @@ -60,7 +68,7 @@ func TestNewBlockProcessor(t *testing.T) { func TestBlockProcessor_PrepareBlockForDBShouldWork(t *testing.T) { t.Parallel() - bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}) + bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}, &mock.PubkeyConverterMock{}) outportBlockWithHeader := &outport.OutportBlockWithHeader{ Header: &dataBlock.Header{ @@ -122,7 +130,7 @@ func TestBlockProcessor_PrepareBlockForDBShouldWork(t *testing.T) { func TestBlockProcessor_PrepareBlockForDBNilHeader(t *testing.T) { t.Parallel() - bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}) + bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}, &mock.PubkeyConverterMock{}) outportBlockWithHeader := &outport.OutportBlockWithHeader{} dbBlock, err := bp.PrepareBlockForDB(outportBlockWithHeader) @@ -133,7 +141,7 @@ func TestBlockProcessor_PrepareBlockForDBNilHeader(t *testing.T) { func TestBlockProcessor_PrepareBlockForDBNilBody(t *testing.T) { t.Parallel() - bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}) + bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}, &mock.PubkeyConverterMock{}) outportBlockWithHeader := &outport.OutportBlockWithHeader{ Header: &dataBlock.MetaBlock{}, @@ -154,7 +162,7 @@ func TestBlockProcessor_PrepareBlockForDBMarshalFailHeader(t *testing.T) { MarshalCalled: func(obj interface{}) ([]byte, error) { return nil, expectedErr }, - }) + }, &mock.PubkeyConverterMock{}) outportBlockWithHeader := &outport.OutportBlockWithHeader{ Header: &dataBlock.Header{}, @@ -181,7 +189,7 @@ func TestBlockProcessor_PrepareBlockForDBMarshalFailBlock(t *testing.T) { MarshalCalled: func(obj interface{}) ([]byte, error) { return nil, expectedErr }, - }) + }, &mock.PubkeyConverterMock{}) outportBlockWithHeader := &outport.OutportBlockWithHeader{ Header: &dataBlock.Header{}, @@ -203,7 +211,7 @@ func TestBlockProcessor_PrepareBlockForDBMarshalFailBlock(t *testing.T) { func TestBlockProcessor_ComputeHeaderHash(t *testing.T) { t.Parallel() - bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}) + bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}, &mock.PubkeyConverterMock{}) header := &dataBlock.Header{} hashBytes, err := bp.ComputeHeaderHash(header) @@ -214,7 +222,7 @@ func TestBlockProcessor_ComputeHeaderHash(t *testing.T) { func TestBlockProcessor_PrepareBlockForDBEpochStartMeta(t *testing.T) { t.Parallel() - bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}) + bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}, &mock.PubkeyConverterMock{}) header := &dataBlock.MetaBlock{ TxCount: 1000, @@ -265,6 +273,16 @@ func TestBlockProcessor_PrepareBlockForDBEpochStartMeta(t *testing.T) { Header: header, OutportBlock: &outport.OutportBlock{ BlockData: &outport.BlockData{ + HeaderProof: &dataBlock.HeaderProof{ + PubKeysBitmap: []byte("bitmap1"), + AggregatedSignature: []byte("sig1"), + HeaderHash: []byte("hash1"), + HeaderEpoch: 2, + HeaderNonce: 2, + HeaderShardId: 2, + HeaderRound: 2, + IsStartOfEpoch: false, + }, HeaderBytes: headerBytes, HeaderHash: []byte("hash"), Body: &dataBlock.Body{ @@ -292,7 +310,7 @@ func TestBlockProcessor_PrepareBlockForDBEpochStartMeta(t *testing.T) { NotarizedBlocksHashes: nil, Proposer: 0, Validators: nil, - PubKeyBitmap: "", + PubKeyBitmap: "6269746d617031", Size: 898, SizeTxs: 0, Timestamp: 0, @@ -331,6 +349,16 @@ func TestBlockProcessor_PrepareBlockForDBEpochStartMeta(t *testing.T) { TxsHashes: []string{}, }, }, + Proof: &api.HeaderProof{ + PubKeysBitmap: "6269746d617031", + AggregatedSignature: "73696731", + HeaderHash: "6861736831", + HeaderEpoch: 2, + HeaderNonce: 2, + HeaderShardId: 2, + HeaderRound: 2, + IsStartOfEpoch: false, + }, EpochStartShardsData: []*data.EpochStartShardData{ { ShardID: 1, @@ -364,7 +392,7 @@ func TestBlockProcessor_PrepareBlockForDBMiniBlocksDetails(t *testing.T) { t.Parallel() gogoMarshaller := &marshal.GogoProtoMarshalizer{} - bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}) + bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}, &mock.PubkeyConverterMock{}) mbhr := &dataBlock.MiniBlockHeaderReserved{ IndexOfFirstTxProcessed: 0, diff --git a/process/elasticproc/block/serialize_test.go b/process/elasticproc/block/serialize_test.go index e88fb1dc..c8146550 100644 --- a/process/elasticproc/block/serialize_test.go +++ b/process/elasticproc/block/serialize_test.go @@ -16,7 +16,7 @@ import ( func TestBlockProcessor_SerializeBlockNilElasticBlockErrors(t *testing.T) { t.Parallel() - bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}) + bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}, &mock.PubkeyConverterMock{}) err := bp.SerializeBlock(nil, nil, "") require.True(t, errors.Is(err, dataindexer.ErrNilElasticBlock)) @@ -25,20 +25,20 @@ func TestBlockProcessor_SerializeBlockNilElasticBlockErrors(t *testing.T) { func TestBlockProcessor_SerializeBlock(t *testing.T) { t.Parallel() - bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}) + bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}, &mock.PubkeyConverterMock{}) buffSlice := data.NewBufferSlice(data.DefaultMaxBulkSize) err := bp.SerializeBlock(&data.Block{Nonce: 1}, buffSlice, "blocks") require.Nil(t, err) require.Equal(t, `{ "index" : { "_index":"blocks", "_id" : "" } } -{"uuid":"","nonce":1,"round":0,"epoch":0,"miniBlocksHashes":null,"notarizedBlocksHashes":null,"proposer":0,"validators":null,"pubKeyBitmap":"","size":0,"sizeTxs":0,"timestamp":0,"stateRootHash":"","prevHash":"","shardId":0,"txCount":0,"notarizedTxsCount":0,"accumulatedFees":"","developerFees":"","epochStartBlock":false,"searchOrder":0,"gasProvided":0,"gasRefunded":0,"gasPenalized":0,"maxGasLimit":0} +{"uuid":"","nonce":1,"round":0,"epoch":0,"miniBlocksHashes":null,"notarizedBlocksHashes":null,"proposer":0,"pubKeyBitmap":"","size":0,"sizeTxs":0,"timestamp":0,"stateRootHash":"","prevHash":"","shardId":0,"txCount":0,"notarizedTxsCount":0,"accumulatedFees":"","developerFees":"","epochStartBlock":false,"searchOrder":0,"gasProvided":0,"gasRefunded":0,"gasPenalized":0,"maxGasLimit":0} `, buffSlice.Buffers()[0].String()) } func TestBlockProcessor_SerializeEpochInfoDataErrors(t *testing.T) { t.Parallel() - bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}) + bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}, &mock.PubkeyConverterMock{}) err := bp.SerializeEpochInfoData(nil, nil, "") require.Equal(t, dataindexer.ErrNilHeaderHandler, err) @@ -50,7 +50,7 @@ func TestBlockProcessor_SerializeEpochInfoDataErrors(t *testing.T) { func TestBlockProcessor_SerializeEpochInfoData(t *testing.T) { t.Parallel() - bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}) + bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}, &mock.PubkeyConverterMock{}) buffSlice := data.NewBufferSlice(data.DefaultMaxBulkSize) err := bp.SerializeEpochInfoData(&dataBlock.MetaBlock{ @@ -66,7 +66,7 @@ func TestBlockProcessor_SerializeEpochInfoData(t *testing.T) { func TestBlockProcessor_SerializeBlockEpochStartMeta(t *testing.T) { t.Parallel() - bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}) + bp, _ := NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}, &mock.PubkeyConverterMock{}) buffSlice := data.NewBufferSlice(data.DefaultMaxBulkSize) err := bp.SerializeBlock(&data.Block{ diff --git a/process/elasticproc/elasticProcessor_test.go b/process/elasticproc/elasticProcessor_test.go index 9f3311af..ac9123b9 100644 --- a/process/elasticproc/elasticProcessor_test.go +++ b/process/elasticproc/elasticProcessor_test.go @@ -62,7 +62,7 @@ func createMockElasticProcessorArgs() *ArgElasticProcessor { balanceConverter, _ := converters.NewBalanceConverter(10) acp, _ := accounts.NewAccountsProcessor(&mock.PubkeyConverterMock{}, balanceConverter) - bp, _ := block.NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}) + bp, _ := block.NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}, &mock.PubkeyConverterMock{}) mp, _ := miniblocks.NewMiniblocksProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}) vp, _ := validators.NewValidatorsProcessor(mock.NewPubkeyConverterMock(32), 0) args := logsevents.ArgsLogsAndEventsProcessor{ @@ -244,7 +244,7 @@ func TestElasticProcessor_RemoveHeader(t *testing.T) { }, } - args.BlockProc, _ = block.NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}) + args.BlockProc, _ = block.NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}, &mock.PubkeyConverterMock{}) elasticProc, err := NewElasticProcessor(args) require.NoError(t, err) @@ -329,7 +329,7 @@ func TestElasticseachDatabaseSaveHeader_RequestError(t *testing.T) { return localErr }, } - arguments.BlockProc, _ = block.NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}) + arguments.BlockProc, _ = block.NewBlockProcessor(&mock.HasherMock{}, &mock.MarshalizerMock{}, &mock.PubkeyConverterMock{}) elasticDatabase := newElasticsearchProcessor(dbWriter, arguments) err := elasticDatabase.SaveHeader(createEmptyOutportBlockWithHeader()) diff --git a/process/elasticproc/factory/elasticProcessorFactory.go b/process/elasticproc/factory/elasticProcessorFactory.go index ad865953..37ea72e0 100644 --- a/process/elasticproc/factory/elasticProcessorFactory.go +++ b/process/elasticproc/factory/elasticProcessorFactory.go @@ -66,7 +66,7 @@ func CreateElasticProcessor(arguments ArgElasticProcessorFactory) (dataindexer.E return nil, err } - blockProcHandler, err := blockProc.NewBlockProcessor(arguments.Hasher, arguments.Marshalizer) + blockProcHandler, err := blockProc.NewBlockProcessor(arguments.Hasher, arguments.Marshalizer, arguments.ValidatorPubkeyConverter) if err != nil { return nil, err } diff --git a/process/elasticproc/transactions/serialize.go b/process/elasticproc/transactions/serialize.go index 0f9b57a3..e5188fbc 100644 --- a/process/elasticproc/transactions/serialize.go +++ b/process/elasticproc/transactions/serialize.go @@ -279,7 +279,7 @@ func prepareNFTESDTTransferOrMultiESDTTransfer(marshaledTx []byte) ([]byte, erro } func isNFTTransferOrMultiTransfer(tx *data.Transaction) bool { - if len(tx.SmartContractResults) < 0 || tx.SenderShard != tx.ReceiverShard { + if tx.SenderShard != tx.ReceiverShard { return false }