-
Notifications
You must be signed in to change notification settings - Fork 12
Remove score in headers #21
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
Comments
I read the code, but it seems not easy. |
@sgkim126 @majecty @HoOngEe Parts using core/blockchainThe usage of "score"The // blockchain/extras.rs
pub struct BlockDetails {
pub number: BlockNumber,
/// Total score of the block and all its parents
pub total_score: U256,
pub parent: BlockHash,
} I think the most important parts where // best_block_changed() in blockchain/blockchain.rs
if parent_details_of_new_block.total_score + new_header.score() > self.best_proposal_block_detail().total_score
&& engine.can_change_canon_chain(
new_header.hash(),
parent_hash_of_new_block,
grandparent_hash_of_new_block,
prev_best_hash,
)
{ and, // best_header_changed() in blockchain/headerchain.rs
let is_new_best = parent_details_of_new_header.total_score + new_header.score()
> self.best_proposal_header_detail().total_score
&& engine.can_change_canon_chain(
new_header.hash(),
parent_hash_of_new_header,
grandparent_hash_of_new_header,
prev_best_hash,
); The condition flow in ProposalHere, to remove core/consensus/tendermintThe usage of "score"I think the most important part where // verify_header_basic() in tendermint/worker.rs
let score = calculate_score(height, author_view);
if *header.score() != score {
return Err(BlockError::InvalidScore(Mismatch {
expected: score,
found: *header.score(),
})
.into())
} ProposalIn this function, I think the core/clientThe usage of "score"
// BlockChainInfo in core/src/block.rs
pub struct BlockChainInfo {
/// Score of the canonical chain.
pub best_score: U256,
/// The best score from proposal blocks.
pub best_proposal_score: U256,
/// Block queue score.
pub pending_total_score: U256, ProposalI think they are not used for verification and condition flow, but just for recording. When I removed them and modified some of the codes to check results caused by removing the core/verification/queueThe usage of "score"I think the most important part where // import() in queue/mod.rs
match K::create(input, &*self.engine) {
Ok(item) => {
self.verification.sizes.unverified.fetch_add(item.mem_usage(), AtomicOrdering::SeqCst);
self.processing.write().insert(h, item.score());
{
let mut ts = self.total_score.write();
*ts += item.score();
}
self.verification.unverified.lock().push_back(item);
self.more_to_verify.notify_all();
Ok(h)
}
Err(err) => {
match err { ProposalThe The other part of using core/schemeThe usage of "score"/// Genesis components.
pub struct Genesis {
/// Seal.
pub seal: Seal,
/// Score.
pub score: U256,
/// Author.
pub author: Address,
/// Timestamp.
pub timestamp: u64, pub struct Scheme {
pub name: String,
pub engine: Arc<dyn CodeChainEngine>,
pub data_dir: String,
pub nodes: Vec<String>,
pub parent_hash: BlockHash,
pub author: Address,
pub score: U256,
.... ProposalIn this part, since the core is declared only and is not used for specific purposes, it will be easy to remove. json/src/schemeThe usage of "score"Here, there are test codes in JSON format as follows: // scheme/cuckoo.rs
fn cuckoo_deserialization() {
let s = r#"{
"params": {
"blockReward": "0x0d",
"blockInterval" : "120",
"minScore" : "0x020000",
"maxVertex" : "16",
"maxEdge" : "8",
"cycleLength" : "6",
"recommendedConfirmation": 6
}
}"#; and, // scheme/genesis.rs
fn genesis_deserialization() {
let s = r#"{
"score": "0x400000000",
"seal": {
"tendermint": {
"prev_view": "0x0",
"cur_view": "0x0",
"precommits": [ ... ProposalI think I can revise other things first and then modify this. Nothing matters except this. SummaryIn summary, I subdivided the parts that are using the |
Could you check whether height and view is verified or not? If height and view is verified in other code, we don't need to check it again. We can just remove the score verification logic. |
IMO, we may use the block number. However, we should check how the header sync works again. @HoOngEe, Could you check it? I remembered that the score was used to select the best proposal block. Previous header sync code was requesting a peer's headers if the peer has a higher scored header. I heard that snapshot sync changed some of the behavior. So I want to know the relationship between header sync and best proposal header. |
How about moving the prev_view and cur_view from a seal to a header? |
@sgkim126 I agree with you. We don't need a fat |
@majecty I found these codes related to verification for the height and the view.
|
@somniumism Then we don't need to verify them again. Thanks. |
@somniumism I think you can start working on it. |
We split removing the score into two PRs. One is not using the score. The other one is removing the score field. Changing the
I will close this issue for the time being and create new issue #208 . |
#1 (comment)
The text was updated successfully, but these errors were encountered: