Skip to content

Commit c573669

Browse files
Juhyung Parkmergify[bot]
authored andcommitted
Use best_proposal_block_hash in the sync extension
Tendermint consensus: Block sync was using best proposal block's score. Although currently the best hash is not used, it should be matched with the score. Other consensuses: Best proposal block is the same as the best block. Nothing changed.
1 parent c045f9b commit c573669

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

core/src/blockchain/blockchain.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ impl BlockChain {
303303
pending_total_score: best_block_detail.total_score,
304304
genesis_hash: self.genesis_hash(),
305305
best_block_hash: best_block_header.hash(),
306+
best_proposal_block_hash,
306307
best_block_number: best_block_detail.number,
307308
best_block_timestamp: best_block_header.timestamp(),
308309
}

core/src/blockchain_info.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ pub struct BlockChainInfo {
3030
pub genesis_hash: H256,
3131
/// Best blockchain block hash.
3232
pub best_block_hash: H256,
33+
/// Best blockchain proposal block hash.
34+
pub best_proposal_block_hash: H256,
3335
/// Best blockchain block number.
3436
pub best_block_number: BlockNumber,
3537
/// Best blockchain block timestamp.

core/src/client/test_client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ impl ChainInfo for TestBlockChainClient {
379379
pending_total_score: *self.score.read(),
380380
genesis_hash: self.genesis_hash,
381381
best_block_hash: *self.last_hash.read(),
382+
best_proposal_block_hash: *self.last_hash.read(),
382383
best_block_number: number,
383384
best_block_timestamp: number,
384385
}

sync/src/block/extension.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl NetworkExtension<Event> for Extension {
216216
Arc::new(
217217
Message::Status {
218218
total_score: chain_info.best_proposal_score,
219-
best_hash: chain_info.best_block_hash,
219+
best_hash: chain_info.best_proposal_block_hash,
220220
genesis_hash: chain_info.genesis_hash,
221221
}
222222
.rlp_bytes()
@@ -422,7 +422,7 @@ impl Extension {
422422
Arc::new(
423423
Message::Status {
424424
total_score: chain_info.best_proposal_score,
425-
best_hash: chain_info.best_block_hash,
425+
best_hash: chain_info.best_proposal_block_hash,
426426
genesis_hash: chain_info.genesis_hash,
427427
}
428428
.rlp_bytes()

0 commit comments

Comments
 (0)