diff --git a/core/constants.go b/core/constants.go index e1861bee..61a28a30 100644 --- a/core/constants.go +++ b/core/constants.go @@ -10,6 +10,8 @@ const ( ShardHeaderV1 HeaderType = "Header" // ShardHeaderV2 defines the type of *block.HeaderV2 ShardHeaderV2 HeaderType = "HeaderV2" + // SovereignChainHeader defines the type of *block.SovereignChainHeader + SovereignChainHeader = "SovereignChainHeader" ) // NodeType represents the node's role in the network @@ -31,12 +33,6 @@ const FileModeUserReadWrite = 0600 // for others const FileModeReadWrite = 0664 -// MetachainShardId will be used to identify a shard ID as metachain -const MetachainShardId = uint32(0xFFFFFFFF) - -// AllShardId will be used to identify that a message is for all shards -const AllShardId = uint32(0xFFFFFFF0) - // MegabyteSize represents the size in bytes of a megabyte const MegabyteSize = 1024 * 1024 diff --git a/core/shardIDConstants.go b/core/shardIDConstants.go new file mode 100644 index 00000000..d16c410b --- /dev/null +++ b/core/shardIDConstants.go @@ -0,0 +1,13 @@ +package core + +// MetachainShardId will be used to identify a shard ID as metachain +const MetachainShardId = uint32(0xFFFFFFFF) + +// AllShardId will be used to identify that a message is for all shards +const AllShardId = uint32(0xFFFFFFF0) + +// SovereignChainShardId will be used to identify a shard ID as sovereign chain +const SovereignChainShardId = uint32(0) + +// MainChainShardId will be used to identify a shard ID as main chain +const MainChainShardId = uint32(0xFFFFFFFD) diff --git a/data/block/block.go b/data/block/block.go index b1b305a8..5fff022e 100644 --- a/data/block/block.go +++ b/data/block/block.go @@ -64,7 +64,8 @@ func (h *Header) SetRootHash(rHash []byte) error { } // SetValidatorStatsRootHash sets the root hash for the validator statistics trie -func (h *Header) SetValidatorStatsRootHash(_ []byte) { +func (h *Header) SetValidatorStatsRootHash(_ []byte) error { + return nil } // SetPrevHash sets prev hash @@ -77,11 +78,6 @@ func (h *Header) SetPrevHash(pvHash []byte) error { return nil } -// GetValidatorStatsRootHash returns the root hash for the validator statistics trie -func (h *Header) GetValidatorStatsRootHash() []byte { - return []byte{} -} - // SetPrevRandSeed sets previous random seed func (h *Header) SetPrevRandSeed(pvRandSeed []byte) error { if h == nil { @@ -396,6 +392,39 @@ func (h *Header) ValidateHeaderVersion() error { return nil } +// Clone creates a clones the miniblock +func (m *MiniBlock) Clone() data.MiniBlockHandler { + if m == nil { + return nil + } + + return m.DeepClone() +} + +// IsInterfaceNil returns true if underlying object is nil +func (m *MiniBlock) IsInterfaceNil() bool { + return m == nil +} + +// SetMiniBlocks will set a new set of miniblocks +func (b *Body) SetMiniBlocks(miniBlocks []data.MiniBlockHandler) error { + if b == nil { + return data.ErrNilPointerReceiver + } + + b.MiniBlocks = make([]*MiniBlock, len(miniBlocks)) + for i, mb := range miniBlocks { + mbHandlerClone := mb.Clone() + mbClone, ok := mbHandlerClone.(*MiniBlock) + if !ok { + return data.ErrWrongTypeAssertion + } + b.MiniBlocks[i] = mbClone + } + + return nil +} + // IntegrityAndValidity checks if data is valid func (b *Body) IntegrityAndValidity() error { if b == nil { @@ -427,8 +456,8 @@ func (b *Body) IsInterfaceNil() bool { return b == nil } -// Clone the underlying data -func (mb *MiniBlock) Clone() *MiniBlock { +// DeepClone the underlying data +func (mb *MiniBlock) DeepClone() *MiniBlock { if mb == nil { return nil } @@ -594,6 +623,11 @@ func (h *Header) GetAdditionalData() headerVersionData.HeaderAdditionalData { return nil } +// GetValidatorStatsRootHash returns the root hash for the validator statistics trie +func (h *Header) GetValidatorStatsRootHash() []byte { + return []byte{} +} + // CheckFieldsForNil checks a predefined set of fields for nil values func (h *Header) CheckFieldsForNil() error { if h == nil { diff --git a/data/block/block.proto b/data/block/block.proto index 9551b001..72d35fdf 100644 --- a/data/block/block.proto +++ b/data/block/block.proto @@ -22,7 +22,7 @@ enum Type { InvalidBlock = 120; ReceiptBlock = 150; RewardsBlock = 255; -} +}; enum ProcessingType { Normal = 0; diff --git a/data/block/blockV2.go b/data/block/blockV2.go index 4fb87a15..5f67a712 100644 --- a/data/block/blockV2.go +++ b/data/block/blockV2.go @@ -234,6 +234,11 @@ func (hv2 *HeaderV2) SetRootHash(rHash []byte) error { return hv2.Header.SetRootHash(rHash) } +// SetValidatorStatsRootHash sets the root hash for the validator statistics trie +func (hv2 *HeaderV2) SetValidatorStatsRootHash(_ []byte) error { + return nil +} + // SetPrevHash sets prev hash func (hv2 *HeaderV2) SetPrevHash(pvHash []byte) error { if hv2 == nil { @@ -640,6 +645,11 @@ func (hv2 *HeaderV2) GetAdditionalData() headerVersionData.HeaderAdditionalData return additionalVersionData } +// GetValidatorStatsRootHash returns the root hash for the validator statistics trie +func (hv2 *HeaderV2) GetValidatorStatsRootHash() []byte { + return []byte{} +} + // CheckFieldsForNil checks a predefined set of fields for nil values func (hv2 *HeaderV2) CheckFieldsForNil() error { if hv2 == nil { diff --git a/data/block/emptySovereignHeaderCreator.go b/data/block/emptySovereignHeaderCreator.go new file mode 100644 index 00000000..756729d2 --- /dev/null +++ b/data/block/emptySovereignHeaderCreator.go @@ -0,0 +1,20 @@ +package block + +import "github.com/multiversx/mx-chain-core-go/data" + +type emptySovereignHeaderCreator struct{} + +// NewEmptySovereignHeaderCreator is able to create empty sovereign header instances +func NewEmptySovereignHeaderCreator() *emptySovereignHeaderCreator { + return &emptySovereignHeaderCreator{} +} + +// CreateNewHeader creates a new empty sovereign header +func (creator *emptySovereignHeaderCreator) CreateNewHeader() data.HeaderHandler { + return &SovereignChainHeader{} +} + +// IsInterfaceNil returns true if there is no value under the interface +func (creator *emptySovereignHeaderCreator) IsInterfaceNil() bool { + return creator == nil +} diff --git a/data/block/emptySovereignHeaderCreator_test.go b/data/block/emptySovereignHeaderCreator_test.go new file mode 100644 index 00000000..7a6dd604 --- /dev/null +++ b/data/block/emptySovereignHeaderCreator_test.go @@ -0,0 +1,15 @@ +package block + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func Test_emptySovereignHeaderCreator_CreateNewHeader(t *testing.T) { + creator := NewEmptySovereignHeaderCreator() + require.False(t, creator.IsInterfaceNil()) + + hdr := creator.CreateNewHeader() + require.IsType(t, &SovereignChainHeader{}, hdr) +} diff --git a/data/block/shardHeaderExtended.go b/data/block/shardHeaderExtended.go new file mode 100644 index 00000000..6664aa45 --- /dev/null +++ b/data/block/shardHeaderExtended.go @@ -0,0 +1,925 @@ +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. shardHeaderExtended.proto +package block + +import ( + "fmt" + "math/big" + + "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" +) + +// GetShardID returns the header shardID +func (she *ShardHeaderExtended) GetShardID() uint32 { + if she == nil { + return 0 + } + if she.Header == nil { + return 0 + } + + return she.Header.GetShardID() +} + +// GetNonce returns the header nonce +func (she *ShardHeaderExtended) GetNonce() uint64 { + if she == nil { + return 0 + } + if she.Header == nil { + return 0 + } + + return she.Header.GetNonce() +} + +// GetEpoch returns the header epoch +func (she *ShardHeaderExtended) GetEpoch() uint32 { + if she == nil { + return 0 + } + if she.Header == nil { + return 0 + } + + return she.Header.GetEpoch() +} + +// GetRound returns the header round +func (she *ShardHeaderExtended) GetRound() uint64 { + if she == nil { + return 0 + } + if she.Header == nil { + return 0 + } + + return she.Header.GetRound() +} + +// GetRootHash returns the header root hash +func (she *ShardHeaderExtended) GetRootHash() []byte { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetRootHash() +} + +// GetPrevHash returns the header previous header hash +func (she *ShardHeaderExtended) GetPrevHash() []byte { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetPrevHash() +} + +// GetPrevRandSeed returns the header previous random seed +func (she *ShardHeaderExtended) GetPrevRandSeed() []byte { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetPrevRandSeed() +} + +// GetRandSeed returns the header random seed +func (she *ShardHeaderExtended) GetRandSeed() []byte { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetRandSeed() +} + +// GetPubKeysBitmap returns the header public key bitmap for the aggregated signatures +func (she *ShardHeaderExtended) GetPubKeysBitmap() []byte { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetPubKeysBitmap() +} + +// GetSignature returns the header aggregated signature +func (she *ShardHeaderExtended) GetSignature() []byte { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetSignature() +} + +// GetLeaderSignature returns the leader signature on top of the finalized (signed) header +func (she *ShardHeaderExtended) GetLeaderSignature() []byte { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetLeaderSignature() +} + +// GetChainID returns the chain ID +func (she *ShardHeaderExtended) GetChainID() []byte { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetChainID() +} + +// GetSoftwareVersion returns the header software version +func (she *ShardHeaderExtended) GetSoftwareVersion() []byte { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetSoftwareVersion() +} + +// GetTimeStamp returns the header timestamp +func (she *ShardHeaderExtended) GetTimeStamp() uint64 { + if she == nil { + return 0 + } + if she.Header == nil { + return 0 + } + + return she.Header.GetTimeStamp() +} + +// GetTxCount returns the number of txs included in the block +func (she *ShardHeaderExtended) GetTxCount() uint32 { + if she == nil { + return 0 + } + if she.Header == nil { + return 0 + } + + return she.Header.GetTxCount() +} + +// GetReceiptsHash returns the header receipt hash +func (she *ShardHeaderExtended) GetReceiptsHash() []byte { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetReceiptsHash() +} + +// GetAccumulatedFees returns the block accumulated fees +func (she *ShardHeaderExtended) GetAccumulatedFees() *big.Int { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetAccumulatedFees() +} + +// GetDeveloperFees returns the block developer fees +func (she *ShardHeaderExtended) GetDeveloperFees() *big.Int { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetDeveloperFees() +} + +// GetReserved returns the reserved field +func (she *ShardHeaderExtended) GetReserved() []byte { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetReserved() +} + +// GetMetaBlockHashes returns the metaBlock hashes +func (she *ShardHeaderExtended) GetMetaBlockHashes() [][]byte { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetMetaBlockHashes() +} + +// GetEpochStartMetaHash returns the epoch start metaBlock hash +func (she *ShardHeaderExtended) GetEpochStartMetaHash() []byte { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetEpochStartMetaHash() +} + +// SetNonce sets the header nonce +func (she *ShardHeaderExtended) SetNonce(n uint64) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetNonce(n) +} + +// SetEpoch sets the header epoch +func (she *ShardHeaderExtended) SetEpoch(e uint32) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetEpoch(e) +} + +// SetRound sets the header round +func (she *ShardHeaderExtended) SetRound(r uint64) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetRound(r) +} + +// SetRootHash sets the root hash +func (she *ShardHeaderExtended) SetRootHash(rHash []byte) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetRootHash(rHash) +} + +// SetValidatorStatsRootHash does nothing and returns nil +func (she *ShardHeaderExtended) SetValidatorStatsRootHash(_ []byte) error { + return nil +} + +// SetPrevHash sets the previous hash +func (she *ShardHeaderExtended) SetPrevHash(pvHash []byte) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetPrevHash(pvHash) +} + +// SetPrevRandSeed sets the previous random seed +func (she *ShardHeaderExtended) SetPrevRandSeed(pvRandSeed []byte) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetPrevRandSeed(pvRandSeed) +} + +// SetRandSeed sets the random seed +func (she *ShardHeaderExtended) SetRandSeed(randSeed []byte) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetRandSeed(randSeed) +} + +// SetPubKeysBitmap sets the public key bitmap +func (she *ShardHeaderExtended) SetPubKeysBitmap(pkbm []byte) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetPubKeysBitmap(pkbm) +} + +// SetSignature sets the header signature +func (she *ShardHeaderExtended) SetSignature(sg []byte) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetSignature(sg) +} + +// SetLeaderSignature sets the leader's signature +func (she *ShardHeaderExtended) SetLeaderSignature(sg []byte) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetLeaderSignature(sg) +} + +// SetChainID sets the chain ID on which this block is valid on +func (she *ShardHeaderExtended) SetChainID(chainID []byte) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetChainID(chainID) +} + +// SetSoftwareVersion sets the software version of the header +func (she *ShardHeaderExtended) SetSoftwareVersion(version []byte) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetSoftwareVersion(version) +} + +// SetTimeStamp sets the header timestamp +func (she *ShardHeaderExtended) SetTimeStamp(ts uint64) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetTimeStamp(ts) +} + +// SetAccumulatedFees sets the accumulated fees in the header +func (she *ShardHeaderExtended) SetAccumulatedFees(value *big.Int) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetAccumulatedFees(value) +} + +// SetDeveloperFees sets the developer fees in the header +func (she *ShardHeaderExtended) SetDeveloperFees(value *big.Int) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetDeveloperFees(value) +} + +// SetTxCount sets the transaction count of the block associated with this header +func (she *ShardHeaderExtended) SetTxCount(txCount uint32) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetTxCount(txCount) +} + +// SetShardID sets the header shard ID +func (she *ShardHeaderExtended) SetShardID(shId uint32) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetShardID(shId) +} + +// GetMiniBlockHeadersWithDst gets the map of miniBlockHeader hashes and sender IDs +func (she *ShardHeaderExtended) GetMiniBlockHeadersWithDst(destId uint32) map[string]uint32 { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetMiniBlockHeadersWithDst(destId) +} + +// GetOrderedCrossMiniblocksWithDst gets all the cross miniBlocks with the given destination shard ID, ordered in a +// chronological way, taking into consideration the round in which they were created/executed in the sender shard +func (she *ShardHeaderExtended) GetOrderedCrossMiniblocksWithDst(destId uint32) []*data.MiniBlockInfo { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetOrderedCrossMiniblocksWithDst(destId) +} + +// GetMiniBlockHeadersHashes gets the miniBlock hashes +func (she *ShardHeaderExtended) GetMiniBlockHeadersHashes() [][]byte { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetMiniBlockHeadersHashes() +} + +// MapMiniBlockHashesToShards gets the map of miniBlock hashes and sender IDs +func (she *ShardHeaderExtended) MapMiniBlockHashesToShards() map[string]uint32 { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.MapMiniBlockHashesToShards() +} + +// ShallowClone returns a clone of the object +func (she *ShardHeaderExtended) ShallowClone() data.HeaderHandler { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + internalHeaderCopy := *she.Header + headerCopy := *she + headerCopy.Header = &internalHeaderCopy + + return &headerCopy +} + +// IsInterfaceNil returns true if there is no value under the interface +func (she *ShardHeaderExtended) IsInterfaceNil() bool { + return she == nil +} + +// IsStartOfEpochBlock verifies if the block is of type start of epoch +func (she *ShardHeaderExtended) IsStartOfEpochBlock() bool { + if she == nil { + return false + } + if she.Header == nil { + return false + } + + return she.Header.IsStartOfEpochBlock() +} + +// GetBlockBodyTypeInt32 returns the blockBody type as int32 +func (she *ShardHeaderExtended) GetBlockBodyTypeInt32() int32 { + if she == nil { + return -1 + } + if she.Header == nil { + return -1 + } + + return she.Header.GetBlockBodyTypeInt32() +} + +// GetMiniBlockHeaderHandlers returns the miniBlock headers as an array of miniBlock header handlers +func (she *ShardHeaderExtended) GetMiniBlockHeaderHandlers() []data.MiniBlockHeaderHandler { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + return she.Header.GetMiniBlockHeaderHandlers() +} + +// SetMiniBlockHeaderHandlers sets the miniBlock headers from the given miniBlock header handlers +func (she *ShardHeaderExtended) SetMiniBlockHeaderHandlers(mbHeaderHandlers []data.MiniBlockHeaderHandler) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetMiniBlockHeaderHandlers(mbHeaderHandlers) +} + +// SetReceiptsHash sets the receipts hash +func (she *ShardHeaderExtended) SetReceiptsHash(hash []byte) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetReceiptsHash(hash) +} + +// SetMetaBlockHashes sets the metaBlock hashes +func (she *ShardHeaderExtended) SetMetaBlockHashes(hashes [][]byte) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetMetaBlockHashes(hashes) +} + +// SetEpochStartMetaHash sets the epoch start metaBlock hash +func (she *ShardHeaderExtended) SetEpochStartMetaHash(hash []byte) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + return she.Header.SetEpochStartMetaHash(hash) +} + +// HasScheduledSupport returns true as the second block version does support scheduled data +func (she *ShardHeaderExtended) HasScheduledSupport() bool { + return true +} + +// HasScheduledMiniBlocks returns true if the header has scheduled miniBlock headers +func (she *ShardHeaderExtended) HasScheduledMiniBlocks() bool { + if she == nil { + return false + } + + mbHeaderHandlers := she.GetMiniBlockHeaderHandlers() + for _, mbHeader := range mbHeaderHandlers { + processingType := ProcessingType(mbHeader.GetProcessingType()) + if processingType == Scheduled { + return true + } + } + + return false +} + +// SetScheduledRootHash sets the scheduled root hash +func (she *ShardHeaderExtended) SetScheduledRootHash(rootHash []byte) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + she.Header.ScheduledRootHash = rootHash + + return nil +} + +// SetScheduledAccumulatedFees sets the scheduled accumulated fees +func (she *ShardHeaderExtended) SetScheduledAccumulatedFees(value *big.Int) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + if she.Header.ScheduledAccumulatedFees == nil { + she.Header.ScheduledAccumulatedFees = big.NewInt(0) + } + if value == nil { + value = big.NewInt(0) + } + + she.Header.ScheduledAccumulatedFees.Set(value) + + return nil +} + +// SetScheduledDeveloperFees sets the scheduled developer fees +func (she *ShardHeaderExtended) SetScheduledDeveloperFees(value *big.Int) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + if she.Header.ScheduledDeveloperFees == nil { + she.Header.ScheduledDeveloperFees = big.NewInt(0) + } + if value == nil { + value = big.NewInt(0) + } + + she.Header.ScheduledDeveloperFees.Set(value) + + return nil +} + +// SetScheduledGasProvided sets the scheduled SC calls provided gas +func (she *ShardHeaderExtended) SetScheduledGasProvided(gasProvided uint64) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + she.Header.ScheduledGasProvided = gasProvided + + return nil +} + +// SetScheduledGasPenalized sets the scheduled SC calls penalized gas +func (she *ShardHeaderExtended) SetScheduledGasPenalized(gasPenalized uint64) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + she.Header.ScheduledGasPenalized = gasPenalized + + return nil +} + +// SetScheduledGasRefunded sets the scheduled SC calls refunded gas +func (she *ShardHeaderExtended) SetScheduledGasRefunded(gasRefunded uint64) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + she.Header.ScheduledGasRefunded = gasRefunded + + return nil +} + +// ValidateHeaderVersion does extra validation for header version +func (she *ShardHeaderExtended) ValidateHeaderVersion() error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + + // the header needs to have a not nil & not empty scheduled root hash + if len(she.Header.ScheduledRootHash) == 0 { + return data.ErrNilScheduledRootHash + } + + return she.Header.ValidateHeaderVersion() +} + +// SetAdditionalData sets the additional version related data for the header +func (she *ShardHeaderExtended) SetAdditionalData(headerVersionData headerVersionData.HeaderAdditionalData) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + if check.IfNil(headerVersionData) { + return data.ErrNilPointerDereference + } + + err := she.SetScheduledRootHash(headerVersionData.GetScheduledRootHash()) + if err != nil { + return err + } + + she.Header.ScheduledGasProvided = headerVersionData.GetScheduledGasProvided() + she.Header.ScheduledGasPenalized = headerVersionData.GetScheduledGasPenalized() + she.Header.ScheduledGasRefunded = headerVersionData.GetScheduledGasRefunded() + + err = she.SetScheduledAccumulatedFees(headerVersionData.GetScheduledAccumulatedFees()) + if err != nil { + return err + } + + return she.SetScheduledDeveloperFees(headerVersionData.GetScheduledDeveloperFees()) +} + +// GetAdditionalData gets the additional version related data for the header +func (she *ShardHeaderExtended) GetAdditionalData() headerVersionData.HeaderAdditionalData { + if she == nil { + return nil + } + if she.Header == nil { + return nil + } + + accFees := big.NewInt(0) + if she.Header.GetScheduledAccumulatedFees() != nil { + accFees = big.NewInt(0).Set(she.Header.GetScheduledAccumulatedFees()) + } + devFees := big.NewInt(0) + if she.Header.GetScheduledDeveloperFees() != nil { + devFees = big.NewInt(0).Set(she.Header.GetScheduledDeveloperFees()) + } + + additionalVersionData := &headerVersionData.AdditionalData{ + ScheduledRootHash: she.Header.GetScheduledRootHash(), + ScheduledAccumulatedFees: accFees, + ScheduledDeveloperFees: devFees, + ScheduledGasProvided: she.Header.GetScheduledGasProvided(), + ScheduledGasPenalized: she.Header.GetScheduledGasPenalized(), + ScheduledGasRefunded: she.Header.GetScheduledGasRefunded(), + } + + return additionalVersionData +} + +// GetValidatorStatsRootHash returns an empty byte slice +func (she *ShardHeaderExtended) GetValidatorStatsRootHash() []byte { + return make([]byte, 0) +} + +// CheckFieldsForNil checks a predefined set of fields for nil values +func (she *ShardHeaderExtended) CheckFieldsForNil() error { + if she == nil { + return data.ErrNilPointerReceiver + } + if she.Header == nil { + return data.ErrNilHeader + } + err := she.Header.CheckFieldsForNil() + if err != nil { + return err + } + if she.Header.ScheduledAccumulatedFees == nil { + return fmt.Errorf("%w in ShardHeaderExtended.ScheduledAccumulatedFees", data.ErrNilValue) + } + if she.Header.ScheduledDeveloperFees == nil { + return fmt.Errorf("%w in ShardHeaderExtended.ScheduledDeveloperFees", data.ErrNilValue) + } + + return nil +} + +// GetIncomingMiniBlockHandlers gets the incoming mini blocks as an array of mini blocks handlers +func (she *ShardHeaderExtended) GetIncomingMiniBlockHandlers() []data.MiniBlockHandler { + if she == nil { + return nil + } + + miniBlocks := she.GetIncomingMiniBlocks() + miniBlockHandlers := make([]data.MiniBlockHandler, len(miniBlocks)) + + for i := range miniBlocks { + miniBlockHandlers[i] = miniBlocks[i] + } + + return miniBlockHandlers +} + +// SetIncomingMiniBlockHandlers sets the incoming mini blocks from the given array of mini blocks handlers +func (she *ShardHeaderExtended) SetIncomingMiniBlockHandlers(miniBlockHandlers []data.MiniBlockHandler) error { + if she == nil { + return data.ErrNilPointerReceiver + } + if len(miniBlockHandlers) == 0 { + she.IncomingMiniBlocks = nil + return nil + } + + incomingMiniBlocks := make([]*MiniBlock, len(miniBlockHandlers)) + for i, miniBlockHandler := range miniBlockHandlers { + miniBlockHandlerClone := miniBlockHandler.Clone() + miniBlock, ok := miniBlockHandlerClone.(*MiniBlock) + if !ok { + return data.ErrWrongTypeAssertion + } + + incomingMiniBlocks[i] = miniBlock + } + + she.IncomingMiniBlocks = incomingMiniBlocks + + return nil +} + +// GetIncomingEventHandlers returns the incoming events as an array of event handlers +func (she *ShardHeaderExtended) GetIncomingEventHandlers() []data.EventHandler { + if she == nil { + return nil + } + + events := she.GetIncomingEvents() + logHandlers := make([]data.EventHandler, len(events)) + + for i := range events { + logHandlers[i] = events[i] + } + + return logHandlers +} + +// GetHeaderHandler returns the incoming headerV2 as a header handler +func (she *ShardHeaderExtended) GetHeaderHandler() data.HeaderHandler { + if she == nil { + return nil + } + + return she.GetHeader() +} + +// SetBlockBodyTypeInt32 sets the blockBodyType in the header +func (she *ShardHeaderExtended) SetBlockBodyTypeInt32(blockBodyType int32) error { + if she == nil { + return data.ErrNilPointerReceiver + } + + return she.Header.SetBlockBodyTypeInt32(blockBodyType) +} diff --git a/data/block/shardHeaderExtended.pb.go b/data/block/shardHeaderExtended.pb.go new file mode 100644 index 00000000..c265208d --- /dev/null +++ b/data/block/shardHeaderExtended.pb.go @@ -0,0 +1,558 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: shardHeaderExtended.proto + +package block + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + transaction "github.com/multiversx/mx-chain-core-go/data/transaction" + io "io" + math "math" + math_bits "math/bits" + reflect "reflect" + strings "strings" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// ShardHeaderExtended extends the HeaderV2 structure with extra fields needed by sovereign chain +type ShardHeaderExtended struct { + Header *HeaderV2 `protobuf:"bytes,1,opt,name=Header,proto3" json:"header"` + IncomingMiniBlocks []*MiniBlock `protobuf:"bytes,2,rep,name=IncomingMiniBlocks,proto3" json:"incomingMiniBlocks,omitempty"` + IncomingEvents []*transaction.Event `protobuf:"bytes,3,rep,name=IncomingEvents,proto3" json:"incomingEvents,omitempty"` +} + +func (m *ShardHeaderExtended) Reset() { *m = ShardHeaderExtended{} } +func (*ShardHeaderExtended) ProtoMessage() {} +func (*ShardHeaderExtended) Descriptor() ([]byte, []int) { + return fileDescriptor_549610f8c128bd02, []int{0} +} +func (m *ShardHeaderExtended) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ShardHeaderExtended) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *ShardHeaderExtended) XXX_Merge(src proto.Message) { + xxx_messageInfo_ShardHeaderExtended.Merge(m, src) +} +func (m *ShardHeaderExtended) XXX_Size() int { + return m.Size() +} +func (m *ShardHeaderExtended) XXX_DiscardUnknown() { + xxx_messageInfo_ShardHeaderExtended.DiscardUnknown(m) +} + +var xxx_messageInfo_ShardHeaderExtended proto.InternalMessageInfo + +func (m *ShardHeaderExtended) GetHeader() *HeaderV2 { + if m != nil { + return m.Header + } + return nil +} + +func (m *ShardHeaderExtended) GetIncomingMiniBlocks() []*MiniBlock { + if m != nil { + return m.IncomingMiniBlocks + } + return nil +} + +func (m *ShardHeaderExtended) GetIncomingEvents() []*transaction.Event { + if m != nil { + return m.IncomingEvents + } + return nil +} + +func init() { + proto.RegisterType((*ShardHeaderExtended)(nil), "proto.ShardHeaderExtended") +} + +func init() { proto.RegisterFile("shardHeaderExtended.proto", fileDescriptor_549610f8c128bd02) } + +var fileDescriptor_549610f8c128bd02 = []byte{ + // 348 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xc1, 0x4e, 0xfa, 0x30, + 0x1c, 0xc7, 0x57, 0x08, 0x1c, 0xc6, 0xff, 0xaf, 0x66, 0x5e, 0x26, 0x21, 0x3f, 0x88, 0x27, 0x0e, + 0x8e, 0x25, 0xe3, 0x01, 0x8c, 0x4b, 0x48, 0xf4, 0xe0, 0x05, 0x13, 0x0e, 0xde, 0xba, 0xad, 0x6e, + 0x8d, 0xac, 0x25, 0x5d, 0x21, 0x78, 0x33, 0x3e, 0x81, 0x8f, 0xe1, 0xa3, 0x78, 0xe4, 0xc8, 0x89, + 0x48, 0xb9, 0x98, 0x9d, 0x78, 0x04, 0x63, 0x37, 0x0d, 0x8a, 0xa7, 0xf6, 0xfb, 0xed, 0x27, 0x9f, + 0xb6, 0xf9, 0x99, 0x27, 0x59, 0x82, 0x45, 0x74, 0x49, 0x70, 0x44, 0xc4, 0x60, 0x2e, 0x09, 0x8b, + 0x48, 0xd4, 0x9b, 0x08, 0x2e, 0xb9, 0x55, 0xd3, 0x4b, 0xb3, 0x11, 0x8c, 0x79, 0x78, 0x5f, 0x74, + 0xcd, 0xff, 0x3a, 0x8c, 0xbc, 0x32, 0x3a, 0x31, 0x95, 0xc9, 0x34, 0xe8, 0x85, 0x3c, 0x75, 0x63, + 0x1e, 0x73, 0x57, 0xd7, 0xc1, 0xf4, 0x4e, 0x27, 0x1d, 0xf4, 0xae, 0xc4, 0x2f, 0x76, 0xf0, 0x74, + 0x3a, 0x96, 0x74, 0x46, 0x44, 0x36, 0x77, 0xd3, 0xb9, 0x13, 0x26, 0x98, 0x32, 0x27, 0xe4, 0x82, + 0x38, 0x31, 0x77, 0x23, 0x2c, 0xb1, 0x2b, 0x05, 0x66, 0x19, 0x0e, 0x25, 0xe5, 0xcc, 0x1d, 0xf3, + 0xb8, 0x50, 0x9c, 0x3e, 0x55, 0xcc, 0xe3, 0x9b, 0xfd, 0x27, 0x5b, 0x7d, 0xb3, 0x5e, 0x34, 0x36, + 0xea, 0xa0, 0x6e, 0xc3, 0x3b, 0x2c, 0xf8, 0x5e, 0x51, 0x8e, 0x3c, 0xdf, 0xcc, 0x57, 0xed, 0x7a, + 0xa2, 0xd3, 0xb0, 0x44, 0xad, 0xc0, 0xb4, 0xae, 0x58, 0xc8, 0x53, 0xca, 0xe2, 0x6b, 0xca, 0xa8, + 0xff, 0xf9, 0xb7, 0xcc, 0xae, 0x74, 0xaa, 0xdd, 0x86, 0x77, 0x54, 0x0a, 0xbe, 0x0f, 0xfc, 0x4e, + 0xbe, 0x6a, 0xb7, 0xe8, 0x1e, 0x7f, 0xc6, 0x53, 0x2a, 0x49, 0x3a, 0x91, 0x0f, 0xc3, 0x3f, 0x6c, + 0xd6, 0xd0, 0x3c, 0xf8, 0x6a, 0x07, 0x33, 0xc2, 0x64, 0x66, 0x57, 0xb5, 0xff, 0x5f, 0xe9, 0xd7, + 0xa5, 0xdf, 0xca, 0x57, 0x6d, 0x9b, 0xfe, 0xe0, 0x76, 0xbc, 0xbf, 0x0c, 0xfe, 0xf9, 0x62, 0x0d, + 0xc6, 0x72, 0x0d, 0xc6, 0x76, 0x0d, 0xe8, 0x51, 0x01, 0x7a, 0x51, 0x80, 0x5e, 0x15, 0xa0, 0x85, + 0x02, 0xb4, 0x54, 0x80, 0xde, 0x14, 0xa0, 0x77, 0x05, 0xc6, 0x56, 0x01, 0x7a, 0xde, 0x80, 0xb1, + 0xd8, 0x80, 0xb1, 0xdc, 0x80, 0x71, 0x5b, 0xd3, 0xf3, 0x0b, 0xea, 0xfa, 0xee, 0xfe, 0x47, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x1b, 0x9a, 0x02, 0x49, 0xfe, 0x01, 0x00, 0x00, +} + +func (this *ShardHeaderExtended) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ShardHeaderExtended) + if !ok { + that2, ok := that.(ShardHeaderExtended) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Header.Equal(that1.Header) { + return false + } + if len(this.IncomingMiniBlocks) != len(that1.IncomingMiniBlocks) { + return false + } + for i := range this.IncomingMiniBlocks { + if !this.IncomingMiniBlocks[i].Equal(that1.IncomingMiniBlocks[i]) { + return false + } + } + if len(this.IncomingEvents) != len(that1.IncomingEvents) { + return false + } + for i := range this.IncomingEvents { + if !this.IncomingEvents[i].Equal(that1.IncomingEvents[i]) { + return false + } + } + return true +} +func (this *ShardHeaderExtended) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 7) + s = append(s, "&block.ShardHeaderExtended{") + if this.Header != nil { + s = append(s, "Header: "+fmt.Sprintf("%#v", this.Header)+",\n") + } + if this.IncomingMiniBlocks != nil { + s = append(s, "IncomingMiniBlocks: "+fmt.Sprintf("%#v", this.IncomingMiniBlocks)+",\n") + } + if this.IncomingEvents != nil { + s = append(s, "IncomingEvents: "+fmt.Sprintf("%#v", this.IncomingEvents)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringShardHeaderExtended(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *ShardHeaderExtended) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ShardHeaderExtended) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ShardHeaderExtended) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.IncomingEvents) > 0 { + for iNdEx := len(m.IncomingEvents) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.IncomingEvents[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintShardHeaderExtended(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.IncomingMiniBlocks) > 0 { + for iNdEx := len(m.IncomingMiniBlocks) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.IncomingMiniBlocks[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintShardHeaderExtended(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Header != nil { + { + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintShardHeaderExtended(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintShardHeaderExtended(dAtA []byte, offset int, v uint64) int { + offset -= sovShardHeaderExtended(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ShardHeaderExtended) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Header != nil { + l = m.Header.Size() + n += 1 + l + sovShardHeaderExtended(uint64(l)) + } + if len(m.IncomingMiniBlocks) > 0 { + for _, e := range m.IncomingMiniBlocks { + l = e.Size() + n += 1 + l + sovShardHeaderExtended(uint64(l)) + } + } + if len(m.IncomingEvents) > 0 { + for _, e := range m.IncomingEvents { + l = e.Size() + n += 1 + l + sovShardHeaderExtended(uint64(l)) + } + } + return n +} + +func sovShardHeaderExtended(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozShardHeaderExtended(x uint64) (n int) { + return sovShardHeaderExtended(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *ShardHeaderExtended) String() string { + if this == nil { + return "nil" + } + repeatedStringForIncomingMiniBlocks := "[]*MiniBlock{" + for _, f := range this.IncomingMiniBlocks { + repeatedStringForIncomingMiniBlocks += strings.Replace(fmt.Sprintf("%v", f), "MiniBlock", "MiniBlock", 1) + "," + } + repeatedStringForIncomingMiniBlocks += "}" + repeatedStringForIncomingEvents := "[]*Event{" + for _, f := range this.IncomingEvents { + repeatedStringForIncomingEvents += strings.Replace(fmt.Sprintf("%v", f), "Event", "transaction.Event", 1) + "," + } + repeatedStringForIncomingEvents += "}" + s := strings.Join([]string{`&ShardHeaderExtended{`, + `Header:` + strings.Replace(fmt.Sprintf("%v", this.Header), "HeaderV2", "HeaderV2", 1) + `,`, + `IncomingMiniBlocks:` + repeatedStringForIncomingMiniBlocks + `,`, + `IncomingEvents:` + repeatedStringForIncomingEvents + `,`, + `}`, + }, "") + return s +} +func valueToStringShardHeaderExtended(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *ShardHeaderExtended) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShardHeaderExtended + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ShardHeaderExtended: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ShardHeaderExtended: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShardHeaderExtended + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthShardHeaderExtended + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthShardHeaderExtended + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Header == nil { + m.Header = &HeaderV2{} + } + if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IncomingMiniBlocks", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShardHeaderExtended + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthShardHeaderExtended + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthShardHeaderExtended + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IncomingMiniBlocks = append(m.IncomingMiniBlocks, &MiniBlock{}) + if err := m.IncomingMiniBlocks[len(m.IncomingMiniBlocks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IncomingEvents", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShardHeaderExtended + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthShardHeaderExtended + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthShardHeaderExtended + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IncomingEvents = append(m.IncomingEvents, &transaction.Event{}) + if err := m.IncomingEvents[len(m.IncomingEvents)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipShardHeaderExtended(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthShardHeaderExtended + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthShardHeaderExtended + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipShardHeaderExtended(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowShardHeaderExtended + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowShardHeaderExtended + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowShardHeaderExtended + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthShardHeaderExtended + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupShardHeaderExtended + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthShardHeaderExtended + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthShardHeaderExtended = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowShardHeaderExtended = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupShardHeaderExtended = fmt.Errorf("proto: unexpected end of group") +) diff --git a/data/block/shardHeaderExtended.proto b/data/block/shardHeaderExtended.proto new file mode 100644 index 00000000..3a3ea605 --- /dev/null +++ b/data/block/shardHeaderExtended.proto @@ -0,0 +1,19 @@ +// This file holds the data structures related with the functionality of an extended shard header needed by sovereign chain +syntax = "proto3"; + +package proto; + +option go_package = "block"; +option (gogoproto.stable_marshaler_all) = true; + +import "block.proto"; +import "blockV2.proto"; +import "github.com/gogo/protobuf/gogoproto/gogo.proto"; +import "github.com/multiversx/mx-chain-core-go/data/transaction/log.proto"; + +// ShardHeaderExtended extends the HeaderV2 structure with extra fields needed by sovereign chain +message ShardHeaderExtended { + HeaderV2 Header = 1 [(gogoproto.jsontag) = "header"]; + repeated MiniBlock IncomingMiniBlocks = 2 [(gogoproto.jsontag) = "incomingMiniBlocks,omitempty"]; + repeated Event IncomingEvents = 3 [(gogoproto.jsontag) = "incomingEvents,omitempty"]; +} diff --git a/data/block/sovereignChainHeader.go b/data/block/sovereignChainHeader.go new file mode 100644 index 00000000..09d7941d --- /dev/null +++ b/data/block/sovereignChainHeader.go @@ -0,0 +1,872 @@ +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. sovereignChainHeader.proto +package block + +import ( + "fmt" + "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" +) + +// GetAdditionalData returns nil for the sovereign chain header +func (sch *SovereignChainHeader) GetAdditionalData() headerVersionData.HeaderAdditionalData { + return nil +} + +// HasScheduledMiniBlocks returns false for the sovereign chain header +func (sch *SovereignChainHeader) HasScheduledMiniBlocks() bool { + return false +} + +// SetScheduledRootHash does nothing and returns nil for the sovereign chain header +func (sch *SovereignChainHeader) SetScheduledRootHash(_ []byte) error { + return nil +} + +// SetAdditionalData does nothing and returns nil for the sovereign chain header +func (sch *SovereignChainHeader) SetAdditionalData(_ headerVersionData.HeaderAdditionalData) error { + return nil +} + +// ShallowClone returns a clone of the object +func (sch *SovereignChainHeader) ShallowClone() data.HeaderHandler { + if sch == nil || sch.Header == nil { + return nil + } + + internalHeaderCopy := *sch.Header + + headerCopy := *sch + headerCopy.Header = &internalHeaderCopy + + if !check.IfNil(sch.OutGoingMiniBlockHeader) { + internalOutGoingMbHeader := *sch.OutGoingMiniBlockHeader + headerCopy.OutGoingMiniBlockHeader = &internalOutGoingMbHeader + } + + return &headerCopy +} + +// GetShardID returns internal header shard id +func (sch *SovereignChainHeader) GetShardID() uint32 { + if sch == nil { + return 0 + } + + return sch.Header.ShardID +} + +// GetNonce returns the header nonce +func (sch *SovereignChainHeader) GetNonce() uint64 { + if sch == nil { + return 0 + } + + return sch.Header.GetNonce() +} + +// GetEpoch returns the header epoch +func (sch *SovereignChainHeader) GetEpoch() uint32 { + if sch == nil { + return 0 + } + + return sch.Header.GetEpoch() +} + +// GetRound returns the header round +func (sch *SovereignChainHeader) GetRound() uint64 { + if sch == nil { + return 0 + } + + return sch.Header.GetRound() +} + +// GetRootHash returns the header root hash +func (sch *SovereignChainHeader) GetRootHash() []byte { + if sch == nil { + return nil + } + + return sch.Header.GetRootHash() +} + +// GetPrevHash returns the header previous header hash +func (sch *SovereignChainHeader) GetPrevHash() []byte { + if sch == nil { + return nil + } + + return sch.Header.GetPrevHash() +} + +// GetPrevRandSeed returns the header previous random seed +func (sch *SovereignChainHeader) GetPrevRandSeed() []byte { + if sch == nil { + return nil + } + + return sch.Header.GetPrevRandSeed() +} + +// GetRandSeed returns the header random seed +func (sch *SovereignChainHeader) GetRandSeed() []byte { + if sch == nil { + return nil + } + + return sch.Header.GetRandSeed() +} + +// GetPubKeysBitmap returns the header public key bitmap for the aggregated signatures +func (sch *SovereignChainHeader) GetPubKeysBitmap() []byte { + if sch == nil { + return nil + } + + return sch.Header.GetPubKeysBitmap() +} + +// GetSignature returns the header aggregated signature +func (sch *SovereignChainHeader) GetSignature() []byte { + if sch == nil { + return nil + } + + return sch.Header.GetSignature() +} + +// GetLeaderSignature returns the leader signature on top of the finalized (signed) header +func (sch *SovereignChainHeader) GetLeaderSignature() []byte { + if sch == nil { + return nil + } + + return sch.Header.GetLeaderSignature() +} + +// GetChainID returns the chain ID +func (sch *SovereignChainHeader) GetChainID() []byte { + if sch == nil { + return nil + } + + return sch.Header.GetChainID() +} + +// GetSoftwareVersion returns the header software version +func (sch *SovereignChainHeader) GetSoftwareVersion() []byte { + if sch == nil { + return nil + } + + return sch.Header.GetSoftwareVersion() +} + +// GetTimeStamp returns the header timestamp +func (sch *SovereignChainHeader) GetTimeStamp() uint64 { + if sch == nil { + return 0 + } + + return sch.Header.GetTimeStamp() +} + +// GetTxCount returns the number of txs included in the block +func (sch *SovereignChainHeader) GetTxCount() uint32 { + if sch == nil { + return 0 + } + + return sch.Header.GetTxCount() +} + +// GetReceiptsHash returns the header receipt hash +func (sch *SovereignChainHeader) GetReceiptsHash() []byte { + if sch == nil { + return nil + } + + return sch.Header.GetReceiptsHash() +} + +// GetAccumulatedFees returns the block accumulated fees +func (sch *SovereignChainHeader) GetAccumulatedFees() *big.Int { + if sch == nil { + return nil + } + + return sch.Header.GetAccumulatedFees() +} + +// GetDeveloperFees returns the block developer fees +func (sch *SovereignChainHeader) GetDeveloperFees() *big.Int { + if sch == nil { + return nil + } + + return sch.Header.GetDeveloperFees() +} + +// GetReserved returns the reserved field +func (sch *SovereignChainHeader) GetReserved() []byte { + if sch == nil { + return nil + } + + return sch.Header.GetReserved() +} + +// GetMetaBlockHashes returns the metaBlock hashes +func (sch *SovereignChainHeader) GetMetaBlockHashes() [][]byte { + if sch == nil { + return nil + } + + return sch.Header.GetMetaBlockHashes() +} + +// GetEpochStartMetaHash returns the epoch start metaBlock hash +func (sch *SovereignChainHeader) GetEpochStartMetaHash() []byte { + if sch == nil { + return nil + } + + return sch.Header.GetEpochStartMetaHash() +} + +// SetNonce sets the header nonce +func (sch *SovereignChainHeader) SetNonce(n uint64) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + return sch.Header.SetNonce(n) +} + +// SetEpoch sets the header epoch +func (sch *SovereignChainHeader) SetEpoch(e uint32) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetEpoch(e) +} + +// SetRound sets the header round +func (sch *SovereignChainHeader) SetRound(r uint64) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetRound(r) +} + +// SetRootHash sets the root hash +func (sch *SovereignChainHeader) SetRootHash(rHash []byte) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetRootHash(rHash) +} + +// SetPrevHash sets the previous hash +func (sch *SovereignChainHeader) SetPrevHash(pvHash []byte) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetPrevHash(pvHash) +} + +// SetPrevRandSeed sets the previous random seed +func (sch *SovereignChainHeader) SetPrevRandSeed(pvRandSeed []byte) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetPrevRandSeed(pvRandSeed) +} + +// SetRandSeed sets the random seed +func (sch *SovereignChainHeader) SetRandSeed(randSeed []byte) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetRandSeed(randSeed) +} + +// SetPubKeysBitmap sets the public key bitmap +func (sch *SovereignChainHeader) SetPubKeysBitmap(pkbm []byte) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetPubKeysBitmap(pkbm) +} + +// SetSignature sets the header signature +func (sch *SovereignChainHeader) SetSignature(sg []byte) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetSignature(sg) +} + +// SetLeaderSignature sets the leader's signature +func (sch *SovereignChainHeader) SetLeaderSignature(sg []byte) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetLeaderSignature(sg) +} + +// SetChainID sets the chain ID on which this block is valid on +func (sch *SovereignChainHeader) SetChainID(chainID []byte) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetChainID(chainID) +} + +// SetSoftwareVersion sets the software version of the header +func (sch *SovereignChainHeader) SetSoftwareVersion(version []byte) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetSoftwareVersion(version) +} + +// SetTimeStamp sets the header timestamp +func (sch *SovereignChainHeader) SetTimeStamp(ts uint64) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetTimeStamp(ts) +} + +// SetAccumulatedFees sets the accumulated fees in the header +func (sch *SovereignChainHeader) SetAccumulatedFees(value *big.Int) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetAccumulatedFees(value) +} + +// SetDeveloperFees sets the developer fees in the header +func (sch *SovereignChainHeader) SetDeveloperFees(value *big.Int) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetDeveloperFees(value) +} + +// SetTxCount sets the transaction count of the block associated with this header +func (sch *SovereignChainHeader) SetTxCount(txCount uint32) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetTxCount(txCount) +} + +// SetShardID sets the shard id +func (sch *SovereignChainHeader) SetShardID(shardID uint32) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetShardID(shardID) +} + +// SetValidatorStatsRootHash sets the root hash for the validator statistics trie +func (sch *SovereignChainHeader) SetValidatorStatsRootHash(rootHash []byte) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + sch.ValidatorStatsRootHash = rootHash + + return nil +} + +// SetExtendedShardHeaderHashes sets the extended shard header hashes +func (sch *SovereignChainHeader) SetExtendedShardHeaderHashes(hdrHashes [][]byte) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + sch.ExtendedShardHeaderHashes = hdrHashes + + return nil +} + +// GetMiniBlockHeadersWithDst returns the miniblocks headers hashes for the destination shard +func (sch *SovereignChainHeader) GetMiniBlockHeadersWithDst(destId uint32) map[string]uint32 { + if sch == nil { + return nil + } + + return sch.Header.GetMiniBlockHeadersWithDst(destId) +} + +// GetOrderedCrossMiniblocksWithDst gets all the cross miniblocks with the given destination shard ID, ordered in a +// chronological way, taking into consideration the round in which they were created/executed in the sender shard +func (sch *SovereignChainHeader) GetOrderedCrossMiniblocksWithDst(destId uint32) []*data.MiniBlockInfo { + if sch == nil { + return nil + } + + return sch.Header.GetOrderedCrossMiniblocksWithDst(destId) +} + +// GetMiniBlockHeadersHashes gets the miniBlock hashes +func (sch *SovereignChainHeader) GetMiniBlockHeadersHashes() [][]byte { + if sch == nil { + return nil + } + + return sch.Header.GetMiniBlockHeadersHashes() +} + +// MapMiniBlockHashesToShards gets the map of miniBlock hashes and sender IDs +func (sch *SovereignChainHeader) MapMiniBlockHashesToShards() map[string]uint32 { + if sch == nil { + return nil + } + + return sch.Header.MapMiniBlockHashesToShards() +} + +// IsInterfaceNil returns true if there is no value under the interface +func (sch *SovereignChainHeader) IsInterfaceNil() bool { + return sch == nil +} + +// IsStartOfEpochBlock returns false for the sovereign chain header +func (sch *SovereignChainHeader) IsStartOfEpochBlock() bool { + if sch == nil { + return false + } + + return sch.IsStartOfEpoch +} + +// GetBlockBodyTypeInt32 returns the blockBody type as int32 +func (sch *SovereignChainHeader) GetBlockBodyTypeInt32() int32 { + if sch == nil { + return -1 + } + + return sch.Header.GetBlockBodyTypeInt32() +} + +// GetMiniBlockHeaderHandlers returns the miniBlock headers as an array of miniBlock header handlers +func (sch *SovereignChainHeader) GetMiniBlockHeaderHandlers() []data.MiniBlockHeaderHandler { + if sch == nil { + return nil + } + + return sch.Header.GetMiniBlockHeaderHandlers() +} + +// SetMiniBlockHeaderHandlers sets the miniBlock headers from the given miniBlock header handlers +func (sch *SovereignChainHeader) SetMiniBlockHeaderHandlers(mbHeaderHandlers []data.MiniBlockHeaderHandler) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetMiniBlockHeaderHandlers(mbHeaderHandlers) +} + +// SetReceiptsHash sets the receipts hash +func (sch *SovereignChainHeader) SetReceiptsHash(hash []byte) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetReceiptsHash(hash) +} + +// SetMetaBlockHashes sets the metaBlock hashes +func (sch *SovereignChainHeader) SetMetaBlockHashes(hashes [][]byte) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetMetaBlockHashes(hashes) +} + +// SetEpochStartMetaHash sets the epoch start metaBlock hash +func (sch *SovereignChainHeader) SetEpochStartMetaHash(hash []byte) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetEpochStartMetaHash(hash) +} + +// HasScheduledSupport returns false for the sovereign chain header +func (sch *SovereignChainHeader) HasScheduledSupport() bool { + return false +} + +// ValidateHeaderVersion does extra validation for the header version +func (sch *SovereignChainHeader) ValidateHeaderVersion() error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return nil +} + +// CheckFieldsForNil checks a predefined set of fields for nil values +func (sch *SovereignChainHeader) CheckFieldsForNil() error { + if sch == nil { + return data.ErrNilPointerReceiver + } + err := sch.Header.CheckFieldsForNil() + if err != nil { + return err + } + + if sch.ValidatorStatsRootHash == nil { + return fmt.Errorf("%w in sch.ValidatorStatsRootHash", data.ErrNilValue) + } + + return nil +} + +// GetOutGoingMiniBlockHeaderHandler returns the outgoing mini block header +func (sch *SovereignChainHeader) GetOutGoingMiniBlockHeaderHandler() data.OutGoingMiniBlockHeaderHandler { + if sch == nil { + return nil + } + + return sch.GetOutGoingMiniBlockHeader() +} + +// SetOutGoingMiniBlockHeaderHandler returns the outgoing mini block header +func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeaderHandler(mbHeader data.OutGoingMiniBlockHeaderHandler) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + if check.IfNil(mbHeader) { + sch.OutGoingMiniBlockHeader = nil + return nil + } + + sch.OutGoingMiniBlockHeader = &OutGoingMiniBlockHeader{ + Hash: mbHeader.GetHash(), + OutGoingOperationsHash: mbHeader.GetOutGoingOperationsHash(), + AggregatedSignatureOutGoingOperations: mbHeader.GetAggregatedSignatureOutGoingOperations(), + LeaderSignatureOutGoingOperations: mbHeader.GetLeaderSignatureOutGoingOperations(), + } + + return nil +} + +// SetBlockBodyTypeInt32 sets the blockBodyType in the header +func (sch *SovereignChainHeader) SetBlockBodyTypeInt32(blockBodyType int32) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return sch.Header.SetBlockBodyTypeInt32(blockBodyType) +} + +// SetStartOfEpochHeader sets the bool flag for epoch start header +func (sch *SovereignChainHeader) SetStartOfEpochHeader() error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + sch.IsStartOfEpoch = true + return nil +} + +// SetDevFeesInEpoch sets the developer fees in the header +func (sch *SovereignChainHeader) SetDevFeesInEpoch(value *big.Int) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + if value == nil { + return data.ErrInvalidValue + } + if sch.DevFeesInEpoch == nil { + sch.DevFeesInEpoch = big.NewInt(0) + } + + sch.DevFeesInEpoch.Set(value) + + return nil +} + +// SetAccumulatedFeesInEpoch sets the epoch accumulated fees in the header +func (sch *SovereignChainHeader) SetAccumulatedFeesInEpoch(value *big.Int) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + if value == nil { + return data.ErrInvalidValue + } + if sch.AccumulatedFeesInEpoch == nil { + sch.AccumulatedFeesInEpoch = big.NewInt(0) + } + + sch.AccumulatedFeesInEpoch.Set(value) + + return nil +} + +// GetEpochStartHandler returns epoch start header handler as for metachain, but with last finalized headers from main chain, if found. +func (sch *SovereignChainHeader) GetEpochStartHandler() data.EpochStartHandler { + if sch == nil { + return nil + } + + return &sch.EpochStart +} + +// GetLastFinalizedCrossChainHeaderHandler returns the last finalized cross chain header data +func (sch *SovereignChainHeader) GetLastFinalizedCrossChainHeaderHandler() data.EpochStartChainDataHandler { + if sch == nil { + return nil + } + + return &sch.EpochStart.LastFinalizedCrossChainHeader +} + +// GetShardInfoHandlers returns empty slice +func (sch *SovereignChainHeader) GetShardInfoHandlers() []data.ShardDataHandler { + if sch == nil { + return nil + } + + return make([]data.ShardDataHandler, 0) +} + +// SetShardInfoHandlers does nothing +func (sch *SovereignChainHeader) SetShardInfoHandlers(_ []data.ShardDataHandler) error { + if sch == nil { + return data.ErrNilPointerReceiver + } + + return nil +} + +// SetHash returns the hash +func (omb *OutGoingMiniBlockHeader) SetHash(hash []byte) error { + if omb == nil { + return data.ErrNilPointerReceiver + } + + omb.Hash = hash + return nil +} + +// SetOutGoingOperationsHash returns the outgoing operations hash +func (omb *OutGoingMiniBlockHeader) SetOutGoingOperationsHash(hash []byte) error { + if omb == nil { + return data.ErrNilPointerReceiver + } + + omb.OutGoingOperationsHash = hash + return nil +} + +// SetLeaderSignatureOutGoingOperations returns the leader signature +func (omb *OutGoingMiniBlockHeader) SetLeaderSignatureOutGoingOperations(sig []byte) error { + if omb == nil { + return data.ErrNilPointerReceiver + } + + omb.LeaderSignatureOutGoingOperations = sig + return nil +} + +// SetAggregatedSignatureOutGoingOperations returns the aggregated signature +func (omb *OutGoingMiniBlockHeader) SetAggregatedSignatureOutGoingOperations(sig []byte) error { + if omb == nil { + return data.ErrNilPointerReceiver + } + + omb.AggregatedSignatureOutGoingOperations = sig + return nil +} + +// IsInterfaceNil checks if the underlying interface is nil +func (omb *OutGoingMiniBlockHeader) IsInterfaceNil() bool { + return omb == nil +} + +// SetShardID sets the epoch start shardID +func (essd *EpochStartCrossChainData) SetShardID(shardID uint32) error { + if essd == nil { + return data.ErrNilPointerReceiver + } + + essd.ShardID = shardID + + return nil +} + +// SetEpoch sets the epoch start epoch +func (essd *EpochStartCrossChainData) SetEpoch(epoch uint32) error { + if essd == nil { + return data.ErrNilPointerReceiver + } + + essd.Epoch = epoch + + return nil +} + +// SetRound sets the epoch start round +func (essd *EpochStartCrossChainData) SetRound(round uint64) error { + if essd == nil { + return data.ErrNilPointerReceiver + } + + essd.Round = round + + return nil +} + +// SetNonce sets the epoch start nonce +func (essd *EpochStartCrossChainData) SetNonce(nonce uint64) error { + if essd == nil { + return data.ErrNilPointerReceiver + } + + essd.Nonce = nonce + + return nil +} + +// SetHeaderHash sets the epoch start header hash +func (essd *EpochStartCrossChainData) SetHeaderHash(hash []byte) error { + if essd == nil { + return data.ErrNilPointerReceiver + } + + essd.HeaderHash = hash + + return nil +} + +// GetRootHash returns nothing +func (essd *EpochStartCrossChainData) GetRootHash() []byte { + return nil +} + +// GetFirstPendingMetaBlock returns nothing +func (essd *EpochStartCrossChainData) GetFirstPendingMetaBlock() []byte { + return nil +} + +// GetLastFinishedMetaBlock returns nothing +func (essd *EpochStartCrossChainData) GetLastFinishedMetaBlock() []byte { + return nil +} + +// GetPendingMiniBlockHeaderHandlers returns empty slice +func (essd *EpochStartCrossChainData) GetPendingMiniBlockHeaderHandlers() []data.MiniBlockHeaderHandler { + return make([]data.MiniBlockHeaderHandler, 0) +} + +// SetRootHash does nothing +func (essd *EpochStartCrossChainData) SetRootHash([]byte) error { + return nil +} + +// SetFirstPendingMetaBlock does nothing +func (essd *EpochStartCrossChainData) SetFirstPendingMetaBlock([]byte) error { + return nil +} + +// SetLastFinishedMetaBlock does nothing +func (essd *EpochStartCrossChainData) SetLastFinishedMetaBlock([]byte) error { + return nil +} + +// SetPendingMiniBlockHeaders does nothing +func (essd *EpochStartCrossChainData) SetPendingMiniBlockHeaders(_ []data.MiniBlockHeaderHandler) error { + return nil +} + +// GetLastFinalizedHeaderHandlers returns last cross main chain finalized header in a slice w.r.t to the interface +func (m *EpochStartSovereign) GetLastFinalizedHeaderHandlers() []data.EpochStartShardDataHandler { + if m == nil { + return nil + } + + epochStartShardData := make([]data.EpochStartShardDataHandler, 0) + if m.LastFinalizedCrossChainHeader.ShardID == core.MainChainShardId { + epochStartShardData = append(epochStartShardData, &m.LastFinalizedCrossChainHeader) + } + + return epochStartShardData +} + +// GetEconomicsHandler returns the economics +func (m *EpochStartSovereign) GetEconomicsHandler() data.EconomicsHandler { + if m == nil { + return nil + } + + return &m.Economics +} + +// SetLastFinalizedHeaders sets epoch start data for main chain chain only +func (m *EpochStartSovereign) SetLastFinalizedHeaders(epochStartShardDataHandlers []data.EpochStartShardDataHandler) error { + if m == nil { + return data.ErrNilPointerReceiver + } + + for _, epochStartShardData := range epochStartShardDataHandlers { + if epochStartShardData.GetShardID() == core.MainChainShardId { + m.LastFinalizedCrossChainHeader = EpochStartCrossChainData{ + ShardID: epochStartShardData.GetShardID(), + Epoch: epochStartShardData.GetEpoch(), + Round: epochStartShardData.GetRound(), + Nonce: epochStartShardData.GetNonce(), + HeaderHash: epochStartShardData.GetHeaderHash(), + } + } + } + + return nil +} + +// SetEconomics sets economics +func (m *EpochStartSovereign) SetEconomics(economicsHandler data.EconomicsHandler) error { + if m == nil { + return data.ErrNilPointerReceiver + } + + ec, ok := economicsHandler.(*Economics) + if !ok { + return data.ErrInvalidTypeAssertion + } + if ec == nil { + return data.ErrNilPointerDereference + } + + m.Economics = *ec + + return nil +} diff --git a/data/block/sovereignChainHeader.pb.go b/data/block/sovereignChainHeader.pb.go new file mode 100644 index 00000000..e282df49 --- /dev/null +++ b/data/block/sovereignChainHeader.pb.go @@ -0,0 +1,1902 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: sovereignChainHeader.proto + +package block + +import ( + bytes "bytes" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + github_com_multiversx_mx_chain_core_go_data "github.com/multiversx/mx-chain-core-go/data" + io "io" + math "math" + math_big "math/big" + math_bits "math/bits" + reflect "reflect" + strings "strings" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// EpochStart holds the block information for end-of-epoch +type EpochStartSovereign struct { + Economics Economics `protobuf:"bytes,1,opt,name=Economics,proto3" json:"economics"` + LastFinalizedCrossChainHeader EpochStartCrossChainData `protobuf:"bytes,2,opt,name=LastFinalizedCrossChainHeader,proto3" json:"lastFinalizedCrossChainHeader"` +} + +func (m *EpochStartSovereign) Reset() { *m = EpochStartSovereign{} } +func (*EpochStartSovereign) ProtoMessage() {} +func (*EpochStartSovereign) Descriptor() ([]byte, []int) { + return fileDescriptor_b9b8ff297a820152, []int{0} +} +func (m *EpochStartSovereign) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EpochStartSovereign) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *EpochStartSovereign) XXX_Merge(src proto.Message) { + xxx_messageInfo_EpochStartSovereign.Merge(m, src) +} +func (m *EpochStartSovereign) XXX_Size() int { + return m.Size() +} +func (m *EpochStartSovereign) XXX_DiscardUnknown() { + xxx_messageInfo_EpochStartSovereign.DiscardUnknown(m) +} + +var xxx_messageInfo_EpochStartSovereign proto.InternalMessageInfo + +func (m *EpochStartSovereign) GetEconomics() Economics { + if m != nil { + return m.Economics + } + return Economics{} +} + +func (m *EpochStartSovereign) GetLastFinalizedCrossChainHeader() EpochStartCrossChainData { + if m != nil { + return m.LastFinalizedCrossChainHeader + } + return EpochStartCrossChainData{} +} + +// EpochStartShardData hold the last finalized headers hash and state root hash +type EpochStartCrossChainData struct { + ShardID uint32 `protobuf:"varint,1,opt,name=ShardID,proto3" json:"shardID"` + Epoch uint32 `protobuf:"varint,9,opt,name=Epoch,proto3" json:"epoch"` + Round uint64 `protobuf:"varint,7,opt,name=Round,proto3" json:"round"` + Nonce uint64 `protobuf:"varint,8,opt,name=Nonce,proto3" json:"nonce"` + HeaderHash []byte `protobuf:"bytes,2,opt,name=HeaderHash,proto3" json:"headerHash,omitempty"` +} + +func (m *EpochStartCrossChainData) Reset() { *m = EpochStartCrossChainData{} } +func (*EpochStartCrossChainData) ProtoMessage() {} +func (*EpochStartCrossChainData) Descriptor() ([]byte, []int) { + return fileDescriptor_b9b8ff297a820152, []int{1} +} +func (m *EpochStartCrossChainData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EpochStartCrossChainData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *EpochStartCrossChainData) XXX_Merge(src proto.Message) { + xxx_messageInfo_EpochStartCrossChainData.Merge(m, src) +} +func (m *EpochStartCrossChainData) XXX_Size() int { + return m.Size() +} +func (m *EpochStartCrossChainData) XXX_DiscardUnknown() { + xxx_messageInfo_EpochStartCrossChainData.DiscardUnknown(m) +} + +var xxx_messageInfo_EpochStartCrossChainData proto.InternalMessageInfo + +func (m *EpochStartCrossChainData) GetShardID() uint32 { + if m != nil { + return m.ShardID + } + return 0 +} + +func (m *EpochStartCrossChainData) GetEpoch() uint32 { + if m != nil { + return m.Epoch + } + return 0 +} + +func (m *EpochStartCrossChainData) GetRound() uint64 { + if m != nil { + return m.Round + } + return 0 +} + +func (m *EpochStartCrossChainData) GetNonce() uint64 { + if m != nil { + return m.Nonce + } + return 0 +} + +func (m *EpochStartCrossChainData) GetHeaderHash() []byte { + if m != nil { + return m.HeaderHash + } + return nil +} + +// 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"` +} + +func (m *SovereignChainHeader) Reset() { *m = SovereignChainHeader{} } +func (*SovereignChainHeader) ProtoMessage() {} +func (*SovereignChainHeader) Descriptor() ([]byte, []int) { + return fileDescriptor_b9b8ff297a820152, []int{2} +} +func (m *SovereignChainHeader) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SovereignChainHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *SovereignChainHeader) XXX_Merge(src proto.Message) { + xxx_messageInfo_SovereignChainHeader.Merge(m, src) +} +func (m *SovereignChainHeader) XXX_Size() int { + return m.Size() +} +func (m *SovereignChainHeader) XXX_DiscardUnknown() { + xxx_messageInfo_SovereignChainHeader.DiscardUnknown(m) +} + +var xxx_messageInfo_SovereignChainHeader proto.InternalMessageInfo + +func (m *SovereignChainHeader) GetHeader() *Header { + if m != nil { + return m.Header + } + return nil +} + +func (m *SovereignChainHeader) GetValidatorStatsRootHash() []byte { + if m != nil { + return m.ValidatorStatsRootHash + } + return nil +} + +func (m *SovereignChainHeader) GetExtendedShardHeaderHashes() [][]byte { + if m != nil { + return m.ExtendedShardHeaderHashes + } + return nil +} + +func (m *SovereignChainHeader) GetOutGoingMiniBlockHeader() *OutGoingMiniBlockHeader { + if m != nil { + return m.OutGoingMiniBlockHeader + } + return nil +} + +func (m *SovereignChainHeader) GetIsStartOfEpoch() bool { + if m != nil { + return m.IsStartOfEpoch + } + return false +} + +func (m *SovereignChainHeader) GetAccumulatedFeesInEpoch() *math_big.Int { + if m != nil { + return m.AccumulatedFeesInEpoch + } + return nil +} + +func (m *SovereignChainHeader) GetDevFeesInEpoch() *math_big.Int { + if m != nil { + return m.DevFeesInEpoch + } + return nil +} + +func (m *SovereignChainHeader) GetEpochStart() EpochStartSovereign { + if m != nil { + return m.EpochStart + } + return 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"` +} + +func (m *OutGoingMiniBlockHeader) Reset() { *m = OutGoingMiniBlockHeader{} } +func (*OutGoingMiniBlockHeader) ProtoMessage() {} +func (*OutGoingMiniBlockHeader) Descriptor() ([]byte, []int) { + return fileDescriptor_b9b8ff297a820152, []int{3} +} +func (m *OutGoingMiniBlockHeader) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OutGoingMiniBlockHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *OutGoingMiniBlockHeader) XXX_Merge(src proto.Message) { + xxx_messageInfo_OutGoingMiniBlockHeader.Merge(m, src) +} +func (m *OutGoingMiniBlockHeader) XXX_Size() int { + return m.Size() +} +func (m *OutGoingMiniBlockHeader) XXX_DiscardUnknown() { + xxx_messageInfo_OutGoingMiniBlockHeader.DiscardUnknown(m) +} + +var xxx_messageInfo_OutGoingMiniBlockHeader proto.InternalMessageInfo + +func (m *OutGoingMiniBlockHeader) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + +func (m *OutGoingMiniBlockHeader) GetOutGoingOperationsHash() []byte { + if m != nil { + return m.OutGoingOperationsHash + } + return nil +} + +func (m *OutGoingMiniBlockHeader) GetAggregatedSignatureOutGoingOperations() []byte { + if m != nil { + return m.AggregatedSignatureOutGoingOperations + } + return nil +} + +func (m *OutGoingMiniBlockHeader) GetLeaderSignatureOutGoingOperations() []byte { + if m != nil { + return m.LeaderSignatureOutGoingOperations + } + return nil +} + +func init() { + proto.RegisterType((*EpochStartSovereign)(nil), "proto.EpochStartSovereign") + proto.RegisterType((*EpochStartCrossChainData)(nil), "proto.EpochStartCrossChainData") + proto.RegisterType((*SovereignChainHeader)(nil), "proto.SovereignChainHeader") + proto.RegisterType((*OutGoingMiniBlockHeader)(nil), "proto.OutGoingMiniBlockHeader") +} + +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, 0x02, 0xf8, 0xce, 0x78, 0xc9, 0x0d, 0x7b, 0x26, 0x88, 0x27, 0x66, + 0x9b, 0xe0, 0xe8, 0x04, 0x36, 0xc6, 0x06, 0x77, 0xb9, 0xc3, 0x0c, 0x5f, 0x01, 0x1d, 0xd0, 0x6b, + 0xde, 0x7b, 0x2b, 0x75, 0x19, 0x6c, 0x71, 0xed, 0xed, 0x67, 0x21, 0xae, 0xc4, 0x21, 0x6e, 0xd0, + 0x0d, 0xa4, 0xe7, 0x5e, 0xe8, 0x37, 0x00, 0xef, 0x3e, 0x22, 0xbe, 0x78, 0xc0, 0x5c, 0xb2, 0x60, + 0x4f, 0xa8, 0x79, 0xea, 0x71, 0xdf, 0x2f, 0x94, 0xa5, 0xbc, 0x21, 0x75, 0xf1, 0x46, 0x77, 0x9b, + 0x46, 0x4e, 0x1c, 0x11, 0x41, 0xb4, 0xe3, 0x2c, 0xcc, 0xdd, 0xc5, 0x4d, 0x6a, 0xfa, 0xcd, 0xc1, + 0xba, 0x21, 0x80, 0x4a, 0x59, 0x08, 0x74, 0x0c, 0xeb, 0x33, 0x9b, 0x78, 0xe6, 0x64, 0x24, 0x8b, + 0xbd, 0xa3, 0x35, 0xe3, 0x10, 0xd7, 0xfd, 0x14, 0xd2, 0x37, 0x36, 0x84, 0x61, 0x55, 0x4a, 0x28, + 0x0d, 0x49, 0x6a, 0xc4, 0x21, 0xae, 0xd2, 0x04, 0xd0, 0x53, 0x3c, 0x21, 0xe8, 0x3c, 0x70, 0x4d, + 0xa5, 0xde, 0x01, 0xbd, 0xfd, 0x94, 0xe0, 0x25, 0x80, 0x9e, 0xe2, 0x09, 0xe1, 0x1b, 0xee, 0x1a, + 0x54, 0xb9, 0x95, 0x13, 0xdc, 0x04, 0xd0, 0x53, 0x1c, 0x7d, 0x0e, 0x61, 0x9a, 0xf0, 0x43, 0xe2, + 0xdb, 0xb2, 0x43, 0xb7, 0x35, 0x25, 0x0e, 0xf1, 0xa1, 0xbd, 0x45, 0x3f, 0xe5, 0x0e, 0x13, 0xd4, + 0x59, 0x8a, 0x9f, 0xf4, 0x02, 0xb7, 0xbb, 0xae, 0xc1, 0xc3, 0xd9, 0x8e, 0xe9, 0x41, 0x9f, 0xc1, + 0x5a, 0xd6, 0xf0, 0xf4, 0x22, 0xef, 0x64, 0x0d, 0x4f, 0x41, 0x0d, 0xc6, 0x21, 0xae, 0xa5, 0xea, + 0x7a, 0x46, 0x44, 0x3a, 0x6c, 0x7d, 0x4b, 0x16, 0xcc, 0x24, 0x82, 0x7b, 0x33, 0x41, 0x84, 0xaf, + 0x73, 0x2e, 0x0a, 0x19, 0xb5, 0xe3, 0x10, 0xb7, 0x56, 0x3b, 0x19, 0x7a, 0x89, 0x27, 0xa2, 0xf0, + 0xbd, 0xf1, 0x99, 0xa0, 0xae, 0x49, 0x4d, 0xd9, 0xcf, 0x3c, 0x75, 0xea, 0x2b, 0x7b, 0x9d, 0xbd, + 0xde, 0x6d, 0xed, 0xe3, 0x38, 0xc4, 0x1f, 0xd0, 0x32, 0x52, 0xa1, 0xee, 0x72, 0x25, 0xf4, 0x04, + 0xbe, 0x3b, 0x0d, 0xc4, 0x57, 0x9c, 0xb9, 0xd6, 0xd7, 0xcc, 0x65, 0x72, 0xd8, 0xb3, 0xf2, 0xf7, + 0x65, 0xf9, 0x6a, 0x56, 0x7e, 0x09, 0x4b, 0xeb, 0xc4, 0x21, 0x3e, 0xe2, 0x99, 0x71, 0xba, 0xa4, + 0x1e, 0x11, 0x8c, 0xbb, 0xc5, 0xe8, 0x65, 0x01, 0xd0, 0x08, 0x1e, 0x4c, 0x7c, 0x39, 0x5f, 0xd3, + 0xc7, 0xe9, 0xa0, 0x54, 0x3b, 0xa0, 0x77, 0x4b, 0x3b, 0x8a, 0x43, 0xac, 0xb0, 0x2b, 0x96, 0x82, + 0xdc, 0x0b, 0x3e, 0xe8, 0x4f, 0x00, 0x5b, 0x27, 0x86, 0x11, 0x38, 0xc1, 0x82, 0x08, 0x6a, 0x3e, + 0xa0, 0xd4, 0x9f, 0xb8, 0xa9, 0x5c, 0x4d, 0x76, 0xdf, 0x89, 0x43, 0xdc, 0x21, 0x3b, 0x19, 0xb9, + 0xec, 0xd3, 0xbf, 0xf1, 0xd8, 0x21, 0xc2, 0x1e, 0xce, 0x99, 0x35, 0x98, 0xb8, 0xe2, 0x8b, 0xc2, + 0xb3, 0xe1, 0x04, 0x0b, 0xc1, 0x56, 0xd4, 0xf3, 0xcf, 0x86, 0xce, 0x59, 0xdf, 0x48, 0x66, 0xa5, + 0x6f, 0x70, 0x8f, 0xf6, 0x2d, 0x3e, 0x34, 0x89, 0x20, 0x03, 0x8d, 0x59, 0x13, 0x57, 0x9c, 0x12, + 0x5f, 0x50, 0x4f, 0x2f, 0x49, 0x06, 0xfd, 0x0e, 0xe0, 0xc1, 0x88, 0xae, 0x8a, 0xf9, 0xd5, 0x65, + 0x7e, 0x34, 0x29, 0xd7, 0xbc, 0x62, 0x79, 0x1d, 0x79, 0xbd, 0x10, 0x1c, 0x7d, 0x07, 0x61, 0xbe, + 0xe0, 0x72, 0xc1, 0x9a, 0xf7, 0xda, 0xd7, 0x1e, 0x97, 0xed, 0x8a, 0x68, 0x47, 0xd9, 0xbb, 0x72, + 0x48, 0xb7, 0xc6, 0xe2, 0x6a, 0xe5, 0x2e, 0xdd, 0xa7, 0x7b, 0xa5, 0x43, 0x85, 0x3e, 0x82, 0xfb, + 0x72, 0x31, 0x80, 0x2c, 0x1d, 0xc5, 0x21, 0x3e, 0xb0, 0xaf, 0x2e, 0xa9, 0xb4, 0xa3, 0x1f, 0x60, + 0x6b, 0x7a, 0x6d, 0xa8, 0x0a, 0x2b, 0xf5, 0x61, 0x72, 0xa9, 0x7c, 0x27, 0xa3, 0xa0, 0x55, 0xa2, + 0x81, 0x7e, 0x05, 0xf0, 0xf8, 0xc4, 0xb2, 0x3c, 0x6a, 0x25, 0xb7, 0x34, 0x63, 0x96, 0x4b, 0x44, + 0xe0, 0xd1, 0xeb, 0x6c, 0x65, 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, +} + +func (this *EpochStartSovereign) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*EpochStartSovereign) + if !ok { + that2, ok := that.(EpochStartSovereign) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Economics.Equal(&that1.Economics) { + return false + } + if !this.LastFinalizedCrossChainHeader.Equal(&that1.LastFinalizedCrossChainHeader) { + return false + } + return true +} +func (this *EpochStartCrossChainData) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*EpochStartCrossChainData) + if !ok { + that2, ok := that.(EpochStartCrossChainData) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ShardID != that1.ShardID { + return false + } + if this.Epoch != that1.Epoch { + return false + } + if this.Round != that1.Round { + return false + } + if this.Nonce != that1.Nonce { + return false + } + if !bytes.Equal(this.HeaderHash, that1.HeaderHash) { + return false + } + return true +} +func (this *SovereignChainHeader) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*SovereignChainHeader) + if !ok { + that2, ok := that.(SovereignChainHeader) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Header.Equal(that1.Header) { + return false + } + if !bytes.Equal(this.ValidatorStatsRootHash, that1.ValidatorStatsRootHash) { + return false + } + if len(this.ExtendedShardHeaderHashes) != len(that1.ExtendedShardHeaderHashes) { + return false + } + for i := range this.ExtendedShardHeaderHashes { + if !bytes.Equal(this.ExtendedShardHeaderHashes[i], that1.ExtendedShardHeaderHashes[i]) { + return false + } + } + if !this.OutGoingMiniBlockHeader.Equal(that1.OutGoingMiniBlockHeader) { + return false + } + if this.IsStartOfEpoch != that1.IsStartOfEpoch { + return false + } + { + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} + if !__caster.Equal(this.AccumulatedFeesInEpoch, that1.AccumulatedFeesInEpoch) { + return false + } + } + { + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} + if !__caster.Equal(this.DevFeesInEpoch, that1.DevFeesInEpoch) { + return false + } + } + if !this.EpochStart.Equal(&that1.EpochStart) { + return false + } + return true +} +func (this *OutGoingMiniBlockHeader) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*OutGoingMiniBlockHeader) + if !ok { + that2, ok := that.(OutGoingMiniBlockHeader) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !bytes.Equal(this.Hash, that1.Hash) { + return false + } + if !bytes.Equal(this.OutGoingOperationsHash, that1.OutGoingOperationsHash) { + return false + } + if !bytes.Equal(this.AggregatedSignatureOutGoingOperations, that1.AggregatedSignatureOutGoingOperations) { + return false + } + if !bytes.Equal(this.LeaderSignatureOutGoingOperations, that1.LeaderSignatureOutGoingOperations) { + return false + } + return true +} +func (this *EpochStartSovereign) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&block.EpochStartSovereign{") + s = append(s, "Economics: "+strings.Replace(this.Economics.GoString(), `&`, ``, 1)+",\n") + s = append(s, "LastFinalizedCrossChainHeader: "+strings.Replace(this.LastFinalizedCrossChainHeader.GoString(), `&`, ``, 1)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *EpochStartCrossChainData) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 9) + s = append(s, "&block.EpochStartCrossChainData{") + s = append(s, "ShardID: "+fmt.Sprintf("%#v", this.ShardID)+",\n") + s = append(s, "Epoch: "+fmt.Sprintf("%#v", this.Epoch)+",\n") + s = append(s, "Round: "+fmt.Sprintf("%#v", this.Round)+",\n") + s = append(s, "Nonce: "+fmt.Sprintf("%#v", this.Nonce)+",\n") + s = append(s, "HeaderHash: "+fmt.Sprintf("%#v", this.HeaderHash)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *SovereignChainHeader) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 12) + s = append(s, "&block.SovereignChainHeader{") + if this.Header != nil { + s = append(s, "Header: "+fmt.Sprintf("%#v", this.Header)+",\n") + } + 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") + } + s = append(s, "IsStartOfEpoch: "+fmt.Sprintf("%#v", this.IsStartOfEpoch)+",\n") + s = append(s, "AccumulatedFeesInEpoch: "+fmt.Sprintf("%#v", this.AccumulatedFeesInEpoch)+",\n") + s = append(s, "DevFeesInEpoch: "+fmt.Sprintf("%#v", this.DevFeesInEpoch)+",\n") + s = append(s, "EpochStart: "+strings.Replace(this.EpochStart.GoString(), `&`, ``, 1)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *OutGoingMiniBlockHeader) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 8) + 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, "}") + return strings.Join(s, "") +} +func valueToGoStringSovereignChainHeader(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *EpochStartSovereign) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EpochStartSovereign) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EpochStartSovereign) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.LastFinalizedCrossChainHeader.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Economics.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *EpochStartCrossChainData) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EpochStartCrossChainData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EpochStartCrossChainData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Epoch != 0 { + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(m.Epoch)) + i-- + dAtA[i] = 0x48 + } + if m.Nonce != 0 { + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(m.Nonce)) + i-- + dAtA[i] = 0x40 + } + if m.Round != 0 { + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(m.Round)) + i-- + dAtA[i] = 0x38 + } + if len(m.HeaderHash) > 0 { + i -= len(m.HeaderHash) + copy(dAtA[i:], m.HeaderHash) + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(len(m.HeaderHash))) + i-- + dAtA[i] = 0x12 + } + if m.ShardID != 0 { + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(m.ShardID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *SovereignChainHeader) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SovereignChainHeader) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SovereignChainHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.EpochStart.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + { + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} + size := __caster.Size(m.DevFeesInEpoch) + i -= size + if _, err := __caster.MarshalTo(m.DevFeesInEpoch, dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + { + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} + size := __caster.Size(m.AccumulatedFeesInEpoch) + i -= size + if _, err := __caster.MarshalTo(m.AccumulatedFeesInEpoch, dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + if m.IsStartOfEpoch { + i-- + if m.IsStartOfEpoch { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } + if m.OutGoingMiniBlockHeader != nil { + { + size, err := m.OutGoingMiniBlockHeader.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if len(m.ExtendedShardHeaderHashes) > 0 { + for iNdEx := len(m.ExtendedShardHeaderHashes) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ExtendedShardHeaderHashes[iNdEx]) + copy(dAtA[i:], m.ExtendedShardHeaderHashes[iNdEx]) + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(len(m.ExtendedShardHeaderHashes[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.ValidatorStatsRootHash) > 0 { + i -= len(m.ValidatorStatsRootHash) + copy(dAtA[i:], m.ValidatorStatsRootHash) + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(len(m.ValidatorStatsRootHash))) + i-- + dAtA[i] = 0x12 + } + if m.Header != nil { + { + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSovereignChainHeader(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OutGoingMiniBlockHeader) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OutGoingMiniBlockHeader) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OutGoingMiniBlockHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + 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 + } + 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 + } + 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 + } + 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 + } + return len(dAtA) - i, nil +} + +func encodeVarintSovereignChainHeader(dAtA []byte, offset int, v uint64) int { + offset -= sovSovereignChainHeader(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *EpochStartSovereign) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Economics.Size() + n += 1 + l + sovSovereignChainHeader(uint64(l)) + l = m.LastFinalizedCrossChainHeader.Size() + n += 1 + l + sovSovereignChainHeader(uint64(l)) + return n +} + +func (m *EpochStartCrossChainData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ShardID != 0 { + n += 1 + sovSovereignChainHeader(uint64(m.ShardID)) + } + l = len(m.HeaderHash) + if l > 0 { + n += 1 + l + sovSovereignChainHeader(uint64(l)) + } + if m.Round != 0 { + n += 1 + sovSovereignChainHeader(uint64(m.Round)) + } + if m.Nonce != 0 { + n += 1 + sovSovereignChainHeader(uint64(m.Nonce)) + } + if m.Epoch != 0 { + n += 1 + sovSovereignChainHeader(uint64(m.Epoch)) + } + return n +} + +func (m *SovereignChainHeader) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Header != nil { + l = m.Header.Size() + n += 1 + l + sovSovereignChainHeader(uint64(l)) + } + l = len(m.ValidatorStatsRootHash) + if l > 0 { + n += 1 + l + sovSovereignChainHeader(uint64(l)) + } + if len(m.ExtendedShardHeaderHashes) > 0 { + for _, b := range m.ExtendedShardHeaderHashes { + l = len(b) + n += 1 + l + sovSovereignChainHeader(uint64(l)) + } + } + if m.OutGoingMiniBlockHeader != nil { + l = m.OutGoingMiniBlockHeader.Size() + n += 1 + l + sovSovereignChainHeader(uint64(l)) + } + if m.IsStartOfEpoch { + n += 2 + } + { + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} + l = __caster.Size(m.AccumulatedFeesInEpoch) + n += 1 + l + sovSovereignChainHeader(uint64(l)) + } + { + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} + l = __caster.Size(m.DevFeesInEpoch) + n += 1 + l + sovSovereignChainHeader(uint64(l)) + } + l = m.EpochStart.Size() + n += 1 + l + sovSovereignChainHeader(uint64(l)) + return n +} + +func (m *OutGoingMiniBlockHeader) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovSovereignChainHeader(uint64(l)) + } + l = len(m.OutGoingOperationsHash) + if l > 0 { + n += 1 + l + sovSovereignChainHeader(uint64(l)) + } + l = len(m.AggregatedSignatureOutGoingOperations) + if l > 0 { + n += 1 + l + sovSovereignChainHeader(uint64(l)) + } + l = len(m.LeaderSignatureOutGoingOperations) + if l > 0 { + n += 1 + l + sovSovereignChainHeader(uint64(l)) + } + return n +} + +func sovSovereignChainHeader(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozSovereignChainHeader(x uint64) (n int) { + return sovSovereignChainHeader(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *EpochStartSovereign) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&EpochStartSovereign{`, + `Economics:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Economics), "Economics", "Economics", 1), `&`, ``, 1) + `,`, + `LastFinalizedCrossChainHeader:` + strings.Replace(strings.Replace(this.LastFinalizedCrossChainHeader.String(), "EpochStartCrossChainData", "EpochStartCrossChainData", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} +func (this *EpochStartCrossChainData) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&EpochStartCrossChainData{`, + `ShardID:` + fmt.Sprintf("%v", this.ShardID) + `,`, + `HeaderHash:` + fmt.Sprintf("%v", this.HeaderHash) + `,`, + `Round:` + fmt.Sprintf("%v", this.Round) + `,`, + `Nonce:` + fmt.Sprintf("%v", this.Nonce) + `,`, + `Epoch:` + fmt.Sprintf("%v", this.Epoch) + `,`, + `}`, + }, "") + return s +} +func (this *SovereignChainHeader) String() string { + if this == nil { + return "nil" + } + 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) + `,`, + `IsStartOfEpoch:` + fmt.Sprintf("%v", this.IsStartOfEpoch) + `,`, + `AccumulatedFeesInEpoch:` + fmt.Sprintf("%v", this.AccumulatedFeesInEpoch) + `,`, + `DevFeesInEpoch:` + fmt.Sprintf("%v", this.DevFeesInEpoch) + `,`, + `EpochStart:` + strings.Replace(strings.Replace(this.EpochStart.String(), "EpochStartSovereign", "EpochStartSovereign", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} +func (this *OutGoingMiniBlockHeader) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&OutGoingMiniBlockHeader{`, + `Hash:` + fmt.Sprintf("%v", this.Hash) + `,`, + `OutGoingOperationsHash:` + fmt.Sprintf("%v", this.OutGoingOperationsHash) + `,`, + `AggregatedSignatureOutGoingOperations:` + fmt.Sprintf("%v", this.AggregatedSignatureOutGoingOperations) + `,`, + `LeaderSignatureOutGoingOperations:` + fmt.Sprintf("%v", this.LeaderSignatureOutGoingOperations) + `,`, + `}`, + }, "") + return s +} +func valueToStringSovereignChainHeader(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *EpochStartSovereign) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EpochStartSovereign: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EpochStartSovereign: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Economics", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSovereignChainHeader + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Economics.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastFinalizedCrossChainHeader", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSovereignChainHeader + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.LastFinalizedCrossChainHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSovereignChainHeader(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EpochStartCrossChainData) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EpochStartCrossChainData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EpochStartCrossChainData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ShardID", wireType) + } + m.ShardID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ShardID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HeaderHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSovereignChainHeader + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.HeaderHash = append(m.HeaderHash[:0], dAtA[iNdEx:postIndex]...) + if m.HeaderHash == nil { + m.HeaderHash = []byte{} + } + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Round", wireType) + } + m.Round = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Round |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) + } + m.Nonce = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Nonce |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Epoch", wireType) + } + m.Epoch = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Epoch |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSovereignChainHeader(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SovereignChainHeader) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SovereignChainHeader: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SovereignChainHeader: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSovereignChainHeader + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Header == nil { + m.Header = &Header{} + } + if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorStatsRootHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSovereignChainHeader + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorStatsRootHash = append(m.ValidatorStatsRootHash[:0], dAtA[iNdEx:postIndex]...) + if m.ValidatorStatsRootHash == nil { + m.ValidatorStatsRootHash = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExtendedShardHeaderHashes", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSovereignChainHeader + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExtendedShardHeaderHashes = append(m.ExtendedShardHeaderHashes, make([]byte, postIndex-iNdEx)) + copy(m.ExtendedShardHeaderHashes[len(m.ExtendedShardHeaderHashes)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OutGoingMiniBlockHeader", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSovereignChainHeader + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.OutGoingMiniBlockHeader == nil { + m.OutGoingMiniBlockHeader = &OutGoingMiniBlockHeader{} + } + if err := m.OutGoingMiniBlockHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsStartOfEpoch", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsStartOfEpoch = bool(v != 0) + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AccumulatedFeesInEpoch", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSovereignChainHeader + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + { + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} + if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } else { + m.AccumulatedFeesInEpoch = tmp + } + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DevFeesInEpoch", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSovereignChainHeader + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + { + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} + if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } else { + m.DevFeesInEpoch = tmp + } + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochStart", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSovereignChainHeader + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.EpochStart.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSovereignChainHeader(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OutGoingMiniBlockHeader) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OutGoingMiniBlockHeader: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OutGoingMiniBlockHeader: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSovereignChainHeader + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) + if m.Hash == nil { + m.Hash = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OutGoingOperationsHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSovereignChainHeader + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OutGoingOperationsHash = append(m.OutGoingOperationsHash[:0], dAtA[iNdEx:postIndex]...) + if m.OutGoingOperationsHash == nil { + m.OutGoingOperationsHash = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AggregatedSignatureOutGoingOperations", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSovereignChainHeader + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AggregatedSignatureOutGoingOperations = append(m.AggregatedSignatureOutGoingOperations[:0], dAtA[iNdEx:postIndex]...) + if m.AggregatedSignatureOutGoingOperations == nil { + m.AggregatedSignatureOutGoingOperations = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LeaderSignatureOutGoingOperations", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSovereignChainHeader + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LeaderSignatureOutGoingOperations = append(m.LeaderSignatureOutGoingOperations[:0], dAtA[iNdEx:postIndex]...) + if m.LeaderSignatureOutGoingOperations == nil { + m.LeaderSignatureOutGoingOperations = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSovereignChainHeader(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthSovereignChainHeader + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipSovereignChainHeader(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSovereignChainHeader + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthSovereignChainHeader + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupSovereignChainHeader + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthSovereignChainHeader + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthSovereignChainHeader = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowSovereignChainHeader = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupSovereignChainHeader = fmt.Errorf("proto: unexpected end of group") +) diff --git a/data/block/sovereignChainHeader.proto b/data/block/sovereignChainHeader.proto new file mode 100644 index 00000000..ad63cf56 --- /dev/null +++ b/data/block/sovereignChainHeader.proto @@ -0,0 +1,45 @@ +// This file holds the data structures related with the functionality of a sovereign chain header +syntax = "proto3"; + +package proto; + +option go_package = "block"; +option (gogoproto.stable_marshaler_all) = true; + +import "github.com/gogo/protobuf/gogoproto/gogo.proto"; +import "block.proto"; +import "metaBlock.proto"; + +// EpochStart holds the block information for end-of-epoch +message EpochStartSovereign { + Economics Economics = 1 [(gogoproto.jsontag) = "economics", (gogoproto.nullable) = false]; + EpochStartCrossChainData LastFinalizedCrossChainHeader = 2 [(gogoproto.jsontag) = "lastFinalizedCrossChainHeader", (gogoproto.nullable) = false]; +} + +// EpochStartShardData hold the last finalized headers hash and state root hash +message EpochStartCrossChainData { + uint32 ShardID = 1 [(gogoproto.jsontag) = "shardID"]; + uint32 Epoch = 9 [(gogoproto.jsontag) = "epoch"]; + uint64 Round = 7 [(gogoproto.jsontag) = "round"]; + uint64 Nonce = 8 [(gogoproto.jsontag) = "nonce"]; + bytes HeaderHash = 2 [(gogoproto.jsontag) = "headerHash,omitempty"]; +} + +// 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]; +} + +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"]; +} diff --git a/data/block/sovereignChainHeader_test.go b/data/block/sovereignChainHeader_test.go new file mode 100644 index 00000000..fa6535c2 --- /dev/null +++ b/data/block/sovereignChainHeader_test.go @@ -0,0 +1,67 @@ +package block + +import ( + "math/big" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/data" +) + +func TestSovereignChainHeader_GetEpochStartHandler(t *testing.T) { + t.Parallel() + + economics := Economics{ + NodePrice: big.NewInt(100), + } + epochStartData := EpochStartCrossChainData{ + Round: 4, + } + epochStartSov := EpochStartSovereign{ + Economics: economics, + LastFinalizedCrossChainHeader: epochStartData, + } + sovHdr := &SovereignChainHeader{ + EpochStart: epochStartSov, + } + + require.Equal(t, &epochStartSov, sovHdr.GetEpochStartHandler()) + require.Equal(t, &economics, sovHdr.GetEpochStartHandler().GetEconomicsHandler()) + require.Empty(t, sovHdr.GetEpochStartHandler().GetLastFinalizedHeaderHandlers()) + + epochStartData.ShardID = 8 + err := sovHdr.GetEpochStartHandler().SetLastFinalizedHeaders([]data.EpochStartShardDataHandler{&epochStartData}) + require.Nil(t, err) + require.Empty(t, sovHdr.GetEpochStartHandler().GetLastFinalizedHeaderHandlers()) + + epochStartData.ShardID = core.MainChainShardId + epochStartSov.LastFinalizedCrossChainHeader = epochStartData + err = sovHdr.GetEpochStartHandler().SetLastFinalizedHeaders([]data.EpochStartShardDataHandler{&epochStartData}) + require.Nil(t, err) + + require.Equal(t, []data.EpochStartShardDataHandler{&epochStartData}, sovHdr.GetEpochStartHandler().GetLastFinalizedHeaderHandlers()) + require.Equal(t, &epochStartSov, sovHdr.GetEpochStartHandler()) +} + +func TestSovereignChainHeader_GetEconomicsHandler(t *testing.T) { + t.Parallel() + + economics := Economics{ + NodePrice: big.NewInt(100), + } + sovHdr := &SovereignChainHeader{ + EpochStart: EpochStartSovereign{ + Economics: economics, + }, + } + require.Equal(t, &economics, sovHdr.GetEpochStartHandler().GetEconomicsHandler()) + + economics2 := Economics{ + NodePrice: big.NewInt(200), + } + err := sovHdr.GetEpochStartHandler().SetEconomics(&economics2) + require.Nil(t, err) + require.Equal(t, &economics2, sovHdr.GetEpochStartHandler().GetEconomicsHandler()) +} diff --git a/data/block/trigger.go b/data/block/trigger.go index c8b511e3..6d091e1e 100644 --- a/data/block/trigger.go +++ b/data/block/trigger.go @@ -191,3 +191,21 @@ func (strV2 *ShardTriggerRegistryV2) SetEpochStartHeaderHandler(epochStartHeader } return nil } + +// GetEpochStartHeaderHandler returns the epoch start header handler +func (m *MetaTriggerRegistry) GetEpochStartHeaderHandler() data.HeaderHandler { + if m == nil { + return nil + } + + return m.EpochStartMeta +} + +// GetEpochStartHeaderHandler returns the epoch start header handler +func (m *SovereignShardTriggerRegistry) GetEpochStartHeaderHandler() data.HeaderHandler { + if m == nil { + return nil + } + + return m.SovereignChainHeader +} diff --git a/data/block/trigger.pb.go b/data/block/trigger.pb.go index 3db9b331..6defb93c 100644 --- a/data/block/trigger.pb.go +++ b/data/block/trigger.pb.go @@ -319,50 +319,141 @@ func (m *MetaTriggerRegistry) GetEpochStartMeta() *MetaBlock { return nil } +type SovereignShardTriggerRegistry struct { + Epoch uint32 `protobuf:"varint,1,opt,name=Epoch,proto3" json:"Epoch,omitempty"` + CurrentRound uint64 `protobuf:"varint,2,opt,name=CurrentRound,proto3" json:"CurrentRound,omitempty"` + EpochFinalityAttestingRound uint64 `protobuf:"varint,3,opt,name=EpochFinalityAttestingRound,proto3" json:"EpochFinalityAttestingRound,omitempty"` + CurrEpochStartRound uint64 `protobuf:"varint,4,opt,name=CurrEpochStartRound,proto3" json:"CurrEpochStartRound,omitempty"` + PrevEpochStartRound uint64 `protobuf:"varint,5,opt,name=PrevEpochStartRound,proto3" json:"PrevEpochStartRound,omitempty"` + EpochStartMetaHash []byte `protobuf:"bytes,6,opt,name=EpochStartMetaHash,proto3" json:"EpochStartMetaHash,omitempty"` + SovereignChainHeader *SovereignChainHeader `protobuf:"bytes,7,opt,name=SovereignChainHeader,proto3" json:"SovereignChainHeader,omitempty"` +} + +func (m *SovereignShardTriggerRegistry) Reset() { *m = SovereignShardTriggerRegistry{} } +func (*SovereignShardTriggerRegistry) ProtoMessage() {} +func (*SovereignShardTriggerRegistry) Descriptor() ([]byte, []int) { + return fileDescriptor_8c31e6d8b4368946, []int{3} +} +func (m *SovereignShardTriggerRegistry) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SovereignShardTriggerRegistry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *SovereignShardTriggerRegistry) XXX_Merge(src proto.Message) { + xxx_messageInfo_SovereignShardTriggerRegistry.Merge(m, src) +} +func (m *SovereignShardTriggerRegistry) XXX_Size() int { + return m.Size() +} +func (m *SovereignShardTriggerRegistry) XXX_DiscardUnknown() { + xxx_messageInfo_SovereignShardTriggerRegistry.DiscardUnknown(m) +} + +var xxx_messageInfo_SovereignShardTriggerRegistry proto.InternalMessageInfo + +func (m *SovereignShardTriggerRegistry) GetEpoch() uint32 { + if m != nil { + return m.Epoch + } + return 0 +} + +func (m *SovereignShardTriggerRegistry) GetCurrentRound() uint64 { + if m != nil { + return m.CurrentRound + } + return 0 +} + +func (m *SovereignShardTriggerRegistry) GetEpochFinalityAttestingRound() uint64 { + if m != nil { + return m.EpochFinalityAttestingRound + } + return 0 +} + +func (m *SovereignShardTriggerRegistry) GetCurrEpochStartRound() uint64 { + if m != nil { + return m.CurrEpochStartRound + } + return 0 +} + +func (m *SovereignShardTriggerRegistry) GetPrevEpochStartRound() uint64 { + if m != nil { + return m.PrevEpochStartRound + } + return 0 +} + +func (m *SovereignShardTriggerRegistry) GetEpochStartMetaHash() []byte { + if m != nil { + return m.EpochStartMetaHash + } + return nil +} + +func (m *SovereignShardTriggerRegistry) GetSovereignChainHeader() *SovereignChainHeader { + if m != nil { + return m.SovereignChainHeader + } + return nil +} + func init() { proto.RegisterType((*ShardTriggerRegistry)(nil), "proto.ShardTriggerRegistry") proto.RegisterType((*ShardTriggerRegistryV2)(nil), "proto.ShardTriggerRegistryV2") proto.RegisterType((*MetaTriggerRegistry)(nil), "proto.MetaTriggerRegistry") + proto.RegisterType((*SovereignShardTriggerRegistry)(nil), "proto.SovereignShardTriggerRegistry") } func init() { proto.RegisterFile("trigger.proto", fileDescriptor_8c31e6d8b4368946) } var fileDescriptor_8c31e6d8b4368946 = []byte{ - // 532 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xcb, 0x6e, 0xd3, 0x40, - 0x14, 0xf5, 0xc4, 0x76, 0x9a, 0x4c, 0x12, 0x02, 0xd3, 0x52, 0x59, 0x05, 0x8d, 0x2c, 0xaf, 0xbc, - 0x80, 0x14, 0x19, 0x09, 0xb1, 0x03, 0x5a, 0x15, 0xb5, 0x8b, 0x22, 0x34, 0x45, 0x59, 0xb0, 0x73, - 0xe2, 0xc1, 0xb1, 0x68, 0xed, 0x6a, 0x32, 0x29, 0x74, 0xc7, 0x27, 0xf0, 0x19, 0xfc, 0x00, 0x0b, - 0xfe, 0x80, 0x65, 0x96, 0xd9, 0x41, 0x9c, 0x0d, 0xcb, 0x7e, 0x02, 0xf2, 0x75, 0x48, 0x62, 0xd7, - 0xa6, 0x8f, 0x55, 0x72, 0xcf, 0xb9, 0xe7, 0xce, 0xcc, 0xb9, 0x27, 0xc1, 0x2d, 0x29, 0x02, 0xdf, - 0xe7, 0xa2, 0x73, 0x2a, 0x22, 0x19, 0x11, 0x1d, 0x3e, 0xb6, 0x1e, 0xfb, 0x81, 0x1c, 0x8c, 0x7a, - 0x9d, 0x7e, 0x74, 0xb2, 0xed, 0x47, 0x7e, 0xb4, 0x0d, 0x70, 0x6f, 0xf4, 0x01, 0x2a, 0x28, 0xe0, - 0x5b, 0xaa, 0xda, 0x6a, 0xf4, 0x8e, 0xa3, 0xfe, 0xc7, 0x79, 0xd1, 0x82, 0xa2, 0xeb, 0xcc, 0xcb, - 0xf6, 0x09, 0x97, 0xee, 0xce, 0x92, 0xb7, 0xbe, 0xab, 0x78, 0xe3, 0x68, 0xe0, 0x0a, 0xef, 0x5d, - 0x7a, 0x32, 0xe3, 0x7e, 0x30, 0x94, 0xe2, 0x9c, 0x58, 0xb8, 0x79, 0x30, 0xdc, 0x3b, 0x8d, 0xfa, - 0x83, 0x23, 0xe9, 0x0a, 0x69, 0x20, 0x13, 0xd9, 0x35, 0x96, 0xc1, 0xc8, 0x33, 0xbc, 0xf9, 0x86, - 0x7f, 0x02, 0x60, 0x9f, 0xbb, 0x5e, 0xa2, 0xee, 0xf3, 0xe0, 0x8c, 0x7b, 0x46, 0x05, 0xba, 0x4b, - 0x58, 0xb2, 0x81, 0x75, 0x80, 0x0d, 0xd5, 0x44, 0x76, 0x8b, 0xa5, 0x05, 0x79, 0x88, 0xeb, 0x87, - 0x5c, 0xba, 0x29, 0xa3, 0x01, 0xb3, 0x04, 0xc8, 0x23, 0x7c, 0x6f, 0x77, 0x24, 0x04, 0x0f, 0x25, - 0x8b, 0x46, 0xa1, 0x77, 0x10, 0x7a, 0xfc, 0xb3, 0xa1, 0x9b, 0xc8, 0x56, 0xd9, 0x65, 0x82, 0xd8, - 0xb8, 0xbd, 0xbc, 0x27, 0xe0, 0x46, 0xd5, 0x44, 0xb6, 0xc6, 0xf2, 0x30, 0x79, 0x89, 0x1f, 0x00, - 0xf4, 0x3a, 0x08, 0xdd, 0xe3, 0x40, 0x9e, 0xbf, 0x92, 0x92, 0x0f, 0x65, 0x10, 0xfa, 0xa9, 0x6a, - 0x0d, 0x54, 0xff, 0x6b, 0x21, 0x1d, 0x4c, 0x80, 0x3e, 0xfc, 0x67, 0xed, 0xbe, 0x3b, 0x1c, 0x18, - 0x35, 0x13, 0xd9, 0x4d, 0x56, 0xc0, 0x90, 0x5d, 0x7c, 0x7f, 0x79, 0x09, 0xf0, 0x3e, 0xb5, 0xc7, - 0xa8, 0x9b, 0xc8, 0x6e, 0x38, 0xad, 0x74, 0x33, 0x9d, 0xb9, 0x67, 0xc5, 0xbd, 0xd6, 0x0f, 0x15, - 0x6f, 0x16, 0xed, 0xad, 0xeb, 0x90, 0xbd, 0xb2, 0xf9, 0x08, 0xe6, 0xb7, 0x33, 0xf3, 0xbb, 0x4e, - 0xc9, 0x09, 0x97, 0x02, 0x50, 0xb9, 0x51, 0x00, 0xd4, 0xeb, 0x05, 0x40, 0x2b, 0x0d, 0x80, 0x7e, - 0xad, 0x00, 0x54, 0x6f, 0x10, 0x80, 0xb5, 0x5b, 0x05, 0xa0, 0x76, 0xdb, 0x00, 0xd4, 0xcb, 0x02, - 0x60, 0xfd, 0xaa, 0xe0, 0xf5, 0x04, 0xc9, 0xff, 0xe4, 0x16, 0xae, 0xa0, 0x55, 0x57, 0x2c, 0xdc, - 0x5c, 0x7d, 0x1e, 0xec, 0x41, 0x63, 0x19, 0xec, 0xaa, 0x37, 0xa8, 0x57, 0xbf, 0xe1, 0x09, 0x5e, - 0x4f, 0x26, 0xe6, 0x3d, 0xd3, 0x40, 0x59, 0x44, 0x25, 0x8a, 0xb7, 0x82, 0x9f, 0xe5, 0x15, 0x7a, - 0xaa, 0x28, 0xa0, 0x16, 0x3e, 0x01, 0x94, 0x18, 0x00, 0x3e, 0x55, 0x57, 0x7c, 0xca, 0x30, 0xe4, - 0x39, 0xbe, 0x93, 0x45, 0x61, 0x85, 0x0d, 0xe7, 0xee, 0x3c, 0xc1, 0x0b, 0x57, 0x59, 0xae, 0x6f, - 0xe7, 0xc5, 0x78, 0x4a, 0x95, 0xc9, 0x94, 0x2a, 0x17, 0x53, 0x8a, 0xbe, 0xc4, 0x14, 0x7d, 0x8b, - 0x29, 0xfa, 0x19, 0x53, 0x34, 0x8e, 0x29, 0x9a, 0xc4, 0x14, 0xfd, 0x8e, 0x29, 0xfa, 0x13, 0x53, - 0xe5, 0x22, 0xa6, 0xe8, 0xeb, 0x8c, 0x2a, 0xe3, 0x19, 0x55, 0x26, 0x33, 0xaa, 0xbc, 0xd7, 0xe1, - 0xff, 0xb2, 0x57, 0x85, 0x13, 0x9e, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x15, 0x5a, 0xda, 0x3b, - 0x91, 0x05, 0x00, 0x00, + // 581 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0x4d, 0x73, 0xd2, 0x40, + 0x18, 0xce, 0x36, 0x84, 0xc2, 0x02, 0xa2, 0x5b, 0xec, 0x64, 0xa8, 0xee, 0x64, 0x72, 0xca, 0x41, + 0xa9, 0x83, 0x33, 0x8e, 0x37, 0xb5, 0x4c, 0x9d, 0xf6, 0x50, 0x75, 0x16, 0x87, 0x83, 0xb7, 0x00, + 0x6b, 0xc8, 0xd8, 0x26, 0x9d, 0x65, 0x41, 0x7b, 0xeb, 0x4f, 0xf0, 0x67, 0xf8, 0x07, 0x3c, 0xf8, + 0x0f, 0x3c, 0x72, 0xe4, 0xa6, 0x84, 0x8b, 0xc7, 0xfe, 0x04, 0x87, 0x37, 0xe1, 0x23, 0x34, 0xb1, + 0x1f, 0x67, 0x4f, 0xf0, 0x3e, 0xcf, 0xfb, 0xbc, 0xbb, 0xfb, 0xec, 0x93, 0x04, 0x97, 0xa4, 0x70, + 0x1d, 0x87, 0x8b, 0xda, 0xa9, 0xf0, 0xa5, 0x4f, 0x34, 0xf8, 0xa9, 0x3e, 0x76, 0x5c, 0xd9, 0x1b, + 0xb4, 0x6b, 0x1d, 0xff, 0x64, 0xd7, 0xf1, 0x1d, 0x7f, 0x17, 0xe0, 0xf6, 0xe0, 0x23, 0x54, 0x50, + 0xc0, 0xbf, 0x50, 0x55, 0x2d, 0xb4, 0x8f, 0xfd, 0xce, 0xa7, 0xa8, 0x28, 0x41, 0xd1, 0xaa, 0x47, + 0x65, 0xf9, 0x84, 0x4b, 0x7b, 0x6f, 0x85, 0xaf, 0xf6, 0xfd, 0x21, 0x17, 0xdc, 0x75, 0xbc, 0x46, + 0xcf, 0x76, 0xbd, 0x03, 0x6e, 0x77, 0xe7, 0xcb, 0x9b, 0xdf, 0x55, 0x5c, 0x69, 0xf6, 0x6c, 0xd1, + 0x7d, 0x1f, 0xee, 0x8a, 0x71, 0xc7, 0xed, 0x4b, 0x71, 0x46, 0x4c, 0x5c, 0x3c, 0xec, 0xef, 0x9f, + 0xfa, 0x9d, 0x5e, 0x53, 0xda, 0x42, 0xea, 0xc8, 0x40, 0x56, 0x8e, 0xc5, 0x30, 0xf2, 0x0c, 0x6f, + 0xbf, 0xe1, 0x9f, 0x01, 0x08, 0x87, 0x32, 0xde, 0xe1, 0xee, 0x90, 0x77, 0xf5, 0x0d, 0xe8, 0x4e, + 0x61, 0x49, 0x05, 0x6b, 0x00, 0xeb, 0xaa, 0x81, 0xac, 0x12, 0x0b, 0x0b, 0xf2, 0x00, 0xe7, 0x8f, + 0xb8, 0xb4, 0x43, 0x26, 0x03, 0xcc, 0x12, 0x20, 0x8f, 0xf0, 0xbd, 0xc6, 0x40, 0x08, 0xee, 0x49, + 0xe6, 0x0f, 0xbc, 0xee, 0xa1, 0xd7, 0xe5, 0x5f, 0x74, 0xcd, 0x40, 0x96, 0xca, 0x2e, 0x13, 0xc4, + 0xc2, 0xe5, 0xe5, 0x3e, 0x01, 0xd7, 0xb3, 0x06, 0xb2, 0x32, 0x6c, 0x1d, 0x26, 0x2f, 0xf1, 0x0e, + 0x40, 0xaf, 0x5d, 0xcf, 0x3e, 0x76, 0xe5, 0xd9, 0x2b, 0x29, 0x79, 0x5f, 0xba, 0x9e, 0x13, 0xaa, + 0x36, 0x41, 0xf5, 0xaf, 0x16, 0x52, 0xc3, 0x04, 0xe8, 0xa3, 0xb9, 0xed, 0x07, 0x76, 0xbf, 0xa7, + 0xe7, 0x0c, 0x64, 0x15, 0x59, 0x02, 0x43, 0x1a, 0xf8, 0xfe, 0x72, 0x13, 0xe0, 0x7d, 0x68, 0x8f, + 0x9e, 0x37, 0x90, 0x55, 0xa8, 0x97, 0xc2, 0x9b, 0xa9, 0x45, 0x9e, 0x25, 0xf7, 0x9a, 0x3f, 0x54, + 0xbc, 0x9d, 0x74, 0x6f, 0xad, 0x3a, 0xd9, 0x4f, 0x9b, 0x8f, 0x60, 0x7e, 0x39, 0x36, 0xbf, 0x55, + 0x4f, 0x59, 0xe1, 0x52, 0x00, 0x36, 0x6e, 0x14, 0x00, 0xf5, 0x7a, 0x01, 0xc8, 0xa4, 0x06, 0x40, + 0xbb, 0x56, 0x00, 0xb2, 0x37, 0x08, 0xc0, 0xe6, 0xad, 0x02, 0x90, 0xbb, 0x6d, 0x00, 0xf2, 0x69, + 0x01, 0x30, 0x7f, 0x6d, 0xe0, 0xad, 0x19, 0xb2, 0xfe, 0xc8, 0x2d, 0x5c, 0x41, 0xab, 0xae, 0x98, + 0xb8, 0xb8, 0x7a, 0x3c, 0xb8, 0x87, 0x0c, 0x8b, 0x61, 0x57, 0x9d, 0x41, 0xbd, 0xfa, 0x0c, 0x4f, + 0xf0, 0xd6, 0x6c, 0xe2, 0xba, 0x67, 0x19, 0x50, 0x26, 0x51, 0x33, 0xc5, 0x3b, 0xc1, 0x87, 0xeb, + 0x0a, 0x2d, 0x54, 0x24, 0x50, 0x0b, 0x9f, 0x00, 0x9a, 0x19, 0x00, 0x3e, 0x65, 0x57, 0x7c, 0x8a, + 0x31, 0xe4, 0x39, 0xbe, 0x13, 0x47, 0xe1, 0x0a, 0x0b, 0xf5, 0xbb, 0x51, 0x82, 0x17, 0xae, 0xb2, + 0xb5, 0x3e, 0xf3, 0x5c, 0xc5, 0x0f, 0x9b, 0xf3, 0x97, 0x5e, 0xe2, 0xeb, 0xed, 0xbf, 0xd7, 0x71, + 0xaf, 0xdf, 0xe2, 0x4a, 0x33, 0xe1, 0x2b, 0x11, 0x39, 0xbe, 0x13, 0x39, 0x9e, 0xd4, 0xc2, 0x12, + 0x85, 0x7b, 0x2f, 0x46, 0x13, 0xaa, 0x8c, 0x27, 0x54, 0xb9, 0x98, 0x50, 0x74, 0x1e, 0x50, 0xf4, + 0x2d, 0xa0, 0xe8, 0x67, 0x40, 0xd1, 0x28, 0xa0, 0x68, 0x1c, 0x50, 0xf4, 0x3b, 0xa0, 0xe8, 0x4f, + 0x40, 0x95, 0x8b, 0x80, 0xa2, 0xaf, 0x53, 0xaa, 0x8c, 0xa6, 0x54, 0x19, 0x4f, 0xa9, 0xf2, 0x41, + 0x83, 0xcf, 0x59, 0x3b, 0x0b, 0x4b, 0x3e, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x3a, 0xf5, 0x77, + 0x50, 0x30, 0x07, 0x00, 0x00, } func (this *ShardTriggerRegistry) Equal(that interface{}) bool { @@ -503,6 +594,48 @@ func (this *MetaTriggerRegistry) Equal(that interface{}) bool { } return true } +func (this *SovereignShardTriggerRegistry) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*SovereignShardTriggerRegistry) + if !ok { + that2, ok := that.(SovereignShardTriggerRegistry) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Epoch != that1.Epoch { + return false + } + if this.CurrentRound != that1.CurrentRound { + return false + } + if this.EpochFinalityAttestingRound != that1.EpochFinalityAttestingRound { + return false + } + if this.CurrEpochStartRound != that1.CurrEpochStartRound { + return false + } + if this.PrevEpochStartRound != that1.PrevEpochStartRound { + return false + } + if !bytes.Equal(this.EpochStartMetaHash, that1.EpochStartMetaHash) { + return false + } + if !this.SovereignChainHeader.Equal(that1.SovereignChainHeader) { + return false + } + return true +} func (this *ShardTriggerRegistry) GoString() string { if this == nil { return "nil" @@ -561,6 +694,24 @@ func (this *MetaTriggerRegistry) GoString() string { s = append(s, "}") return strings.Join(s, "") } +func (this *SovereignShardTriggerRegistry) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 11) + s = append(s, "&block.SovereignShardTriggerRegistry{") + s = append(s, "Epoch: "+fmt.Sprintf("%#v", this.Epoch)+",\n") + s = append(s, "CurrentRound: "+fmt.Sprintf("%#v", this.CurrentRound)+",\n") + s = append(s, "EpochFinalityAttestingRound: "+fmt.Sprintf("%#v", this.EpochFinalityAttestingRound)+",\n") + s = append(s, "CurrEpochStartRound: "+fmt.Sprintf("%#v", this.CurrEpochStartRound)+",\n") + s = append(s, "PrevEpochStartRound: "+fmt.Sprintf("%#v", this.PrevEpochStartRound)+",\n") + s = append(s, "EpochStartMetaHash: "+fmt.Sprintf("%#v", this.EpochStartMetaHash)+",\n") + if this.SovereignChainHeader != nil { + s = append(s, "SovereignChainHeader: "+fmt.Sprintf("%#v", this.SovereignChainHeader)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} func valueToGoStringTrigger(v interface{}, typ string) string { rv := reflect.ValueOf(v) if rv.IsNil() { @@ -810,6 +961,73 @@ func (m *MetaTriggerRegistry) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *SovereignShardTriggerRegistry) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SovereignShardTriggerRegistry) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SovereignShardTriggerRegistry) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.SovereignChainHeader != nil { + { + size, err := m.SovereignChainHeader.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrigger(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + if len(m.EpochStartMetaHash) > 0 { + i -= len(m.EpochStartMetaHash) + copy(dAtA[i:], m.EpochStartMetaHash) + i = encodeVarintTrigger(dAtA, i, uint64(len(m.EpochStartMetaHash))) + i-- + dAtA[i] = 0x32 + } + if m.PrevEpochStartRound != 0 { + i = encodeVarintTrigger(dAtA, i, uint64(m.PrevEpochStartRound)) + i-- + dAtA[i] = 0x28 + } + if m.CurrEpochStartRound != 0 { + i = encodeVarintTrigger(dAtA, i, uint64(m.CurrEpochStartRound)) + i-- + dAtA[i] = 0x20 + } + if m.EpochFinalityAttestingRound != 0 { + i = encodeVarintTrigger(dAtA, i, uint64(m.EpochFinalityAttestingRound)) + i-- + dAtA[i] = 0x18 + } + if m.CurrentRound != 0 { + i = encodeVarintTrigger(dAtA, i, uint64(m.CurrentRound)) + i-- + dAtA[i] = 0x10 + } + if m.Epoch != 0 { + i = encodeVarintTrigger(dAtA, i, uint64(m.Epoch)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintTrigger(dAtA []byte, offset int, v uint64) int { offset -= sovTrigger(v) base := offset @@ -929,6 +1147,38 @@ func (m *MetaTriggerRegistry) Size() (n int) { return n } +func (m *SovereignShardTriggerRegistry) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Epoch != 0 { + n += 1 + sovTrigger(uint64(m.Epoch)) + } + if m.CurrentRound != 0 { + n += 1 + sovTrigger(uint64(m.CurrentRound)) + } + if m.EpochFinalityAttestingRound != 0 { + n += 1 + sovTrigger(uint64(m.EpochFinalityAttestingRound)) + } + if m.CurrEpochStartRound != 0 { + n += 1 + sovTrigger(uint64(m.CurrEpochStartRound)) + } + if m.PrevEpochStartRound != 0 { + n += 1 + sovTrigger(uint64(m.PrevEpochStartRound)) + } + l = len(m.EpochStartMetaHash) + if l > 0 { + n += 1 + l + sovTrigger(uint64(l)) + } + if m.SovereignChainHeader != nil { + l = m.SovereignChainHeader.Size() + n += 1 + l + sovTrigger(uint64(l)) + } + return n +} + func sovTrigger(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -987,6 +1237,22 @@ func (this *MetaTriggerRegistry) String() string { }, "") return s } +func (this *SovereignShardTriggerRegistry) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&SovereignShardTriggerRegistry{`, + `Epoch:` + fmt.Sprintf("%v", this.Epoch) + `,`, + `CurrentRound:` + fmt.Sprintf("%v", this.CurrentRound) + `,`, + `EpochFinalityAttestingRound:` + fmt.Sprintf("%v", this.EpochFinalityAttestingRound) + `,`, + `CurrEpochStartRound:` + fmt.Sprintf("%v", this.CurrEpochStartRound) + `,`, + `PrevEpochStartRound:` + fmt.Sprintf("%v", this.PrevEpochStartRound) + `,`, + `EpochStartMetaHash:` + fmt.Sprintf("%v", this.EpochStartMetaHash) + `,`, + `SovereignChainHeader:` + strings.Replace(fmt.Sprintf("%v", this.SovereignChainHeader), "SovereignChainHeader", "SovereignChainHeader", 1) + `,`, + `}`, + }, "") + return s +} func valueToStringTrigger(v interface{}) string { rv := reflect.ValueOf(v) if rv.IsNil() { @@ -1729,6 +1995,224 @@ func (m *MetaTriggerRegistry) Unmarshal(dAtA []byte) error { } return nil } +func (m *SovereignShardTriggerRegistry) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTrigger + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SovereignShardTriggerRegistry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SovereignShardTriggerRegistry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Epoch", wireType) + } + m.Epoch = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTrigger + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Epoch |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentRound", wireType) + } + m.CurrentRound = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTrigger + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentRound |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochFinalityAttestingRound", wireType) + } + m.EpochFinalityAttestingRound = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTrigger + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EpochFinalityAttestingRound |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrEpochStartRound", wireType) + } + m.CurrEpochStartRound = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTrigger + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrEpochStartRound |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PrevEpochStartRound", wireType) + } + m.PrevEpochStartRound = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTrigger + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PrevEpochStartRound |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochStartMetaHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTrigger + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTrigger + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTrigger + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EpochStartMetaHash = append(m.EpochStartMetaHash[:0], dAtA[iNdEx:postIndex]...) + if m.EpochStartMetaHash == nil { + m.EpochStartMetaHash = []byte{} + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SovereignChainHeader", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTrigger + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTrigger + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTrigger + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SovereignChainHeader == nil { + m.SovereignChainHeader = &SovereignChainHeader{} + } + if err := m.SovereignChainHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTrigger(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTrigger + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTrigger + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTrigger(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/data/block/trigger.proto b/data/block/trigger.proto index ae590942..87ae04cd 100644 --- a/data/block/trigger.proto +++ b/data/block/trigger.proto @@ -9,6 +9,7 @@ import "github.com/gogo/protobuf/gogoproto/gogo.proto"; import "block.proto"; import "blockV2.proto"; import "metaBlock.proto"; +import "sovereignChainHeader.proto"; message ShardTriggerRegistry { bool IsEpochStart = 1; @@ -43,3 +44,13 @@ message MetaTriggerRegistry { bytes EpochStartMetaHash = 6; MetaBlock EpochStartMeta = 7; } + +message SovereignShardTriggerRegistry { + uint32 Epoch = 1; + uint64 CurrentRound = 2; + uint64 EpochFinalityAttestingRound = 3; + uint64 CurrEpochStartRound = 4; + uint64 PrevEpochStartRound = 5; + bytes EpochStartMetaHash = 6; + SovereignChainHeader SovereignChainHeader = 7; +} diff --git a/data/errors.go b/data/errors.go index ab2dae17..716a480e 100644 --- a/data/errors.go +++ b/data/errors.go @@ -84,3 +84,9 @@ var ErrWrongTransactionsTypeSize = errors.New("wrong transactions type size") // ErrNilReservedField signals that a nil reserved field was provided var ErrNilReservedField = errors.New("reserved field is nil") + +// ErrWrongTypeAssertion signals that there was a wrong type assertion +var ErrWrongTypeAssertion = errors.New("wrong type assertion") + +// ErrNilHeader signals that a nil header has been provided +var ErrNilHeader = errors.New("nil header") diff --git a/data/esdt/common.go b/data/esdt/common.go index d2467ec4..7d240b51 100644 --- a/data/esdt/common.go +++ b/data/esdt/common.go @@ -35,7 +35,7 @@ func IsValidPrefixedToken(token string) (string, bool) { } tokenRandSeq := tokenSplit[2] - if !(len(tokenRandSeq) >= esdtTickerNumRandChars) { + if !IsRandomSeqValid(tokenRandSeq) { return "", false } @@ -83,3 +83,21 @@ func IsTickerValid(ticker string) bool { func IsTokenTickerLenCorrect(tokenTickerLen int) bool { return !(tokenTickerLen < minLengthForTickerName || tokenTickerLen > maxLengthForTickerName) } + +// IsRandomSeqValid checks if the token random sequence is valid +func IsRandomSeqValid(randomSeq string) bool { + if len(randomSeq) != esdtTickerNumRandChars { + return false + } + + for _, ch := range randomSeq { + isSmallCharacter := ch >= 'a' && ch <= 'f' + isNumber := ch >= '0' && ch <= '9' + isReadable := isSmallCharacter || isNumber + if !isReadable { + return false + } + } + + return true +} diff --git a/data/esdt/common_test.go b/data/esdt/common_test.go index 8052c23a..0e65fd9d 100644 --- a/data/esdt/common_test.go +++ b/data/esdt/common_test.go @@ -7,19 +7,19 @@ import ( ) func TestIsValidPrefixedToken(t *testing.T) { - prefix, valid := IsValidPrefixedToken("sov1-TKN-coffee") + prefix, valid := IsValidPrefixedToken("sov1-TKN-c0ffee") require.True(t, valid) require.Equal(t, "sov1", prefix) - prefix, valid = IsValidPrefixedToken("sOv1-TKN-coffee") + prefix, valid = IsValidPrefixedToken("sOv1-TKN-c0ffee") require.False(t, valid) require.Equal(t, "", prefix) - prefix, valid = IsValidPrefixedToken("sov1-TkN-coffee") + prefix, valid = IsValidPrefixedToken("sov1-TkN-c0ffee") require.False(t, valid) require.Equal(t, "", prefix) - prefix, valid = IsValidPrefixedToken("sov1-TKN-coffe") + prefix, valid = IsValidPrefixedToken("sov1-TKN-c0ffe") require.False(t, valid) require.Equal(t, "", prefix) @@ -27,7 +27,7 @@ func TestIsValidPrefixedToken(t *testing.T) { require.False(t, valid) require.Equal(t, "", prefix) - prefix, valid = IsValidPrefixedToken("TKN-coffee") + prefix, valid = IsValidPrefixedToken("TKN-c0ffee") require.False(t, valid) require.Equal(t, "", prefix) } diff --git a/data/interface.go b/data/interface.go index 97f5ecd7..ee2f0ed0 100644 --- a/data/interface.go +++ b/data/interface.go @@ -29,8 +29,19 @@ type TriggerRegistryHandler interface { SetEpochStartHeaderHandler(epochStartHeaderHandler HeaderHandler) error } -// HeaderHandler defines getters and setters for header data holder -type HeaderHandler interface { +// MetaTriggerRegistryHandler defines meta chain trigger registry interface +type MetaTriggerRegistryHandler interface { + GetEpoch() uint32 + GetCurrentRound() uint64 + GetEpochFinalityAttestingRound() uint64 + GetCurrEpochStartRound() uint64 + GetPrevEpochStartRound() uint64 + GetEpochStartMetaHash() []byte + GetEpochStartHeaderHandler() HeaderHandler +} + +// CommonHeaderHandler defines getters and setters for header data holder +type CommonHeaderHandler interface { GetShardID() uint32 GetNonce() uint64 GetEpoch() uint32 @@ -47,20 +58,12 @@ type HeaderHandler interface { GetTimeStamp() uint64 GetTxCount() uint32 GetReceiptsHash() []byte + GetReserved() []byte GetAccumulatedFees() *big.Int GetDeveloperFees() *big.Int - GetReserved() []byte - GetMiniBlockHeadersWithDst(destId uint32) map[string]uint32 - GetOrderedCrossMiniblocksWithDst(destId uint32) []*MiniBlockInfo GetMiniBlockHeadersHashes() [][]byte GetMiniBlockHeaderHandlers() []MiniBlockHeaderHandler - HasScheduledSupport() bool - GetAdditionalData() headerVersionData.HeaderAdditionalData - HasScheduledMiniBlocks() bool - SetAccumulatedFees(value *big.Int) error - SetDeveloperFees(value *big.Int) error - SetShardID(shId uint32) error SetNonce(n uint64) error SetEpoch(e uint32) error SetRound(r uint64) error @@ -75,17 +78,77 @@ type HeaderHandler interface { SetChainID(chainID []byte) error SetSoftwareVersion(version []byte) error SetTxCount(txCount uint32) error + SetDeveloperFees(value *big.Int) error + SetAccumulatedFees(value *big.Int) error SetMiniBlockHeaderHandlers(mbHeaderHandlers []MiniBlockHeaderHandler) error SetReceiptsHash(hash []byte) error - SetScheduledRootHash(rootHash []byte) error ValidateHeaderVersion() error - SetAdditionalData(headerVersionData headerVersionData.HeaderAdditionalData) error IsStartOfEpochBlock() bool ShallowClone() HeaderHandler CheckFieldsForNil() error IsInterfaceNil() bool } +// ValidatorStatisticsInfoHandler is a simple handler needed for validator statistics info +type ValidatorStatisticsInfoHandler interface { + SetValidatorStatsRootHash(rootHash []byte) error + GetValidatorStatsRootHash() []byte + IsInterfaceNil() bool +} + +// SovereignChainHeaderHandler defines getters and setters for the sovereign chain header +type SovereignChainHeaderHandler interface { + CommonHeaderHandler + GetMiniBlockHeadersWithDst(destId uint32) map[string]uint32 + SetValidatorStatsRootHash(rootHash []byte) error + GetValidatorStatsRootHash() []byte + SetExtendedShardHeaderHashes(hdrHashes [][]byte) error + GetExtendedShardHeaderHashes() [][]byte + GetOutGoingMiniBlockHeaderHandler() OutGoingMiniBlockHeaderHandler + SetOutGoingMiniBlockHeaderHandler(mbHeader OutGoingMiniBlockHeaderHandler) error + GetDevFeesInEpoch() *big.Int + SetDevFeesInEpoch(value *big.Int) error + GetAccumulatedFeesInEpoch() *big.Int + SetAccumulatedFeesInEpoch(value *big.Int) error + SetStartOfEpochHeader() error + GetEpochStartHandler() EpochStartHandler + GetShardInfoHandlers() []ShardDataHandler + SetShardInfoHandlers(shardInfo []ShardDataHandler) error + GetLastFinalizedCrossChainHeaderHandler() EpochStartChainDataHandler +} + +// OutGoingMiniBlockHeaderHandler defines setters and getters for sovereign outgoing mini block header +type OutGoingMiniBlockHeaderHandler interface { + GetHash() []byte + GetOutGoingOperationsHash() []byte + GetAggregatedSignatureOutGoingOperations() []byte + GetLeaderSignatureOutGoingOperations() []byte + + SetHash(hash []byte) error + SetOutGoingOperationsHash(hash []byte) error + SetLeaderSignatureOutGoingOperations(sig []byte) error + SetAggregatedSignatureOutGoingOperations(sig []byte) error + + IsInterfaceNil() bool +} + +// HeaderHandler defines getters and setters for header data holder +type HeaderHandler interface { + CommonHeaderHandler + GetMiniBlockHeadersWithDst(destId uint32) map[string]uint32 + GetOrderedCrossMiniblocksWithDst(destId uint32) []*MiniBlockInfo + HasScheduledSupport() bool + GetAdditionalData() headerVersionData.HeaderAdditionalData + HasScheduledMiniBlocks() bool + GetValidatorStatsRootHash() []byte + + SetShardID(shId uint32) error + SetScheduledRootHash(rootHash []byte) error + SetAdditionalData(headerVersionData headerVersionData.HeaderAdditionalData) error + SetValidatorStatsRootHash(rHash []byte) error + ShallowClone() HeaderHandler +} + // ShardHeaderHandler defines getters and setters for the shard block header type ShardHeaderHandler interface { HeaderHandler @@ -101,11 +164,10 @@ type ShardHeaderHandler interface { // MetaHeaderHandler defines getters and setters for the meta block header type MetaHeaderHandler interface { HeaderHandler - GetValidatorStatsRootHash() []byte GetEpochStartHandler() EpochStartHandler GetDevFeesInEpoch() *big.Int + GetAccumulatedFeesInEpoch() *big.Int GetShardInfoHandlers() []ShardDataHandler - SetValidatorStatsRootHash(rHash []byte) error SetDevFeesInEpoch(value *big.Int) error SetShardInfoHandlers(shardInfo []ShardDataHandler) error SetAccumulatedFeesInEpoch(value *big.Int) error @@ -182,23 +244,30 @@ type ShardDataHandler interface { ShallowClone() ShardDataHandler } -// EpochStartShardDataHandler defines setters and getters for EpochStartShardData -type EpochStartShardDataHandler interface { +// EpochStartChainDataHandler defines setters and getters for basic information related to epoch start data +type EpochStartChainDataHandler interface { GetShardID() uint32 GetEpoch() uint32 GetRound() uint64 GetNonce() uint64 GetHeaderHash() []byte - GetRootHash() []byte - GetFirstPendingMetaBlock() []byte - GetLastFinishedMetaBlock() []byte - GetPendingMiniBlockHeaderHandlers() []MiniBlockHeaderHandler SetShardID(uint32) error SetEpoch(uint32) error SetRound(uint64) error SetNonce(uint64) error SetHeaderHash([]byte) error +} + +// EpochStartShardDataHandler defines setters and getters for EpochStartShardData +type EpochStartShardDataHandler interface { + EpochStartChainDataHandler + + GetRootHash() []byte + GetFirstPendingMetaBlock() []byte + GetLastFinishedMetaBlock() []byte + GetPendingMiniBlockHeaderHandlers() []MiniBlockHeaderHandler + SetRootHash([]byte) error SetFirstPendingMetaBlock([]byte) error SetLastFinishedMetaBlock([]byte) error @@ -235,8 +304,16 @@ type EpochStartHandler interface { SetEconomics(economicsHandler EconomicsHandler) error } +// MiniBlockHandler interface for miniblock +type MiniBlockHandler interface { + Clone() MiniBlockHandler + // IsInterfaceNil returns true if there is no value under the interface + IsInterfaceNil() bool +} + // BodyHandler interface for a block body type BodyHandler interface { + SetMiniBlocks(miniBlocks []MiniBlockHandler) error Clone() BodyHandler // IntegrityAndValidity checks the integrity and validity of the block IntegrityAndValidity() error @@ -408,3 +485,12 @@ type UserAccountHandler interface { AddressBytes() []byte IsInterfaceNil() bool } + +// ShardHeaderExtendedHandler extends ShardHeaderHandler interface, by also including incoming mini blocks needed by sovereign chain +type ShardHeaderExtendedHandler interface { + ShardHeaderHandler + GetIncomingMiniBlockHandlers() []MiniBlockHandler + SetIncomingMiniBlockHandlers(miniBlockHandlers []MiniBlockHandler) error + GetHeaderHandler() HeaderHandler + GetIncomingEventHandlers() []EventHandler +} diff --git a/data/outport/common.go b/data/outport/common.go index 82548511..e48757f0 100644 --- a/data/outport/common.go +++ b/data/outport/common.go @@ -25,6 +25,8 @@ func GetHeaderBytesAndType(marshaller marshal.Marshalizer, headerHandler data.He headerType = core.MetaHeader case *block.Header: headerType = core.ShardHeaderV1 + case *block.SovereignChainHeader: + headerType = core.SovereignChainHeader default: return nil, "", errInvalidHeaderType } diff --git a/data/sovereign/eventData.go b/data/sovereign/eventData.go new file mode 100644 index 00000000..386cf8f3 --- /dev/null +++ b/data/sovereign/eventData.go @@ -0,0 +1,15 @@ +package sovereign + +// TransferData holds the required data for a transfer to smart contract +type TransferData struct { + GasLimit uint64 + Function []byte + Args [][]byte +} + +// EventData holds the full event data structure +type EventData struct { + Nonce uint64 + Sender []byte + *TransferData +} diff --git a/data/sovereign/incomingHeader.go b/data/sovereign/incomingHeader.go new file mode 100644 index 00000000..718bb0cc --- /dev/null +++ b/data/sovereign/incomingHeader.go @@ -0,0 +1,35 @@ +//go:generate protoc -I=. -I=$GOPATH/src/github.com/multiversx/mx-chain-core-go/data/block -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. incomingHeader.proto + +package sovereign + +import "github.com/multiversx/mx-chain-core-go/data" + +// GetIncomingEventHandlers returns the incoming events as an array of event handlers +func (ih *IncomingHeader) GetIncomingEventHandlers() []data.EventHandler { + if ih == nil { + return nil + } + + events := ih.GetIncomingEvents() + logHandlers := make([]data.EventHandler, len(events)) + + for i := range events { + logHandlers[i] = events[i] + } + + return logHandlers +} + +// GetHeaderHandler returns the incoming headerV2 as a header handler +func (ih *IncomingHeader) GetHeaderHandler() data.HeaderHandler { + if ih == nil { + return nil + } + + return ih.GetHeader() +} + +// IsInterfaceNil checks if the underlying pointer is nil +func (ih *IncomingHeader) IsInterfaceNil() bool { + return ih == nil +} diff --git a/data/sovereign/incomingHeader.pb.go b/data/sovereign/incomingHeader.pb.go new file mode 100644 index 00000000..91b86477 --- /dev/null +++ b/data/sovereign/incomingHeader.pb.go @@ -0,0 +1,477 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: incomingHeader.proto + +package sovereign + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + block "github.com/multiversx/mx-chain-core-go/data/block" + transaction "github.com/multiversx/mx-chain-core-go/data/transaction" + io "io" + math "math" + math_bits "math/bits" + reflect "reflect" + strings "strings" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type IncomingHeader struct { + Header *block.HeaderV2 `protobuf:"bytes,1,opt,name=Header,proto3" json:"header"` + IncomingEvents []*transaction.Event `protobuf:"bytes,2,rep,name=IncomingEvents,proto3" json:"incomingEvents,omitempty"` +} + +func (m *IncomingHeader) Reset() { *m = IncomingHeader{} } +func (*IncomingHeader) ProtoMessage() {} +func (*IncomingHeader) Descriptor() ([]byte, []int) { + return fileDescriptor_dd583eddd7d6ee94, []int{0} +} +func (m *IncomingHeader) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IncomingHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *IncomingHeader) XXX_Merge(src proto.Message) { + xxx_messageInfo_IncomingHeader.Merge(m, src) +} +func (m *IncomingHeader) XXX_Size() int { + return m.Size() +} +func (m *IncomingHeader) XXX_DiscardUnknown() { + xxx_messageInfo_IncomingHeader.DiscardUnknown(m) +} + +var xxx_messageInfo_IncomingHeader proto.InternalMessageInfo + +func (m *IncomingHeader) GetHeader() *block.HeaderV2 { + if m != nil { + return m.Header + } + return nil +} + +func (m *IncomingHeader) GetIncomingEvents() []*transaction.Event { + if m != nil { + return m.IncomingEvents + } + return nil +} + +func init() { + proto.RegisterType((*IncomingHeader)(nil), "proto.IncomingHeader") +} + +func init() { proto.RegisterFile("incomingHeader.proto", fileDescriptor_dd583eddd7d6ee94) } + +var fileDescriptor_dd583eddd7d6ee94 = []byte{ + // 309 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x8f, 0xb1, 0x4e, 0x72, 0x31, + 0x14, 0xc7, 0x6f, 0xbf, 0x2f, 0x92, 0x78, 0x31, 0x9a, 0x10, 0x07, 0x42, 0xcc, 0x81, 0x38, 0x31, + 0x78, 0xb9, 0xc9, 0xe5, 0x01, 0x8c, 0x18, 0x13, 0x5d, 0x19, 0x18, 0xdc, 0x7a, 0x4b, 0x2d, 0x8d, + 0xb4, 0x87, 0xf4, 0x16, 0x82, 0x9b, 0x8f, 0xe0, 0xea, 0x1b, 0xf8, 0x28, 0x8e, 0x8c, 0x4c, 0x44, + 0xca, 0x62, 0x98, 0x78, 0x04, 0x93, 0xf6, 0x26, 0x8a, 0x9b, 0x4b, 0x7b, 0xfe, 0xff, 0xfc, 0xce, + 0xaf, 0x69, 0x7c, 0x2a, 0x35, 0x43, 0x25, 0xb5, 0xb8, 0xe5, 0x74, 0xc8, 0x4d, 0x67, 0x62, 0xd0, + 0x62, 0xed, 0xc0, 0x5f, 0x8d, 0x44, 0x48, 0x3b, 0x9a, 0xe6, 0x1d, 0x86, 0x2a, 0x15, 0x28, 0x30, + 0xf5, 0x75, 0x3e, 0x7d, 0xf0, 0xc9, 0x07, 0x3f, 0x85, 0xad, 0xc6, 0xe5, 0x0f, 0x5c, 0x4d, 0xc7, + 0x56, 0xce, 0xb8, 0x29, 0xe6, 0xa9, 0x9a, 0x27, 0x6c, 0x44, 0xa5, 0x4e, 0x18, 0x1a, 0x9e, 0x08, + 0x4c, 0x87, 0xd4, 0xd2, 0x34, 0x1f, 0x23, 0x7b, 0x0c, 0xe7, 0x20, 0x2b, 0x05, 0x57, 0x7f, 0x11, + 0x58, 0x43, 0x75, 0x41, 0x99, 0x95, 0xa8, 0xd3, 0x31, 0x8a, 0xa0, 0x38, 0x7f, 0x25, 0xf1, 0xf1, + 0xdd, 0xde, 0x97, 0x6a, 0xdd, 0xb8, 0x12, 0xa6, 0x3a, 0x69, 0x91, 0x76, 0x35, 0x3b, 0x09, 0x68, + 0x27, 0x94, 0x83, 0xac, 0x17, 0x6f, 0x57, 0xcd, 0xca, 0xc8, 0xa7, 0x7e, 0x89, 0xd6, 0xfa, 0xdf, + 0x9a, 0x9b, 0x19, 0xd7, 0xb6, 0xa8, 0xff, 0x6b, 0xfd, 0x6f, 0x57, 0xb3, 0xa3, 0x72, 0xd9, 0x97, + 0xbd, 0xb3, 0xed, 0xaa, 0x59, 0x97, 0x7b, 0xdc, 0x05, 0x2a, 0x69, 0xb9, 0x9a, 0xd8, 0xa7, 0xfe, + 0x2f, 0x43, 0xef, 0x7a, 0xb1, 0x86, 0x68, 0xb9, 0x86, 0x68, 0xb7, 0x06, 0xf2, 0xec, 0x80, 0xbc, + 0x39, 0x20, 0xef, 0x0e, 0xc8, 0xc2, 0x01, 0x59, 0x3a, 0x20, 0x1f, 0x0e, 0xc8, 0xa7, 0x83, 0x68, + 0xe7, 0x80, 0xbc, 0x6c, 0x20, 0x5a, 0x6c, 0x20, 0x5a, 0x6e, 0x20, 0xba, 0x3f, 0x2c, 0x70, 0xc6, + 0x0d, 0x97, 0x42, 0xe7, 0x15, 0xff, 0x7e, 0xf7, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xec, 0x68, 0xc0, + 0x62, 0xb9, 0x01, 0x00, 0x00, +} + +func (this *IncomingHeader) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*IncomingHeader) + if !ok { + that2, ok := that.(IncomingHeader) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Header.Equal(that1.Header) { + return false + } + if len(this.IncomingEvents) != len(that1.IncomingEvents) { + return false + } + for i := range this.IncomingEvents { + if !this.IncomingEvents[i].Equal(that1.IncomingEvents[i]) { + return false + } + } + return true +} +func (this *IncomingHeader) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&sovereign.IncomingHeader{") + if this.Header != nil { + s = append(s, "Header: "+fmt.Sprintf("%#v", this.Header)+",\n") + } + if this.IncomingEvents != nil { + s = append(s, "IncomingEvents: "+fmt.Sprintf("%#v", this.IncomingEvents)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringIncomingHeader(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *IncomingHeader) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IncomingHeader) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IncomingHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.IncomingEvents) > 0 { + for iNdEx := len(m.IncomingEvents) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.IncomingEvents[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintIncomingHeader(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Header != nil { + { + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintIncomingHeader(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintIncomingHeader(dAtA []byte, offset int, v uint64) int { + offset -= sovIncomingHeader(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *IncomingHeader) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Header != nil { + l = m.Header.Size() + n += 1 + l + sovIncomingHeader(uint64(l)) + } + if len(m.IncomingEvents) > 0 { + for _, e := range m.IncomingEvents { + l = e.Size() + n += 1 + l + sovIncomingHeader(uint64(l)) + } + } + return n +} + +func sovIncomingHeader(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozIncomingHeader(x uint64) (n int) { + return sovIncomingHeader(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *IncomingHeader) String() string { + if this == nil { + return "nil" + } + repeatedStringForIncomingEvents := "[]*Event{" + for _, f := range this.IncomingEvents { + repeatedStringForIncomingEvents += strings.Replace(fmt.Sprintf("%v", f), "Event", "transaction.Event", 1) + "," + } + repeatedStringForIncomingEvents += "}" + s := strings.Join([]string{`&IncomingHeader{`, + `Header:` + strings.Replace(fmt.Sprintf("%v", this.Header), "HeaderV2", "block.HeaderV2", 1) + `,`, + `IncomingEvents:` + repeatedStringForIncomingEvents + `,`, + `}`, + }, "") + return s +} +func valueToStringIncomingHeader(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *IncomingHeader) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIncomingHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IncomingHeader: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IncomingHeader: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIncomingHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthIncomingHeader + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthIncomingHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Header == nil { + m.Header = &block.HeaderV2{} + } + if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IncomingEvents", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIncomingHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthIncomingHeader + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthIncomingHeader + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IncomingEvents = append(m.IncomingEvents, &transaction.Event{}) + if err := m.IncomingEvents[len(m.IncomingEvents)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipIncomingHeader(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthIncomingHeader + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthIncomingHeader + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipIncomingHeader(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowIncomingHeader + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowIncomingHeader + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowIncomingHeader + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthIncomingHeader + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupIncomingHeader + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthIncomingHeader + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthIncomingHeader = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowIncomingHeader = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupIncomingHeader = fmt.Errorf("proto: unexpected end of group") +) diff --git a/data/sovereign/incomingHeader.proto b/data/sovereign/incomingHeader.proto new file mode 100644 index 00000000..1e3c6c10 --- /dev/null +++ b/data/sovereign/incomingHeader.proto @@ -0,0 +1,17 @@ +// This file holds data structures related to incoming headers from one chain(local/main/test/etc.) to a sovereign chain. +// This incoming header will be received from a notifier. In the future, this will also hold a proof of the incoming operations +syntax = "proto3"; + +package proto; + +option go_package = "sovereign"; +option (gogoproto.stable_marshaler_all) = true; + +import "github.com/gogo/protobuf/gogoproto/gogo.proto"; +import "github.com/multiversx/mx-chain-core-go/data/block/blockV2.proto"; +import "github.com/multiversx/mx-chain-core-go/data/transaction/log.proto"; + +message IncomingHeader { + HeaderV2 Header = 1 [(gogoproto.jsontag) = "header"]; + repeated Event IncomingEvents = 2 [(gogoproto.jsontag) = "incomingEvents,omitempty"]; +} diff --git a/data/sovereign/interface.go b/data/sovereign/interface.go new file mode 100644 index 00000000..c68865da --- /dev/null +++ b/data/sovereign/interface.go @@ -0,0 +1,18 @@ +package sovereign + +import "github.com/multiversx/mx-chain-core-go/data" + +// IncomingHeaderHandler defines the incoming header to a sovereign chain that is sent by a notifier +type IncomingHeaderHandler interface { + GetIncomingEventHandlers() []data.EventHandler + GetHeaderHandler() data.HeaderHandler + IsInterfaceNil() bool +} + +// Proof defines the proof of proposed mini blocks, using provided incoming header and events +type Proof interface { + GetHeaderHandler() data.HeaderHandler + GetIncomingEventHandlers() []data.EventHandler + GetIncomingMiniBlockHandlers() []data.MiniBlockHandler + IsInterfaceNil() bool +} diff --git a/data/sovereign/operationData.go b/data/sovereign/operationData.go new file mode 100644 index 00000000..b62a8253 --- /dev/null +++ b/data/sovereign/operationData.go @@ -0,0 +1,34 @@ +package sovereign + +import ( + "math/big" + + "github.com/multiversx/mx-chain-core-go/core" +) + +// Operation holds the data needed for an outgoing operation +type Operation struct { + Address []byte + Tokens []EsdtToken + Data *EventData +} + +// EsdtToken holds the token data +type EsdtToken struct { + Identifier []byte + Nonce uint64 + Data EsdtTokenData +} + +// EsdtTokenData holds the properties for a token +type EsdtTokenData struct { + TokenType core.ESDTType + Amount *big.Int + Frozen bool + Hash []byte + Name []byte + Attributes []byte + Creator []byte + Royalties *big.Int + Uris [][]byte +} diff --git a/data/sovereign/outGoingBridgeData.go b/data/sovereign/outGoingBridgeData.go new file mode 100644 index 00000000..82e6be31 --- /dev/null +++ b/data/sovereign/outGoingBridgeData.go @@ -0,0 +1,2 @@ +//go:generate protoc -I=. --go_out=$GOPATH/src --go-grpc_out=$GOPATH/src outGoingBridgeData.proto +package sovereign diff --git a/data/sovereign/outGoingBridgeData.pb.go b/data/sovereign/outGoingBridgeData.pb.go new file mode 100644 index 00000000..01a4fa32 --- /dev/null +++ b/data/sovereign/outGoingBridgeData.pb.go @@ -0,0 +1,244 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: outGoingBridgeData.proto + +package sovereign + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type BridgeOperations struct { + Data []*BridgeOutGoingData `protobuf:"bytes,1,rep,name=Data,proto3" json:"Data,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *BridgeOperations) Reset() { *m = BridgeOperations{} } +func (m *BridgeOperations) String() string { return proto.CompactTextString(m) } +func (*BridgeOperations) ProtoMessage() {} +func (*BridgeOperations) Descriptor() ([]byte, []int) { + return fileDescriptor_62fb23e431426efc, []int{0} +} + +func (m *BridgeOperations) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_BridgeOperations.Unmarshal(m, b) +} +func (m *BridgeOperations) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_BridgeOperations.Marshal(b, m, deterministic) +} +func (m *BridgeOperations) XXX_Merge(src proto.Message) { + xxx_messageInfo_BridgeOperations.Merge(m, src) +} +func (m *BridgeOperations) XXX_Size() int { + return xxx_messageInfo_BridgeOperations.Size(m) +} +func (m *BridgeOperations) XXX_DiscardUnknown() { + xxx_messageInfo_BridgeOperations.DiscardUnknown(m) +} + +var xxx_messageInfo_BridgeOperations proto.InternalMessageInfo + +func (m *BridgeOperations) GetData() []*BridgeOutGoingData { + if m != nil { + return m.Data + } + return nil +} + +type BridgeOutGoingData struct { + Hash []byte `protobuf:"bytes,1,opt,name=Hash,proto3" json:"Hash,omitempty"` + OutGoingOperations []*OutGoingOperation `protobuf:"bytes,2,rep,name=OutGoingOperations,proto3" json:"OutGoingOperations,omitempty"` + AggregatedSignature []byte `protobuf:"bytes,3,opt,name=AggregatedSignature,proto3" json:"AggregatedSignature,omitempty"` + LeaderSignature []byte `protobuf:"bytes,4,opt,name=LeaderSignature,proto3" json:"LeaderSignature,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *BridgeOutGoingData) Reset() { *m = BridgeOutGoingData{} } +func (m *BridgeOutGoingData) String() string { return proto.CompactTextString(m) } +func (*BridgeOutGoingData) ProtoMessage() {} +func (*BridgeOutGoingData) Descriptor() ([]byte, []int) { + return fileDescriptor_62fb23e431426efc, []int{1} +} + +func (m *BridgeOutGoingData) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_BridgeOutGoingData.Unmarshal(m, b) +} +func (m *BridgeOutGoingData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_BridgeOutGoingData.Marshal(b, m, deterministic) +} +func (m *BridgeOutGoingData) XXX_Merge(src proto.Message) { + xxx_messageInfo_BridgeOutGoingData.Merge(m, src) +} +func (m *BridgeOutGoingData) XXX_Size() int { + return xxx_messageInfo_BridgeOutGoingData.Size(m) +} +func (m *BridgeOutGoingData) XXX_DiscardUnknown() { + xxx_messageInfo_BridgeOutGoingData.DiscardUnknown(m) +} + +var xxx_messageInfo_BridgeOutGoingData proto.InternalMessageInfo + +func (m *BridgeOutGoingData) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + +func (m *BridgeOutGoingData) GetOutGoingOperations() []*OutGoingOperation { + if m != nil { + return m.OutGoingOperations + } + return nil +} + +func (m *BridgeOutGoingData) GetAggregatedSignature() []byte { + if m != nil { + return m.AggregatedSignature + } + return nil +} + +func (m *BridgeOutGoingData) GetLeaderSignature() []byte { + if m != nil { + return m.LeaderSignature + } + return nil +} + +type OutGoingOperation struct { + Hash []byte `protobuf:"bytes,1,opt,name=Hash,proto3" json:"Hash,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *OutGoingOperation) Reset() { *m = OutGoingOperation{} } +func (m *OutGoingOperation) String() string { return proto.CompactTextString(m) } +func (*OutGoingOperation) ProtoMessage() {} +func (*OutGoingOperation) Descriptor() ([]byte, []int) { + return fileDescriptor_62fb23e431426efc, []int{2} +} + +func (m *OutGoingOperation) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_OutGoingOperation.Unmarshal(m, b) +} +func (m *OutGoingOperation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_OutGoingOperation.Marshal(b, m, deterministic) +} +func (m *OutGoingOperation) XXX_Merge(src proto.Message) { + xxx_messageInfo_OutGoingOperation.Merge(m, src) +} +func (m *OutGoingOperation) XXX_Size() int { + return xxx_messageInfo_OutGoingOperation.Size(m) +} +func (m *OutGoingOperation) XXX_DiscardUnknown() { + xxx_messageInfo_OutGoingOperation.DiscardUnknown(m) +} + +var xxx_messageInfo_OutGoingOperation proto.InternalMessageInfo + +func (m *OutGoingOperation) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + +func (m *OutGoingOperation) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + +type BridgeOperationsResponse struct { + TxHashes []string `protobuf:"bytes,1,rep,name=TxHashes,proto3" json:"TxHashes,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *BridgeOperationsResponse) Reset() { *m = BridgeOperationsResponse{} } +func (m *BridgeOperationsResponse) String() string { return proto.CompactTextString(m) } +func (*BridgeOperationsResponse) ProtoMessage() {} +func (*BridgeOperationsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_62fb23e431426efc, []int{3} +} + +func (m *BridgeOperationsResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_BridgeOperationsResponse.Unmarshal(m, b) +} +func (m *BridgeOperationsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_BridgeOperationsResponse.Marshal(b, m, deterministic) +} +func (m *BridgeOperationsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_BridgeOperationsResponse.Merge(m, src) +} +func (m *BridgeOperationsResponse) XXX_Size() int { + return xxx_messageInfo_BridgeOperationsResponse.Size(m) +} +func (m *BridgeOperationsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_BridgeOperationsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_BridgeOperationsResponse proto.InternalMessageInfo + +func (m *BridgeOperationsResponse) GetTxHashes() []string { + if m != nil { + return m.TxHashes + } + return nil +} + +func init() { + proto.RegisterType((*BridgeOperations)(nil), "sovereign.BridgeOperations") + proto.RegisterType((*BridgeOutGoingData)(nil), "sovereign.BridgeOutGoingData") + proto.RegisterType((*OutGoingOperation)(nil), "sovereign.OutGoingOperation") + proto.RegisterType((*BridgeOperationsResponse)(nil), "sovereign.BridgeOperationsResponse") +} + +func init() { + proto.RegisterFile("outGoingBridgeData.proto", fileDescriptor_62fb23e431426efc) +} + +var fileDescriptor_62fb23e431426efc = []byte{ + // 320 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0x4f, 0x4b, 0xc3, 0x40, + 0x10, 0xc5, 0x4d, 0x1b, 0xc4, 0x8e, 0xe2, 0x9f, 0xf1, 0x12, 0xaa, 0x42, 0x89, 0x97, 0x5e, 0x9a, + 0x68, 0x05, 0x2f, 0x3d, 0x48, 0x8b, 0xa2, 0x48, 0x41, 0x48, 0x7b, 0x12, 0x2f, 0xdb, 0x66, 0xd8, + 0x2e, 0xd8, 0xdd, 0xb2, 0xbb, 0x29, 0xf9, 0x9c, 0x7e, 0x22, 0xc9, 0xb6, 0x4d, 0xa5, 0x29, 0xde, + 0x66, 0xe7, 0xfd, 0x66, 0x1e, 0xfb, 0x76, 0x21, 0x50, 0x99, 0x7d, 0x55, 0x42, 0xf2, 0x81, 0x16, + 0x29, 0xa7, 0x67, 0x66, 0x59, 0xb4, 0xd0, 0xca, 0x2a, 0x6c, 0x18, 0xb5, 0x24, 0x4d, 0x82, 0xcb, + 0xf0, 0x05, 0xce, 0x57, 0xf2, 0xc7, 0x82, 0x34, 0xb3, 0x42, 0x49, 0x83, 0xf7, 0xe0, 0x17, 0x70, + 0xe0, 0xb5, 0xea, 0xed, 0xe3, 0xee, 0x4d, 0x54, 0xd2, 0xd1, 0x1a, 0x5d, 0xef, 0x2d, 0xa0, 0xc4, + 0xa1, 0xe1, 0x8f, 0x07, 0x58, 0x15, 0x11, 0xc1, 0x7f, 0x63, 0x66, 0x16, 0x78, 0x2d, 0xaf, 0x7d, + 0x92, 0xb8, 0x1a, 0x87, 0x80, 0x1b, 0x66, 0xeb, 0x19, 0xd4, 0x9c, 0xd7, 0xf5, 0x1f, 0xaf, 0x0a, + 0x94, 0xec, 0x99, 0xc3, 0x3b, 0xb8, 0xec, 0x73, 0xae, 0x89, 0x33, 0x4b, 0xe9, 0x48, 0x70, 0xc9, + 0x6c, 0xa6, 0x29, 0xa8, 0x3b, 0xc3, 0x7d, 0x12, 0xb6, 0xe1, 0x6c, 0x48, 0x2c, 0x25, 0xbd, 0xa5, + 0x7d, 0x47, 0xef, 0xb6, 0xc3, 0x1e, 0x5c, 0x54, 0x1c, 0xf7, 0x5e, 0x09, 0xd7, 0x81, 0xd5, 0x56, + 0x3d, 0x97, 0xc8, 0x23, 0x04, 0xbb, 0xc1, 0x26, 0x64, 0x16, 0x4a, 0x1a, 0xc2, 0x26, 0x1c, 0x8d, + 0xf3, 0x62, 0x92, 0x8c, 0x0b, 0xb9, 0x91, 0x94, 0xe7, 0xee, 0x17, 0x9c, 0xae, 0xe6, 0xc6, 0xf9, + 0x88, 0x64, 0x4a, 0x1a, 0xdf, 0xc1, 0x2f, 0x2a, 0xbc, 0xaa, 0x3e, 0x44, 0xb9, 0xba, 0x79, 0xfb, + 0x8f, 0xb8, 0xf1, 0x0d, 0x0f, 0x06, 0xfd, 0xcf, 0x27, 0x2e, 0xec, 0x2c, 0x9b, 0x44, 0x53, 0x35, + 0x8f, 0xe7, 0xd9, 0xb7, 0x15, 0x4b, 0xd2, 0x26, 0x8f, 0xe7, 0x79, 0x67, 0x3a, 0x63, 0x42, 0x76, + 0xa6, 0x4a, 0x53, 0x87, 0xab, 0x38, 0x65, 0x96, 0xc5, 0xe5, 0xce, 0x5e, 0x59, 0x4d, 0x0e, 0xdd, + 0x1f, 0x7a, 0xf8, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x55, 0xb2, 0xc7, 0x90, 0x5f, 0x02, 0x00, 0x00, +} diff --git a/data/sovereign/outGoingBridgeData.proto b/data/sovereign/outGoingBridgeData.proto new file mode 100644 index 00000000..63a7b272 --- /dev/null +++ b/data/sovereign/outGoingBridgeData.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; + +package sovereign; +option go_package = "github.com/multiversx/mx-chain-core-go/data/sovereign;sovereign"; + +message BridgeOperations { + repeated BridgeOutGoingData Data = 1; +} + +message BridgeOutGoingData { + bytes Hash = 1; + repeated OutGoingOperation OutGoingOperations = 2; + bytes AggregatedSignature = 3; + bytes LeaderSignature = 4; +} + +message OutGoingOperation { + bytes Hash = 1; + bytes Data = 2; +} + +message BridgeOperationsResponse { + repeated string TxHashes = 1; +} + +service BridgeTxSender { + rpc Send(BridgeOperations) returns (BridgeOperationsResponse) {} +} diff --git a/data/sovereign/outGoingBridgeData_grpc.pb.go b/data/sovereign/outGoingBridgeData_grpc.pb.go new file mode 100644 index 00000000..b4a53d81 --- /dev/null +++ b/data/sovereign/outGoingBridgeData_grpc.pb.go @@ -0,0 +1,105 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.12.4 +// source: outGoingBridgeData.proto + +package sovereign + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// BridgeTxSenderClient is the client API for BridgeTxSender service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type BridgeTxSenderClient interface { + Send(ctx context.Context, in *BridgeOperations, opts ...grpc.CallOption) (*BridgeOperationsResponse, error) +} + +type bridgeTxSenderClient struct { + cc grpc.ClientConnInterface +} + +func NewBridgeTxSenderClient(cc grpc.ClientConnInterface) BridgeTxSenderClient { + return &bridgeTxSenderClient{cc} +} + +func (c *bridgeTxSenderClient) Send(ctx context.Context, in *BridgeOperations, opts ...grpc.CallOption) (*BridgeOperationsResponse, error) { + out := new(BridgeOperationsResponse) + err := c.cc.Invoke(ctx, "/sovereign.BridgeTxSender/Send", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// BridgeTxSenderServer is the server API for BridgeTxSender service. +// All implementations must embed UnimplementedBridgeTxSenderServer +// for forward compatibility +type BridgeTxSenderServer interface { + Send(context.Context, *BridgeOperations) (*BridgeOperationsResponse, error) + mustEmbedUnimplementedBridgeTxSenderServer() +} + +// UnimplementedBridgeTxSenderServer must be embedded to have forward compatible implementations. +type UnimplementedBridgeTxSenderServer struct { +} + +func (UnimplementedBridgeTxSenderServer) Send(context.Context, *BridgeOperations) (*BridgeOperationsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Send not implemented") +} +func (UnimplementedBridgeTxSenderServer) mustEmbedUnimplementedBridgeTxSenderServer() {} + +// UnsafeBridgeTxSenderServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to BridgeTxSenderServer will +// result in compilation errors. +type UnsafeBridgeTxSenderServer interface { + mustEmbedUnimplementedBridgeTxSenderServer() +} + +func RegisterBridgeTxSenderServer(s grpc.ServiceRegistrar, srv BridgeTxSenderServer) { + s.RegisterService(&BridgeTxSender_ServiceDesc, srv) +} + +func _BridgeTxSender_Send_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BridgeOperations) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BridgeTxSenderServer).Send(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/sovereign.BridgeTxSender/Send", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BridgeTxSenderServer).Send(ctx, req.(*BridgeOperations)) + } + return interceptor(ctx, in, info, handler) +} + +// BridgeTxSender_ServiceDesc is the grpc.ServiceDesc for BridgeTxSender service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var BridgeTxSender_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "sovereign.BridgeTxSender", + HandlerType: (*BridgeTxSenderServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Send", + Handler: _BridgeTxSender_Send_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "outGoingBridgeData.proto", +} diff --git a/data/transaction/interface.go b/data/transaction/status/interface.go similarity index 51% rename from data/transaction/interface.go rename to data/transaction/status/interface.go index cbc0bb1c..d9f5de85 100644 --- a/data/transaction/interface.go +++ b/data/transaction/status/interface.go @@ -1,13 +1,16 @@ -package transaction +package status -import "github.com/multiversx/mx-chain-core-go/data/block" +import ( + "github.com/multiversx/mx-chain-core-go/data/block" + "github.com/multiversx/mx-chain-core-go/data/transaction" +) // StatusComputerHandler computes a transaction status type StatusComputerHandler interface { - ComputeStatusWhenInStorageKnowingMiniblock(miniblockType block.Type, tx *ApiTransactionResult) (TxStatus, error) - ComputeStatusWhenInStorageNotKnowingMiniblock(destinationShard uint32, tx *ApiTransactionResult) (TxStatus, error) + ComputeStatusWhenInStorageKnowingMiniblock(miniblockType block.Type, tx *transaction.ApiTransactionResult) (transaction.TxStatus, error) + ComputeStatusWhenInStorageNotKnowingMiniblock(destinationShard uint32, tx *transaction.ApiTransactionResult) (transaction.TxStatus, error) SetStatusIfIsRewardReverted( - tx *ApiTransactionResult, + tx *transaction.ApiTransactionResult, miniblockType block.Type, headerNonce uint64, headerHash []byte, diff --git a/go.mod b/go.mod index 26892ac4..e90f990e 100644 --- a/go.mod +++ b/go.mod @@ -6,19 +6,23 @@ require ( github.com/btcsuite/btcd/btcutil v1.1.3 github.com/denisbrodbeck/machineid v1.0.1 github.com/gogo/protobuf v1.3.2 - github.com/golang/protobuf v1.5.2 + github.com/golang/protobuf v1.5.3 github.com/mr-tron/base58 v1.2.0 github.com/pelletier/go-toml v1.9.3 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.7.0 - golang.org/x/crypto v0.3.0 + golang.org/x/crypto v0.14.0 + google.golang.org/grpc v1.60.1 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/sys v0.2.0 // indirect - google.golang.org/protobuf v1.26.0 // indirect + golang.org/x/net v0.16.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect ) diff --git a/go.sum b/go.sum index 1b4ae877..839b1b7a 100644 --- a/go.sum +++ b/go.sum @@ -38,14 +38,14 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= @@ -79,13 +79,15 @@ github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45 golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A= -golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos= +golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -96,16 +98,21 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY= +google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= +google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -113,8 +120,9 @@ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miE google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=