Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardfork: execute pending txs in correct order #2471

Merged

Conversation

SebastianMarian
Copy link
Contributor

  • Implemented a fix in Hardfork mechanism, which would execute all pending transactions in the correct order
  • Exported/Imported unFinished metaBlocks as well, as they are needed for execution of pending transactions in the correct order
  • Extracted common used code in a new file
  • Refactored some prints and some methods names

…nding transactions in the correct order

* Exported/Imported unFinished metaBlocks as well, as they are needed for execution of pending transactions in the correct order
* Extracted common used code in a new file
* Refactored some prints and some methods names
@SebastianMarian SebastianMarian added type:bug Something isn't working type:feature New feature or request labels Nov 13, 2020
@SebastianMarian SebastianMarian self-assigned this Nov 13, 2020
@SebastianMarian SebastianMarian changed the title Hradfork: execute pending txs in correct order Hardfork: execute pending txs in correct order Nov 13, 2020
@sasurobert sasurobert self-requested a review November 14, 2020 09:05
update/common.go Outdated
}

// CreateNonceToHashMap creates a map of nonce to hash from all the given metaBlocks
func CreateNonceToHashMap(unFinishedMetaBlocks map[string]*block.MetaBlock) map[uint64]string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need all these functions exported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, only GetPendingMiniBlocks, I will make them unexported

}

for _, mbHdr := range metaBlock.MiniBlockHeaders {
if mbHdr.ReceiverShardID == destShardID && mbHdr.SenderShardID != destShardID {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isForMe := (mbHdr.ReceiverShardID == destShardID || mbHdr.ReceiverShardID == core.AllShardId) && mbHdr.SenderShardID != destShardID

as we have to take into account all shard ID value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually core.AllShardId refers to PeerBlock right now, and PendingTransactionProcessor does not know to process this type of miniblock. More than this, in the commented code above from line 49 this type of miniblock was also avoided in the original code. Actually, the whole file is just a copy-paste of the original one with slightly renaming here and there. We should discuss/analyze if this type of miniblock which could appear only in the start of epoch metablock (hardfork meta block) should be executed or not in the import phase or it would be executed in a normal way afterwards.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, more mental mapping to have as to not use core.AllShardId on miniblocks other than peer miniblocks because there are some edgecases.

func (p *pendingProcessor) ProcessTransactionsDstMe(mapTxs map[string]data.TransactionHandler) (block.MiniBlockSlice, error) {
sortedTxs := getSortedSliceFromTxsMap(mapTxs)

func (p *pendingProcessor) ProcessTransactionsDstMe(txsInfo []*update.TxInfo) (block.MiniBlockSlice, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return nil, update.ErrTransactionNotFoundInImportedMap
}

txsInfo = append(txsInfo, &update.TxInfo{TxHash: txHash, Tx: tx})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multiline?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

update/common.go Outdated Show resolved Hide resolved
update/genesis/export.go Show resolved Hide resolved
@@ -161,6 +164,45 @@ func (s *shardBlockCreator) createBody() (*block.Body, error) {
}, nil
}

func (s *shardBlockCreator) getPendingTxsInCorrectOrder() ([]*update.TxInfo, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might go one miniblock at a time - in order to protect against out of memory issues

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you refering to OOM in this method or afterwards when we call with the []*update.TxInfo result the method ProcessTransactionsDstMe ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOM in for all when you have millions of transactions.

Copy link
Contributor

@stefanandy stefanandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

System test passed

@LucianMincu LucianMincu merged commit 7071483 into development Nov 18, 2020
@LucianMincu LucianMincu deleted the Hardfork-execute-pending-txs-in-correct-order branch November 18, 2020 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working type:feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants