From fec7542044c805fb54b5cdb4355ec6c0714e3dfa Mon Sep 17 00:00:00 2001 From: axenteoctavian Date: Thu, 24 Oct 2024 16:23:05 +0300 Subject: [PATCH] fix requesting incoming SCRs --- .../incomingHeader/extendedHeaderProcessor.go | 15 ++++++++++++++- .../incomingHeader/incomingHeaderProcessor.go | 15 ++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/cmd/sovereignnode/incomingHeader/extendedHeaderProcessor.go b/cmd/sovereignnode/incomingHeader/extendedHeaderProcessor.go index 0eecf47b258..e161d5e1af5 100644 --- a/cmd/sovereignnode/incomingHeader/extendedHeaderProcessor.go +++ b/cmd/sovereignnode/incomingHeader/extendedHeaderProcessor.go @@ -8,10 +8,13 @@ import ( "github.com/multiversx/mx-chain-core-go/data/transaction" "github.com/multiversx/mx-chain-core-go/hashing" "github.com/multiversx/mx-chain-core-go/marshal" + + "github.com/multiversx/mx-chain-go/process" ) type extendedHeaderProcessor struct { headersPool HeadersPool + txPool TransactionPool marshaller marshal.Marshalizer hasher hashing.Hasher } @@ -68,12 +71,22 @@ func createIncomingMb(scrs []*scrInfo) []*block.MiniBlock { } } -func (ehp *extendedHeaderProcessor) addExtendedHeaderToPool(extendedHeader data.ShardHeaderExtendedHandler) error { +func (ehp *extendedHeaderProcessor) addExtendedHeaderAndSCRsToPool(extendedHeader data.ShardHeaderExtendedHandler, scrs []*scrInfo) error { extendedHeaderHash, err := core.CalculateHash(ehp.marshaller, ehp.hasher, extendedHeader) if err != nil { return err } + ehp.addSCRsToPool(scrs) + ehp.headersPool.AddHeaderInShard(extendedHeaderHash, extendedHeader, core.MainChainShardId) return nil } + +func (ehp *extendedHeaderProcessor) addSCRsToPool(scrs []*scrInfo) { + cacheID := process.ShardCacherIdentifier(core.MainChainShardId, core.SovereignChainShardId) + + for _, scrData := range scrs { + ehp.txPool.AddData(scrData.hash, scrData.scr, scrData.scr.Size(), cacheID) + } +} diff --git a/cmd/sovereignnode/incomingHeader/incomingHeaderProcessor.go b/cmd/sovereignnode/incomingHeader/incomingHeaderProcessor.go index 7ed14822ed6..c7e794a93e3 100644 --- a/cmd/sovereignnode/incomingHeader/incomingHeaderProcessor.go +++ b/cmd/sovereignnode/incomingHeader/incomingHeaderProcessor.go @@ -5,7 +5,6 @@ import ( sovereignBlock "github.com/multiversx/mx-chain-go/dataRetriever/dataPool/sovereign" "github.com/multiversx/mx-chain-go/errors" - "github.com/multiversx/mx-chain-go/process" "github.com/multiversx/mx-chain-go/sovereignnode/dataCodec" "github.com/multiversx/mx-chain-core-go/core" @@ -35,7 +34,6 @@ type incomingHeaderProcessor struct { eventsProc *incomingEventsProcessor extendedHeaderProc *extendedHeaderProcessor - txPool TransactionPool outGoingPool sovereignBlock.OutGoingOperationsPool mainChainNotarizationStartRound uint64 } @@ -75,6 +73,7 @@ func NewIncomingHeaderProcessor(args ArgsIncomingHeaderProcessor) (*incomingHead extendedHearProc := &extendedHeaderProcessor{ headersPool: args.HeadersPool, + txPool: args.TxPool, marshaller: args.Marshaller, hasher: args.Hasher, } @@ -84,7 +83,6 @@ func NewIncomingHeaderProcessor(args ArgsIncomingHeaderProcessor) (*incomingHead return &incomingHeaderProcessor{ eventsProc: eventsProc, extendedHeaderProc: extendedHearProc, - txPool: args.TxPool, outGoingPool: args.OutGoingOperationsPool, mainChainNotarizationStartRound: args.MainChainNotarizationStartRound, }, nil @@ -116,24 +114,15 @@ func (ihp *incomingHeaderProcessor) AddHeader(headerHash []byte, header sovereig return err } - err = ihp.extendedHeaderProc.addExtendedHeaderToPool(extendedHeader) + err = ihp.extendedHeaderProc.addExtendedHeaderAndSCRsToPool(extendedHeader, res.scrs) if err != nil { return err } ihp.addConfirmedBridgeOpsToPool(res.confirmedBridgeOps) - ihp.addSCRsToPool(res.scrs) return nil } -func (ihp *incomingHeaderProcessor) addSCRsToPool(scrs []*scrInfo) { - cacheID := process.ShardCacherIdentifier(core.MainChainShardId, core.SovereignChainShardId) - - for _, scrData := range scrs { - ihp.txPool.AddData(scrData.hash, scrData.scr, scrData.scr.Size(), cacheID) - } -} - func (ihp *incomingHeaderProcessor) addConfirmedBridgeOpsToPool(ops []*confirmedBridgeOp) { for _, op := range ops { // This is not a critical error. This might just happen when a leader tries to re-send unconfirmed confirmation