File tree Expand file tree Collapse file tree 6 files changed +53
-14
lines changed
Expand file tree Collapse file tree 6 files changed +53
-14
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,10 @@ impl ChainService {
9292 fn asynchronous_process_block ( & self , lonely_block : LonelyBlock ) {
9393 let block_number = lonely_block. block ( ) . number ( ) ;
9494 let block_hash = lonely_block. block ( ) . hash ( ) ;
95+ debug ! (
96+ "[ChainService] asynchronous_process_block {}-{}" ,
97+ block_number, block_hash
98+ ) ;
9599 // Skip verifying a genesis block if its hash is equal to our genesis hash,
96100 // otherwise, return error and ban peer.
97101 if block_number < 1 {
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ use std::{path::PathBuf, str::FromStr};
1515use crate :: cli;
1616
1717// 500_000 total difficulty
18- const MIN_CHAIN_WORK_500K : U256 = u256 ! ( "0x3314412053c82802a7 " ) ;
18+ const MIN_CHAIN_WORK_500K : U256 = u256 ! ( "0x0 " ) ;
1919
2020/// A struct including all the information to start the ckb process.
2121pub struct Setup {
Original file line number Diff line number Diff line change @@ -423,19 +423,21 @@ impl Shared {
423423 match self . block_status_map ( ) . get ( block_hash) {
424424 Some ( status_ref) => * status_ref. value ( ) ,
425425 None => {
426- if self . header_map ( ) . contains_key ( block_hash) {
427- BlockStatus :: HEADER_VALID
428- } else {
429- let verified = self
430- . snapshot ( )
431- . get_block_ext ( block_hash)
432- . map ( |block_ext| block_ext. verified ) ;
433- match verified {
434- None => BlockStatus :: UNKNOWN ,
435- Some ( None ) => BlockStatus :: BLOCK_STORED ,
436- Some ( Some ( true ) ) => BlockStatus :: BLOCK_VALID ,
437- Some ( Some ( false ) ) => BlockStatus :: BLOCK_INVALID ,
426+ let verified = self
427+ . snapshot ( )
428+ . get_block_ext ( block_hash)
429+ . map ( |block_ext| block_ext. verified ) ;
430+ match verified {
431+ None => {
432+ if self . header_map ( ) . contains_key ( block_hash) {
433+ BlockStatus :: HEADER_VALID
434+ } else {
435+ BlockStatus :: UNKNOWN
436+ }
438437 }
438+ Some ( None ) => BlockStatus :: BLOCK_STORED ,
439+ Some ( Some ( true ) ) => BlockStatus :: BLOCK_VALID ,
440+ Some ( Some ( false ) ) => BlockStatus :: BLOCK_INVALID ,
439441 }
440442 }
441443 }
Original file line number Diff line number Diff line change @@ -257,7 +257,13 @@ impl<'a> HeadersProcess<'a> {
257257
258258 // Batch insert all valid headers in ONE transaction
259259 if !headers_to_insert. is_empty ( ) {
260+ debug ! (
261+ "Calling insert_valid_headers_batch for {} headers" ,
262+ headers_to_insert. len( )
263+ ) ;
260264 shared. insert_valid_headers_batch ( self . peer , & headers_to_insert) ;
265+ } else {
266+ debug ! ( "No new headers to insert (all already valid)" ) ;
261267 }
262268
263269 self . debug ( ) ;
Original file line number Diff line number Diff line change @@ -464,12 +464,18 @@ impl Synchronizer {
464464 //TODO: process block which we don't request
465465 pub fn asynchronous_process_remote_block ( & self , remote_block : RemoteBlock ) {
466466 let block_hash = remote_block. block . hash ( ) ;
467+ let block_number = remote_block. block . number ( ) ;
467468 let status = self . shared . active_chain ( ) . get_block_status ( & block_hash) ;
469+ debug ! (
470+ "asynchronous_process_remote_block {}-{}, status: {:?}" ,
471+ block_number, block_hash, status
472+ ) ;
468473 // NOTE: Filtering `BLOCK_STORED` but not `BLOCK_RECEIVED`, is for avoiding
469474 // stopping synchronization even when orphan_pool maintains dirty items by bugs.
470475 if status. contains ( BlockStatus :: BLOCK_STORED ) {
471476 error ! ( "Block {} already stored" , block_hash) ;
472477 } else if status. contains ( BlockStatus :: HEADER_VALID ) {
478+ debug ! ( "Calling accept_remote_block for {}-{}" , block_number, block_hash) ;
473479 self . shared . accept_remote_block ( & self . chain , remote_block) ;
474480 } else {
475481 debug ! (
Original file line number Diff line number Diff line change @@ -1084,16 +1084,28 @@ impl SyncShared {
10841084 }
10851085
10861086 pub ( crate ) fn accept_remote_block ( & self , chain : & ChainController , remote_block : RemoteBlock ) {
1087+ let block_number = remote_block. block . number ( ) ;
1088+ let block_hash = remote_block. block . header ( ) . hash ( ) ;
1089+ debug ! (
1090+ "accept_remote_block {}-{}" ,
1091+ block_number,
1092+ block_hash
1093+ ) ;
10871094 {
10881095 let entry = self
10891096 . shared ( )
10901097 . block_status_map ( )
1091- . entry ( remote_block . block . header ( ) . hash ( ) ) ;
1098+ . entry ( block_hash . clone ( ) ) ;
10921099 if let dashmap:: mapref:: entry:: Entry :: Vacant ( entry) = entry {
10931100 entry. insert ( BlockStatus :: BLOCK_RECEIVED ) ;
10941101 }
10951102 }
10961103
1104+ debug ! (
1105+ "Calling chain.asynchronous_process_remote_block for {}-{}" ,
1106+ block_number,
1107+ block_hash
1108+ ) ;
10971109 chain. asynchronous_process_remote_block ( remote_block)
10981110 }
10991111
@@ -1212,6 +1224,15 @@ impl SyncShared {
12121224 // Commit ONCE - single fsync for all headers
12131225 db_txn. commit ( ) . expect ( "commit should be ok" ) ;
12141226
1227+ debug ! (
1228+ "insert_valid_headers_batch committed {} headers, range: {}-{} to {}-{}" ,
1229+ headers. len( ) ,
1230+ headers. first( ) . map( |h| h. number( ) ) . unwrap_or( 0 ) ,
1231+ headers. first( ) . map( |h| h. hash( ) ) . unwrap_or_default( ) ,
1232+ headers. last( ) . map( |h| h. number( ) ) . unwrap_or( 0 ) ,
1233+ headers. last( ) . map( |h| h. hash( ) ) . unwrap_or_default( )
1234+ ) ;
1235+
12151236 last_header_index
12161237 }
12171238
You can’t perform that action at this time.
0 commit comments