-
Notifications
You must be signed in to change notification settings - Fork 664
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
challenges_root #1957
challenges_root #1957
Conversation
core/primitives/src/block.rs
Outdated
@@ -596,6 +607,11 @@ impl Block { | |||
.0 | |||
} | |||
|
|||
pub fn compute_challenges_root(challenges: &Challenges) -> CryptoHash { | |||
merklize(&challenges.iter().map(|challenges| challenges.hash).collect::<Vec<CryptoHash>>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bowenwang1996 can I rely that challenges are sorted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no they don't
Codecov Report
@@ Coverage Diff @@
## staging #1957 +/- ##
==========================================
Coverage ? 86.67%
==========================================
Files ? 167
Lines ? 31605
Branches ? 0
==========================================
Hits ? 27395
Misses ? 4210
Partials ? 0 Continue to review full report at Codecov.
|
4af8eaa
to
09a4466
Compare
core/primitives/src/block.rs
Outdated
pub fn compute_challenges_root(challenges: &Challenges) -> CryptoHash { | ||
let mut arr = | ||
challenges.iter().map(|challenges| challenges.hash).collect::<Vec<CryptoHash>>(); | ||
arr.sort(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does sort do here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does sort do here?
I've added test_elements_order
to merkle to show you. Should block hash be depended on order of challenges?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should because a block is produced by a given block producer and what we want to make sure is that other people cannot also produce blocks that have the same hash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, we can leave them unsorted.
Is it okay that having Block header, chunks and challenges it may be impossible to get same block hash because of order of challenges?
* challenges_root * test_elements_order * don't sort challenges * challenges -> challenge in closure * Merge branch 'staging' into challenges_root
Fixes #1921