Skip to content

Commit

Permalink
Merge pull request #170 from ElrondNetwork/delete-scrs-at-soruce
Browse files Browse the repository at this point in the history
Delete also scrs at source
  • Loading branch information
miiu96 authored Sep 20, 2022
2 parents 0c41f75 + d4b2b44 commit 78d3e7f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
11 changes: 6 additions & 5 deletions process/transactions/transactionsProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ func (tdp *txsDatabaseProcessor) GetHexEncodedHashesForRemove(header coreData.He
encodedTxsHashes := make([]string, 0)
encodedScrsHashes := make([]string, 0)
for _, miniblock := range body.MiniBlocks {
if isCrossShardAtSourceAndNoRewardsMB(selfShardID, miniblock) {
// ignore cross-shard miniblocks at source ( exception to this rule are rewards miniblocks)
shouldIgnore := isCrossShardAtSourceNormalTx(selfShardID, miniblock)
if shouldIgnore {
// ignore cross-shard miniblocks at source with normal txs
continue
}

Expand All @@ -193,12 +194,12 @@ func (tdp *txsDatabaseProcessor) GetHexEncodedHashesForRemove(header coreData.He
return encodedTxsHashes, encodedScrsHashes
}

func isCrossShardAtSourceAndNoRewardsMB(selfShardID uint32, miniblock *block.MiniBlock) bool {
func isCrossShardAtSourceNormalTx(selfShardID uint32, miniblock *block.MiniBlock) bool {
isCrossShard := miniblock.SenderShardID != miniblock.ReceiverShardID
isAtSource := miniblock.SenderShardID == selfShardID
noRewardsMb := miniblock.Type != block.RewardsBlock
txBlock := miniblock.Type == block.TxBlock

return isCrossShard && isAtSource && noRewardsMb
return isCrossShard && isAtSource && txBlock
}

func shouldIgnoreProcessedMBScheduled(header coreData.HeaderHandler, mbIndex int) bool {
Expand Down
10 changes: 9 additions & 1 deletion process/transactions/transactionsProcessor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,14 +562,22 @@ func TestGetRewardsTxsHashesHexEncoded(t *testing.T) {
SenderShardID: 2,
ReceiverShardID: core.MetachainShardId,
},
{
TxHashes: [][]byte{
[]byte("h7"),
},
Type: block.SmartContractResultBlock,
SenderShardID: core.MetachainShardId,
ReceiverShardID: 0,
},
},
}

expectedHashes := []string{
"6831", "6832", "6833", "6835",
}
expectedScrHashes := []string{
"6836",
"6836", "6837",
}

txsHashes, scrHashes := txDBProc.GetHexEncodedHashesForRemove(header, body)
Expand Down

0 comments on commit 78d3e7f

Please sign in to comment.