@@ -718,12 +718,12 @@ impl<DB: database::DB, VM: vm::VMExecution, N: Network> Acceptor<N, DB, VM> {
718718 ///
719719 /// * blk: the block to accept as successor of the tip
720720 /// * restart_consensus: `true` if the consensus loop has to be restarted
721- /// after accepting a block, false otherwise .
721+ /// after accepting a block.
722722 ///
723723 /// # Returns
724724 ///
725725 /// * `true` if the accepted block triggered rolling finality on a previous
726- /// block; `false` otherwise .
726+ /// block.
727727 pub ( crate ) async fn accept_block (
728728 & mut self ,
729729 blk : & Block ,
@@ -740,6 +740,8 @@ impl<DB: database::DB, VM: vm::VMExecution, N: Network> Acceptor<N, DB, VM> {
740740
741741 let header_verification_start = std:: time:: Instant :: now ( ) ;
742742 // Verify Block Header
743+ // `cert_voters` and `att_voters` are the voters of the previous-block
744+ // Certificate and the `blk` Attestation, respectively
743745 let ( pni, cert_voters, att_voters) = verify_block_header (
744746 self . db . clone ( ) ,
745747 & prev_header,
@@ -767,34 +769,36 @@ impl<DB: database::DB, VM: vm::VMExecution, N: Network> Acceptor<N, DB, VM> {
767769 let ( contract_events, finality) =
768770 self . db . read ( ) . await . update ( |db| {
769771 // Execute, verify, and persist the state_transition
770- let ( txs , transition_result , contract_events) = vm
771- . do_accept_state_transition (
772+ let ( spent_txs , contract_events) = vm
773+ . accept_state_transition (
772774 prev_header. state_hash ,
773775 blk,
774776 & cert_voters[ ..] ,
775777 ) ?;
776778
777- for spent_tx in txs. iter ( ) {
779+ // Add spent txs to event list
780+ for spent_tx in spent_txs. iter ( ) {
778781 events
779782 . push ( TransactionEvent :: Executed ( spent_tx) . into ( ) ) ;
780783 }
781- est_elapsed_time = start. elapsed ( ) ;
782784
783- assert_eq ! ( header. state_hash, transition_result. state_root) ;
784- assert_eq ! (
785- header. event_bloom,
786- transition_result. event_bloom
787- ) ;
785+ // Stop elapsed time
786+ est_elapsed_time = start. elapsed ( ) ;
788787
789- // Check if the new block triggers rolling finality
788+ // Check finality for previous blocks and the Consensus
789+ // State label for the accepted block
790790 let finality =
791791 self . rolling_finality :: < DB > ( pni, blk, db, & mut events) ?;
792-
793792 let label = finality. 0 ;
793+
794794 // Store block with spent transactions info (including
795795 // GasSpent and Errors), faults, and consensus status label
796- block_size_on_disk =
797- db. store_block ( header, & txs, blk. faults ( ) , label) ?;
796+ block_size_on_disk = db. store_block (
797+ header,
798+ & spent_txs,
799+ blk. faults ( ) ,
800+ label,
801+ ) ?;
798802
799803 Ok ( ( contract_events, finality) )
800804 } ) ?;
@@ -1531,10 +1535,13 @@ async fn broadcast<N: Network>(network: &Arc<RwLock<N>>, msg: &Message) {
15311535 } ) ;
15321536}
15331537
1534- /// Performs full verification of block header against prev_block header where
1535- /// prev_block is usually the blockchain tip
1538+ /// Verifies a block header against its previous block
1539+ ///
1540+ /// # Returns
15361541///
1537- /// Returns the number of Previous Non-Attested Iterations (PNI).
1542+ /// * The number of Previous Non-Attested Iterations (PNI)
1543+ /// * The list of voters in the previous-block Certificate
1544+ /// * The list of voters in the current-block Attestation
15381545pub ( crate ) async fn verify_block_header < DB : database:: DB > (
15391546 db : Arc < RwLock < DB > > ,
15401547 prev_header : & ledger:: Header ,
@@ -1565,6 +1572,6 @@ pub(crate) async fn verify_block_header<DB: database::DB>(
15651572 // Verify header validity
15661573 let validator = Validator :: new ( db, prev_header, provisioners) ;
15671574 validator
1568- . execute_checks ( header, & expected_generator, check_att)
1575+ . verify_block_header_fields ( header, & expected_generator, check_att)
15691576 . await
15701577}
0 commit comments