Skip to content

Commit ebcf07c

Browse files
committed
fix linter
1 parent 21d951d commit ebcf07c

File tree

5 files changed

+49
-4
lines changed

5 files changed

+49
-4
lines changed

data/block.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package data
22

33
import (
44
"time"
5+
6+
"github.com/multiversx/mx-chain-core-go/data/api"
57
)
68

79
// Block is a structure containing all the fields that need
@@ -39,6 +41,7 @@ type Block struct {
3941
MaxGasLimit uint64 `json:"maxGasLimit"`
4042
ScheduledData *ScheduledData `json:"scheduledData,omitempty"`
4143
EpochStartShardsData []*EpochStartShardData `json:"epochStartShardsData,omitempty"`
44+
PreviousHeaderProof *api.HeaderProof `json:"previousHeaderProof,omitempty"`
4245
RandSeed string `json:"randSeed,omitempty"`
4346
PrevRandSeed string `json:"prevRandSeed,omitempty"`
4447
Signature string `json:"signature,omitempty"`

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/gin-gonic/gin v1.10.0
99
github.com/google/uuid v1.6.0
1010
github.com/multiversx/mx-chain-communication-go v1.1.1
11-
github.com/multiversx/mx-chain-core-go v1.2.24
11+
github.com/multiversx/mx-chain-core-go v1.2.25-0.20250217130858-055baa51891a
1212
github.com/multiversx/mx-chain-logger-go v1.0.15
1313
github.com/multiversx/mx-chain-vm-common-go v1.5.16
1414
github.com/prometheus/client_model v0.4.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
253253
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
254254
github.com/multiversx/mx-chain-communication-go v1.1.1 h1:y4DoQeQOJTaSUsRzczQFazf8JYQmInddypApqA3AkwM=
255255
github.com/multiversx/mx-chain-communication-go v1.1.1/go.mod h1:WK6bP4pGEHGDDna/AYRIMtl6G9OA0NByI1Lw8PmOnRM=
256-
github.com/multiversx/mx-chain-core-go v1.2.24 h1:O0X7N9GfNVUCE9fukXA+dvfCRRjViYn88zOaE7feUog=
257-
github.com/multiversx/mx-chain-core-go v1.2.24/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
256+
github.com/multiversx/mx-chain-core-go v1.2.25-0.20250217130858-055baa51891a h1:iX2qWuxBO3nUKfT5Vs2QGG4KqlB4SgYAv3yW7YWA3GI=
257+
github.com/multiversx/mx-chain-core-go v1.2.25-0.20250217130858-055baa51891a/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
258258
github.com/multiversx/mx-chain-crypto-go v1.2.12 h1:zWip7rpUS4CGthJxfKn5MZfMfYPjVjIiCID6uX5BSOk=
259259
github.com/multiversx/mx-chain-logger-go v1.0.15 h1:HlNdK8etyJyL9NQ+6mIXyKPEBo+wRqOwi3n+m2QIHXc=
260260
github.com/multiversx/mx-chain-logger-go v1.0.15/go.mod h1:t3PRKaWB1M+i6gUfD27KXgzLJJC+mAQiN+FLlL1yoGQ=

process/elasticproc/block/blockProcessor.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/hex"
55
"errors"
66
"fmt"
7+
"github.com/multiversx/mx-chain-core-go/data/api"
78
"strconv"
89
"time"
910

@@ -131,9 +132,29 @@ func (bp *blockProcessor) PrepareBlockForDB(obh *outport.OutportBlockWithHeader)
131132
appendBlockDetailsFromHeaders(elasticBlock, obh.Header, obh.BlockData.Body, obh.TransactionPool)
132133
appendBlockDetailsFromIntraShardMbs(elasticBlock, obh.BlockData.IntraShardMiniBlocks, obh.TransactionPool, len(obh.Header.GetMiniBlockHeaderHandlers()))
133134

135+
appendPreviousHeaderProof(elasticBlock, obh.Header)
136+
134137
return elasticBlock, nil
135138
}
136139

140+
func appendPreviousHeaderProof(elasticBlock *data.Block, header coreData.HeaderHandler) {
141+
prevHeaderProof := header.GetPreviousProof()
142+
if prevHeaderProof == nil {
143+
return
144+
}
145+
146+
elasticBlock.PreviousHeaderProof = &api.HeaderProof{
147+
PubKeysBitmap: hex.EncodeToString(prevHeaderProof.GetPubKeysBitmap()),
148+
AggregatedSignature: hex.EncodeToString(prevHeaderProof.GetAggregatedSignature()),
149+
HeaderHash: hex.EncodeToString(prevHeaderProof.GetHeaderHash()),
150+
HeaderEpoch: prevHeaderProof.GetHeaderEpoch(),
151+
HeaderNonce: prevHeaderProof.GetHeaderNonce(),
152+
HeaderShardId: prevHeaderProof.GetHeaderShardId(),
153+
HeaderRound: prevHeaderProof.GetHeaderRound(),
154+
IsStartOfEpoch: prevHeaderProof.GetIsStartOfEpoch(),
155+
}
156+
}
157+
137158
func getTxsCount(header coreData.HeaderHandler) (numTxs, notarizedTxs uint32) {
138159
numTxs = header.GetTxCount()
139160

process/elasticproc/block/blockProcessor_test.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package block
33
import (
44
"encoding/hex"
55
"errors"
6+
"github.com/multiversx/mx-chain-core-go/data/api"
67
"math/big"
78
"testing"
89

@@ -258,6 +259,16 @@ func TestBlockProcessor_PrepareBlockForDBEpochStartMeta(t *testing.T) {
258259
TxCount: 120,
259260
},
260261
},
262+
PreviousHeaderProof: &dataBlock.HeaderProof{
263+
PubKeysBitmap: []byte("bitmap"),
264+
AggregatedSignature: []byte("sig"),
265+
HeaderHash: []byte("hash"),
266+
HeaderEpoch: 1,
267+
HeaderNonce: 3,
268+
HeaderShardId: 2,
269+
HeaderRound: 4,
270+
IsStartOfEpoch: true,
271+
},
261272
}
262273

263274
headerBytes, _ := bp.marshalizer.Marshal(header)
@@ -293,7 +304,7 @@ func TestBlockProcessor_PrepareBlockForDBEpochStartMeta(t *testing.T) {
293304
Proposer: 0,
294305
Validators: nil,
295306
PubKeyBitmap: "",
296-
Size: 898,
307+
Size: 1090,
297308
SizeTxs: 0,
298309
Timestamp: 0,
299310
StateRootHash: "",
@@ -331,6 +342,16 @@ func TestBlockProcessor_PrepareBlockForDBEpochStartMeta(t *testing.T) {
331342
TxsHashes: []string{},
332343
},
333344
},
345+
PreviousHeaderProof: &api.HeaderProof{
346+
PubKeysBitmap: "6269746d6170",
347+
AggregatedSignature: "736967",
348+
HeaderHash: "68617368",
349+
HeaderEpoch: 1,
350+
HeaderNonce: 3,
351+
HeaderShardId: 2,
352+
HeaderRound: 4,
353+
IsStartOfEpoch: true,
354+
},
334355
EpochStartShardsData: []*data.EpochStartShardData{
335356
{
336357
ShardID: 1,

0 commit comments

Comments
 (0)