Skip to content

Commit

Permalink
fixes after first review
Browse files Browse the repository at this point in the history
  • Loading branch information
sstanculeanu committed Dec 21, 2023
1 parent cdaa098 commit 1b69f48
Show file tree
Hide file tree
Showing 9 changed files with 402 additions and 306 deletions.
12 changes: 6 additions & 6 deletions data/block/blockV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,16 +653,16 @@ func (hv2 *HeaderV2) CheckFieldsForNil() error {

// GetPreviousAggregatedSignatureAndBitmap returns the previous aggregated signature and the previous pubkeys bitmap
func (hv2 *HeaderV2) GetPreviousAggregatedSignatureAndBitmap() ([]byte, []byte) {
if hv2.Proof == nil {
if hv2.PreviousHeaderProof == nil {
return nil, nil
}
return hv2.Proof.PreviousAggregatedSignature, hv2.Proof.PreviousPubkeysBitmap
return hv2.PreviousHeaderProof.AggregatedSignature, hv2.PreviousHeaderProof.PubKeysBitmap
}

// SetPreviousAggregatedSignatureAndBitmap sets the previous aggregated signature and the previous pubkeys bitmap
func (hv2 *HeaderV2) SetPreviousAggregatedSignatureAndBitmap(aggregatedSignature []byte, pubkeysBitmap []byte) {
hv2.Proof = &Proof{
PreviousPubkeysBitmap: pubkeysBitmap,
PreviousAggregatedSignature: aggregatedSignature,
func (hv2 *HeaderV2) SetPreviousAggregatedSignatureAndBitmap(aggregatedSignature []byte, pubKeysBitmap []byte) {
hv2.PreviousHeaderProof = &PreviousHeaderProof{
PubKeysBitmap: pubKeysBitmap,
AggregatedSignature: aggregatedSignature,
}
}
252 changes: 126 additions & 126 deletions data/block/blockV2.pb.go

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions data/block/blockV2.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import "block.proto";

// HeaderV2 extends the Header structure with extra fields for version 2
message HeaderV2 {
Header Header = 1 [(gogoproto.jsontag) = "header,omitempty"];
bytes ScheduledRootHash = 2 [(gogoproto.jsontag) = "scheduledRootHash,omitempty"];
bytes ScheduledAccumulatedFees = 3 [(gogoproto.jsontag) = "scheduledAccumulatedFees,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"];
bytes ScheduledDeveloperFees = 4 [(gogoproto.jsontag) = "scheduledDeveloperFees,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"];
uint64 ScheduledGasProvided = 5 [(gogoproto.jsontag) = "scheduledGasProvided"];
uint64 ScheduledGasPenalized = 6 [(gogoproto.jsontag) = "scheduledGasPenalized"];
uint64 ScheduledGasRefunded = 7 [(gogoproto.jsontag) = "scheduledGasRefunded"];
Proof Proof = 8 [(gogoproto.jsontag) = "proof"];
Header Header = 1 [(gogoproto.jsontag) = "header,omitempty"];
bytes ScheduledRootHash = 2 [(gogoproto.jsontag) = "scheduledRootHash,omitempty"];
bytes ScheduledAccumulatedFees = 3 [(gogoproto.jsontag) = "scheduledAccumulatedFees,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"];
bytes ScheduledDeveloperFees = 4 [(gogoproto.jsontag) = "scheduledDeveloperFees,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"];
uint64 ScheduledGasProvided = 5 [(gogoproto.jsontag) = "scheduledGasProvided"];
uint64 ScheduledGasPenalized = 6 [(gogoproto.jsontag) = "scheduledGasPenalized"];
uint64 ScheduledGasRefunded = 7 [(gogoproto.jsontag) = "scheduledGasRefunded"];
PreviousHeaderProof PreviousHeaderProof = 8 [(gogoproto.jsontag) = "previousHeaderProof"];
}

message MiniBlockReserved {
Expand All @@ -33,8 +33,8 @@ message MiniBlockHeaderReserved {
int32 IndexOfLastTxProcessed = 4 [(gogoproto.jsontag) = "indexOfLastTxProcessed"];
}

// Proof defines a block proof
message Proof {
bytes PreviousPubkeysBitmap = 1 [(gogoproto.jsontag) = "previousPubkeysBitmap"];
bytes PreviousAggregatedSignature = 2 [(gogoproto.jsontag) = "previousAggregatedSignature"];
// PreviousHeaderProof defines a header proof
message PreviousHeaderProof {
bytes PubKeysBitmap = 1 [(gogoproto.jsontag) = "pubKeysBitmap"];
bytes AggregatedSignature = 2 [(gogoproto.jsontag) = "aggregatedSignature"];
}
6 changes: 3 additions & 3 deletions data/block/blockV2Checks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
var headerV2ExceptionFields = []string{
"Header",
"ScheduledRootHash",
"Proof",
"PreviousHeaderProof",
}

func TestBlockHeaderV2_Checks(t *testing.T) {
Expand Down Expand Up @@ -69,8 +69,8 @@ func TestBlockHeaderV2_Checks(t *testing.T) {
t.Parallel()

objectToTest := &HeaderV2{
Header: &Header{},
Proof: &Proof{},
Header: &Header{},
PreviousHeaderProof: &PreviousHeaderProof{},
}

fieldsForHeaderV1 := prepareFieldsList(objectToTest.Header, headerV1ExceptionFields...)
Expand Down
13 changes: 9 additions & 4 deletions data/block/metaBlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,16 @@ func (m *MetaBlock) CheckFieldsForNil() error {

// GetPreviousAggregatedSignatureAndBitmap returns the previous aggregated signature and the previous pubkeys bitmap
func (m *MetaBlock) GetPreviousAggregatedSignatureAndBitmap() ([]byte, []byte) {
// no proof for meta block header
return nil, nil
if m.PreviousHeaderProof == nil {
return nil, nil
}
return m.PreviousHeaderProof.AggregatedSignature, m.PreviousHeaderProof.PubKeysBitmap
}

// SetPreviousAggregatedSignatureAndBitmap sets the previous aggregated signature and the previous pubkeys bitmap
func (m *MetaBlock) SetPreviousAggregatedSignatureAndBitmap(_ []byte, _ []byte) {
// no proof for meta block header
func (m *MetaBlock) SetPreviousAggregatedSignatureAndBitmap(aggregatedSignature []byte, pubKeysBitmap []byte) {
m.PreviousHeaderProof = &PreviousHeaderProof{
PubKeysBitmap: pubKeysBitmap,
AggregatedSignature: aggregatedSignature,
}
}
Loading

0 comments on commit 1b69f48

Please sign in to comment.