From f7dd448bb8b56938de24b9f6572375fd88a331cc Mon Sep 17 00:00:00 2001 From: Marius C Date: Mon, 27 Jan 2025 16:38:03 +0200 Subject: [PATCH 01/12] FEAT: Change sov header with outgoing mb slice --- data/block/sovereignChainHeader.go | 44 ++++--- data/block/sovereignChainHeader.pb.go | 178 ++++++++++++++------------ data/block/sovereignChainHeader.proto | 2 +- data/interface.go | 4 +- 4 files changed, 129 insertions(+), 99 deletions(-) diff --git a/data/block/sovereignChainHeader.go b/data/block/sovereignChainHeader.go index 3887490c..b7e9807e 100644 --- a/data/block/sovereignChainHeader.go +++ b/data/block/sovereignChainHeader.go @@ -6,7 +6,6 @@ import ( "math/big" "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" "github.com/multiversx/mx-chain-core-go/data/headerVersionData" ) @@ -42,9 +41,13 @@ func (sch *SovereignChainHeader) ShallowClone() data.HeaderHandler { headerCopy := *sch headerCopy.Header = &internalHeaderCopy - if !check.IfNil(sch.OutGoingMiniBlockHeader) { - internalOutGoingMbHeader := *sch.OutGoingMiniBlockHeader - headerCopy.OutGoingMiniBlockHeader = &internalOutGoingMbHeader + if len(sch.OutGoingMiniBlockHeader) != 0 { + internalOutGoingMbHeaders := make([]OutGoingMiniBlockHeader, len(sch.OutGoingMiniBlockHeader)) + for idx, outGoingMbHdr := range sch.OutGoingMiniBlockHeader { + internalOutGoingMbHeaders[idx] = outGoingMbHdr + } + + headerCopy.OutGoingMiniBlockHeader = internalOutGoingMbHeaders } return &headerCopy @@ -549,33 +552,44 @@ func (sch *SovereignChainHeader) CheckFieldsForNil() error { return nil } -// GetOutGoingMiniBlockHeaderHandler returns the outgoing mini block header -func (sch *SovereignChainHeader) GetOutGoingMiniBlockHeaderHandler() data.OutGoingMiniBlockHeaderHandler { +// GetOutGoingMiniBlockHeaderHandlers returns the outgoing mini block headers +func (sch *SovereignChainHeader) GetOutGoingMiniBlockHeaderHandlers() []data.OutGoingMiniBlockHeaderHandler { if sch == nil { return nil } - return sch.GetOutGoingMiniBlockHeader() + mbHeaders := sch.GetOutGoingMiniBlockHeader() + mbHeaderHandlers := make([]data.OutGoingMiniBlockHeaderHandler, len(mbHeaders)) + + for i := range mbHeaders { + mbHeaderHandlers[i] = &mbHeaders[i] + } + + return mbHeaderHandlers } -// SetOutGoingMiniBlockHeaderHandler returns the outgoing mini block header -func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeaderHandler(mbHeader data.OutGoingMiniBlockHeaderHandler) error { +// SetOutGoingMiniBlockHeaderHandlers returns the outgoing mini block headers +func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeaderHandlers(mbHeaders []data.OutGoingMiniBlockHeaderHandler) error { if sch == nil { return data.ErrNilPointerReceiver } - if check.IfNil(mbHeader) { + if len(mbHeaders) == 0 { sch.OutGoingMiniBlockHeader = nil return nil } - sch.OutGoingMiniBlockHeader = &OutGoingMiniBlockHeader{ - Hash: mbHeader.GetHash(), - OutGoingOperationsHash: mbHeader.GetOutGoingOperationsHash(), - AggregatedSignatureOutGoingOperations: mbHeader.GetAggregatedSignatureOutGoingOperations(), - LeaderSignatureOutGoingOperations: mbHeader.GetLeaderSignatureOutGoingOperations(), + miniBlockHeaders := make([]OutGoingMiniBlockHeader, len(mbHeaders)) + for i, mbHeaderHandler := range mbHeaders { + miniBlockHeaders[i] = OutGoingMiniBlockHeader{ + Hash: mbHeaderHandler.GetHash(), + OutGoingOperationsHash: mbHeaderHandler.GetOutGoingOperationsHash(), + AggregatedSignatureOutGoingOperations: mbHeaderHandler.GetAggregatedSignatureOutGoingOperations(), + LeaderSignatureOutGoingOperations: mbHeaderHandler.GetLeaderSignatureOutGoingOperations(), + } } + sch.OutGoingMiniBlockHeader = miniBlockHeaders return nil } diff --git a/data/block/sovereignChainHeader.pb.go b/data/block/sovereignChainHeader.pb.go index e282df49..6e3fc280 100644 --- a/data/block/sovereignChainHeader.pb.go +++ b/data/block/sovereignChainHeader.pb.go @@ -150,14 +150,14 @@ func (m *EpochStartCrossChainData) GetHeaderHash() []byte { // SovereignChainHeader extends the Header structure with extra fields needed by sovereign chain type SovereignChainHeader struct { - Header *Header `protobuf:"bytes,1,opt,name=Header,proto3" json:"header"` - ValidatorStatsRootHash []byte `protobuf:"bytes,2,opt,name=ValidatorStatsRootHash,proto3" json:"validatorStatsRootHash"` - ExtendedShardHeaderHashes [][]byte `protobuf:"bytes,3,rep,name=ExtendedShardHeaderHashes,proto3" json:"extendedShardHeaderHashes,omitempty"` - OutGoingMiniBlockHeader *OutGoingMiniBlockHeader `protobuf:"bytes,4,opt,name=OutGoingMiniBlockHeader,proto3" json:"outGoingOperations,omitempty"` - IsStartOfEpoch bool `protobuf:"varint,5,opt,name=IsStartOfEpoch,proto3" json:"isStartOfEpoch,omitempty"` - AccumulatedFeesInEpoch *math_big.Int `protobuf:"bytes,6,opt,name=AccumulatedFeesInEpoch,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"accumulatedFeesInEpoch,omitempty"` - DevFeesInEpoch *math_big.Int `protobuf:"bytes,7,opt,name=DevFeesInEpoch,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"devFeesInEpoch,omitempty"` - EpochStart EpochStartSovereign `protobuf:"bytes,8,opt,name=EpochStart,proto3" json:"epochStart,omitempty"` + Header *Header `protobuf:"bytes,1,opt,name=Header,proto3" json:"header"` + ValidatorStatsRootHash []byte `protobuf:"bytes,2,opt,name=ValidatorStatsRootHash,proto3" json:"validatorStatsRootHash"` + ExtendedShardHeaderHashes [][]byte `protobuf:"bytes,3,rep,name=ExtendedShardHeaderHashes,proto3" json:"extendedShardHeaderHashes,omitempty"` + OutGoingMiniBlockHeader []OutGoingMiniBlockHeader `protobuf:"bytes,4,rep,name=OutGoingMiniBlockHeader,proto3" json:"outGoingOperations,omitempty"` + IsStartOfEpoch bool `protobuf:"varint,5,opt,name=IsStartOfEpoch,proto3" json:"isStartOfEpoch,omitempty"` + AccumulatedFeesInEpoch *math_big.Int `protobuf:"bytes,6,opt,name=AccumulatedFeesInEpoch,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"accumulatedFeesInEpoch,omitempty"` + DevFeesInEpoch *math_big.Int `protobuf:"bytes,7,opt,name=DevFeesInEpoch,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"devFeesInEpoch,omitempty"` + EpochStart EpochStartSovereign `protobuf:"bytes,8,opt,name=EpochStart,proto3" json:"epochStart,omitempty"` } func (m *SovereignChainHeader) Reset() { *m = SovereignChainHeader{} } @@ -209,7 +209,7 @@ func (m *SovereignChainHeader) GetExtendedShardHeaderHashes() [][]byte { return nil } -func (m *SovereignChainHeader) GetOutGoingMiniBlockHeader() *OutGoingMiniBlockHeader { +func (m *SovereignChainHeader) GetOutGoingMiniBlockHeader() []OutGoingMiniBlockHeader { if m != nil { return m.OutGoingMiniBlockHeader } @@ -317,59 +317,59 @@ func init() { func init() { proto.RegisterFile("sovereignChainHeader.proto", fileDescriptor_b9b8ff297a820152) } var fileDescriptor_b9b8ff297a820152 = []byte{ - // 821 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4f, 0x8f, 0xdb, 0x44, - 0x14, 0xcf, 0xb0, 0x9b, 0xa4, 0x99, 0xb4, 0x0b, 0x0c, 0xab, 0x60, 0xa2, 0xad, 0x27, 0x04, 0x16, - 0x22, 0x41, 0x12, 0xd1, 0x5e, 0x90, 0x38, 0xa0, 0xf5, 0x26, 0xa5, 0x91, 0x0a, 0x91, 0x1c, 0x09, - 0x21, 0xc4, 0x65, 0x62, 0x4f, 0xed, 0x11, 0xb1, 0x27, 0xb2, 0xc7, 0xd1, 0x52, 0x09, 0x89, 0x2b, - 0x12, 0x48, 0x7c, 0x09, 0x24, 0xd4, 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 0xf5, 0xa5, 0x5a, 0xf9, 0xbe, 0x2a, - 0x3f, 0x95, 0xf3, 0x9a, 0x1c, 0x99, 0xfb, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0x70, 0xb9, 0xae, - 0xb8, 0x8c, 0x07, 0x00, 0x00, + // 825 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x41, 0x6f, 0xe3, 0x44, + 0x14, 0xce, 0x90, 0x26, 0xdd, 0x4c, 0x76, 0x0b, 0x0c, 0x55, 0x30, 0x51, 0xd7, 0x13, 0xc2, 0x16, + 0x22, 0x41, 0x12, 0xd1, 0xbd, 0x20, 0x71, 0x40, 0x75, 0x93, 0x65, 0x23, 0x2d, 0x44, 0x72, 0x24, + 0x84, 0x10, 0x97, 0x89, 0x3d, 0x6b, 0x8f, 0x88, 0x3d, 0x91, 0x3d, 0x8e, 0x0a, 0x12, 0x88, 0x2b, + 0x12, 0x48, 0xfc, 0x09, 0x24, 0xb4, 0xbf, 0x64, 0x8f, 0x3d, 0xf6, 0x80, 0x0c, 0x75, 0x0f, 0x20, + 0x9f, 0xf6, 0x27, 0x20, 0x8f, 0x9d, 0xd8, 0xdd, 0xc6, 0xdd, 0xbd, 0xec, 0xa9, 0x9d, 0x6f, 0xbe, + 0xf7, 0xbd, 0xef, 0xcd, 0x7b, 0xcf, 0x81, 0x6d, 0x9f, 0xaf, 0xa8, 0x47, 0x99, 0xe5, 0x9e, 0xd8, + 0x84, 0xb9, 0x0f, 0x29, 0x31, 0xa9, 0x37, 0x58, 0x7a, 0x5c, 0x70, 0x54, 0x93, 0x7f, 0xda, 0x7d, + 0x8b, 0x09, 0x3b, 0x98, 0x0f, 0x0c, 0xee, 0x0c, 0x2d, 0x6e, 0xf1, 0xa1, 0x84, 0xe7, 0xc1, 0x63, + 0x79, 0x92, 0x07, 0xf9, 0x5f, 0x1a, 0xd5, 0x6e, 0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, 0x0b, 0x80, 0x87, 0xc7, 0x96, 0xe5, 0x51, 0x2b, 0xe9, 0xd2, + 0x8c, 0x59, 0x2e, 0x11, 0x81, 0x47, 0xaf, 0xb3, 0x95, 0xaa, 0xcc, 0x76, 0x3f, 0x0e, 0xf1, 0x90, + 0xbc, 0x4c, 0x40, 0x21, 0xf9, 0xcb, 0x65, 0x40, 0x3f, 0xc2, 0x77, 0x1f, 0xc9, 0xb7, 0xb9, 0xc9, + 0xc6, 0x8e, 0xb4, 0x31, 0x8c, 0x43, 0xfc, 0xe1, 0xe2, 0x45, 0xe4, 0x82, 0x85, 0x17, 0x2b, 0x6b, + 0x9f, 0x9d, 0x5d, 0xa8, 0x95, 0xf3, 0x0b, 0xb5, 0xf2, 0xec, 0x42, 0x05, 0x3f, 0x47, 0x2a, 0xf8, + 0x33, 0x52, 0xc1, 0xd3, 0x48, 0x05, 0x67, 0x91, 0x0a, 0xce, 0x23, 0x15, 0xfc, 0x13, 0xa9, 0xe0, + 0xbf, 0x48, 0xad, 0x3c, 0x8b, 0x54, 0xf0, 0xfb, 0xa5, 0x5a, 0x39, 0xbb, 0x54, 0x2b, 0xe7, 0x97, + 0x6a, 0xe5, 0x9b, 0x9a, 0xfc, 0xb9, 0x9c, 0xd7, 0xe5, 0xc8, 0xdc, 0xff, 0x3f, 0x00, 0x00, 0xff, + 0xff, 0xe6, 0x82, 0x23, 0xf3, 0x90, 0x07, 0x00, 0x00, } func (this *EpochStartSovereign) Equal(that interface{}) bool { @@ -468,9 +468,14 @@ func (this *SovereignChainHeader) Equal(that interface{}) bool { return false } } - if !this.OutGoingMiniBlockHeader.Equal(that1.OutGoingMiniBlockHeader) { + if len(this.OutGoingMiniBlockHeader) != len(that1.OutGoingMiniBlockHeader) { return false } + for i := range this.OutGoingMiniBlockHeader { + if !this.OutGoingMiniBlockHeader[i].Equal(&that1.OutGoingMiniBlockHeader[i]) { + return false + } + } if this.IsStartOfEpoch != that1.IsStartOfEpoch { return false } @@ -561,7 +566,11 @@ func (this *SovereignChainHeader) GoString() string { s = append(s, "ValidatorStatsRootHash: "+fmt.Sprintf("%#v", this.ValidatorStatsRootHash)+",\n") s = append(s, "ExtendedShardHeaderHashes: "+fmt.Sprintf("%#v", this.ExtendedShardHeaderHashes)+",\n") if this.OutGoingMiniBlockHeader != nil { - s = append(s, "OutGoingMiniBlockHeader: "+fmt.Sprintf("%#v", this.OutGoingMiniBlockHeader)+",\n") + vs := make([]OutGoingMiniBlockHeader, len(this.OutGoingMiniBlockHeader)) + for i := range vs { + vs[i] = this.OutGoingMiniBlockHeader[i] + } + s = append(s, "OutGoingMiniBlockHeader: "+fmt.Sprintf("%#v", vs)+",\n") } s = append(s, "IsStartOfEpoch: "+fmt.Sprintf("%#v", this.IsStartOfEpoch)+",\n") s = append(s, "AccumulatedFeesInEpoch: "+fmt.Sprintf("%#v", this.AccumulatedFeesInEpoch)+",\n") @@ -746,17 +755,19 @@ func (m *SovereignChainHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x28 } - if m.OutGoingMiniBlockHeader != nil { - { - size, err := m.OutGoingMiniBlockHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.OutGoingMiniBlockHeader) > 0 { + for iNdEx := len(m.OutGoingMiniBlockHeader) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OutGoingMiniBlockHeader[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintSovereignChainHeader(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 } - i-- - dAtA[i] = 0x22 } if len(m.ExtendedShardHeaderHashes) > 0 { for iNdEx := len(m.ExtendedShardHeaderHashes) - 1; iNdEx >= 0; iNdEx-- { @@ -909,9 +920,11 @@ func (m *SovereignChainHeader) Size() (n int) { n += 1 + l + sovSovereignChainHeader(uint64(l)) } } - if m.OutGoingMiniBlockHeader != nil { - l = m.OutGoingMiniBlockHeader.Size() - n += 1 + l + sovSovereignChainHeader(uint64(l)) + if len(m.OutGoingMiniBlockHeader) > 0 { + for _, e := range m.OutGoingMiniBlockHeader { + l = e.Size() + n += 1 + l + sovSovereignChainHeader(uint64(l)) + } } if m.IsStartOfEpoch { n += 2 @@ -991,11 +1004,16 @@ func (this *SovereignChainHeader) String() string { if this == nil { return "nil" } + repeatedStringForOutGoingMiniBlockHeader := "[]OutGoingMiniBlockHeader{" + for _, f := range this.OutGoingMiniBlockHeader { + repeatedStringForOutGoingMiniBlockHeader += strings.Replace(strings.Replace(f.String(), "OutGoingMiniBlockHeader", "OutGoingMiniBlockHeader", 1), `&`, ``, 1) + "," + } + repeatedStringForOutGoingMiniBlockHeader += "}" s := strings.Join([]string{`&SovereignChainHeader{`, `Header:` + strings.Replace(fmt.Sprintf("%v", this.Header), "Header", "Header", 1) + `,`, `ValidatorStatsRootHash:` + fmt.Sprintf("%v", this.ValidatorStatsRootHash) + `,`, `ExtendedShardHeaderHashes:` + fmt.Sprintf("%v", this.ExtendedShardHeaderHashes) + `,`, - `OutGoingMiniBlockHeader:` + strings.Replace(this.OutGoingMiniBlockHeader.String(), "OutGoingMiniBlockHeader", "OutGoingMiniBlockHeader", 1) + `,`, + `OutGoingMiniBlockHeader:` + repeatedStringForOutGoingMiniBlockHeader + `,`, `IsStartOfEpoch:` + fmt.Sprintf("%v", this.IsStartOfEpoch) + `,`, `AccumulatedFeesInEpoch:` + fmt.Sprintf("%v", this.AccumulatedFeesInEpoch) + `,`, `DevFeesInEpoch:` + fmt.Sprintf("%v", this.DevFeesInEpoch) + `,`, @@ -1467,10 +1485,8 @@ func (m *SovereignChainHeader) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.OutGoingMiniBlockHeader == nil { - m.OutGoingMiniBlockHeader = &OutGoingMiniBlockHeader{} - } - if err := m.OutGoingMiniBlockHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.OutGoingMiniBlockHeader = append(m.OutGoingMiniBlockHeader, OutGoingMiniBlockHeader{}) + if err := m.OutGoingMiniBlockHeader[len(m.OutGoingMiniBlockHeader)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/data/block/sovereignChainHeader.proto b/data/block/sovereignChainHeader.proto index ad63cf56..e98e4fdd 100644 --- a/data/block/sovereignChainHeader.proto +++ b/data/block/sovereignChainHeader.proto @@ -30,7 +30,7 @@ message SovereignChainHeader { Header Header = 1 [(gogoproto.jsontag) = "header"]; bytes ValidatorStatsRootHash = 2 [(gogoproto.jsontag) = "validatorStatsRootHash"]; repeated bytes ExtendedShardHeaderHashes = 3 [(gogoproto.jsontag) = "extendedShardHeaderHashes,omitempty"]; - OutGoingMiniBlockHeader OutGoingMiniBlockHeader = 4 [(gogoproto.jsontag) = "outGoingOperations,omitempty"]; + repeated OutGoingMiniBlockHeader OutGoingMiniBlockHeader = 4 [(gogoproto.jsontag) = "outGoingOperations,omitempty", (gogoproto.nullable) = false]; bool IsStartOfEpoch = 5 [(gogoproto.jsontag) = "isStartOfEpoch,omitempty"]; bytes AccumulatedFeesInEpoch = 6 [(gogoproto.jsontag) = "accumulatedFeesInEpoch,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; bytes DevFeesInEpoch = 7 [(gogoproto.jsontag) = "devFeesInEpoch,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; diff --git a/data/interface.go b/data/interface.go index 8ad08d52..56617a45 100644 --- a/data/interface.go +++ b/data/interface.go @@ -104,8 +104,8 @@ type SovereignChainHeaderHandler interface { GetValidatorStatsRootHash() []byte SetExtendedShardHeaderHashes(hdrHashes [][]byte) error GetExtendedShardHeaderHashes() [][]byte - GetOutGoingMiniBlockHeaderHandler() OutGoingMiniBlockHeaderHandler - SetOutGoingMiniBlockHeaderHandler(mbHeader OutGoingMiniBlockHeaderHandler) error + GetOutGoingMiniBlockHeaderHandlers() []OutGoingMiniBlockHeaderHandler + SetOutGoingMiniBlockHeaderHandlers(mbHeader []OutGoingMiniBlockHeaderHandler) error GetDevFeesInEpoch() *big.Int SetDevFeesInEpoch(value *big.Int) error GetAccumulatedFeesInEpoch() *big.Int From b2de4b5acbdc3e270bab750aa7fa9d943fe4542a Mon Sep 17 00:00:00 2001 From: Marius C Date: Mon, 27 Jan 2025 16:55:10 +0200 Subject: [PATCH 02/12] FEAT: Outgoing mb type --- data/block/sovereignChainHeader.go | 11 ++ data/block/sovereignChainHeader.pb.go | 190 ++++++++++++++++++-------- data/block/sovereignChainHeader.proto | 31 +++-- data/interface.go | 3 + 4 files changed, 165 insertions(+), 70 deletions(-) diff --git a/data/block/sovereignChainHeader.go b/data/block/sovereignChainHeader.go index b7e9807e..f1788c9e 100644 --- a/data/block/sovereignChainHeader.go +++ b/data/block/sovereignChainHeader.go @@ -582,6 +582,7 @@ func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeaderHandlers(mbHeaders [] miniBlockHeaders := make([]OutGoingMiniBlockHeader, len(mbHeaders)) for i, mbHeaderHandler := range mbHeaders { miniBlockHeaders[i] = OutGoingMiniBlockHeader{ + OutGoingMBType: mbHeaderHandler.GetOutGoingMBType(), Hash: mbHeaderHandler.GetHash(), OutGoingOperationsHash: mbHeaderHandler.GetOutGoingOperationsHash(), AggregatedSignatureOutGoingOperations: mbHeaderHandler.GetAggregatedSignatureOutGoingOperations(), @@ -739,6 +740,16 @@ func (omb *OutGoingMiniBlockHeader) SetAggregatedSignatureOutGoingOperations(sig return nil } +// SetOutGoingMBType sets the mb type +func (omb *OutGoingMiniBlockHeader) SetOutGoingMBType(mbType OutGoingMBType) error { + if omb == nil { + return data.ErrNilPointerReceiver + } + + omb.OutGoingMBType = mbType + return nil +} + // IsInterfaceNil checks if the underlying interface is nil func (omb *OutGoingMiniBlockHeader) IsInterfaceNil() bool { return omb == nil diff --git a/data/block/sovereignChainHeader.pb.go b/data/block/sovereignChainHeader.pb.go index 6e3fc280..1ab91dd4 100644 --- a/data/block/sovereignChainHeader.pb.go +++ b/data/block/sovereignChainHeader.pb.go @@ -14,6 +14,7 @@ import ( math_big "math/big" math_bits "math/bits" reflect "reflect" + strconv "strconv" strings "strings" ) @@ -28,6 +29,27 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type OutGoingMBType int32 + +const ( + OutGoingTxMB OutGoingMBType = 0 + ChangeValidatorSetMB OutGoingMBType = 30 +) + +var OutGoingMBType_name = map[int32]string{ + 0: "OutGoingTxMB", + 30: "ChangeValidatorSetMB", +} + +var OutGoingMBType_value = map[string]int32{ + "OutGoingTxMB": 0, + "ChangeValidatorSetMB": 30, +} + +func (OutGoingMBType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_b9b8ff297a820152, []int{0} +} + // EpochStart holds the block information for end-of-epoch type EpochStartSovereign struct { Economics Economics `protobuf:"bytes,1,opt,name=Economics,proto3" json:"economics"` @@ -245,10 +267,11 @@ func (m *SovereignChainHeader) GetEpochStart() EpochStartSovereign { } type OutGoingMiniBlockHeader struct { - Hash []byte `protobuf:"bytes,1,opt,name=Hash,proto3" json:"hash,omitempty"` - OutGoingOperationsHash []byte `protobuf:"bytes,2,opt,name=OutGoingOperationsHash,proto3" json:"outGoingOperationsHash,omitempty"` - AggregatedSignatureOutGoingOperations []byte `protobuf:"bytes,3,opt,name=AggregatedSignatureOutGoingOperations,proto3" json:"aggregatedSignatureOutGoingOperations,omitempty"` - LeaderSignatureOutGoingOperations []byte `protobuf:"bytes,4,opt,name=LeaderSignatureOutGoingOperations,proto3" json:"leaderSignatureOutGoingOperations,omitempty"` + Hash []byte `protobuf:"bytes,1,opt,name=Hash,proto3" json:"hash,omitempty"` + OutGoingOperationsHash []byte `protobuf:"bytes,2,opt,name=OutGoingOperationsHash,proto3" json:"outGoingOperationsHash,omitempty"` + AggregatedSignatureOutGoingOperations []byte `protobuf:"bytes,3,opt,name=AggregatedSignatureOutGoingOperations,proto3" json:"aggregatedSignatureOutGoingOperations,omitempty"` + LeaderSignatureOutGoingOperations []byte `protobuf:"bytes,4,opt,name=LeaderSignatureOutGoingOperations,proto3" json:"leaderSignatureOutGoingOperations,omitempty"` + OutGoingMBType OutGoingMBType `protobuf:"varint,5,opt,name=OutGoingMBType,proto3,enum=proto.OutGoingMBType" json:"outGoingMBType,omitempty"` } func (m *OutGoingMiniBlockHeader) Reset() { *m = OutGoingMiniBlockHeader{} } @@ -307,7 +330,15 @@ func (m *OutGoingMiniBlockHeader) GetLeaderSignatureOutGoingOperations() []byte return nil } +func (m *OutGoingMiniBlockHeader) GetOutGoingMBType() OutGoingMBType { + if m != nil { + return m.OutGoingMBType + } + return OutGoingTxMB +} + func init() { + proto.RegisterEnum("proto.OutGoingMBType", OutGoingMBType_name, OutGoingMBType_value) proto.RegisterType((*EpochStartSovereign)(nil), "proto.EpochStartSovereign") proto.RegisterType((*EpochStartCrossChainData)(nil), "proto.EpochStartCrossChainData") proto.RegisterType((*SovereignChainHeader)(nil), "proto.SovereignChainHeader") @@ -317,61 +348,72 @@ func init() { func init() { proto.RegisterFile("sovereignChainHeader.proto", fileDescriptor_b9b8ff297a820152) } var fileDescriptor_b9b8ff297a820152 = []byte{ - // 825 bytes of a gzipped FileDescriptorProto + // 886 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x41, 0x6f, 0xe3, 0x44, - 0x14, 0xce, 0x90, 0x26, 0xdd, 0x4c, 0x76, 0x0b, 0x0c, 0x55, 0x30, 0x51, 0xd7, 0x13, 0xc2, 0x16, - 0x22, 0x41, 0x12, 0xd1, 0xbd, 0x20, 0x71, 0x40, 0x75, 0x93, 0x65, 0x23, 0x2d, 0x44, 0x72, 0x24, - 0x84, 0x10, 0x97, 0x89, 0x3d, 0x6b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91, 0x0a, 0xce, 0x23, 0x15, 0xfc, 0x13, 0xa9, 0xe0, - 0xbf, 0x48, 0xad, 0x3c, 0x8b, 0x54, 0xf0, 0xfb, 0xa5, 0x5a, 0x39, 0xbb, 0x54, 0x2b, 0xe7, 0x97, - 0x6a, 0xe5, 0x9b, 0x9a, 0xfc, 0xb9, 0x9c, 0xd7, 0xe5, 0xc8, 0xdc, 0xff, 0x3f, 0x00, 0x00, 0xff, - 0xff, 0xe6, 0x82, 0x23, 0xf3, 0x90, 0x07, 0x00, 0x00, + 0x14, 0xce, 0xd0, 0x24, 0xdd, 0x4e, 0xba, 0xa1, 0x0c, 0xa5, 0x98, 0xa8, 0xeb, 0x09, 0x65, 0x0b, + 0x11, 0xd0, 0x44, 0x74, 0x2f, 0x48, 0x20, 0xa1, 0xba, 0xed, 0xb2, 0x91, 0xb6, 0x54, 0x72, 0x56, + 0x08, 0x01, 0x97, 0x89, 0x3d, 0x6b, 0x8f, 0x88, 0x67, 0x22, 0x7b, 0x52, 0x75, 0x91, 0x40, 0xdc, + 0x10, 0x12, 0x48, 0xfc, 0x09, 0x24, 0xc4, 0x2f, 0xd9, 0x63, 0x8f, 0x3d, 0x20, 0x43, 0xdd, 0x03, + 0xc8, 0xa7, 0xfd, 0x09, 0xc8, 0x63, 0x27, 0x76, 0xda, 0xb8, 0xbb, 0x17, 0x4e, 0xad, 0xbf, 0xf9, + 0xde, 0xf7, 0xbe, 0x37, 0xef, 0xbd, 0x09, 0x6c, 0x05, 0xe2, 0x84, 0xfa, 0x94, 0x39, 0x7c, 0xdf, + 0x25, 0x8c, 0x3f, 0xa0, 0xc4, 0xa6, 0x7e, 0x77, 0xec, 0x0b, 0x29, 0x50, 0x4d, 0xfd, 0x69, 0xed, + 0x38, 0x4c, 0xba, 0x93, 0x61, 0xd7, 0x12, 0x5e, 0xcf, 0x11, 0x8e, 0xe8, 0x29, 0x78, 0x38, 0x79, + 0xac, 0xbe, 0xd4, 0x87, 0xfa, 0x2f, 0x8d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x66, 0x78, + 0xb4, 0x99, 0x2b, 0x08, 0x00, 0x00, +} + +func (x OutGoingMBType) String() string { + s, ok := OutGoingMBType_name[int32(x)] + if ok { + return s + } + return strconv.Itoa(int(x)) } - func (this *EpochStartSovereign) Equal(that interface{}) bool { if that == nil { return this == nil @@ -527,6 +569,9 @@ func (this *OutGoingMiniBlockHeader) Equal(that interface{}) bool { if !bytes.Equal(this.LeaderSignatureOutGoingOperations, that1.LeaderSignatureOutGoingOperations) { return false } + if this.OutGoingMBType != that1.OutGoingMBType { + return false + } return true } func (this *EpochStartSovereign) GoString() string { @@ -583,12 +628,13 @@ func (this *OutGoingMiniBlockHeader) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 8) + s := make([]string, 0, 9) s = append(s, "&block.OutGoingMiniBlockHeader{") s = append(s, "Hash: "+fmt.Sprintf("%#v", this.Hash)+",\n") s = append(s, "OutGoingOperationsHash: "+fmt.Sprintf("%#v", this.OutGoingOperationsHash)+",\n") s = append(s, "AggregatedSignatureOutGoingOperations: "+fmt.Sprintf("%#v", this.AggregatedSignatureOutGoingOperations)+",\n") s = append(s, "LeaderSignatureOutGoingOperations: "+fmt.Sprintf("%#v", this.LeaderSignatureOutGoingOperations)+",\n") + s = append(s, "OutGoingMBType: "+fmt.Sprintf("%#v", this.OutGoingMBType)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -820,6 +866,11 @@ func (m *OutGoingMiniBlockHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l + if m.OutGoingMBType != 0 { + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(m.OutGoingMBType)) + i-- + dAtA[i] = 0x28 + } if len(m.LeaderSignatureOutGoingOperations) > 0 { i -= len(m.LeaderSignatureOutGoingOperations) copy(dAtA[i:], m.LeaderSignatureOutGoingOperations) @@ -966,6 +1017,9 @@ func (m *OutGoingMiniBlockHeader) Size() (n int) { if l > 0 { n += 1 + l + sovSovereignChainHeader(uint64(l)) } + if m.OutGoingMBType != 0 { + n += 1 + sovSovereignChainHeader(uint64(m.OutGoingMBType)) + } return n } @@ -1031,6 +1085,7 @@ func (this *OutGoingMiniBlockHeader) String() string { `OutGoingOperationsHash:` + fmt.Sprintf("%v", this.OutGoingOperationsHash) + `,`, `AggregatedSignatureOutGoingOperations:` + fmt.Sprintf("%v", this.AggregatedSignatureOutGoingOperations) + `,`, `LeaderSignatureOutGoingOperations:` + fmt.Sprintf("%v", this.LeaderSignatureOutGoingOperations) + `,`, + `OutGoingMBType:` + fmt.Sprintf("%v", this.OutGoingMBType) + `,`, `}`, }, "") return s @@ -1808,6 +1863,25 @@ func (m *OutGoingMiniBlockHeader) Unmarshal(dAtA []byte) error { m.LeaderSignatureOutGoingOperations = []byte{} } iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OutGoingMBType", wireType) + } + m.OutGoingMBType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OutGoingMBType |= OutGoingMBType(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipSovereignChainHeader(dAtA[iNdEx:]) diff --git a/data/block/sovereignChainHeader.proto b/data/block/sovereignChainHeader.proto index e98e4fdd..e96c07e4 100644 --- a/data/block/sovereignChainHeader.proto +++ b/data/block/sovereignChainHeader.proto @@ -27,19 +27,26 @@ message EpochStartCrossChainData { // SovereignChainHeader extends the Header structure with extra fields needed by sovereign chain message SovereignChainHeader { - Header Header = 1 [(gogoproto.jsontag) = "header"]; - bytes ValidatorStatsRootHash = 2 [(gogoproto.jsontag) = "validatorStatsRootHash"]; - repeated bytes ExtendedShardHeaderHashes = 3 [(gogoproto.jsontag) = "extendedShardHeaderHashes,omitempty"]; - repeated OutGoingMiniBlockHeader OutGoingMiniBlockHeader = 4 [(gogoproto.jsontag) = "outGoingOperations,omitempty", (gogoproto.nullable) = false]; - bool IsStartOfEpoch = 5 [(gogoproto.jsontag) = "isStartOfEpoch,omitempty"]; - bytes AccumulatedFeesInEpoch = 6 [(gogoproto.jsontag) = "accumulatedFeesInEpoch,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; - bytes DevFeesInEpoch = 7 [(gogoproto.jsontag) = "devFeesInEpoch,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; - EpochStartSovereign EpochStart = 8 [(gogoproto.jsontag) = "epochStart,omitempty", (gogoproto.nullable) = false]; + Header Header = 1 [(gogoproto.jsontag) = "header"]; + bytes ValidatorStatsRootHash = 2 [(gogoproto.jsontag) = "validatorStatsRootHash"]; + repeated bytes ExtendedShardHeaderHashes = 3 [(gogoproto.jsontag) = "extendedShardHeaderHashes,omitempty"]; + repeated OutGoingMiniBlockHeader OutGoingMiniBlockHeader = 4 [(gogoproto.jsontag) = "outGoingOperations,omitempty", (gogoproto.nullable) = false]; + bool IsStartOfEpoch = 5 [(gogoproto.jsontag) = "isStartOfEpoch,omitempty"]; + bytes AccumulatedFeesInEpoch = 6 [(gogoproto.jsontag) = "accumulatedFeesInEpoch,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes DevFeesInEpoch = 7 [(gogoproto.jsontag) = "devFeesInEpoch,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + EpochStartSovereign EpochStart = 8 [(gogoproto.jsontag) = "epochStart,omitempty", (gogoproto.nullable) = false]; } +enum OutGoingMBType { + OutGoingTxMB = 0; + ChangeValidatorSetMB = 30; +}; + + message OutGoingMiniBlockHeader { - bytes Hash = 1 [(gogoproto.jsontag) = "hash,omitempty"]; - bytes OutGoingOperationsHash = 2 [(gogoproto.jsontag) = "outGoingOperationsHash,omitempty"]; - bytes AggregatedSignatureOutGoingOperations = 3 [(gogoproto.jsontag) = "aggregatedSignatureOutGoingOperations,omitempty"]; - bytes LeaderSignatureOutGoingOperations = 4 [(gogoproto.jsontag) = "leaderSignatureOutGoingOperations,omitempty"]; + bytes Hash = 1 [(gogoproto.jsontag) = "hash,omitempty"]; + bytes OutGoingOperationsHash = 2 [(gogoproto.jsontag) = "outGoingOperationsHash,omitempty"]; + bytes AggregatedSignatureOutGoingOperations = 3 [(gogoproto.jsontag) = "aggregatedSignatureOutGoingOperations,omitempty"]; + bytes LeaderSignatureOutGoingOperations = 4 [(gogoproto.jsontag) = "leaderSignatureOutGoingOperations,omitempty"]; + OutGoingMBType OutGoingMBType = 5 [(gogoproto.jsontag) = "outGoingMBType,omitempty"]; } diff --git a/data/interface.go b/data/interface.go index 56617a45..03c054fa 100644 --- a/data/interface.go +++ b/data/interface.go @@ -3,6 +3,7 @@ package data import ( "math/big" + "github.com/multiversx/mx-chain-core-go/data/block" "github.com/multiversx/mx-chain-core-go/data/headerVersionData" ) @@ -124,11 +125,13 @@ type OutGoingMiniBlockHeaderHandler interface { GetOutGoingOperationsHash() []byte GetAggregatedSignatureOutGoingOperations() []byte GetLeaderSignatureOutGoingOperations() []byte + GetOutGoingMBType() block.OutGoingMBType SetHash(hash []byte) error SetOutGoingOperationsHash(hash []byte) error SetLeaderSignatureOutGoingOperations(sig []byte) error SetAggregatedSignatureOutGoingOperations(sig []byte) error + SetOutGoingMBType(mbType block.OutGoingMBType) error IsInterfaceNil() bool } From 5498b573e4f5d3cd21b6e9884a9c33db63917eff Mon Sep 17 00:00:00 2001 From: Marius C Date: Mon, 27 Jan 2025 17:49:16 +0200 Subject: [PATCH 03/12] FIX: Import cycle outgoing mb --- data/block/sovereignChainHeader.go | 16 ++++++++++++---- data/interface.go | 5 ++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/data/block/sovereignChainHeader.go b/data/block/sovereignChainHeader.go index f1788c9e..7ed86f9c 100644 --- a/data/block/sovereignChainHeader.go +++ b/data/block/sovereignChainHeader.go @@ -582,7 +582,7 @@ func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeaderHandlers(mbHeaders [] miniBlockHeaders := make([]OutGoingMiniBlockHeader, len(mbHeaders)) for i, mbHeaderHandler := range mbHeaders { miniBlockHeaders[i] = OutGoingMiniBlockHeader{ - OutGoingMBType: mbHeaderHandler.GetOutGoingMBType(), + OutGoingMBType: OutGoingMBType(mbHeaderHandler.GetOutGoingMBTypeInt32()), Hash: mbHeaderHandler.GetHash(), OutGoingOperationsHash: mbHeaderHandler.GetOutGoingOperationsHash(), AggregatedSignatureOutGoingOperations: mbHeaderHandler.GetAggregatedSignatureOutGoingOperations(), @@ -740,13 +740,21 @@ func (omb *OutGoingMiniBlockHeader) SetAggregatedSignatureOutGoingOperations(sig return nil } -// SetOutGoingMBType sets the mb type -func (omb *OutGoingMiniBlockHeader) SetOutGoingMBType(mbType OutGoingMBType) error { +func (omb *OutGoingMiniBlockHeader) GetOutGoingMBTypeInt32() int32 { + if omb == nil { + return 0 + } + + return int32(omb.OutGoingMBType) +} + +// SetOutGoingMBTypeInt32 sets the mb type +func (omb *OutGoingMiniBlockHeader) SetOutGoingMBTypeInt32(mbType int32) error { if omb == nil { return data.ErrNilPointerReceiver } - omb.OutGoingMBType = mbType + omb.OutGoingMBType = OutGoingMBType(mbType) return nil } diff --git a/data/interface.go b/data/interface.go index 03c054fa..e4468884 100644 --- a/data/interface.go +++ b/data/interface.go @@ -3,7 +3,6 @@ package data import ( "math/big" - "github.com/multiversx/mx-chain-core-go/data/block" "github.com/multiversx/mx-chain-core-go/data/headerVersionData" ) @@ -125,13 +124,13 @@ type OutGoingMiniBlockHeaderHandler interface { GetOutGoingOperationsHash() []byte GetAggregatedSignatureOutGoingOperations() []byte GetLeaderSignatureOutGoingOperations() []byte - GetOutGoingMBType() block.OutGoingMBType + GetOutGoingMBTypeInt32() int32 SetHash(hash []byte) error SetOutGoingOperationsHash(hash []byte) error SetLeaderSignatureOutGoingOperations(sig []byte) error SetAggregatedSignatureOutGoingOperations(sig []byte) error - SetOutGoingMBType(mbType block.OutGoingMBType) error + SetOutGoingMBTypeInt32(mbType int32) error IsInterfaceNil() bool } From 3624ad40be481eedeae4a19c2f2d036e9d9b7664 Mon Sep 17 00:00:00 2001 From: Marius C Date: Mon, 27 Jan 2025 17:56:58 +0200 Subject: [PATCH 04/12] FIX: Simplify ShallowClone outgoing mb slice --- data/block/sovereignChainHeader.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/data/block/sovereignChainHeader.go b/data/block/sovereignChainHeader.go index 7ed86f9c..a6b7d3c3 100644 --- a/data/block/sovereignChainHeader.go +++ b/data/block/sovereignChainHeader.go @@ -42,12 +42,8 @@ func (sch *SovereignChainHeader) ShallowClone() data.HeaderHandler { headerCopy.Header = &internalHeaderCopy if len(sch.OutGoingMiniBlockHeader) != 0 { - internalOutGoingMbHeaders := make([]OutGoingMiniBlockHeader, len(sch.OutGoingMiniBlockHeader)) - for idx, outGoingMbHdr := range sch.OutGoingMiniBlockHeader { - internalOutGoingMbHeaders[idx] = outGoingMbHdr - } - - headerCopy.OutGoingMiniBlockHeader = internalOutGoingMbHeaders + headerCopy.OutGoingMiniBlockHeader = make([]OutGoingMiniBlockHeader, len(sch.OutGoingMiniBlockHeader)) + copy(headerCopy.OutGoingMiniBlockHeader, sch.OutGoingMiniBlockHeader) } return &headerCopy From 47ba8e13c8781cabff7c5a883209353376b5d835 Mon Sep 17 00:00:00 2001 From: Marius C Date: Mon, 27 Jan 2025 18:10:38 +0200 Subject: [PATCH 05/12] FIX: Typo --- data/block/sovereignChainHeader.proto | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/data/block/sovereignChainHeader.proto b/data/block/sovereignChainHeader.proto index e96c07e4..4dd9fea5 100644 --- a/data/block/sovereignChainHeader.proto +++ b/data/block/sovereignChainHeader.proto @@ -27,14 +27,14 @@ message EpochStartCrossChainData { // SovereignChainHeader extends the Header structure with extra fields needed by sovereign chain message SovereignChainHeader { - Header Header = 1 [(gogoproto.jsontag) = "header"]; - bytes ValidatorStatsRootHash = 2 [(gogoproto.jsontag) = "validatorStatsRootHash"]; - repeated bytes ExtendedShardHeaderHashes = 3 [(gogoproto.jsontag) = "extendedShardHeaderHashes,omitempty"]; - repeated OutGoingMiniBlockHeader OutGoingMiniBlockHeader = 4 [(gogoproto.jsontag) = "outGoingOperations,omitempty", (gogoproto.nullable) = false]; - bool IsStartOfEpoch = 5 [(gogoproto.jsontag) = "isStartOfEpoch,omitempty"]; - bytes AccumulatedFeesInEpoch = 6 [(gogoproto.jsontag) = "accumulatedFeesInEpoch,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; - bytes DevFeesInEpoch = 7 [(gogoproto.jsontag) = "devFeesInEpoch,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; - EpochStartSovereign EpochStart = 8 [(gogoproto.jsontag) = "epochStart,omitempty", (gogoproto.nullable) = false]; + Header Header = 1 [(gogoproto.jsontag) = "header"]; + bytes ValidatorStatsRootHash = 2 [(gogoproto.jsontag) = "validatorStatsRootHash"]; + repeated bytes ExtendedShardHeaderHashes = 3 [(gogoproto.jsontag) = "extendedShardHeaderHashes,omitempty"]; + repeated OutGoingMiniBlockHeader OutGoingMiniBlockHeaders = 4 [(gogoproto.jsontag) = "outGoingOperations,omitempty", (gogoproto.nullable) = false]; + bool IsStartOfEpoch = 5 [(gogoproto.jsontag) = "isStartOfEpoch,omitempty"]; + bytes AccumulatedFeesInEpoch = 6 [(gogoproto.jsontag) = "accumulatedFeesInEpoch,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes DevFeesInEpoch = 7 [(gogoproto.jsontag) = "devFeesInEpoch,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + EpochStartSovereign EpochStart = 8 [(gogoproto.jsontag) = "epochStart,omitempty", (gogoproto.nullable) = false]; } enum OutGoingMBType { @@ -42,7 +42,6 @@ enum OutGoingMBType { ChangeValidatorSetMB = 30; }; - message OutGoingMiniBlockHeader { bytes Hash = 1 [(gogoproto.jsontag) = "hash,omitempty"]; bytes OutGoingOperationsHash = 2 [(gogoproto.jsontag) = "outGoingOperationsHash,omitempty"]; From c740cbfe05ab7c5558cefc7a3f54f9dc351ef03b Mon Sep 17 00:00:00 2001 From: Marius C Date: Tue, 11 Feb 2025 13:45:54 +0200 Subject: [PATCH 06/12] CLN: Extend interface + typos --- data/block/sovereignChainHeader.go | 63 +++++++--- data/block/sovereignChainHeader.pb.go | 158 +++++++++++++------------- data/interface.go | 2 + 3 files changed, 131 insertions(+), 92 deletions(-) diff --git a/data/block/sovereignChainHeader.go b/data/block/sovereignChainHeader.go index a6b7d3c3..83ad714f 100644 --- a/data/block/sovereignChainHeader.go +++ b/data/block/sovereignChainHeader.go @@ -41,9 +41,9 @@ func (sch *SovereignChainHeader) ShallowClone() data.HeaderHandler { headerCopy := *sch headerCopy.Header = &internalHeaderCopy - if len(sch.OutGoingMiniBlockHeader) != 0 { - headerCopy.OutGoingMiniBlockHeader = make([]OutGoingMiniBlockHeader, len(sch.OutGoingMiniBlockHeader)) - copy(headerCopy.OutGoingMiniBlockHeader, sch.OutGoingMiniBlockHeader) + if len(sch.OutGoingMiniBlockHeaders) != 0 { + headerCopy.OutGoingMiniBlockHeaders = make([]OutGoingMiniBlockHeader, len(sch.OutGoingMiniBlockHeaders)) + copy(headerCopy.OutGoingMiniBlockHeaders, sch.OutGoingMiniBlockHeaders) } return &headerCopy @@ -554,7 +554,7 @@ func (sch *SovereignChainHeader) GetOutGoingMiniBlockHeaderHandlers() []data.Out return nil } - mbHeaders := sch.GetOutGoingMiniBlockHeader() + mbHeaders := sch.GetOutGoingMiniBlockHeaders() mbHeaderHandlers := make([]data.OutGoingMiniBlockHeaderHandler, len(mbHeaders)) for i := range mbHeaders { @@ -564,6 +564,49 @@ func (sch *SovereignChainHeader) GetOutGoingMiniBlockHeaderHandlers() []data.Out return mbHeaderHandlers } +// GetOutGoingMiniBlockHeader returns the outgoing mb header with specified type, if found +func (sch *SovereignChainHeader) GetOutGoingMiniBlockHeader(mbType int32) data.OutGoingMiniBlockHeaderHandler { + if sch == nil { + return nil + } + + for _, outGoingMbHdr := range sch.OutGoingMiniBlockHeaders { + if int32(outGoingMbHdr.OutGoingMBType) == mbType { + return &outGoingMbHdr + } + } + + return nil +} + +// SetOutGoingMiniBlockHeader replaces the outgoing mb from the internal outgoing mb slice, if found. +// Otherwise, it adds it add the end of the slice. +func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeader(mbHeader data.OutGoingMiniBlockHeaderHandler) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + outGoingMbHdr := createOutGoingMbHeader(mbHeader) + for idx, currOutGoingMbHdr := range sch.OutGoingMiniBlockHeaders { + if int32(currOutGoingMbHdr.OutGoingMBType) == mbHeader.GetOutGoingMBTypeInt32() { + sch.OutGoingMiniBlockHeaders[idx] = outGoingMbHdr + } + } + + sch.OutGoingMiniBlockHeaders = append(sch.OutGoingMiniBlockHeaders, outGoingMbHdr) + return nil +} + +func createOutGoingMbHeader(mbHeader data.OutGoingMiniBlockHeaderHandler) OutGoingMiniBlockHeader { + return OutGoingMiniBlockHeader{ + OutGoingMBType: OutGoingMBType(mbHeader.GetOutGoingMBTypeInt32()), + Hash: mbHeader.GetHash(), + OutGoingOperationsHash: mbHeader.GetOutGoingOperationsHash(), + AggregatedSignatureOutGoingOperations: mbHeader.GetAggregatedSignatureOutGoingOperations(), + LeaderSignatureOutGoingOperations: mbHeader.GetLeaderSignatureOutGoingOperations(), + } +} + // SetOutGoingMiniBlockHeaderHandlers returns the outgoing mini block headers func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeaderHandlers(mbHeaders []data.OutGoingMiniBlockHeaderHandler) error { if sch == nil { @@ -571,22 +614,16 @@ func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeaderHandlers(mbHeaders [] } if len(mbHeaders) == 0 { - sch.OutGoingMiniBlockHeader = nil + sch.OutGoingMiniBlockHeaders = nil return nil } miniBlockHeaders := make([]OutGoingMiniBlockHeader, len(mbHeaders)) for i, mbHeaderHandler := range mbHeaders { - miniBlockHeaders[i] = OutGoingMiniBlockHeader{ - OutGoingMBType: OutGoingMBType(mbHeaderHandler.GetOutGoingMBTypeInt32()), - Hash: mbHeaderHandler.GetHash(), - OutGoingOperationsHash: mbHeaderHandler.GetOutGoingOperationsHash(), - AggregatedSignatureOutGoingOperations: mbHeaderHandler.GetAggregatedSignatureOutGoingOperations(), - LeaderSignatureOutGoingOperations: mbHeaderHandler.GetLeaderSignatureOutGoingOperations(), - } + miniBlockHeaders[i] = createOutGoingMbHeader(mbHeaderHandler) } - sch.OutGoingMiniBlockHeader = miniBlockHeaders + sch.OutGoingMiniBlockHeaders = miniBlockHeaders return nil } diff --git a/data/block/sovereignChainHeader.pb.go b/data/block/sovereignChainHeader.pb.go index 1ab91dd4..2d59c76a 100644 --- a/data/block/sovereignChainHeader.pb.go +++ b/data/block/sovereignChainHeader.pb.go @@ -175,7 +175,7 @@ type SovereignChainHeader struct { Header *Header `protobuf:"bytes,1,opt,name=Header,proto3" json:"header"` ValidatorStatsRootHash []byte `protobuf:"bytes,2,opt,name=ValidatorStatsRootHash,proto3" json:"validatorStatsRootHash"` ExtendedShardHeaderHashes [][]byte `protobuf:"bytes,3,rep,name=ExtendedShardHeaderHashes,proto3" json:"extendedShardHeaderHashes,omitempty"` - OutGoingMiniBlockHeader []OutGoingMiniBlockHeader `protobuf:"bytes,4,rep,name=OutGoingMiniBlockHeader,proto3" json:"outGoingOperations,omitempty"` + OutGoingMiniBlockHeaders []OutGoingMiniBlockHeader `protobuf:"bytes,4,rep,name=OutGoingMiniBlockHeaders,proto3" json:"outGoingOperations,omitempty"` IsStartOfEpoch bool `protobuf:"varint,5,opt,name=IsStartOfEpoch,proto3" json:"isStartOfEpoch,omitempty"` AccumulatedFeesInEpoch *math_big.Int `protobuf:"bytes,6,opt,name=AccumulatedFeesInEpoch,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"accumulatedFeesInEpoch,omitempty"` DevFeesInEpoch *math_big.Int `protobuf:"bytes,7,opt,name=DevFeesInEpoch,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"devFeesInEpoch,omitempty"` @@ -231,9 +231,9 @@ func (m *SovereignChainHeader) GetExtendedShardHeaderHashes() [][]byte { return nil } -func (m *SovereignChainHeader) GetOutGoingMiniBlockHeader() []OutGoingMiniBlockHeader { +func (m *SovereignChainHeader) GetOutGoingMiniBlockHeaders() []OutGoingMiniBlockHeader { if m != nil { - return m.OutGoingMiniBlockHeader + return m.OutGoingMiniBlockHeaders } return nil } @@ -348,63 +348,63 @@ func init() { func init() { proto.RegisterFile("sovereignChainHeader.proto", fileDescriptor_b9b8ff297a820152) } var fileDescriptor_b9b8ff297a820152 = []byte{ - // 886 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x41, 0x6f, 0xe3, 0x44, - 0x14, 0xce, 0xd0, 0x24, 0xdd, 0x4e, 0xba, 0xa1, 0x0c, 0xa5, 0x98, 0xa8, 0xeb, 0x09, 0x65, 0x0b, + // 888 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4f, 0x6f, 0xe3, 0x44, + 0x1c, 0xcd, 0xd0, 0x24, 0xdd, 0x4e, 0xba, 0xa1, 0x0c, 0xa5, 0x98, 0xa8, 0xeb, 0x09, 0x65, 0x0b, 0x11, 0xd0, 0x44, 0x74, 0x2f, 0x48, 0x20, 0xa1, 0xba, 0xed, 0xb2, 0x91, 0xb6, 0x54, 0x72, 0x56, - 0x08, 0x01, 0x97, 0x89, 0x3d, 0x6b, 0x8f, 0x88, 0x67, 0x22, 0x7b, 0x52, 0x75, 0x91, 0x40, 0xdc, - 0x10, 0x12, 0x48, 0xfc, 0x09, 0x24, 0xc4, 0x2f, 0xd9, 0x63, 0x8f, 0x3d, 0x20, 0x43, 0xdd, 0x03, - 0xc8, 0xa7, 0xfd, 0x09, 0xc8, 0x63, 0x27, 0x76, 0xda, 0xb8, 0xbb, 0x17, 0x4e, 0xad, 0xbf, 0xf9, - 0xde, 0xf7, 0xbe, 0x37, 0xef, 0xbd, 0x09, 0x6c, 0x05, 0xe2, 0x84, 0xfa, 0x94, 0x39, 0x7c, 0xdf, - 0x25, 0x8c, 0x3f, 0xa0, 0xc4, 0xa6, 0x7e, 0x77, 0xec, 0x0b, 0x29, 0x50, 0x4d, 0xfd, 0x69, 0xed, - 0x38, 0x4c, 0xba, 0x93, 0x61, 0xd7, 0x12, 0x5e, 0xcf, 0x11, 0x8e, 0xe8, 0x29, 0x78, 0x38, 0x79, - 0xac, 0xbe, 0xd4, 0x87, 0xfa, 0x2f, 0x8d, 0x6a, 0x35, 0x86, 0x23, 0x61, 0x7d, 0x93, 0x7d, 0xbc, - 0xec, 0x51, 0x49, 0x8c, 0x1c, 0xd8, 0xfa, 0x07, 0xc0, 0x57, 0x0f, 0xc7, 0xc2, 0x72, 0x07, 0x92, - 0xf8, 0x72, 0x30, 0x4d, 0x8e, 0xf6, 0xe0, 0xca, 0xa1, 0x25, 0xb8, 0xf0, 0x98, 0x15, 0x68, 0xa0, - 0x0d, 0x3a, 0x8d, 0xdd, 0xb5, 0x34, 0xa4, 0x3b, 0xc3, 0x8d, 0x57, 0x9e, 0x86, 0xb8, 0x12, 0x87, - 0x78, 0x85, 0x4e, 0x21, 0x33, 0x8f, 0x42, 0x3f, 0x03, 0x78, 0xe7, 0x21, 0x09, 0xe4, 0x7d, 0xc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xc1, 0x79, 0xa4, 0x83, 0xbf, 0x23, 0x1d, 0xfc, 0x1b, + 0xe9, 0x95, 0x17, 0x91, 0x0e, 0x7e, 0xbf, 0xd4, 0x2b, 0x67, 0x97, 0x7a, 0xe5, 0xfc, 0x52, 0xaf, + 0x7c, 0x5b, 0x53, 0x3f, 0xe6, 0xc3, 0xba, 0xba, 0xc2, 0xbd, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, + 0x8c, 0x38, 0xe9, 0x6f, 0x2e, 0x08, 0x00, 0x00, } func (x OutGoingMBType) String() string { @@ -510,11 +510,11 @@ func (this *SovereignChainHeader) Equal(that interface{}) bool { return false } } - if len(this.OutGoingMiniBlockHeader) != len(that1.OutGoingMiniBlockHeader) { + if len(this.OutGoingMiniBlockHeaders) != len(that1.OutGoingMiniBlockHeaders) { return false } - for i := range this.OutGoingMiniBlockHeader { - if !this.OutGoingMiniBlockHeader[i].Equal(&that1.OutGoingMiniBlockHeader[i]) { + for i := range this.OutGoingMiniBlockHeaders { + if !this.OutGoingMiniBlockHeaders[i].Equal(&that1.OutGoingMiniBlockHeaders[i]) { return false } } @@ -610,12 +610,12 @@ func (this *SovereignChainHeader) GoString() string { } s = append(s, "ValidatorStatsRootHash: "+fmt.Sprintf("%#v", this.ValidatorStatsRootHash)+",\n") s = append(s, "ExtendedShardHeaderHashes: "+fmt.Sprintf("%#v", this.ExtendedShardHeaderHashes)+",\n") - if this.OutGoingMiniBlockHeader != nil { - vs := make([]OutGoingMiniBlockHeader, len(this.OutGoingMiniBlockHeader)) + if this.OutGoingMiniBlockHeaders != nil { + vs := make([]OutGoingMiniBlockHeader, len(this.OutGoingMiniBlockHeaders)) for i := range vs { - vs[i] = this.OutGoingMiniBlockHeader[i] + vs[i] = this.OutGoingMiniBlockHeaders[i] } - s = append(s, "OutGoingMiniBlockHeader: "+fmt.Sprintf("%#v", vs)+",\n") + s = append(s, "OutGoingMiniBlockHeaders: "+fmt.Sprintf("%#v", vs)+",\n") } s = append(s, "IsStartOfEpoch: "+fmt.Sprintf("%#v", this.IsStartOfEpoch)+",\n") s = append(s, "AccumulatedFeesInEpoch: "+fmt.Sprintf("%#v", this.AccumulatedFeesInEpoch)+",\n") @@ -801,10 +801,10 @@ func (m *SovereignChainHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x28 } - if len(m.OutGoingMiniBlockHeader) > 0 { - for iNdEx := len(m.OutGoingMiniBlockHeader) - 1; iNdEx >= 0; iNdEx-- { + if len(m.OutGoingMiniBlockHeaders) > 0 { + for iNdEx := len(m.OutGoingMiniBlockHeaders) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.OutGoingMiniBlockHeader[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.OutGoingMiniBlockHeaders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -971,8 +971,8 @@ func (m *SovereignChainHeader) Size() (n int) { n += 1 + l + sovSovereignChainHeader(uint64(l)) } } - if len(m.OutGoingMiniBlockHeader) > 0 { - for _, e := range m.OutGoingMiniBlockHeader { + if len(m.OutGoingMiniBlockHeaders) > 0 { + for _, e := range m.OutGoingMiniBlockHeaders { l = e.Size() n += 1 + l + sovSovereignChainHeader(uint64(l)) } @@ -1058,16 +1058,16 @@ func (this *SovereignChainHeader) String() string { if this == nil { return "nil" } - repeatedStringForOutGoingMiniBlockHeader := "[]OutGoingMiniBlockHeader{" - for _, f := range this.OutGoingMiniBlockHeader { - repeatedStringForOutGoingMiniBlockHeader += strings.Replace(strings.Replace(f.String(), "OutGoingMiniBlockHeader", "OutGoingMiniBlockHeader", 1), `&`, ``, 1) + "," + repeatedStringForOutGoingMiniBlockHeaders := "[]OutGoingMiniBlockHeader{" + for _, f := range this.OutGoingMiniBlockHeaders { + repeatedStringForOutGoingMiniBlockHeaders += strings.Replace(strings.Replace(f.String(), "OutGoingMiniBlockHeader", "OutGoingMiniBlockHeader", 1), `&`, ``, 1) + "," } - repeatedStringForOutGoingMiniBlockHeader += "}" + repeatedStringForOutGoingMiniBlockHeaders += "}" s := strings.Join([]string{`&SovereignChainHeader{`, `Header:` + strings.Replace(fmt.Sprintf("%v", this.Header), "Header", "Header", 1) + `,`, `ValidatorStatsRootHash:` + fmt.Sprintf("%v", this.ValidatorStatsRootHash) + `,`, `ExtendedShardHeaderHashes:` + fmt.Sprintf("%v", this.ExtendedShardHeaderHashes) + `,`, - `OutGoingMiniBlockHeader:` + repeatedStringForOutGoingMiniBlockHeader + `,`, + `OutGoingMiniBlockHeaders:` + repeatedStringForOutGoingMiniBlockHeaders + `,`, `IsStartOfEpoch:` + fmt.Sprintf("%v", this.IsStartOfEpoch) + `,`, `AccumulatedFeesInEpoch:` + fmt.Sprintf("%v", this.AccumulatedFeesInEpoch) + `,`, `DevFeesInEpoch:` + fmt.Sprintf("%v", this.DevFeesInEpoch) + `,`, @@ -1513,7 +1513,7 @@ func (m *SovereignChainHeader) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OutGoingMiniBlockHeader", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field OutGoingMiniBlockHeaders", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1540,8 +1540,8 @@ func (m *SovereignChainHeader) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.OutGoingMiniBlockHeader = append(m.OutGoingMiniBlockHeader, OutGoingMiniBlockHeader{}) - if err := m.OutGoingMiniBlockHeader[len(m.OutGoingMiniBlockHeader)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.OutGoingMiniBlockHeaders = append(m.OutGoingMiniBlockHeaders, OutGoingMiniBlockHeader{}) + if err := m.OutGoingMiniBlockHeaders[len(m.OutGoingMiniBlockHeaders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/data/interface.go b/data/interface.go index e4468884..031bd67a 100644 --- a/data/interface.go +++ b/data/interface.go @@ -106,6 +106,8 @@ type SovereignChainHeaderHandler interface { GetExtendedShardHeaderHashes() [][]byte GetOutGoingMiniBlockHeaderHandlers() []OutGoingMiniBlockHeaderHandler SetOutGoingMiniBlockHeaderHandlers(mbHeader []OutGoingMiniBlockHeaderHandler) error + GetOutGoingMiniBlockHeader(mbType int32) OutGoingMiniBlockHeaderHandler + SetOutGoingMiniBlockHeader(mbHeader OutGoingMiniBlockHeaderHandler) error GetDevFeesInEpoch() *big.Int SetDevFeesInEpoch(value *big.Int) error GetAccumulatedFeesInEpoch() *big.Int From d718ad53ac65e7b639d1ff2204204081db5bd57b Mon Sep 17 00:00:00 2001 From: Marius C Date: Tue, 11 Feb 2025 15:28:58 +0200 Subject: [PATCH 07/12] FIX: Interface rename to be compatible in node --- data/block/sovereignChainHeader.go | 8 ++++---- data/interface.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data/block/sovereignChainHeader.go b/data/block/sovereignChainHeader.go index 83ad714f..21a9ad16 100644 --- a/data/block/sovereignChainHeader.go +++ b/data/block/sovereignChainHeader.go @@ -564,8 +564,8 @@ func (sch *SovereignChainHeader) GetOutGoingMiniBlockHeaderHandlers() []data.Out return mbHeaderHandlers } -// GetOutGoingMiniBlockHeader returns the outgoing mb header with specified type, if found -func (sch *SovereignChainHeader) GetOutGoingMiniBlockHeader(mbType int32) data.OutGoingMiniBlockHeaderHandler { +// GetOutGoingMiniBlockHeaderHandler returns the outgoing mb header with specified type, if found +func (sch *SovereignChainHeader) GetOutGoingMiniBlockHeaderHandler(mbType int32) data.OutGoingMiniBlockHeaderHandler { if sch == nil { return nil } @@ -579,9 +579,9 @@ func (sch *SovereignChainHeader) GetOutGoingMiniBlockHeader(mbType int32) data.O return nil } -// SetOutGoingMiniBlockHeader replaces the outgoing mb from the internal outgoing mb slice, if found. +// SetOutGoingMiniBlockHeaderHandler replaces the outgoing mb from the internal outgoing mb slice, if found. // Otherwise, it adds it add the end of the slice. -func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeader(mbHeader data.OutGoingMiniBlockHeaderHandler) error { +func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeaderHandler(mbHeader data.OutGoingMiniBlockHeaderHandler) error { if sch == nil { return data.ErrNilPointerReceiver } diff --git a/data/interface.go b/data/interface.go index 031bd67a..8de04236 100644 --- a/data/interface.go +++ b/data/interface.go @@ -106,8 +106,8 @@ type SovereignChainHeaderHandler interface { GetExtendedShardHeaderHashes() [][]byte GetOutGoingMiniBlockHeaderHandlers() []OutGoingMiniBlockHeaderHandler SetOutGoingMiniBlockHeaderHandlers(mbHeader []OutGoingMiniBlockHeaderHandler) error - GetOutGoingMiniBlockHeader(mbType int32) OutGoingMiniBlockHeaderHandler - SetOutGoingMiniBlockHeader(mbHeader OutGoingMiniBlockHeaderHandler) error + GetOutGoingMiniBlockHeaderHandler(mbType int32) OutGoingMiniBlockHeaderHandler + SetOutGoingMiniBlockHeaderHandler(mbHeader OutGoingMiniBlockHeaderHandler) error GetDevFeesInEpoch() *big.Int SetDevFeesInEpoch(value *big.Int) error GetAccumulatedFeesInEpoch() *big.Int From 065d3787e30325c1c8856e740c2300c99bc28c66 Mon Sep 17 00:00:00 2001 From: Marius C Date: Tue, 11 Feb 2025 16:58:12 +0200 Subject: [PATCH 08/12] FIX: SetOutGoingMiniBlockHeaderHandler --- data/block/sovereignChainHeader.go | 1 + 1 file changed, 1 insertion(+) diff --git a/data/block/sovereignChainHeader.go b/data/block/sovereignChainHeader.go index 21a9ad16..cc4f5beb 100644 --- a/data/block/sovereignChainHeader.go +++ b/data/block/sovereignChainHeader.go @@ -590,6 +590,7 @@ func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeaderHandler(mbHeader data for idx, currOutGoingMbHdr := range sch.OutGoingMiniBlockHeaders { if int32(currOutGoingMbHdr.OutGoingMBType) == mbHeader.GetOutGoingMBTypeInt32() { sch.OutGoingMiniBlockHeaders[idx] = outGoingMbHdr + return nil } } From 8998ffbadaa0e6e17049523dc8f1e7cba2d0816d Mon Sep 17 00:00:00 2001 From: Marius C Date: Tue, 11 Feb 2025 17:31:17 +0200 Subject: [PATCH 09/12] FIX: Pointer receiver in OutGoingMiniBlockHeaders slice --- data/block/sovereignChainHeader.go | 12 +-- data/block/sovereignChainHeader.pb.go | 142 +++++++++++++------------- data/block/sovereignChainHeader.proto | 2 +- 3 files changed, 76 insertions(+), 80 deletions(-) diff --git a/data/block/sovereignChainHeader.go b/data/block/sovereignChainHeader.go index cc4f5beb..dd8328a5 100644 --- a/data/block/sovereignChainHeader.go +++ b/data/block/sovereignChainHeader.go @@ -42,7 +42,7 @@ func (sch *SovereignChainHeader) ShallowClone() data.HeaderHandler { headerCopy.Header = &internalHeaderCopy if len(sch.OutGoingMiniBlockHeaders) != 0 { - headerCopy.OutGoingMiniBlockHeaders = make([]OutGoingMiniBlockHeader, len(sch.OutGoingMiniBlockHeaders)) + headerCopy.OutGoingMiniBlockHeaders = make([]*OutGoingMiniBlockHeader, len(sch.OutGoingMiniBlockHeaders)) copy(headerCopy.OutGoingMiniBlockHeaders, sch.OutGoingMiniBlockHeaders) } @@ -558,7 +558,7 @@ func (sch *SovereignChainHeader) GetOutGoingMiniBlockHeaderHandlers() []data.Out mbHeaderHandlers := make([]data.OutGoingMiniBlockHeaderHandler, len(mbHeaders)) for i := range mbHeaders { - mbHeaderHandlers[i] = &mbHeaders[i] + mbHeaderHandlers[i] = mbHeaders[i] } return mbHeaderHandlers @@ -572,7 +572,7 @@ func (sch *SovereignChainHeader) GetOutGoingMiniBlockHeaderHandler(mbType int32) for _, outGoingMbHdr := range sch.OutGoingMiniBlockHeaders { if int32(outGoingMbHdr.OutGoingMBType) == mbType { - return &outGoingMbHdr + return outGoingMbHdr } } @@ -598,8 +598,8 @@ func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeaderHandler(mbHeader data return nil } -func createOutGoingMbHeader(mbHeader data.OutGoingMiniBlockHeaderHandler) OutGoingMiniBlockHeader { - return OutGoingMiniBlockHeader{ +func createOutGoingMbHeader(mbHeader data.OutGoingMiniBlockHeaderHandler) *OutGoingMiniBlockHeader { + return &OutGoingMiniBlockHeader{ OutGoingMBType: OutGoingMBType(mbHeader.GetOutGoingMBTypeInt32()), Hash: mbHeader.GetHash(), OutGoingOperationsHash: mbHeader.GetOutGoingOperationsHash(), @@ -619,7 +619,7 @@ func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeaderHandlers(mbHeaders [] return nil } - miniBlockHeaders := make([]OutGoingMiniBlockHeader, len(mbHeaders)) + miniBlockHeaders := make([]*OutGoingMiniBlockHeader, len(mbHeaders)) for i, mbHeaderHandler := range mbHeaders { miniBlockHeaders[i] = createOutGoingMbHeader(mbHeaderHandler) } diff --git a/data/block/sovereignChainHeader.pb.go b/data/block/sovereignChainHeader.pb.go index 2d59c76a..d8df6ce2 100644 --- a/data/block/sovereignChainHeader.pb.go +++ b/data/block/sovereignChainHeader.pb.go @@ -172,14 +172,14 @@ func (m *EpochStartCrossChainData) GetHeaderHash() []byte { // SovereignChainHeader extends the Header structure with extra fields needed by sovereign chain type SovereignChainHeader struct { - Header *Header `protobuf:"bytes,1,opt,name=Header,proto3" json:"header"` - ValidatorStatsRootHash []byte `protobuf:"bytes,2,opt,name=ValidatorStatsRootHash,proto3" json:"validatorStatsRootHash"` - ExtendedShardHeaderHashes [][]byte `protobuf:"bytes,3,rep,name=ExtendedShardHeaderHashes,proto3" json:"extendedShardHeaderHashes,omitempty"` - OutGoingMiniBlockHeaders []OutGoingMiniBlockHeader `protobuf:"bytes,4,rep,name=OutGoingMiniBlockHeaders,proto3" json:"outGoingOperations,omitempty"` - IsStartOfEpoch bool `protobuf:"varint,5,opt,name=IsStartOfEpoch,proto3" json:"isStartOfEpoch,omitempty"` - AccumulatedFeesInEpoch *math_big.Int `protobuf:"bytes,6,opt,name=AccumulatedFeesInEpoch,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"accumulatedFeesInEpoch,omitempty"` - DevFeesInEpoch *math_big.Int `protobuf:"bytes,7,opt,name=DevFeesInEpoch,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"devFeesInEpoch,omitempty"` - EpochStart EpochStartSovereign `protobuf:"bytes,8,opt,name=EpochStart,proto3" json:"epochStart,omitempty"` + Header *Header `protobuf:"bytes,1,opt,name=Header,proto3" json:"header"` + ValidatorStatsRootHash []byte `protobuf:"bytes,2,opt,name=ValidatorStatsRootHash,proto3" json:"validatorStatsRootHash"` + ExtendedShardHeaderHashes [][]byte `protobuf:"bytes,3,rep,name=ExtendedShardHeaderHashes,proto3" json:"extendedShardHeaderHashes,omitempty"` + OutGoingMiniBlockHeaders []*OutGoingMiniBlockHeader `protobuf:"bytes,4,rep,name=OutGoingMiniBlockHeaders,proto3" json:"outGoingOperations,omitempty"` + IsStartOfEpoch bool `protobuf:"varint,5,opt,name=IsStartOfEpoch,proto3" json:"isStartOfEpoch,omitempty"` + AccumulatedFeesInEpoch *math_big.Int `protobuf:"bytes,6,opt,name=AccumulatedFeesInEpoch,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"accumulatedFeesInEpoch,omitempty"` + DevFeesInEpoch *math_big.Int `protobuf:"bytes,7,opt,name=DevFeesInEpoch,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"devFeesInEpoch,omitempty"` + EpochStart EpochStartSovereign `protobuf:"bytes,8,opt,name=EpochStart,proto3" json:"epochStart,omitempty"` } func (m *SovereignChainHeader) Reset() { *m = SovereignChainHeader{} } @@ -231,7 +231,7 @@ func (m *SovereignChainHeader) GetExtendedShardHeaderHashes() [][]byte { return nil } -func (m *SovereignChainHeader) GetOutGoingMiniBlockHeaders() []OutGoingMiniBlockHeader { +func (m *SovereignChainHeader) GetOutGoingMiniBlockHeaders() []*OutGoingMiniBlockHeader { if m != nil { return m.OutGoingMiniBlockHeaders } @@ -350,61 +350,61 @@ func init() { proto.RegisterFile("sovereignChainHeader.proto", fileDescriptor_b9 var fileDescriptor_b9b8ff297a820152 = []byte{ // 888 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4f, 0x6f, 0xe3, 0x44, - 0x1c, 0xcd, 0xd0, 0x24, 0xdd, 0x4e, 0xba, 0xa1, 0x0c, 0xa5, 0x98, 0xa8, 0xeb, 0x09, 0x65, 0x0b, - 0x11, 0xd0, 0x44, 0x74, 0x2f, 0x48, 0x20, 0xa1, 0xba, 0xed, 0xb2, 0x91, 0xb6, 0x54, 0x72, 0x56, - 0x08, 0x01, 0x97, 0x89, 0x3d, 0x6b, 0x8f, 0x88, 0x67, 0x22, 0x7b, 0x52, 0x75, 0x91, 0x90, 0xf6, - 0x86, 0x90, 0x40, 0xe2, 0x4b, 0x20, 0x21, 0x3e, 0xc9, 0x1e, 0x7b, 0xec, 0xc9, 0x4b, 0xdd, 0x03, - 0xc8, 0xa7, 0xfd, 0x08, 0xc8, 0x63, 0x27, 0x76, 0xda, 0xb8, 0xbb, 0x17, 0x4e, 0xad, 0xdf, 0xbc, - 0xdf, 0xfb, 0xbd, 0xf9, 0xfd, 0x99, 0xc0, 0x56, 0x20, 0x4e, 0xa8, 0x4f, 0x99, 0xc3, 0xf7, 0x5d, - 0xc2, 0xf8, 0x03, 0x4a, 0x6c, 0xea, 0x77, 0xc7, 0xbe, 0x90, 0x02, 0xd5, 0xd4, 0x9f, 0xd6, 0x8e, - 0xc3, 0xa4, 0x3b, 0x19, 0x76, 0x2d, 0xe1, 0xf5, 0x1c, 0xe1, 0x88, 0x9e, 0x82, 0x87, 0x93, 0xc7, - 0xea, 0x4b, 0x7d, 0xa8, 0xff, 0xd2, 0xa8, 0x56, 0x63, 0x38, 0x12, 0xd6, 0x0f, 0xd9, 0xc7, 0xeb, - 0x1e, 0x95, 0xc4, 0xc8, 0x81, 0xad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, 0xa6, 0xea, 0xd6, 0x84, 0x88, 0x2c, 0xb8, 0xf1, 0x05, 0x1d, 0x70, 0x87, 0x2a, 0x19, 0xf4, + 0x14, 0x55, 0xa1, 0x25, 0xa5, 0xca, 0x65, 0xd4, 0x88, 0x23, 0xb2, 0x71, 0xb2, 0x90, 0x61, 0x15, + 0x78, 0x22, 0x06, 0xdf, 0x38, 0x3c, 0x55, 0x4c, 0x38, 0xcc, 0xd1, 0xfd, 0xcc, 0x52, 0x67, 0xa1, + 0xb1, 0xd4, 0x5c, 0x6a, 0xad, 0x9a, 0xef, 0xc6, 0x11, 0x79, 0x8b, 0x15, 0x91, 0x72, 0x75, 0x17, + 0x2b, 0xa1, 0xef, 0xa1, 0x71, 0x3c, 0x52, 0x9f, 0x49, 0x2e, 0xdc, 0x23, 0x2e, 0xb8, 0x1e, 0xf6, + 0x94, 0x10, 0x1a, 0xe5, 0xe6, 0x52, 0xab, 0xb6, 0x8b, 0x27, 0xf5, 0x17, 0xd0, 0xcc, 0x66, 0x1c, + 0x91, 0x4d, 0x39, 0x31, 0x1e, 0x0f, 0x59, 0x40, 0x15, 0x97, 0x22, 0x1f, 0xbe, 0x30, 0x02, 0x3a, + 0x80, 0xf5, 0x6e, 0xa8, 0x27, 0xec, 0xf8, 0x51, 0x3a, 0x2a, 0x95, 0x26, 0x68, 0xdd, 0x32, 0x37, + 0xe3, 0x88, 0x18, 0x7c, 0xce, 0x92, 0xd3, 0xbb, 0xe2, 0x83, 0x7e, 0x07, 0x70, 0x63, 0xcf, 0xb6, + 0x47, 0xfe, 0x68, 0x40, 0x15, 0x73, 0xee, 0x31, 0x16, 0x76, 0x45, 0x2a, 0x57, 0xd5, 0xfd, 0xf7, + 0xe3, 0x88, 0x34, 0xe9, 0x42, 0x46, 0x26, 0xfb, 0xe7, 0xdf, 0xe4, 0xd0, 0xa7, 0xca, 0xeb, 0xf4, + 0xb9, 0xdb, 0xee, 0x0a, 0xf5, 0x71, 0xee, 0xe1, 0xf0, 0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, 0xb3, 0xc8, + 0xb9, 0x14, 0x9e, 0xad, 0x8c, 0xbe, 0x86, 0xf5, 0xd9, 0x5d, 0x99, 0x0f, 0x1f, 0x0f, 0x99, 0x5e, + 0xc2, 0xfa, 0xee, 0x6b, 0x57, 0x17, 0x5f, 0x1b, 0xd3, 0xdd, 0x94, 0x73, 0x58, 0x7e, 0x37, 0xe7, + 0xd9, 0xef, 0x7d, 0x72, 0x55, 0x1c, 0xad, 0xc1, 0xd5, 0x29, 0xf2, 0xf0, 0xf4, 0xc8, 0x5c, 0x2b, + 0x21, 0x03, 0xae, 0xef, 0x7b, 0x54, 0xb8, 0x2c, 0x7b, 0x0a, 0x99, 0x3a, 0x32, 0xd7, 0xb0, 0xf9, + 0xe9, 0xd9, 0x05, 0x2e, 0x9d, 0x5f, 0xe0, 0xd2, 0xd3, 0x0b, 0x0c, 0x7e, 0x1c, 0x63, 0xf0, 0xc7, + 0x18, 0x83, 0x27, 0x63, 0x0c, 0xce, 0xc6, 0x18, 0x9c, 0x8f, 0x31, 0xf8, 0x67, 0x8c, 0xc1, 0x7f, + 0x63, 0x5c, 0x7a, 0x3a, 0xc6, 0xe0, 0xb7, 0x4b, 0x5c, 0x3a, 0xbb, 0xc4, 0xa5, 0xf3, 0x4b, 0x5c, + 0xfa, 0xaa, 0xa2, 0xbf, 0xe3, 0xfd, 0xaa, 0x2e, 0xe1, 0xee, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, + 0x6e, 0x8a, 0x90, 0x8c, 0x29, 0x08, 0x00, 0x00, } func (x OutGoingMBType) String() string { @@ -514,7 +514,7 @@ func (this *SovereignChainHeader) Equal(that interface{}) bool { return false } for i := range this.OutGoingMiniBlockHeaders { - if !this.OutGoingMiniBlockHeaders[i].Equal(&that1.OutGoingMiniBlockHeaders[i]) { + if !this.OutGoingMiniBlockHeaders[i].Equal(that1.OutGoingMiniBlockHeaders[i]) { return false } } @@ -611,11 +611,7 @@ func (this *SovereignChainHeader) GoString() string { s = append(s, "ValidatorStatsRootHash: "+fmt.Sprintf("%#v", this.ValidatorStatsRootHash)+",\n") s = append(s, "ExtendedShardHeaderHashes: "+fmt.Sprintf("%#v", this.ExtendedShardHeaderHashes)+",\n") if this.OutGoingMiniBlockHeaders != nil { - vs := make([]OutGoingMiniBlockHeader, len(this.OutGoingMiniBlockHeaders)) - for i := range vs { - vs[i] = this.OutGoingMiniBlockHeaders[i] - } - s = append(s, "OutGoingMiniBlockHeaders: "+fmt.Sprintf("%#v", vs)+",\n") + s = append(s, "OutGoingMiniBlockHeaders: "+fmt.Sprintf("%#v", this.OutGoingMiniBlockHeaders)+",\n") } s = append(s, "IsStartOfEpoch: "+fmt.Sprintf("%#v", this.IsStartOfEpoch)+",\n") s = append(s, "AccumulatedFeesInEpoch: "+fmt.Sprintf("%#v", this.AccumulatedFeesInEpoch)+",\n") @@ -1058,9 +1054,9 @@ func (this *SovereignChainHeader) String() string { if this == nil { return "nil" } - repeatedStringForOutGoingMiniBlockHeaders := "[]OutGoingMiniBlockHeader{" + repeatedStringForOutGoingMiniBlockHeaders := "[]*OutGoingMiniBlockHeader{" for _, f := range this.OutGoingMiniBlockHeaders { - repeatedStringForOutGoingMiniBlockHeaders += strings.Replace(strings.Replace(f.String(), "OutGoingMiniBlockHeader", "OutGoingMiniBlockHeader", 1), `&`, ``, 1) + "," + repeatedStringForOutGoingMiniBlockHeaders += strings.Replace(f.String(), "OutGoingMiniBlockHeader", "OutGoingMiniBlockHeader", 1) + "," } repeatedStringForOutGoingMiniBlockHeaders += "}" s := strings.Join([]string{`&SovereignChainHeader{`, @@ -1540,7 +1536,7 @@ func (m *SovereignChainHeader) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.OutGoingMiniBlockHeaders = append(m.OutGoingMiniBlockHeaders, OutGoingMiniBlockHeader{}) + m.OutGoingMiniBlockHeaders = append(m.OutGoingMiniBlockHeaders, &OutGoingMiniBlockHeader{}) if err := m.OutGoingMiniBlockHeaders[len(m.OutGoingMiniBlockHeaders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/data/block/sovereignChainHeader.proto b/data/block/sovereignChainHeader.proto index 4dd9fea5..7ee05d76 100644 --- a/data/block/sovereignChainHeader.proto +++ b/data/block/sovereignChainHeader.proto @@ -30,7 +30,7 @@ message SovereignChainHeader { Header Header = 1 [(gogoproto.jsontag) = "header"]; bytes ValidatorStatsRootHash = 2 [(gogoproto.jsontag) = "validatorStatsRootHash"]; repeated bytes ExtendedShardHeaderHashes = 3 [(gogoproto.jsontag) = "extendedShardHeaderHashes,omitempty"]; - repeated OutGoingMiniBlockHeader OutGoingMiniBlockHeaders = 4 [(gogoproto.jsontag) = "outGoingOperations,omitempty", (gogoproto.nullable) = false]; + repeated OutGoingMiniBlockHeader OutGoingMiniBlockHeaders = 4 [(gogoproto.jsontag) = "outGoingOperations,omitempty"]; bool IsStartOfEpoch = 5 [(gogoproto.jsontag) = "isStartOfEpoch,omitempty"]; bytes AccumulatedFeesInEpoch = 6 [(gogoproto.jsontag) = "accumulatedFeesInEpoch,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; bytes DevFeesInEpoch = 7 [(gogoproto.jsontag) = "devFeesInEpoch,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; From 74c60f42fd752958dc3234e0601eb018dc1cb0cc Mon Sep 17 00:00:00 2001 From: Marius C Date: Thu, 13 Feb 2025 14:05:11 +0200 Subject: [PATCH 10/12] FEAT: Unit tests outgoing mbs --- data/block/sovereignChainHeader.go | 16 ++-- data/block/sovereignChainHeader_test.go | 114 ++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 7 deletions(-) diff --git a/data/block/sovereignChainHeader.go b/data/block/sovereignChainHeader.go index dd8328a5..7653be89 100644 --- a/data/block/sovereignChainHeader.go +++ b/data/block/sovereignChainHeader.go @@ -32,20 +32,21 @@ func (sch *SovereignChainHeader) SetAdditionalData(_ headerVersionData.HeaderAdd // ShallowClone returns a clone of the object func (sch *SovereignChainHeader) ShallowClone() data.HeaderHandler { - if sch == nil || sch.Header == nil { + if sch == nil { return nil } - internalHeaderCopy := *sch.Header - headerCopy := *sch - headerCopy.Header = &internalHeaderCopy - if len(sch.OutGoingMiniBlockHeaders) != 0 { headerCopy.OutGoingMiniBlockHeaders = make([]*OutGoingMiniBlockHeader, len(sch.OutGoingMiniBlockHeaders)) copy(headerCopy.OutGoingMiniBlockHeaders, sch.OutGoingMiniBlockHeaders) } + if sch.Header != nil { + internalHeaderCopy := *sch.Header + headerCopy.Header = &internalHeaderCopy + } + return &headerCopy } @@ -608,7 +609,7 @@ func createOutGoingMbHeader(mbHeader data.OutGoingMiniBlockHeaderHandler) *OutGo } } -// SetOutGoingMiniBlockHeaderHandlers returns the outgoing mini block headers +// SetOutGoingMiniBlockHeaderHandlers sets the outgoing mini block headers func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeaderHandlers(mbHeaders []data.OutGoingMiniBlockHeaderHandler) error { if sch == nil { return data.ErrNilPointerReceiver @@ -774,6 +775,7 @@ func (omb *OutGoingMiniBlockHeader) SetAggregatedSignatureOutGoingOperations(sig return nil } +// GetOutGoingMBTypeInt32 returns the outgoing mb header type as int32 func (omb *OutGoingMiniBlockHeader) GetOutGoingMBTypeInt32() int32 { if omb == nil { return 0 @@ -782,7 +784,7 @@ func (omb *OutGoingMiniBlockHeader) GetOutGoingMBTypeInt32() int32 { return int32(omb.OutGoingMBType) } -// SetOutGoingMBTypeInt32 sets the mb type +// SetOutGoingMBTypeInt32 sets the mini block type func (omb *OutGoingMiniBlockHeader) SetOutGoingMBTypeInt32(mbType int32) error { if omb == nil { return data.ErrNilPointerReceiver diff --git a/data/block/sovereignChainHeader_test.go b/data/block/sovereignChainHeader_test.go index fa6535c2..27bd51df 100644 --- a/data/block/sovereignChainHeader_test.go +++ b/data/block/sovereignChainHeader_test.go @@ -65,3 +65,117 @@ func TestSovereignChainHeader_GetEconomicsHandler(t *testing.T) { require.Nil(t, err) require.Equal(t, &economics2, sovHdr.GetEpochStartHandler().GetEconomicsHandler()) } + +func TestSovereignChainHeader_ShallowClone(t *testing.T) { + t.Parallel() + + sovHdr := &SovereignChainHeader{ + DevFeesInEpoch: big.NewInt(100), + OutGoingMiniBlockHeaders: []*OutGoingMiniBlockHeader{ + { + Hash: []byte("h1"), + }, + { + Hash: []byte("h2"), + }, + }, + } + + sovHdrClone := sovHdr.ShallowClone() + require.Equal(t, sovHdr, sovHdrClone) + require.False(t, sovHdr == sovHdrClone) + + sovHdr.Header = &Header{Nonce: 4} + sovHdrClone = sovHdr.ShallowClone() + require.Equal(t, sovHdr, sovHdrClone) + require.False(t, sovHdr == sovHdrClone) + require.False(t, sovHdr.Header == sovHdrClone.(*SovereignChainHeader).Header) +} + +func TestSovereignChainHeader_GetOutGoingMiniBlockHeaderHandlers(t *testing.T) { + t.Parallel() + + sovHdr := &SovereignChainHeader{ + OutGoingMiniBlockHeaders: []*OutGoingMiniBlockHeader{ + { + Hash: []byte("h1"), + }, + { + Hash: []byte("h2"), + }, + }, + } + + require.Equal(t, + []data.OutGoingMiniBlockHeaderHandler{sovHdr.OutGoingMiniBlockHeaders[0], sovHdr.OutGoingMiniBlockHeaders[1]}, + sovHdr.GetOutGoingMiniBlockHeaderHandlers(), + ) +} + +func TestSovereignChainHeader_GetOutGoingMiniBlockHeaderHandler(t *testing.T) { + t.Parallel() + + sovHdr := &SovereignChainHeader{ + OutGoingMiniBlockHeaders: []*OutGoingMiniBlockHeader{ + { + OutGoingMBType: OutGoingTxMB, + Hash: []byte("h1"), + }, + { + OutGoingMBType: ChangeValidatorSetMB, + Hash: []byte("h2"), + }, + }, + } + + mb := sovHdr.GetOutGoingMiniBlockHeaderHandler(int32(OutGoingTxMB)) + require.Equal(t, sovHdr.OutGoingMiniBlockHeaders[0], mb) + mb = sovHdr.GetOutGoingMiniBlockHeaderHandler(int32(ChangeValidatorSetMB)) + require.Equal(t, sovHdr.OutGoingMiniBlockHeaders[1], mb) + require.Nil(t, sovHdr.GetOutGoingMiniBlockHeaderHandler(-1)) +} + +func TestSovereignChainHeader_SetOutGoingMiniBlockHeaderHandlers(t *testing.T) { + t.Parallel() + + sovHdr := &SovereignChainHeader{} + mbHeader1 := &OutGoingMiniBlockHeader{OutGoingMBType: OutGoingTxMB, Hash: []byte("h1")} + mbHeader2 := &OutGoingMiniBlockHeader{OutGoingMBType: ChangeValidatorSetMB, Hash: []byte("h2")} + + err := sovHdr.SetOutGoingMiniBlockHeaderHandlers([]data.OutGoingMiniBlockHeaderHandler{mbHeader1, mbHeader2}) + require.Nil(t, err) + require.Equal(t, + []data.OutGoingMiniBlockHeaderHandler{mbHeader1, mbHeader2}, + sovHdr.GetOutGoingMiniBlockHeaderHandlers(), + ) +} + +func TestSovereignChainHeader_SetOutGoingMiniBlockHeaderHandler(t *testing.T) { + t.Parallel() + + sovHdr := &SovereignChainHeader{} + mbHeader1 := &OutGoingMiniBlockHeader{OutGoingMBType: OutGoingTxMB, Hash: []byte("h1")} + mbHeader2 := &OutGoingMiniBlockHeader{OutGoingMBType: OutGoingTxMB, Hash: []byte("h2")} + mbHeader3 := &OutGoingMiniBlockHeader{OutGoingMBType: ChangeValidatorSetMB, Hash: []byte("h3")} + + err := sovHdr.SetOutGoingMiniBlockHeaderHandler(mbHeader1) + require.Nil(t, err) + require.Equal(t, + []data.OutGoingMiniBlockHeaderHandler{mbHeader1}, + sovHdr.GetOutGoingMiniBlockHeaderHandlers(), + ) + + err = sovHdr.SetOutGoingMiniBlockHeaderHandler(mbHeader2) + require.Nil(t, err) + require.Equal(t, + []data.OutGoingMiniBlockHeaderHandler{mbHeader2}, + sovHdr.GetOutGoingMiniBlockHeaderHandlers(), + ) + + err = sovHdr.SetOutGoingMiniBlockHeaderHandler(mbHeader3) + require.Nil(t, err) + require.Equal(t, + []data.OutGoingMiniBlockHeaderHandler{mbHeader2, mbHeader3}, + sovHdr.GetOutGoingMiniBlockHeaderHandlers(), + ) +} From 9d2f4612876f9d4c02cd65cbde30783b0cf8dbc1 Mon Sep 17 00:00:00 2001 From: Marius C Date: Thu, 13 Feb 2025 14:33:31 +0200 Subject: [PATCH 11/12] CLN: General naming clearance --- data/block/sovereignChainHeader.go | 10 +- data/block/sovereignChainHeader.pb.go | 228 ++++++++++++------------ data/block/sovereignChainHeader.proto | 15 +- data/block/sovereignChainHeader_test.go | 22 +-- 4 files changed, 138 insertions(+), 137 deletions(-) diff --git a/data/block/sovereignChainHeader.go b/data/block/sovereignChainHeader.go index 7653be89..843211dc 100644 --- a/data/block/sovereignChainHeader.go +++ b/data/block/sovereignChainHeader.go @@ -572,7 +572,7 @@ func (sch *SovereignChainHeader) GetOutGoingMiniBlockHeaderHandler(mbType int32) } for _, outGoingMbHdr := range sch.OutGoingMiniBlockHeaders { - if int32(outGoingMbHdr.OutGoingMBType) == mbType { + if int32(outGoingMbHdr.Type) == mbType { return outGoingMbHdr } } @@ -589,7 +589,7 @@ func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeaderHandler(mbHeader data outGoingMbHdr := createOutGoingMbHeader(mbHeader) for idx, currOutGoingMbHdr := range sch.OutGoingMiniBlockHeaders { - if int32(currOutGoingMbHdr.OutGoingMBType) == mbHeader.GetOutGoingMBTypeInt32() { + if int32(currOutGoingMbHdr.Type) == mbHeader.GetOutGoingMBTypeInt32() { sch.OutGoingMiniBlockHeaders[idx] = outGoingMbHdr return nil } @@ -601,7 +601,7 @@ func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeaderHandler(mbHeader data func createOutGoingMbHeader(mbHeader data.OutGoingMiniBlockHeaderHandler) *OutGoingMiniBlockHeader { return &OutGoingMiniBlockHeader{ - OutGoingMBType: OutGoingMBType(mbHeader.GetOutGoingMBTypeInt32()), + Type: OutGoingMBType(mbHeader.GetOutGoingMBTypeInt32()), Hash: mbHeader.GetHash(), OutGoingOperationsHash: mbHeader.GetOutGoingOperationsHash(), AggregatedSignatureOutGoingOperations: mbHeader.GetAggregatedSignatureOutGoingOperations(), @@ -781,7 +781,7 @@ func (omb *OutGoingMiniBlockHeader) GetOutGoingMBTypeInt32() int32 { return 0 } - return int32(omb.OutGoingMBType) + return int32(omb.Type) } // SetOutGoingMBTypeInt32 sets the mini block type @@ -790,7 +790,7 @@ func (omb *OutGoingMiniBlockHeader) SetOutGoingMBTypeInt32(mbType int32) error { return data.ErrNilPointerReceiver } - omb.OutGoingMBType = OutGoingMBType(mbType) + omb.Type = OutGoingMBType(mbType) return nil } diff --git a/data/block/sovereignChainHeader.pb.go b/data/block/sovereignChainHeader.pb.go index d8df6ce2..37c1b6b4 100644 --- a/data/block/sovereignChainHeader.pb.go +++ b/data/block/sovereignChainHeader.pb.go @@ -32,18 +32,18 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type OutGoingMBType int32 const ( - OutGoingTxMB OutGoingMBType = 0 - ChangeValidatorSetMB OutGoingMBType = 30 + OutGoingMbTx OutGoingMBType = 0 + OutGoingMbChangeValidatorSet OutGoingMBType = 30 ) var OutGoingMBType_name = map[int32]string{ - 0: "OutGoingTxMB", - 30: "ChangeValidatorSetMB", + 0: "OutGoingMbTx", + 30: "OutGoingMbChangeValidatorSet", } var OutGoingMBType_value = map[string]int32{ - "OutGoingTxMB": 0, - "ChangeValidatorSetMB": 30, + "OutGoingMbTx": 0, + "OutGoingMbChangeValidatorSet": 30, } func (OutGoingMBType) EnumDescriptor() ([]byte, []int) { @@ -267,11 +267,11 @@ func (m *SovereignChainHeader) GetEpochStart() EpochStartSovereign { } type OutGoingMiniBlockHeader struct { - Hash []byte `protobuf:"bytes,1,opt,name=Hash,proto3" json:"hash,omitempty"` - OutGoingOperationsHash []byte `protobuf:"bytes,2,opt,name=OutGoingOperationsHash,proto3" json:"outGoingOperationsHash,omitempty"` - AggregatedSignatureOutGoingOperations []byte `protobuf:"bytes,3,opt,name=AggregatedSignatureOutGoingOperations,proto3" json:"aggregatedSignatureOutGoingOperations,omitempty"` - LeaderSignatureOutGoingOperations []byte `protobuf:"bytes,4,opt,name=LeaderSignatureOutGoingOperations,proto3" json:"leaderSignatureOutGoingOperations,omitempty"` - OutGoingMBType OutGoingMBType `protobuf:"varint,5,opt,name=OutGoingMBType,proto3,enum=proto.OutGoingMBType" json:"outGoingMBType,omitempty"` + Type OutGoingMBType `protobuf:"varint,1,opt,name=Type,proto3,enum=proto.OutGoingMBType" json:"type,omitempty"` + Hash []byte `protobuf:"bytes,2,opt,name=Hash,proto3" json:"hash,omitempty"` + OutGoingOperationsHash []byte `protobuf:"bytes,3,opt,name=OutGoingOperationsHash,proto3" json:"outGoingOperationsHash,omitempty"` + AggregatedSignatureOutGoingOperations []byte `protobuf:"bytes,4,opt,name=AggregatedSignatureOutGoingOperations,proto3" json:"aggregatedSignatureOutGoingOperations,omitempty"` + LeaderSignatureOutGoingOperations []byte `protobuf:"bytes,5,opt,name=LeaderSignatureOutGoingOperations,proto3" json:"leaderSignatureOutGoingOperations,omitempty"` } func (m *OutGoingMiniBlockHeader) Reset() { *m = OutGoingMiniBlockHeader{} } @@ -302,6 +302,13 @@ func (m *OutGoingMiniBlockHeader) XXX_DiscardUnknown() { var xxx_messageInfo_OutGoingMiniBlockHeader proto.InternalMessageInfo +func (m *OutGoingMiniBlockHeader) GetType() OutGoingMBType { + if m != nil { + return m.Type + } + return OutGoingMbTx +} + func (m *OutGoingMiniBlockHeader) GetHash() []byte { if m != nil { return m.Hash @@ -330,13 +337,6 @@ func (m *OutGoingMiniBlockHeader) GetLeaderSignatureOutGoingOperations() []byte return nil } -func (m *OutGoingMiniBlockHeader) GetOutGoingMBType() OutGoingMBType { - if m != nil { - return m.OutGoingMBType - } - return OutGoingTxMB -} - func init() { proto.RegisterEnum("proto.OutGoingMBType", OutGoingMBType_name, OutGoingMBType_value) proto.RegisterType((*EpochStartSovereign)(nil), "proto.EpochStartSovereign") @@ -348,63 +348,63 @@ func init() { func init() { proto.RegisterFile("sovereignChainHeader.proto", fileDescriptor_b9b8ff297a820152) } var fileDescriptor_b9b8ff297a820152 = []byte{ - // 888 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4f, 0x6f, 0xe3, 0x44, - 0x14, 0xcf, 0xd0, 0x24, 0xdd, 0x4e, 0xba, 0xa1, 0x0c, 0xa5, 0x98, 0xa8, 0x3b, 0x13, 0x0a, 0x85, - 0x08, 0x68, 0x22, 0xba, 0x17, 0x24, 0x90, 0x50, 0xdd, 0x76, 0xd9, 0x48, 0x5b, 0x2a, 0x39, 0x2b, - 0x84, 0x80, 0xcb, 0xc4, 0x9e, 0xb5, 0x47, 0xc4, 0x33, 0x91, 0x3d, 0xa9, 0xba, 0x08, 0x24, 0x6e, - 0x08, 0x09, 0x24, 0xbe, 0x04, 0x12, 0xe2, 0x93, 0xec, 0xb1, 0xc7, 0x8a, 0x83, 0xa1, 0xe9, 0x01, - 0xe4, 0xd3, 0x7e, 0x04, 0xe4, 0x71, 0x12, 0x3b, 0x6d, 0xdc, 0xdd, 0xcb, 0x9e, 0x92, 0xf9, 0xbd, - 0xdf, 0xfb, 0xbd, 0x3f, 0xf3, 0xde, 0x18, 0x36, 0x42, 0x79, 0xc2, 0x02, 0xc6, 0x5d, 0xb1, 0xef, - 0x51, 0x2e, 0xee, 0x33, 0xea, 0xb0, 0xa0, 0x3d, 0x0c, 0xa4, 0x92, 0xa8, 0xa2, 0x7f, 0x1a, 0x3b, - 0x2e, 0x57, 0xde, 0xa8, 0xdf, 0xb6, 0xa5, 0xdf, 0x71, 0xa5, 0x2b, 0x3b, 0x1a, 0xee, 0x8f, 0x1e, - 0xe9, 0x93, 0x3e, 0xe8, 0x7f, 0xa9, 0x57, 0xa3, 0xd6, 0x1f, 0x48, 0xfb, 0xdb, 0xc9, 0xe1, 0x65, - 0x9f, 0x29, 0x6a, 0x66, 0xc0, 0xd6, 0xbf, 0x00, 0xbe, 0x7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, 0x62, 0xfe, 0x50, 0x3d, 0xb6, 0x72, 0xdc, 0xad, 0xbf, 0xaa, 0x70, 0xbd, 0xb7, 0x60, 0x7a, - 0xd0, 0x87, 0xb0, 0x3a, 0x69, 0x78, 0x7a, 0x91, 0xb7, 0x27, 0x0d, 0x4f, 0x41, 0x13, 0xc6, 0x11, - 0xa9, 0xa6, 0xea, 0xd6, 0x84, 0x88, 0x2c, 0xb8, 0xf1, 0x05, 0x1d, 0x70, 0x87, 0x2a, 0x19, 0xf4, - 0x14, 0x55, 0xa1, 0x25, 0xa5, 0xca, 0x65, 0xd4, 0x88, 0x23, 0xb2, 0x71, 0xb2, 0x90, 0x61, 0x15, - 0x78, 0x22, 0x06, 0xdf, 0x38, 0x3c, 0x55, 0x4c, 0x38, 0xcc, 0xd1, 0xfd, 0xcc, 0x52, 0x67, 0xa1, - 0xb1, 0xd4, 0x5c, 0x6a, 0xad, 0x9a, 0xef, 0xc6, 0x11, 0x79, 0x8b, 0x15, 0x91, 0x72, 0x75, 0x17, - 0x2b, 0xa1, 0xef, 0xa1, 0x71, 0x3c, 0x52, 0x9f, 0x49, 0x2e, 0xdc, 0x23, 0x2e, 0xb8, 0x1e, 0xf6, - 0x94, 0x10, 0x1a, 0xe5, 0xe6, 0x52, 0xab, 0xb6, 0x8b, 0x27, 0xf5, 0x17, 0xd0, 0xcc, 0x66, 0x1c, - 0x91, 0x4d, 0x39, 0x31, 0x1e, 0x0f, 0x59, 0x40, 0x15, 0x97, 0x22, 0x1f, 0xbe, 0x30, 0x02, 0x3a, - 0x80, 0xf5, 0x6e, 0xa8, 0x27, 0xec, 0xf8, 0x51, 0x3a, 0x2a, 0x95, 0x26, 0x68, 0xdd, 0x32, 0x37, - 0xe3, 0x88, 0x18, 0x7c, 0xce, 0x92, 0xd3, 0xbb, 0xe2, 0x83, 0x7e, 0x07, 0x70, 0x63, 0xcf, 0xb6, - 0x47, 0xfe, 0x68, 0x40, 0x15, 0x73, 0xee, 0x31, 0x16, 0x76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e, 0x87, 0x06, 0x68, + 0x81, 0x76, 0x7d, 0x67, 0x35, 0x4d, 0xe9, 0xcc, 0x71, 0xf3, 0x95, 0xa7, 0x11, 0x29, 0xc5, 0x11, + 0x59, 0x66, 0x17, 0x90, 0x95, 0x65, 0xa1, 0x9f, 0x01, 0xbc, 0xf7, 0x88, 0x86, 0xea, 0x01, 0x17, + 0x74, 0xc4, 0xbf, 0x63, 0xce, 0x5e, 0x20, 0xc3, 0x30, 0x77, 0x2c, 0xe3, 0x25, 0xad, 0x4b, 0x2e, + 0x74, 0xe7, 0x36, 0x32, 0x62, 0x8f, 0x2a, 0x6a, 0x6e, 0xcd, 0xca, 0xdc, 0x1b, 0xdd, 0xa4, 0x66, + 0xdd, 0x5c, 0x6c, 0x33, 0x02, 0xd0, 0x28, 0x2a, 0x81, 0xb6, 0xe0, 0xd2, 0xc0, 0xa3, 0x81, 0xd3, + 0xef, 0xe9, 0xc3, 0xde, 0x35, 0xeb, 0x71, 0x44, 0x96, 0xc2, 0x14, 0xb2, 0x2e, 0x62, 0x88, 0xc0, + 0xaa, 0x96, 0x30, 0x96, 0x35, 0x69, 0x39, 0x8e, 0x48, 0x95, 0x25, 0x80, 0x95, 0xe2, 0x09, 0xc1, + 0x92, 0x13, 0xe1, 0x18, 0x4b, 0x2d, 0xd0, 0xae, 0xa4, 0x84, 0x20, 0x01, 0xac, 0x14, 0x4f, 0x08, + 0x5f, 0x48, 0x61, 0x33, 0xe3, 0x4e, 0x46, 0x10, 0x09, 0x60, 0xa5, 0x38, 0xfa, 0x08, 0xc2, 0xd4, + 0xf0, 0x43, 0x1a, 0x7a, 0xba, 0x43, 0x2b, 0xa6, 0x11, 0x47, 0x64, 0xcd, 0x9b, 0xa3, 0x1f, 0x48, + 0x9f, 0x2b, 0xe6, 0x8f, 0xd5, 0xb1, 0x95, 0xe3, 0x6e, 0xfe, 0x59, 0x83, 0x6b, 0x83, 0x05, 0xd3, + 0x83, 0x3e, 0x84, 0xb5, 0x59, 0xc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0xae, 0xa0, 0x6a, 0x12, 0xb0, 0xeb, 0x6c, 0xa3, 0xa2, 0xab, 0xdd, 0x8f, 0x23, 0xd2, 0xa5, 0xb7, + 0x49, 0xc8, 0x15, 0xbf, 0x5d, 0x05, 0xf4, 0x03, 0x7c, 0xf3, 0x91, 0x6e, 0xed, 0x4d, 0x36, 0xaa, + 0xda, 0x46, 0x37, 0x8e, 0xc8, 0xfb, 0xa3, 0xe7, 0x91, 0x73, 0x16, 0x9e, 0xaf, 0xfc, 0x5e, 0x0f, + 0x36, 0x2e, 0x5f, 0x1e, 0x5a, 0x85, 0x2b, 0x73, 0x64, 0xf8, 0xf8, 0x68, 0xb5, 0x84, 0x5a, 0x70, + 0x23, 0x43, 0xf6, 0x3c, 0x2a, 0x5c, 0x96, 0x3d, 0x7b, 0x4c, 0xad, 0x62, 0xf3, 0xd3, 0x93, 0x33, + 0x5c, 0x3a, 0x3d, 0xc3, 0xa5, 0x67, 0x67, 0x18, 0xfc, 0x38, 0xc5, 0xe0, 0xf7, 0x29, 0x06, 0x4f, + 0xa7, 0x18, 0x9c, 0x4c, 0x31, 0x38, 0x9d, 0x62, 0xf0, 0xf7, 0x14, 0x83, 0x7f, 0xa7, 0xb8, 0xf4, + 0x6c, 0x8a, 0xc1, 0xaf, 0xe7, 0xb8, 0x74, 0x72, 0x8e, 0x4b, 0xa7, 0xe7, 0xb8, 0xf4, 0x75, 0x55, + 0xff, 0x62, 0x0f, 0x6b, 0x7a, 0x8e, 0xee, 0xff, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xde, 0xf9, 0x3d, + 0x24, 0x13, 0x08, 0x00, 0x00, } func (x OutGoingMBType) String() string { @@ -557,6 +557,9 @@ func (this *OutGoingMiniBlockHeader) Equal(that interface{}) bool { } else if this == nil { return false } + if this.Type != that1.Type { + return false + } if !bytes.Equal(this.Hash, that1.Hash) { return false } @@ -569,9 +572,6 @@ func (this *OutGoingMiniBlockHeader) Equal(that interface{}) bool { if !bytes.Equal(this.LeaderSignatureOutGoingOperations, that1.LeaderSignatureOutGoingOperations) { return false } - if this.OutGoingMBType != that1.OutGoingMBType { - return false - } return true } func (this *EpochStartSovereign) GoString() string { @@ -626,11 +626,11 @@ func (this *OutGoingMiniBlockHeader) GoString() string { } s := make([]string, 0, 9) s = append(s, "&block.OutGoingMiniBlockHeader{") + s = append(s, "Type: "+fmt.Sprintf("%#v", this.Type)+",\n") s = append(s, "Hash: "+fmt.Sprintf("%#v", this.Hash)+",\n") s = append(s, "OutGoingOperationsHash: "+fmt.Sprintf("%#v", this.OutGoingOperationsHash)+",\n") s = append(s, "AggregatedSignatureOutGoingOperations: "+fmt.Sprintf("%#v", this.AggregatedSignatureOutGoingOperations)+",\n") s = append(s, "LeaderSignatureOutGoingOperations: "+fmt.Sprintf("%#v", this.LeaderSignatureOutGoingOperations)+",\n") - s = append(s, "OutGoingMBType: "+fmt.Sprintf("%#v", this.OutGoingMBType)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -862,38 +862,38 @@ func (m *OutGoingMiniBlockHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l - if m.OutGoingMBType != 0 { - i = encodeVarintSovereignChainHeader(dAtA, i, uint64(m.OutGoingMBType)) - i-- - dAtA[i] = 0x28 - } if len(m.LeaderSignatureOutGoingOperations) > 0 { i -= len(m.LeaderSignatureOutGoingOperations) copy(dAtA[i:], m.LeaderSignatureOutGoingOperations) i = encodeVarintSovereignChainHeader(dAtA, i, uint64(len(m.LeaderSignatureOutGoingOperations))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } if len(m.AggregatedSignatureOutGoingOperations) > 0 { i -= len(m.AggregatedSignatureOutGoingOperations) copy(dAtA[i:], m.AggregatedSignatureOutGoingOperations) i = encodeVarintSovereignChainHeader(dAtA, i, uint64(len(m.AggregatedSignatureOutGoingOperations))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } if len(m.OutGoingOperationsHash) > 0 { i -= len(m.OutGoingOperationsHash) copy(dAtA[i:], m.OutGoingOperationsHash) i = encodeVarintSovereignChainHeader(dAtA, i, uint64(len(m.OutGoingOperationsHash))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } if len(m.Hash) > 0 { i -= len(m.Hash) copy(dAtA[i:], m.Hash) i = encodeVarintSovereignChainHeader(dAtA, i, uint64(len(m.Hash))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + } + if m.Type != 0 { + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(m.Type)) + i-- + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -997,6 +997,9 @@ func (m *OutGoingMiniBlockHeader) Size() (n int) { } var l int _ = l + if m.Type != 0 { + n += 1 + sovSovereignChainHeader(uint64(m.Type)) + } l = len(m.Hash) if l > 0 { n += 1 + l + sovSovereignChainHeader(uint64(l)) @@ -1013,9 +1016,6 @@ func (m *OutGoingMiniBlockHeader) Size() (n int) { if l > 0 { n += 1 + l + sovSovereignChainHeader(uint64(l)) } - if m.OutGoingMBType != 0 { - n += 1 + sovSovereignChainHeader(uint64(m.OutGoingMBType)) - } return n } @@ -1077,11 +1077,11 @@ func (this *OutGoingMiniBlockHeader) String() string { return "nil" } s := strings.Join([]string{`&OutGoingMiniBlockHeader{`, + `Type:` + fmt.Sprintf("%v", this.Type) + `,`, `Hash:` + fmt.Sprintf("%v", this.Hash) + `,`, `OutGoingOperationsHash:` + fmt.Sprintf("%v", this.OutGoingOperationsHash) + `,`, `AggregatedSignatureOutGoingOperations:` + fmt.Sprintf("%v", this.AggregatedSignatureOutGoingOperations) + `,`, `LeaderSignatureOutGoingOperations:` + fmt.Sprintf("%v", this.LeaderSignatureOutGoingOperations) + `,`, - `OutGoingMBType:` + fmt.Sprintf("%v", this.OutGoingMBType) + `,`, `}`, }, "") return s @@ -1724,6 +1724,25 @@ func (m *OutGoingMiniBlockHeader) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + m.Type = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Type |= OutGoingMBType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) } @@ -1757,7 +1776,7 @@ func (m *OutGoingMiniBlockHeader) Unmarshal(dAtA []byte) error { m.Hash = []byte{} } iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OutGoingOperationsHash", wireType) } @@ -1791,7 +1810,7 @@ func (m *OutGoingMiniBlockHeader) Unmarshal(dAtA []byte) error { m.OutGoingOperationsHash = []byte{} } iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AggregatedSignatureOutGoingOperations", wireType) } @@ -1825,7 +1844,7 @@ func (m *OutGoingMiniBlockHeader) Unmarshal(dAtA []byte) error { m.AggregatedSignatureOutGoingOperations = []byte{} } iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LeaderSignatureOutGoingOperations", wireType) } @@ -1859,25 +1878,6 @@ func (m *OutGoingMiniBlockHeader) Unmarshal(dAtA []byte) error { m.LeaderSignatureOutGoingOperations = []byte{} } iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field OutGoingMBType", wireType) - } - m.OutGoingMBType = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSovereignChainHeader - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.OutGoingMBType |= OutGoingMBType(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipSovereignChainHeader(dAtA[iNdEx:]) diff --git a/data/block/sovereignChainHeader.proto b/data/block/sovereignChainHeader.proto index 7ee05d76..bd6f1e9b 100644 --- a/data/block/sovereignChainHeader.proto +++ b/data/block/sovereignChainHeader.proto @@ -38,14 +38,15 @@ message SovereignChainHeader { } enum OutGoingMBType { - OutGoingTxMB = 0; - ChangeValidatorSetMB = 30; + OutGoingMbTx = 0; + OutGoingMbChangeValidatorSet = 30; }; message OutGoingMiniBlockHeader { - bytes Hash = 1 [(gogoproto.jsontag) = "hash,omitempty"]; - bytes OutGoingOperationsHash = 2 [(gogoproto.jsontag) = "outGoingOperationsHash,omitempty"]; - bytes AggregatedSignatureOutGoingOperations = 3 [(gogoproto.jsontag) = "aggregatedSignatureOutGoingOperations,omitempty"]; - bytes LeaderSignatureOutGoingOperations = 4 [(gogoproto.jsontag) = "leaderSignatureOutGoingOperations,omitempty"]; - OutGoingMBType OutGoingMBType = 5 [(gogoproto.jsontag) = "outGoingMBType,omitempty"]; + OutGoingMBType Type = 1 [(gogoproto.jsontag) = "type,omitempty"]; + bytes Hash = 2 [(gogoproto.jsontag) = "hash,omitempty"]; + bytes OutGoingOperationsHash = 3 [(gogoproto.jsontag) = "outGoingOperationsHash,omitempty"]; + bytes AggregatedSignatureOutGoingOperations = 4 [(gogoproto.jsontag) = "aggregatedSignatureOutGoingOperations,omitempty"]; + bytes LeaderSignatureOutGoingOperations = 5 [(gogoproto.jsontag) = "leaderSignatureOutGoingOperations,omitempty"]; + } diff --git a/data/block/sovereignChainHeader_test.go b/data/block/sovereignChainHeader_test.go index 27bd51df..ade1cd4d 100644 --- a/data/block/sovereignChainHeader_test.go +++ b/data/block/sovereignChainHeader_test.go @@ -118,19 +118,19 @@ func TestSovereignChainHeader_GetOutGoingMiniBlockHeaderHandler(t *testing.T) { sovHdr := &SovereignChainHeader{ OutGoingMiniBlockHeaders: []*OutGoingMiniBlockHeader{ { - OutGoingMBType: OutGoingTxMB, - Hash: []byte("h1"), + Type: OutGoingMbTx, + Hash: []byte("h1"), }, { - OutGoingMBType: ChangeValidatorSetMB, - Hash: []byte("h2"), + Type: OutGoingMbChangeValidatorSet, + Hash: []byte("h2"), }, }, } - mb := sovHdr.GetOutGoingMiniBlockHeaderHandler(int32(OutGoingTxMB)) + mb := sovHdr.GetOutGoingMiniBlockHeaderHandler(int32(OutGoingMbTx)) require.Equal(t, sovHdr.OutGoingMiniBlockHeaders[0], mb) - mb = sovHdr.GetOutGoingMiniBlockHeaderHandler(int32(ChangeValidatorSetMB)) + mb = sovHdr.GetOutGoingMiniBlockHeaderHandler(int32(OutGoingMbChangeValidatorSet)) require.Equal(t, sovHdr.OutGoingMiniBlockHeaders[1], mb) require.Nil(t, sovHdr.GetOutGoingMiniBlockHeaderHandler(-1)) } @@ -139,8 +139,8 @@ func TestSovereignChainHeader_SetOutGoingMiniBlockHeaderHandlers(t *testing.T) { t.Parallel() sovHdr := &SovereignChainHeader{} - mbHeader1 := &OutGoingMiniBlockHeader{OutGoingMBType: OutGoingTxMB, Hash: []byte("h1")} - mbHeader2 := &OutGoingMiniBlockHeader{OutGoingMBType: ChangeValidatorSetMB, Hash: []byte("h2")} + mbHeader1 := &OutGoingMiniBlockHeader{Type: OutGoingMbTx, Hash: []byte("h1")} + mbHeader2 := &OutGoingMiniBlockHeader{Type: OutGoingMbChangeValidatorSet, Hash: []byte("h2")} err := sovHdr.SetOutGoingMiniBlockHeaderHandlers([]data.OutGoingMiniBlockHeaderHandler{mbHeader1, mbHeader2}) require.Nil(t, err) @@ -154,9 +154,9 @@ func TestSovereignChainHeader_SetOutGoingMiniBlockHeaderHandler(t *testing.T) { t.Parallel() sovHdr := &SovereignChainHeader{} - mbHeader1 := &OutGoingMiniBlockHeader{OutGoingMBType: OutGoingTxMB, Hash: []byte("h1")} - mbHeader2 := &OutGoingMiniBlockHeader{OutGoingMBType: OutGoingTxMB, Hash: []byte("h2")} - mbHeader3 := &OutGoingMiniBlockHeader{OutGoingMBType: ChangeValidatorSetMB, Hash: []byte("h3")} + mbHeader1 := &OutGoingMiniBlockHeader{Type: OutGoingMbTx, Hash: []byte("h1")} + mbHeader2 := &OutGoingMiniBlockHeader{Type: OutGoingMbTx, Hash: []byte("h2")} + mbHeader3 := &OutGoingMiniBlockHeader{Type: OutGoingMbChangeValidatorSet, Hash: []byte("h3")} err := sovHdr.SetOutGoingMiniBlockHeaderHandler(mbHeader1) require.Nil(t, err) From 319ecbecafecdd84223e403d7cc64d634c8de353 Mon Sep 17 00:00:00 2001 From: Marius C Date: Mon, 17 Feb 2025 18:46:50 +0200 Subject: [PATCH 12/12] FIX: Pointer receiver in sov chain ShallowClone --- data/block/sovereignChainHeader.go | 14 ++++++++-- data/block/sovereignChainHeader_test.go | 35 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/data/block/sovereignChainHeader.go b/data/block/sovereignChainHeader.go index 843211dc..e056bc77 100644 --- a/data/block/sovereignChainHeader.go +++ b/data/block/sovereignChainHeader.go @@ -38,8 +38,7 @@ func (sch *SovereignChainHeader) ShallowClone() data.HeaderHandler { headerCopy := *sch if len(sch.OutGoingMiniBlockHeaders) != 0 { - headerCopy.OutGoingMiniBlockHeaders = make([]*OutGoingMiniBlockHeader, len(sch.OutGoingMiniBlockHeaders)) - copy(headerCopy.OutGoingMiniBlockHeaders, sch.OutGoingMiniBlockHeaders) + headerCopy.OutGoingMiniBlockHeaders = copyOutGoingMBHeaders(sch.OutGoingMiniBlockHeaders) } if sch.Header != nil { @@ -50,6 +49,17 @@ func (sch *SovereignChainHeader) ShallowClone() data.HeaderHandler { return &headerCopy } +func copyOutGoingMBHeaders(outGoingMiniBlockHeaders []*OutGoingMiniBlockHeader) []*OutGoingMiniBlockHeader { + ret := make([]*OutGoingMiniBlockHeader, len(outGoingMiniBlockHeaders)) + + for idx, outGoingMBHdr := range outGoingMiniBlockHeaders { + copyMB := *outGoingMBHdr + ret[idx] = ©MB + } + + return ret +} + // GetShardID returns internal header shard id func (sch *SovereignChainHeader) GetShardID() uint32 { if sch == nil { diff --git a/data/block/sovereignChainHeader_test.go b/data/block/sovereignChainHeader_test.go index ade1cd4d..83258729 100644 --- a/data/block/sovereignChainHeader_test.go +++ b/data/block/sovereignChainHeader_test.go @@ -92,6 +92,41 @@ func TestSovereignChainHeader_ShallowClone(t *testing.T) { require.False(t, sovHdr.Header == sovHdrClone.(*SovereignChainHeader).Header) } +func TestSovereignChainHeader_ShallowCloneWithOutGoingMBs(t *testing.T) { + t.Parallel() + + sovHdr := &SovereignChainHeader{ + DevFeesInEpoch: big.NewInt(100), + OutGoingMiniBlockHeaders: []*OutGoingMiniBlockHeader{ + { + Hash: []byte("h1"), + }, + { + Hash: []byte("h2"), + LeaderSignatureOutGoingOperations: []byte("leaderSig"), + }, + }, + } + + sovHdrHandlerClone := sovHdr.ShallowClone() + + sovHdr.OutGoingMiniBlockHeaders[0].Hash = []byte("h3") + sovHdr.OutGoingMiniBlockHeaders[1].LeaderSignatureOutGoingOperations = nil + + require.Equal(t, &SovereignChainHeader{ + DevFeesInEpoch: big.NewInt(100), + OutGoingMiniBlockHeaders: []*OutGoingMiniBlockHeader{ + { + Hash: []byte("h1"), + }, + { + Hash: []byte("h2"), + LeaderSignatureOutGoingOperations: []byte("leaderSig"), + }, + }, + }, sovHdrHandlerClone.(*SovereignChainHeader)) +} + func TestSovereignChainHeader_GetOutGoingMiniBlockHeaderHandlers(t *testing.T) { t.Parallel()