11// Copyright © Aptos Foundation
22// SPDX-License-Identifier: Apache-2.0
33
4- use crate :: dag:: {
5- dag_fetcher:: TFetchRequester ,
6- dag_network:: RpcHandler ,
7- dag_store:: Dag ,
8- errors:: NodeBroadcastHandleError ,
9- observability:: {
10- logging:: { LogEvent , LogSchema } ,
11- tracing:: { observe_node, NodeStage } ,
4+ use crate :: {
5+ dag:: {
6+ dag_fetcher:: TFetchRequester ,
7+ dag_network:: RpcHandler ,
8+ dag_store:: Dag ,
9+ errors:: NodeBroadcastHandleError ,
10+ observability:: {
11+ logging:: { LogEvent , LogSchema } ,
12+ tracing:: { observe_node, NodeStage } ,
13+ } ,
14+ storage:: DAGStorage ,
15+ types:: { Node , NodeCertificate , Vote } ,
16+ NodeId ,
1217 } ,
13- storage:: DAGStorage ,
14- types:: { Node , NodeCertificate , Vote } ,
15- NodeId ,
18+ util:: is_vtxn_expected,
1619} ;
1720use anyhow:: { bail, ensure} ;
1821use aptos_config:: config:: DagPayloadConfig ;
1922use aptos_consensus_types:: common:: { Author , Round } ;
2023use aptos_infallible:: RwLock ;
2124use aptos_logger:: { debug, error} ;
2225use aptos_types:: {
23- epoch_state:: EpochState , on_chain_config:: ValidatorTxnConfig ,
24- validator_signer:: ValidatorSigner , validator_txn:: ValidatorTransaction ,
26+ epoch_state:: EpochState ,
27+ on_chain_config:: { Features , ValidatorTxnConfig } ,
28+ validator_signer:: ValidatorSigner ,
29+ validator_txn:: ValidatorTransaction ,
2530} ;
2631use async_trait:: async_trait;
2732use std:: { collections:: BTreeMap , mem, sync:: Arc } ;
@@ -35,6 +40,7 @@ pub(crate) struct NodeBroadcastHandler {
3540 fetch_requester : Arc < dyn TFetchRequester > ,
3641 payload_config : DagPayloadConfig ,
3742 vtxn_config : ValidatorTxnConfig ,
43+ features : Features ,
3844}
3945
4046impl NodeBroadcastHandler {
@@ -46,6 +52,7 @@ impl NodeBroadcastHandler {
4652 fetch_requester : Arc < dyn TFetchRequester > ,
4753 payload_config : DagPayloadConfig ,
4854 vtxn_config : ValidatorTxnConfig ,
55+ features : Features ,
4956 ) -> Self {
5057 let epoch = epoch_state. epoch ;
5158 let votes_by_round_peer = read_votes_from_storage ( & storage, epoch) ;
@@ -59,6 +66,7 @@ impl NodeBroadcastHandler {
5966 fetch_requester,
6067 payload_config,
6168 vtxn_config,
69+ features,
6270 }
6371 }
6472
@@ -87,6 +95,13 @@ impl NodeBroadcastHandler {
8795 fn validate ( & self , node : Node ) -> anyhow:: Result < Node > {
8896 let num_vtxns = node. validator_txns ( ) . len ( ) as u64 ;
8997 ensure ! ( num_vtxns <= self . vtxn_config. per_block_limit_txn_count( ) ) ;
98+ for vtxn in node. validator_txns ( ) {
99+ ensure ! (
100+ is_vtxn_expected( & self . features, vtxn) ,
101+ "unexpected validator transaction: {:?}" ,
102+ vtxn. topic( )
103+ ) ;
104+ }
90105 let vtxn_total_bytes = node
91106 . validator_txns ( )
92107 . iter ( )
0 commit comments