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

Cache hash for receipt block #700

Merged
merged 2 commits into from
Mar 11, 2019
Merged

Cache hash for receipt block #700

merged 2 commits into from
Mar 11, 2019

Conversation

bowenwang1996
Copy link
Collaborator

No description provided.

// sufficient to uniquely identify the
// receipt block because of the uniqueness
// of nonce in receipts
pub hash: CryptoHash,
Copy link
Contributor

@MaksymZavershynskyi MaksymZavershynskyi Mar 11, 2019

Choose a reason for hiding this comment

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

This has some issues with serialization:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure if we want to do this right now. If so, we need to fix SignedTransaction, SignedBeaconBlock, SignedBeaconBlockHeader, SignedShardBlock, and SignedShardBlockHeader as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

In general, we need to move to computing hashes once, so at some point, we will have to do this modification to the structs that you have listed. However, since we have decided to do it to one struct at the moment, ReceiptBlock, then why not do it correctly now. Especially since, the modification that I proposed does not add much code. Had it involved adding a lot of code, I would have agreed with your argument.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since the SignedBlock trait requires Sync, we cannot use RefCell in ReceiptBlock. I tried to use Mutex but since Mutex does not implement Clone, it also cannot satisfy the requirement of SignedBlock.

Copy link
Contributor

Choose a reason for hiding this comment

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

SignedBlock does not need neither Send nor Sync. I removed both of them and the project still compiles.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, it would have to be Arc<RefCell<Option<CryptoHash>>. I think it is complex enough to be postponed to a different PR.

// sufficient to uniquely identify the
// receipt block because of the uniqueness
// of nonce in receipts
pub hash: CryptoHash,
Copy link
Contributor

Choose a reason for hiding this comment

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

I see, it would have to be Arc<RefCell<Option<CryptoHash>>. I think it is complex enough to be postponed to a different PR.

@bowenwang1996 bowenwang1996 merged commit b53dc5b into master Mar 11, 2019
@bowenwang1996 bowenwang1996 deleted the cache-hash-for-receipt branch March 11, 2019 22:45
@ilblackdragon ilblackdragon added this to the AlphaNet milestone Mar 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants