-
Notifications
You must be signed in to change notification settings - Fork 51
Rename total_score to nonce in sync message #1864
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
Rename total_score to nonce in sync message #1864
Conversation
d3a5854 to
0eec7ff
Compare
723fc73 to
b26b5db
Compare
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.
It's good to use nonce instead of the total score. total_score isn't saved in the state and need the whole history to calculate it. It is hard to manage and verify total_score.
This commit removes last_request and uses nonce instead. Sync extension is using last_requset to give a unique id of requests. The sync extension will work even though we use nonce instead. However, one variable used by two different purposes makes maintenance hard. IMO using two variables for each purpose will make code maintainable.
Agreed. Let me separate those variables. |
b26b5db to
f03b60c
Compare
fb503c0 to
1b86afa
Compare
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.
Shouldn't we update the self.nonce when a new block is imported?
self.nonce was updated correctly.
When CodeChain is synchronized by snapshot sync, `total_score` doesn't mean the accumulated score from the genesis block. To handle this, the sync extension is updated to not rely on `total_score` for deciding whether a peer is leading or not, and use the value only as a monotonically increasing nonce.
1b86afa to
66ef929
Compare
This PR introduces a change in the sync extension message interpretation.
The
total_scoreinStatusmessage is now interpreted as a `nonce.When the snapshot sync lands, the
total_scoreof a block doesn't mean the total accumulated score from the genesis block anymore.To handle this, we need to avoid relying on the
total_scorefor synchronization.There were two parts to change:
best_hashin the local blockchain.noncein the status message.There are no changes in the message format itself, so I think it is a backward-compatible patch.