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 peer consensus for the last confirmed domain block receipt (domain snap sync). #3082

Open
wants to merge 1 commit into
base: add-mmr-data-verification
Choose a base branch
from

Conversation

shamil-gadelshin
Copy link
Member

This PR modifies the last confirmed domain block execution receipt provider to return the receipt from the consensus of peers. The algorithm tries to gather multiple receipts from the neighboring peers and use the one with the maximum duplicates. It asks neighbors multiple times (ATTEMPTS_NUMBER constant) until it gathers the necessary amount of receipts (PEERS_THRESHOLD constant), otherwise, it takes the existing results and deduces the most popular receipt from that data.

Code contributor checklist:

Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

Makes sense to me, feel free to resolve my style comment if you don't want to change it

Comment on lines +210 to +213
receipts_hashes
.entry(receipt_hash)
.and_modify(|count: &mut u32| *count += 1)
.or_insert(1u32);
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: this is usually written idiomatically as:

Suggested change
receipts_hashes
.entry(receipt_hash)
.and_modify(|count: &mut u32| *count += 1)
.or_insert(1u32);
*receipts_hashes.entry(receipt_hash).or_default() += 1u32;

Or if you want to keep and_modify:

Suggested change
receipts_hashes
.entry(receipt_hash)
.and_modify(|count: &mut u32| *count += 1)
.or_insert(1u32);
receipts_hashes
.entry(receipt_hash)
.or_default()
.and_modify(|count: &mut u32| *count += 1)

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.

2 participants