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

Add receipts hash storer #2235

Merged
merged 5 commits into from
Aug 25, 2020
Merged

Add receipts hash storer #2235

merged 5 commits into from
Aug 25, 2020

Conversation

SebastianMarian
Copy link
Contributor

@SebastianMarian SebastianMarian commented Aug 24, 2020

  • Added receipts hash storer which holds cumulative receipt hash as a key and all the receipts hashes list marshalized as a value, for each committed block

Testing steps:

a) Prerequisites

b) Test steps

Start a normal testnet

c) Expected results

We should have another storage/folder/db created in: .../Epoch_X/Shard_Y/Receipts which holds cumulative receipt hash as a key and all the receipts hashes list marshalized as a value, for each committed block

d) Actual results

Test process is in pending

… key and all the receipts hashes list marshalized as a value
@SebastianMarian SebastianMarian added the type:feature New feature or request label Aug 24, 2020
@SebastianMarian SebastianMarian self-assigned this Aug 24, 2020
@sasurobert sasurobert self-requested a review August 24, 2020 15:19
log.Warn("saveBody.CreateMarshalizedReceipts", "error", errNotCritical.Error())
}

errNotCritical = bp.store.Put(dataRetriever.ReceiptsUnit, finalReceiptHash, marshalizedReceiptsHashes)
Copy link
Contributor

Choose a reason for hiding this comment

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

the problem is not resolved. The saving key for this data structure should come from shardHdr.ReceiptsHash not a new computed hash. otherwise you will not find it,

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 is not a new computed, it will be exactly the one from shardHdr as this check and the hash calculation is already done in ProcessBlock by calling VerifyCreatedBlockTransactions wich uses the same pattern.

return nil, nil, err
}

return finalReceiptHash, marshalizedReceiptsHashes, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to return finalReceiptHash - use the one from shard Header

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I do not have header in caller method but could be added

sasurobert
sasurobert previously approved these changes Aug 24, 2020
@AdoAdoAdo AdoAdoAdo self-requested a review August 25, 2020 06:31
Name = "ReceiptsStorage"
Capacity = 1000
Type = "SizeLRU"
SizeInBytes = 104857600 #100MB
Copy link
Contributor

Choose a reason for hiding this comment

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

usually we set a larger cache capacity if there are reads on recent data so we can have them prepared, in this case I don't think we need 100 MB cache as this is currently seldom read.
I would set it to at most 50 MB.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I also thought that this size is too much when I have copied paste this setting from miniblocks but I forgot to adjust it. I think 10 MB is enough for this kind of receipts as regularly should be < 100 bytes per record/block (1 hash as a key and 1 marshalized hash as a value)

FilePath = "Receipts"
Type = "LvlDBSerial"
BatchDelaySeconds = 2
MaxBatchSize = 100
Copy link
Contributor

@AdoAdoAdo AdoAdoAdo Aug 25, 2020

Choose a reason for hiding this comment

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

this batch size is for separate receipts or aggregated receipts?
If it is for individual receipts, then I would set the size equal to the transaction batch size.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is for the aggregated receipts: key = aggregated receipts hash and value = marshalized individual receipts hashes list. So it is max one record per each block

log.Warn("saveAllTransactionsToStorageIfSelfShard.CreateMarshalizedReceipts", "error", errNotCritical.Error())
}

errNotCritical = s.storage.Put(dataRetriever.ReceiptsUnit, shardHdr.GetReceiptsHash(), marshalizedReceiptsHashes)
Copy link
Contributor

Choose a reason for hiding this comment

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

what if there was an errNotCritical, do we save nil for the marshalizedReceiptHashes? I think in that case the put should be skipped

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, also it should be avoided if len(shardHdr.GetReceiptsHash()) is 0 I think

log.Warn("saveBody.CreateMarshalizedReceipts", "error", errNotCritical.Error())
}

errNotCritical = bp.store.Put(dataRetriever.ReceiptsUnit, header.GetReceiptsHash(), marshalizedReceiptsHashes)
Copy link
Contributor

Choose a reason for hiding this comment

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

if there was an error previously you are storing nil, I think you should skip instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, also it should be avoided if len(shardHdr.GetReceiptsHash()) is 0 I think

Copy link
Contributor

@LucianMincu LucianMincu left a comment

Choose a reason for hiding this comment

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

System tests passed.

@LucianMincu LucianMincu merged commit 8a3e354 into development Aug 25, 2020
@LucianMincu LucianMincu deleted the Add-receipts-hash-storer branch August 25, 2020 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants