@@ -73,7 +73,6 @@ use tendermint::{
73
73
Event ,
74
74
} ,
75
75
account,
76
- block:: Header ,
77
76
AppHash ,
78
77
Hash ,
79
78
} ;
@@ -109,7 +108,10 @@ use crate::{
109
108
StateReadExt as _,
110
109
StateWriteExt as _,
111
110
} ,
112
- component:: Component as _,
111
+ component:: {
112
+ Component as _,
113
+ PrepareStateInfo ,
114
+ } ,
113
115
fees:: {
114
116
component:: FeesComponent ,
115
117
StateReadExt as _,
@@ -207,8 +209,8 @@ pub(crate) struct App {
207
209
208
210
// This is set to the executed hash of the proposal during `process_proposal`
209
211
//
210
- // If it does not match the hash given during `begin_block `, then we clear and
211
- // reset the execution results cache + state delta. Transactions are re-executed.
212
+ // If it does not match the hash given during `prepare_state_for_tx_execution `, then we clear
213
+ // and reset the execution results cache + state delta. Transactions are re-executed.
212
214
// If it does match, we utilize cached results to reduce computation.
213
215
//
214
216
// Resets to default hash at the beginning of `prepare_proposal`, and `process_proposal` if
@@ -682,7 +684,8 @@ impl App {
682
684
}
683
685
684
686
/// sets up the state for execution of the block's transactions.
685
- /// set the current height and timestamp, and calls `begin_block` on all components.
687
+ /// set the current height and timestamp, and calls `prepare_state_for_tx_execution` on all
688
+ /// components.
686
689
///
687
690
/// this *must* be called anytime before a block's txs are executed, whether it's
688
691
/// during the proposal phase, or finalize_block phase.
@@ -697,42 +700,19 @@ impl App {
697
700
// reset recost flag
698
701
self . recost_mempool = false ;
699
702
700
- // call begin_block on all components
701
- // NOTE: the fields marked `unused` are not used by any of the components;
702
- // however, we need to still construct a `BeginBlock` type for now as
703
- // the penumbra IBC implementation still requires it as a parameter.
704
- let begin_block: abci:: request:: BeginBlock = abci:: request:: BeginBlock {
705
- hash : Hash :: default ( ) , // unused
706
- byzantine_validators : block_data. misbehavior . clone ( ) ,
707
- header : Header {
708
- app_hash : self . app_hash . clone ( ) ,
709
- chain_id : chain_id. clone ( ) ,
710
- consensus_hash : Hash :: default ( ) , // unused
711
- data_hash : Some ( Hash :: default ( ) ) , // unused
712
- evidence_hash : Some ( Hash :: default ( ) ) , // unused
713
- height : block_data. height ,
714
- last_block_id : None , // unused
715
- last_commit_hash : Some ( Hash :: default ( ) ) , // unused
716
- last_results_hash : Some ( Hash :: default ( ) ) , // unused
717
- next_validators_hash : block_data. next_validators_hash ,
718
- proposer_address : block_data. proposer_address ,
719
- time : block_data. time ,
720
- validators_hash : Hash :: default ( ) , // unused
721
- version : tendermint:: block:: header:: Version {
722
- // unused
723
- app : 0 ,
724
- block : 0 ,
725
- } ,
726
- } ,
727
- last_commit_info : tendermint:: abci:: types:: CommitInfo {
728
- round : 0u16 . into ( ) , // unused
729
- votes : vec ! [ ] ,
730
- } , // unused
703
+ let prepare_state_info = PrepareStateInfo {
704
+ app_hash : self . app_hash . clone ( ) ,
705
+ byzantine_validators : block_data. misbehavior ,
706
+ chain_id,
707
+ height : block_data. height ,
708
+ next_validators_hash : block_data. next_validators_hash ,
709
+ proposer_address : block_data. proposer_address ,
710
+ time : block_data. time ,
731
711
} ;
732
712
733
- self . begin_block ( & begin_block )
713
+ self . start_block ( & prepare_state_info )
734
714
. await
735
- . wrap_err ( "begin_block failed" ) ?;
715
+ . wrap_err ( "prepare_state_for_tx_execution failed" ) ?;
736
716
737
717
Ok ( ( ) )
738
718
}
@@ -766,7 +746,9 @@ impl App {
766
746
. await
767
747
. wrap_err ( "failed to get sudo address from state" ) ?;
768
748
769
- let end_block = self . end_block ( height. value ( ) , & sudo_address) . await ?;
749
+ let ( validator_updates, events) = self
750
+ . component_post_execution_state_updates ( & sudo_address)
751
+ . await ?;
770
752
771
753
// get deposits for this block from state's ephemeral cache and put them to storage.
772
754
let mut state_tx = StateDelta :: new ( self . state . clone ( ) ) ;
@@ -804,15 +786,14 @@ impl App {
804
786
. wrap_err ( "failed to write sequencer block to state" ) ?;
805
787
806
788
let result = PostTransactionExecutionResult {
807
- events : end_block. events ,
808
- validator_updates : end_block. validator_updates ,
809
- consensus_param_updates : end_block. consensus_param_updates ,
789
+ events,
790
+ validator_updates,
810
791
tx_results : finalize_block_tx_results,
811
792
} ;
812
793
813
794
state_tx. object_put ( POST_TRANSACTION_EXECUTION_RESULT_KEY , result) ;
814
795
815
- // events that occur after end_block are ignored here;
796
+ // events that occur after handle_post_tx_execution are ignored here;
816
797
// there should be none anyways.
817
798
let _ = self . apply ( state_tx) ;
818
799
@@ -931,7 +912,7 @@ impl App {
931
912
let finalize_block = abci:: response:: FinalizeBlock {
932
913
events : post_transaction_execution_result. events ,
933
914
validator_updates : post_transaction_execution_result. validator_updates ,
934
- consensus_param_updates : post_transaction_execution_result . consensus_param_updates ,
915
+ consensus_param_updates : None ,
935
916
app_hash,
936
917
tx_results : post_transaction_execution_result. tx_results ,
937
918
} ;
@@ -976,34 +957,34 @@ impl App {
976
957
Ok ( app_hash)
977
958
}
978
959
979
- #[ instrument( name = "App::begin_block " , skip_all) ]
980
- async fn begin_block (
960
+ #[ instrument( name = "App::start_block " , skip_all) ]
961
+ async fn start_block (
981
962
& mut self ,
982
- begin_block : & abci :: request :: BeginBlock ,
963
+ prepare_state_info : & PrepareStateInfo ,
983
964
) -> Result < Vec < abci:: Event > > {
984
965
let mut state_tx = StateDelta :: new ( self . state . clone ( ) ) ;
985
966
986
967
state_tx
987
- . put_block_height ( begin_block . header . height . into ( ) )
968
+ . put_block_height ( prepare_state_info . height . into ( ) )
988
969
. wrap_err ( "failed to put block height" ) ?;
989
970
state_tx
990
- . put_block_timestamp ( begin_block . header . time )
971
+ . put_block_timestamp ( prepare_state_info . time )
991
972
. wrap_err ( "failed to put block timestamp" ) ?;
992
973
993
- // call begin_block on all components
974
+ // call prepare_state_for_tx_execution on all components
994
975
let mut arc_state_tx = Arc :: new ( state_tx) ;
995
- AccountsComponent :: begin_block ( & mut arc_state_tx, begin_block )
976
+ AccountsComponent :: prepare_state_for_tx_execution ( & mut arc_state_tx, prepare_state_info )
996
977
. await
997
- . wrap_err ( "begin_block failed on AccountsComponent" ) ?;
998
- AuthorityComponent :: begin_block ( & mut arc_state_tx, begin_block )
978
+ . wrap_err ( "prepare_state_for_tx_execution failed on AccountsComponent" ) ?;
979
+ AuthorityComponent :: prepare_state_for_tx_execution ( & mut arc_state_tx, prepare_state_info )
999
980
. await
1000
- . wrap_err ( "begin_block failed on AuthorityComponent" ) ?;
1001
- IbcComponent :: begin_block ( & mut arc_state_tx, begin_block )
981
+ . wrap_err ( "prepare_state_for_tx_execution failed on AuthorityComponent" ) ?;
982
+ IbcComponent :: prepare_state_for_tx_execution ( & mut arc_state_tx, prepare_state_info )
1002
983
. await
1003
- . wrap_err ( "begin_block failed on IbcComponent" ) ?;
1004
- FeesComponent :: begin_block ( & mut arc_state_tx, begin_block )
984
+ . wrap_err ( "prepare_state_for_tx_execution failed on IbcComponent" ) ?;
985
+ FeesComponent :: prepare_state_for_tx_execution ( & mut arc_state_tx, prepare_state_info )
1005
986
. await
1006
- . wrap_err ( "begin_block failed on FeesComponent" ) ?;
987
+ . wrap_err ( "prepare_state_for_tx_execution failed on FeesComponent" ) ?;
1007
988
1008
989
let state_tx = Arc :: try_unwrap ( arc_state_tx)
1009
990
. expect ( "components should not retain copies of shared state" ) ;
@@ -1049,34 +1030,27 @@ impl App {
1049
1030
Ok ( events)
1050
1031
}
1051
1032
1052
- #[ instrument( name = "App::end_block " , skip_all) ]
1053
- async fn end_block (
1033
+ #[ instrument( name = "App::component_post_execution_state_updates " , skip_all) ]
1034
+ async fn component_post_execution_state_updates (
1054
1035
& mut self ,
1055
- height : u64 ,
1056
1036
fee_recipient : & [ u8 ; 20 ] ,
1057
- ) -> Result < abci :: response :: EndBlock > {
1037
+ ) -> Result < ( Vec < tendermint :: validator :: Update > , Vec < Event > ) > {
1058
1038
let state_tx = StateDelta :: new ( self . state . clone ( ) ) ;
1059
1039
let mut arc_state_tx = Arc :: new ( state_tx) ;
1060
1040
1061
- let end_block = abci:: request:: EndBlock {
1062
- height : height
1063
- . try_into ( )
1064
- . expect ( "a block height should be able to fit in an i64" ) ,
1065
- } ;
1066
-
1067
- // call end_block on all components
1068
- AccountsComponent :: end_block ( & mut arc_state_tx, & end_block)
1041
+ // call handle_post_tx_execution on all components
1042
+ AccountsComponent :: handle_post_tx_execution ( & mut arc_state_tx)
1069
1043
. await
1070
- . wrap_err ( "end_block failed on AccountsComponent" ) ?;
1071
- AuthorityComponent :: end_block ( & mut arc_state_tx, & end_block )
1044
+ . wrap_err ( "handle_post_tx_execution failed on AccountsComponent" ) ?;
1045
+ AuthorityComponent :: handle_post_tx_execution ( & mut arc_state_tx)
1072
1046
. await
1073
- . wrap_err ( "end_block failed on AuthorityComponent" ) ?;
1074
- FeesComponent :: end_block ( & mut arc_state_tx, & end_block )
1047
+ . wrap_err ( "handle_post_tx_execution failed on AuthorityComponent" ) ?;
1048
+ FeesComponent :: handle_post_tx_execution ( & mut arc_state_tx)
1075
1049
. await
1076
- . wrap_err ( "end_block failed on FeesComponent" ) ?;
1077
- IbcComponent :: end_block ( & mut arc_state_tx, & end_block )
1050
+ . wrap_err ( "handle_post_tx_execution failed on FeesComponent" ) ?;
1051
+ IbcComponent :: handle_post_tx_execution ( & mut arc_state_tx)
1078
1052
. await
1079
- . wrap_err ( "end_block failed on IbcComponent" ) ?;
1053
+ . wrap_err ( "handle_post_tx_execution failed on IbcComponent" ) ?;
1080
1054
1081
1055
let mut state_tx = Arc :: try_unwrap ( arc_state_tx)
1082
1056
. expect ( "components should not retain copies of shared state" ) ;
@@ -1102,13 +1076,12 @@ impl App {
1102
1076
}
1103
1077
1104
1078
let events = self . apply ( state_tx) ;
1105
- Ok ( abci :: response :: EndBlock {
1106
- validator_updates : validator_updates
1079
+ Ok ( (
1080
+ validator_updates
1107
1081
. try_into_cometbft ( )
1108
1082
. wrap_err ( "failed converting astria validators to cometbft compatible type" ) ?,
1109
1083
events,
1110
- ..Default :: default ( )
1111
- } )
1084
+ ) )
1112
1085
}
1113
1086
1114
1087
#[ instrument( name = "App::commit" , skip_all) ]
@@ -1194,7 +1167,6 @@ struct PostTransactionExecutionResult {
1194
1167
events : Vec < Event > ,
1195
1168
tx_results : Vec < ExecTxResult > ,
1196
1169
validator_updates : Vec < tendermint:: validator:: Update > ,
1197
- consensus_param_updates : Option < tendermint:: consensus:: Params > ,
1198
1170
}
1199
1171
1200
1172
#[ derive( PartialEq ) ]
0 commit comments