Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/elasticClientCommon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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)
}
Expand Down
7 changes: 2 additions & 5 deletions client/elasticClientScroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"strconv"
"time"
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions client/elasticClientScroll_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package client

import (
"context"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"os"
Expand All @@ -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)
}

Expand Down
5 changes: 2 additions & 3 deletions client/logging/customLogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package logging

import (
"io"
"io/ioutil"
"net/http"
"time"

Expand All @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions data/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -39,6 +41,8 @@ type Block struct {
MaxGasLimit uint64 `json:"maxGasLimit"`
ScheduledData *ScheduledData `json:"scheduledData,omitempty"`
EpochStartShardsData []*EpochStartShardData `json:"epochStartShardsData,omitempty"`
Proof *api.HeaderProof `json:"proof,omitempty"`
PreviousHeaderProof *api.HeaderProof `json:"previousHeaderProof,omitempty"`
RandSeed string `json:"randSeed,omitempty"`
PrevRandSeed string `json:"prevRandSeed,omitempty"`
Signature string `json:"signature,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
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-core-go v1.2.25-0.20250219104810-75b7a8ff6bbb
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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ 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-core-go v1.2.25-0.20250219104810-75b7a8ff6bbb h1:XoFaZ3/KEaI7N0o1gqiek+2s/PlqmcvwukAT4iCvAIM=
github.com/multiversx/mx-chain-core-go v1.2.25-0.20250219104810-75b7a8ff6bbb/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=
Expand Down
4 changes: 2 additions & 2 deletions integrationtests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
Expand All @@ -22,6 +21,7 @@ import (
)

var (
// nolint
log = logger.GetOrCreate("integration-tests")
pubKeyConverter, _ = pubkeyConverter.NewBech32PubkeyConverter(32, addressPrefix)
)
Expand Down Expand Up @@ -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
}
Expand Down
28 changes: 28 additions & 0 deletions process/elasticproc/block/blockProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"github.com/multiversx/mx-chain-core-go/data/api"
"strconv"
"time"

Expand Down Expand Up @@ -131,9 +132,36 @@ 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)
}

prevHeaderProof := obh.Header.GetPreviousProof()
if check.IfNilReflect(prevHeaderProof) {
return
}
elasticBlock.PreviousHeaderProof = proofToAPIProof(prevHeaderProof)
}

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()

Expand Down
43 changes: 42 additions & 1 deletion process/elasticproc/block/blockProcessor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package block
import (
"encoding/hex"
"errors"
"github.com/multiversx/mx-chain-core-go/data/api"
"math/big"
"testing"

Expand Down Expand Up @@ -258,13 +259,33 @@ func TestBlockProcessor_PrepareBlockForDBEpochStartMeta(t *testing.T) {
TxCount: 120,
},
},
PreviousHeaderProof: &dataBlock.HeaderProof{
PubKeysBitmap: []byte("bitmap"),
AggregatedSignature: []byte("sig"),
HeaderHash: []byte("hash"),
HeaderEpoch: 1,
HeaderNonce: 3,
HeaderShardId: 2,
HeaderRound: 4,
IsStartOfEpoch: true,
},
}

headerBytes, _ := bp.marshalizer.Marshal(header)
outportBlockWithHeader := &outport.OutportBlockWithHeader{
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{
Expand Down Expand Up @@ -293,7 +314,7 @@ func TestBlockProcessor_PrepareBlockForDBEpochStartMeta(t *testing.T) {
Proposer: 0,
Validators: nil,
PubKeyBitmap: "",
Size: 898,
Size: 1090,
SizeTxs: 0,
Timestamp: 0,
StateRootHash: "",
Expand Down Expand Up @@ -331,6 +352,26 @@ 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,
},
PreviousHeaderProof: &api.HeaderProof{
PubKeysBitmap: "6269746d6170",
AggregatedSignature: "736967",
HeaderHash: "68617368",
HeaderEpoch: 1,
HeaderNonce: 3,
HeaderShardId: 2,
HeaderRound: 4,
IsStartOfEpoch: true,
},
EpochStartShardsData: []*data.EpochStartShardData{
{
ShardID: 1,
Expand Down
2 changes: 1 addition & 1 deletion process/elasticproc/transactions/serialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down