File tree Expand file tree Collapse file tree 3 files changed +49
-3
lines changed
network/src/beacon_processor Expand file tree Collapse file tree 3 files changed +49
-3
lines changed Original file line number Diff line number Diff line change @@ -352,7 +352,7 @@ pub struct BeaconChain<T: BeaconChainTypes> {
352
352
/// in recent epochs.
353
353
pub ( crate ) observed_sync_aggregators : RwLock < ObservedSyncAggregators < T :: EthSpec > > ,
354
354
/// Maintains a record of which validators have proposed blocks for each slot.
355
- pub ( crate ) observed_block_producers : RwLock < ObservedBlockProducers < T :: EthSpec > > ,
355
+ pub observed_block_producers : RwLock < ObservedBlockProducers < T :: EthSpec > > ,
356
356
/// Maintains a record of which validators have submitted voluntary exits.
357
357
pub ( crate ) observed_voluntary_exits : Mutex < ObservedOperations < SignedVoluntaryExit , T :: EthSpec > > ,
358
358
/// Maintains a record of which validators we've seen proposer slashings for.
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ pub const QUEUED_ATTESTATION_DELAY: Duration = Duration::from_secs(12);
56
56
pub const QUEUED_LIGHT_CLIENT_UPDATE_DELAY : Duration = Duration :: from_secs ( 12 ) ;
57
57
58
58
/// For how long to queue rpc blocks before sending them back for reprocessing.
59
- pub const QUEUED_RPC_BLOCK_DELAY : Duration = Duration :: from_secs ( 3 ) ;
59
+ pub const QUEUED_RPC_BLOCK_DELAY : Duration = Duration :: from_secs ( 4 ) ;
60
60
61
61
/// Set an arbitrary upper-bound on the number of queued blocks to avoid DoS attacks. The fact that
62
62
/// we signature-verify blocks before putting them in the queue *should* protect against this, but
@@ -521,7 +521,7 @@ impl<T: BeaconChainTypes> ReprocessQueue<T> {
521
521
return ;
522
522
}
523
523
524
- // Queue the block for 1/4th of a slot
524
+ // Queue the block for 1/3rd of a slot
525
525
self . rpc_block_delay_queue
526
526
. insert ( rpc_block, QUEUED_RPC_BLOCK_DELAY ) ;
527
527
}
Original file line number Diff line number Diff line change @@ -83,6 +83,52 @@ impl<T: BeaconChainTypes> Worker<T> {
83
83
return ;
84
84
}
85
85
} ;
86
+ // Check if a block from this proposer is already known. If so, defer processing until later
87
+ // to avoid wasting time processing duplicates.
88
+ let proposal_already_known = self
89
+ . chain
90
+ . observed_block_producers
91
+ . read ( )
92
+ . proposer_has_been_observed ( block. message ( ) )
93
+ . map_err ( |e| {
94
+ error ! (
95
+ self . log,
96
+ "Failed to check observed proposers" ;
97
+ "error" => ?e,
98
+ "source" => "rpc" ,
99
+ "block_root" => %block_root
100
+ ) ;
101
+ } )
102
+ . unwrap_or ( true ) ;
103
+ if proposal_already_known {
104
+ debug ! (
105
+ self . log,
106
+ "Delaying processing of duplicate RPC block" ;
107
+ "block_root" => ?block_root,
108
+ "proposer" => block. message( ) . proposer_index( ) ,
109
+ "slot" => block. slot( )
110
+ ) ;
111
+
112
+ // Send message to work reprocess queue to retry the block
113
+ let reprocess_msg = ReprocessQueueMessage :: RpcBlock ( QueuedRpcBlock {
114
+ block_root,
115
+ block : block. clone ( ) ,
116
+ process_type,
117
+ seen_timestamp,
118
+ should_process : true ,
119
+ } ) ;
120
+
121
+ if reprocess_tx. try_send ( reprocess_msg) . is_err ( ) {
122
+ error ! (
123
+ self . log,
124
+ "Failed to inform block import" ;
125
+ "source" => "rpc" ,
126
+ "block_root" => %block_root
127
+ ) ;
128
+ }
129
+ return ;
130
+ }
131
+
86
132
let slot = block. slot ( ) ;
87
133
let parent_root = block. message ( ) . parent_root ( ) ;
88
134
let result = self
You can’t perform that action at this time.
0 commit comments