diff --git a/data/block/sovereignChainHeader.go b/data/block/sovereignChainHeader.go index 3887490c..e056bc77 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" ) @@ -33,23 +32,34 @@ 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 = copyOutGoingMBHeaders(sch.OutGoingMiniBlockHeaders) + } - if !check.IfNil(sch.OutGoingMiniBlockHeader) { - internalOutGoingMbHeader := *sch.OutGoingMiniBlockHeader - headerCopy.OutGoingMiniBlockHeader = &internalOutGoingMbHeader + if sch.Header != nil { + internalHeaderCopy := *sch.Header + headerCopy.Header = &internalHeaderCopy } 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 { @@ -549,33 +559,83 @@ 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.GetOutGoingMiniBlockHeaders() + mbHeaderHandlers := make([]data.OutGoingMiniBlockHeaderHandler, len(mbHeaders)) + + for i := range mbHeaders { + mbHeaderHandlers[i] = mbHeaders[i] + } + + return mbHeaderHandlers } -// SetOutGoingMiniBlockHeaderHandler returns the outgoing mini block header +// GetOutGoingMiniBlockHeaderHandler returns the outgoing mb header with specified type, if found +func (sch *SovereignChainHeader) GetOutGoingMiniBlockHeaderHandler(mbType int32) data.OutGoingMiniBlockHeaderHandler { + if sch == nil { + return nil + } + + for _, outGoingMbHdr := range sch.OutGoingMiniBlockHeaders { + if int32(outGoingMbHdr.Type) == mbType { + return outGoingMbHdr + } + } + + return nil +} + +// 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) SetOutGoingMiniBlockHeaderHandler(mbHeader data.OutGoingMiniBlockHeaderHandler) error { if sch == nil { return data.ErrNilPointerReceiver } - if check.IfNil(mbHeader) { - sch.OutGoingMiniBlockHeader = nil - return nil + outGoingMbHdr := createOutGoingMbHeader(mbHeader) + for idx, currOutGoingMbHdr := range sch.OutGoingMiniBlockHeaders { + if int32(currOutGoingMbHdr.Type) == mbHeader.GetOutGoingMBTypeInt32() { + sch.OutGoingMiniBlockHeaders[idx] = outGoingMbHdr + return nil + } } - sch.OutGoingMiniBlockHeader = &OutGoingMiniBlockHeader{ + sch.OutGoingMiniBlockHeaders = append(sch.OutGoingMiniBlockHeaders, outGoingMbHdr) + return nil +} + +func createOutGoingMbHeader(mbHeader data.OutGoingMiniBlockHeaderHandler) *OutGoingMiniBlockHeader { + return &OutGoingMiniBlockHeader{ + Type: OutGoingMBType(mbHeader.GetOutGoingMBTypeInt32()), Hash: mbHeader.GetHash(), OutGoingOperationsHash: mbHeader.GetOutGoingOperationsHash(), AggregatedSignatureOutGoingOperations: mbHeader.GetAggregatedSignatureOutGoingOperations(), LeaderSignatureOutGoingOperations: mbHeader.GetLeaderSignatureOutGoingOperations(), } +} + +// SetOutGoingMiniBlockHeaderHandlers sets the outgoing mini block headers +func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeaderHandlers(mbHeaders []data.OutGoingMiniBlockHeaderHandler) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + if len(mbHeaders) == 0 { + sch.OutGoingMiniBlockHeaders = nil + return nil + } + + miniBlockHeaders := make([]*OutGoingMiniBlockHeader, len(mbHeaders)) + for i, mbHeaderHandler := range mbHeaders { + miniBlockHeaders[i] = createOutGoingMbHeader(mbHeaderHandler) + } + + sch.OutGoingMiniBlockHeaders = miniBlockHeaders return nil } @@ -725,6 +785,25 @@ 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 + } + + return int32(omb.Type) +} + +// SetOutGoingMBTypeInt32 sets the mini block type +func (omb *OutGoingMiniBlockHeader) SetOutGoingMBTypeInt32(mbType int32) error { + if omb == nil { + return data.ErrNilPointerReceiver + } + + omb.Type = 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 e282df49..37c1b6b4 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 ( + OutGoingMbTx OutGoingMBType = 0 + OutGoingMbChangeValidatorSet OutGoingMBType = 30 +) + +var OutGoingMBType_name = map[int32]string{ + 0: "OutGoingMbTx", + 30: "OutGoingMbChangeValidatorSet", +} + +var OutGoingMBType_value = map[string]int32{ + "OutGoingMbTx": 0, + "OutGoingMbChangeValidatorSet": 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"` @@ -150,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"` - 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"` + 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{} } @@ -209,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 } @@ -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"` + 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{} } @@ -279,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 @@ -308,6 +338,7 @@ func (m *OutGoingMiniBlockHeader) GetLeaderSignatureOutGoingOperations() []byte } 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{ - // 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, 0x4f, 0xd2, 0xe3, 0x1e, 0x73, 0x32, 0xac, 0xf7, 0x00, 0xf2, - 0xa9, 0x1f, 0x01, 0x79, 0xec, 0xc4, 0xde, 0x6e, 0xbc, 0xed, 0xa5, 0xa7, 0x64, 0x7e, 0xef, 0xf7, - 0x7e, 0xef, 0xcf, 0xbc, 0x37, 0x86, 0x6d, 0x9f, 0xaf, 0xa8, 0x47, 0x99, 0xe5, 0x9e, 0xda, 0x84, - 0xb9, 0x0f, 0x29, 0x31, 0xa9, 0x37, 0x58, 0x7a, 0x5c, 0x70, 0x54, 0x95, 0x3f, 0xed, 0xbe, 0xc5, - 0x84, 0x1d, 0xcc, 0x07, 0x06, 0x77, 0x86, 0x16, 0xb7, 0xf8, 0x50, 0xc2, 0xf3, 0xe0, 0xb1, 0x3c, - 0xc9, 0x83, 0xfc, 0x97, 0x7a, 0xb5, 0x9b, 0xf3, 0x05, 0x37, 0x7e, 0xcc, 0x0e, 0x6f, 0x3a, 0x54, - 0x10, 0x2d, 0x07, 0xba, 0xff, 0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x65, 0x4f, 0x46, 0xbb, 0x1f, 0x87, 0x78, 0x48, 0x5e, 0xc5, 0xa1, 0x10, - 0xfc, 0xd5, 0x22, 0xa0, 0x9f, 0xe1, 0xfb, 0x8f, 0x64, 0x6f, 0x6e, 0x4a, 0x63, 0x5f, 0xa6, 0x31, - 0x8c, 0x43, 0xfc, 0xc9, 0xe2, 0x65, 0xe4, 0x42, 0x0a, 0x2f, 0x57, 0xd6, 0xbe, 0x3c, 0xbf, 0x50, - 0x2b, 0xeb, 0x0b, 0xb5, 0xf2, 0xfc, 0x42, 0x05, 0xbf, 0x44, 0x2a, 0xf8, 0x2b, 0x52, 0xc1, 0xb3, - 0x48, 0x05, 0xe7, 0x91, 0x0a, 0xd6, 0x91, 0x0a, 0xfe, 0x89, 0x54, 0xf0, 0x5f, 0xa4, 0x56, 0x9e, - 0x47, 0x2a, 0xf8, 0xe3, 0x52, 0xad, 0x9c, 0x5f, 0xaa, 0x95, 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, + // 885 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcf, 0x6f, 0xe3, 0x44, + 0x14, 0xce, 0x90, 0x1f, 0xdd, 0x4e, 0xba, 0xa1, 0x0c, 0xa5, 0x98, 0xa8, 0x3b, 0x13, 0x0a, 0x85, + 0x08, 0x68, 0x22, 0xba, 0x17, 0x24, 0x84, 0x50, 0xdd, 0x74, 0xd9, 0x48, 0x0b, 0x95, 0x9c, 0x15, + 0x42, 0x88, 0xcb, 0xc4, 0x9e, 0xb5, 0x47, 0xc4, 0x33, 0x91, 0x3d, 0xa9, 0x5a, 0x04, 0x12, 0x57, + 0x24, 0x90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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, 0xc3, 0xd3, 0x8b, 0xbc, 0x3b, 0x6b, 0x78, 0x0a, 0x9a, 0x30, 0x8e, + 0x48, 0x2d, 0x55, 0xb7, 0x66, 0x44, 0x64, 0xc1, 0xf5, 0x2f, 0xe9, 0x88, 0x3b, 0x54, 0xc9, 0x60, + 0xa0, 0xa8, 0x0a, 0x2d, 0x29, 0x55, 0xce, 0x51, 0x33, 0x8e, 0xc8, 0xfa, 0xe1, 0x42, 0x86, 0x55, + 0x90, 0x89, 0x18, 0x7c, 0x63, 0xff, 0x48, 0x31, 0xe1, 0x30, 0x47, 0xf7, 0x33, 0xb3, 0xce, 0x42, + 0xa3, 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xf8, 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 { + 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 @@ -468,9 +510,14 @@ func (this *SovereignChainHeader) Equal(that interface{}) bool { return false } } - if !this.OutGoingMiniBlockHeader.Equal(that1.OutGoingMiniBlockHeader) { + if len(this.OutGoingMiniBlockHeaders) != len(that1.OutGoingMiniBlockHeaders) { return false } + for i := range this.OutGoingMiniBlockHeaders { + if !this.OutGoingMiniBlockHeaders[i].Equal(that1.OutGoingMiniBlockHeaders[i]) { + return false + } + } if this.IsStartOfEpoch != that1.IsStartOfEpoch { return false } @@ -510,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 } @@ -560,8 +610,8 @@ 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") + if this.OutGoingMiniBlockHeaders != nil { + 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") @@ -574,8 +624,9 @@ 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, "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") @@ -746,17 +797,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.OutGoingMiniBlockHeaders) > 0 { + for iNdEx := len(m.OutGoingMiniBlockHeaders) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OutGoingMiniBlockHeaders[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-- { @@ -814,28 +867,33 @@ func (m *OutGoingMiniBlockHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) 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 } @@ -909,9 +967,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.OutGoingMiniBlockHeaders) > 0 { + for _, e := range m.OutGoingMiniBlockHeaders { + l = e.Size() + n += 1 + l + sovSovereignChainHeader(uint64(l)) + } } if m.IsStartOfEpoch { n += 2 @@ -937,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)) @@ -991,11 +1054,16 @@ func (this *SovereignChainHeader) String() string { if this == nil { return "nil" } + repeatedStringForOutGoingMiniBlockHeaders := "[]*OutGoingMiniBlockHeader{" + for _, f := range this.OutGoingMiniBlockHeaders { + repeatedStringForOutGoingMiniBlockHeaders += strings.Replace(f.String(), "OutGoingMiniBlockHeader", "OutGoingMiniBlockHeader", 1) + "," + } + 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:` + strings.Replace(this.OutGoingMiniBlockHeader.String(), "OutGoingMiniBlockHeader", "OutGoingMiniBlockHeader", 1) + `,`, + `OutGoingMiniBlockHeaders:` + repeatedStringForOutGoingMiniBlockHeaders + `,`, `IsStartOfEpoch:` + fmt.Sprintf("%v", this.IsStartOfEpoch) + `,`, `AccumulatedFeesInEpoch:` + fmt.Sprintf("%v", this.AccumulatedFeesInEpoch) + `,`, `DevFeesInEpoch:` + fmt.Sprintf("%v", this.DevFeesInEpoch) + `,`, @@ -1009,6 +1077,7 @@ 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) + `,`, @@ -1440,7 +1509,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 { @@ -1467,10 +1536,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.OutGoingMiniBlockHeaders = append(m.OutGoingMiniBlockHeaders, &OutGoingMiniBlockHeader{}) + if err := m.OutGoingMiniBlockHeaders[len(m.OutGoingMiniBlockHeaders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1657,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) } @@ -1690,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) } @@ -1724,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) } @@ -1758,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) } diff --git a/data/block/sovereignChainHeader.proto b/data/block/sovereignChainHeader.proto index ad63cf56..bd6f1e9b 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"]; - OutGoingMiniBlockHeader OutGoingMiniBlockHeader = 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"]; - 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"]; + 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 { + 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 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 fa6535c2..83258729 100644 --- a/data/block/sovereignChainHeader_test.go +++ b/data/block/sovereignChainHeader_test.go @@ -65,3 +65,152 @@ 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_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() + + 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{ + { + Type: OutGoingMbTx, + Hash: []byte("h1"), + }, + { + Type: OutGoingMbChangeValidatorSet, + Hash: []byte("h2"), + }, + }, + } + + mb := sovHdr.GetOutGoingMiniBlockHeaderHandler(int32(OutGoingMbTx)) + require.Equal(t, sovHdr.OutGoingMiniBlockHeaders[0], mb) + mb = sovHdr.GetOutGoingMiniBlockHeaderHandler(int32(OutGoingMbChangeValidatorSet)) + 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{Type: OutGoingMbTx, Hash: []byte("h1")} + mbHeader2 := &OutGoingMiniBlockHeader{Type: OutGoingMbChangeValidatorSet, 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{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) + 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(), + ) +} diff --git a/data/interface.go b/data/interface.go index 894ddbdc..0a271823 100644 --- a/data/interface.go +++ b/data/interface.go @@ -104,7 +104,9 @@ type SovereignChainHeaderHandler interface { GetValidatorStatsRootHash() []byte SetExtendedShardHeaderHashes(hdrHashes [][]byte) error GetExtendedShardHeaderHashes() [][]byte - GetOutGoingMiniBlockHeaderHandler() OutGoingMiniBlockHeaderHandler + GetOutGoingMiniBlockHeaderHandlers() []OutGoingMiniBlockHeaderHandler + SetOutGoingMiniBlockHeaderHandlers(mbHeader []OutGoingMiniBlockHeaderHandler) error + GetOutGoingMiniBlockHeaderHandler(mbType int32) OutGoingMiniBlockHeaderHandler SetOutGoingMiniBlockHeaderHandler(mbHeader OutGoingMiniBlockHeaderHandler) error GetDevFeesInEpoch() *big.Int SetDevFeesInEpoch(value *big.Int) error @@ -124,11 +126,13 @@ type OutGoingMiniBlockHeaderHandler interface { GetOutGoingOperationsHash() []byte GetAggregatedSignatureOutGoingOperations() []byte GetLeaderSignatureOutGoingOperations() []byte + GetOutGoingMBTypeInt32() int32 SetHash(hash []byte) error SetOutGoingOperationsHash(hash []byte) error SetLeaderSignatureOutGoingOperations(sig []byte) error SetAggregatedSignatureOutGoingOperations(sig []byte) error + SetOutGoingMBTypeInt32(mbType int32) error IsInterfaceNil() bool }