Skip to content

Commit

Permalink
fix requesting incoming SCRs
Browse files Browse the repository at this point in the history
  • Loading branch information
axenteoctavian committed Oct 24, 2024
1 parent 8068b30 commit fec7542
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
15 changes: 14 additions & 1 deletion cmd/sovereignnode/incomingHeader/extendedHeaderProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
}
}
15 changes: 2 additions & 13 deletions cmd/sovereignnode/incomingHeader/incomingHeaderProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -35,7 +34,6 @@ type incomingHeaderProcessor struct {
eventsProc *incomingEventsProcessor
extendedHeaderProc *extendedHeaderProcessor

txPool TransactionPool
outGoingPool sovereignBlock.OutGoingOperationsPool
mainChainNotarizationStartRound uint64
}
Expand Down Expand Up @@ -75,6 +73,7 @@ func NewIncomingHeaderProcessor(args ArgsIncomingHeaderProcessor) (*incomingHead

extendedHearProc := &extendedHeaderProcessor{
headersPool: args.HeadersPool,
txPool: args.TxPool,
marshaller: args.Marshaller,
hasher: args.Hasher,
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fec7542

Please sign in to comment.