@@ -66,7 +66,7 @@ use crate::{
66
66
data_types:: {
67
67
BlockHeightRange , ChainInfo , ChainInfoQuery , ChainInfoResponse , ClientOutcome , RoundTimeout ,
68
68
} ,
69
- local_node:: { LocalNodeClient , LocalNodeError , NamedNode } ,
69
+ local_node:: { LocalNodeClient , LocalNodeError , RemoteNode } ,
70
70
node:: {
71
71
CrossChainMessageDelivery , NodeError , NotificationStream , ValidatorNode ,
72
72
ValidatorNodeProvider ,
@@ -293,7 +293,7 @@ where
293
293
{
294
294
async fn download_certificates (
295
295
& self ,
296
- nodes : & [ NamedNode < P :: Node > ] ,
296
+ nodes : & [ RemoteNode < P :: Node > ] ,
297
297
chain_id : ChainId ,
298
298
height : BlockHeight ,
299
299
) -> Result < Box < ChainInfo > , LocalNodeError > {
@@ -308,14 +308,14 @@ where
308
308
309
309
async fn try_process_certificates (
310
310
& self ,
311
- named_node : & NamedNode < P :: Node > ,
311
+ remote_node : & RemoteNode < P :: Node > ,
312
312
chain_id : ChainId ,
313
313
certificates : Vec < Certificate > ,
314
314
) -> Option < Box < ChainInfo > > {
315
315
let mut notifications = Vec :: < Notification > :: new ( ) ;
316
316
let result = self
317
317
. local_node
318
- . try_process_certificates ( named_node , chain_id, certificates, & mut notifications)
318
+ . try_process_certificates ( remote_node , chain_id, certificates, & mut notifications)
319
319
. await ;
320
320
self . notifier . handle_notifications ( & notifications) ;
321
321
result
@@ -830,18 +830,18 @@ where
830
830
}
831
831
832
832
#[ tracing:: instrument( level = "trace" ) ]
833
- fn make_nodes ( & self , committee : & Committee ) -> Result < Vec < NamedNode < P :: Node > > , NodeError > {
833
+ fn make_nodes ( & self , committee : & Committee ) -> Result < Vec < RemoteNode < P :: Node > > , NodeError > {
834
834
Ok ( self
835
835
. client
836
836
. validator_node_provider
837
837
. make_nodes ( committee) ?
838
- . map ( |( name, node) | NamedNode { name, node } )
838
+ . map ( |( name, node) | RemoteNode { name, node } )
839
839
. collect ( ) )
840
840
}
841
841
842
842
#[ tracing:: instrument( level = "trace" ) ]
843
843
/// Obtains the validators trusted by the local chain.
844
- async fn validator_nodes ( & self ) -> Result < Vec < NamedNode < P :: Node > > , ChainClientError > {
844
+ async fn validator_nodes ( & self ) -> Result < Vec < RemoteNode < P :: Node > > , ChainClientError > {
845
845
match self . local_committee ( ) . await {
846
846
Ok ( committee) => Ok ( self . make_nodes ( & committee) ?) ,
847
847
Err ( LocalNodeError :: InactiveChain ( _) ) => Ok ( Vec :: new ( ) ) ,
@@ -1011,9 +1011,9 @@ where
1011
1011
& nodes,
1012
1012
committee,
1013
1013
|_: & ( ) | ( ) ,
1014
- |named_node | {
1014
+ |remote_node | {
1015
1015
let mut updater = ValidatorUpdater {
1016
- named_node ,
1016
+ remote_node ,
1017
1017
local_node : local_node. clone ( ) ,
1018
1018
} ;
1019
1019
Box :: pin ( async move {
@@ -1045,9 +1045,9 @@ where
1045
1045
& nodes,
1046
1046
committee,
1047
1047
|vote : & LiteVote | ( vote. value . value_hash , vote. round ) ,
1048
- |named_node | {
1048
+ |remote_node | {
1049
1049
let mut updater = ValidatorUpdater {
1050
- named_node ,
1050
+ remote_node ,
1051
1051
local_node : local_node. clone ( ) ,
1052
1052
} ;
1053
1053
let action = action. clone ( ) ;
@@ -1159,12 +1159,12 @@ where
1159
1159
async fn synchronize_received_certificates_from_validator (
1160
1160
& self ,
1161
1161
chain_id : ChainId ,
1162
- named_node : & NamedNode < P :: Node > ,
1162
+ remote_node : & RemoteNode < P :: Node > ,
1163
1163
) -> Result < ( ValidatorName , u64 , Vec < Certificate > ) , NodeError > {
1164
1164
let tracker = self
1165
1165
. state ( )
1166
1166
. received_certificate_trackers
1167
- . get ( & named_node . name )
1167
+ . get ( & remote_node . name )
1168
1168
. copied ( )
1169
1169
. unwrap_or ( 0 ) ;
1170
1170
let ( committees, max_epoch) = self
@@ -1173,7 +1173,7 @@ where
1173
1173
. map_err ( |_| NodeError :: InvalidChainInfoResponse ) ?;
1174
1174
// Retrieve newly received certificates from this validator.
1175
1175
let query = ChainInfoQuery :: new ( chain_id) . with_received_log_excluding_first_nth ( tracker) ;
1176
- let info = named_node . handle_chain_info_query ( query) . await ?;
1176
+ let info = remote_node . handle_chain_info_query ( query) . await ?;
1177
1177
let mut certificates = Vec :: new ( ) ;
1178
1178
let mut new_tracker = tracker;
1179
1179
for entry in info. requested_received_log {
@@ -1196,12 +1196,12 @@ where
1196
1196
continue ;
1197
1197
}
1198
1198
1199
- let mut info = named_node . handle_chain_info_query ( query) . await ?;
1199
+ let mut info = remote_node . handle_chain_info_query ( query) . await ?;
1200
1200
let Some ( certificate_hash) = info. requested_sent_certificate_hashes . pop ( ) else {
1201
1201
break ;
1202
1202
} ;
1203
1203
1204
- let certificate = named_node
1204
+ let certificate = remote_node
1205
1205
. node
1206
1206
. download_certificate ( certificate_hash)
1207
1207
. await ?;
@@ -1243,7 +1243,7 @@ where
1243
1243
}
1244
1244
}
1245
1245
}
1246
- Ok ( ( named_node . name , new_tracker, certificates) )
1246
+ Ok ( ( remote_node . name , new_tracker, certificates) )
1247
1247
}
1248
1248
1249
1249
#[ tracing:: instrument( level = "trace" , skip( tracker, certificates) ) ]
@@ -1307,11 +1307,11 @@ where
1307
1307
& nodes,
1308
1308
& local_committee,
1309
1309
|_| ( ) ,
1310
- |named_node | {
1310
+ |remote_node | {
1311
1311
let client = client. clone ( ) ;
1312
1312
Box :: pin ( async move {
1313
1313
client
1314
- . synchronize_received_certificates_from_validator ( chain_id, & named_node )
1314
+ . synchronize_received_certificates_from_validator ( chain_id, & remote_node )
1315
1315
. await
1316
1316
} )
1317
1317
} ,
@@ -1465,19 +1465,19 @@ where
1465
1465
/// Downloads and processes any certificates we are missing for the given chain.
1466
1466
pub async fn synchronize_chain_state (
1467
1467
& self ,
1468
- validators : & [ NamedNode < P :: Node > ] ,
1468
+ validators : & [ RemoteNode < P :: Node > ] ,
1469
1469
chain_id : ChainId ,
1470
1470
) -> Result < Box < ChainInfo > , ChainClientError > {
1471
1471
#[ cfg( with_metrics) ]
1472
1472
let _latency = metrics:: SYNCHRONIZE_CHAIN_STATE_LATENCY . measure_latency ( ) ;
1473
1473
1474
1474
let mut futures = vec ! [ ] ;
1475
1475
1476
- for named_node in validators {
1476
+ for remote_node in validators {
1477
1477
let client = self . clone ( ) ;
1478
1478
futures. push ( async move {
1479
1479
client
1480
- . try_synchronize_chain_state_from ( named_node , chain_id)
1480
+ . try_synchronize_chain_state_from ( remote_node , chain_id)
1481
1481
. await
1482
1482
} ) ;
1483
1483
}
@@ -1495,12 +1495,12 @@ where
1495
1495
. map_err ( Into :: into)
1496
1496
}
1497
1497
1498
- #[ tracing:: instrument( level = "trace" , skip( self , named_node , chain_id) ) ]
1498
+ #[ tracing:: instrument( level = "trace" , skip( self , remote_node , chain_id) ) ]
1499
1499
/// Downloads any certificates from the specified validator that we are missing for the given
1500
1500
/// chain, and processes them.
1501
1501
async fn try_synchronize_chain_state_from (
1502
1502
& self ,
1503
- named_node : & NamedNode < P :: Node > ,
1503
+ remote_node : & RemoteNode < P :: Node > ,
1504
1504
chain_id : ChainId ,
1505
1505
) -> Result < ( ) , ChainClientError > {
1506
1506
let local_info = self . client . local_node . local_chain_info ( chain_id) . await ?;
@@ -1511,19 +1511,19 @@ where
1511
1511
let query = ChainInfoQuery :: new ( chain_id)
1512
1512
. with_sent_certificate_hashes_in_range ( range)
1513
1513
. with_manager_values ( ) ;
1514
- let info = named_node . handle_chain_info_query ( query) . await ?;
1514
+ let info = remote_node . handle_chain_info_query ( query) . await ?;
1515
1515
1516
1516
let certificates = future:: try_join_all (
1517
1517
info. requested_sent_certificate_hashes
1518
1518
. into_iter ( )
1519
- . map ( move |hash| async move { named_node . node . download_certificate ( hash) . await } ) ,
1519
+ . map ( move |hash| async move { remote_node . node . download_certificate ( hash) . await } ) ,
1520
1520
)
1521
1521
. await ?;
1522
1522
1523
1523
if !certificates. is_empty ( )
1524
1524
&& self
1525
1525
. client
1526
- . try_process_certificates ( named_node , chain_id, certificates)
1526
+ . try_process_certificates ( remote_node , chain_id, certificates)
1527
1527
. await
1528
1528
. is_none ( )
1529
1529
{
@@ -1547,14 +1547,14 @@ where
1547
1547
_,
1548
1548
) = & * * chain_error
1549
1549
{
1550
- self . update_local_node_with_blob_from ( * blob_id, named_node )
1550
+ self . update_local_node_with_blob_from ( * blob_id, remote_node )
1551
1551
. await ?;
1552
1552
continue ; // We found the missing blob: retry.
1553
1553
}
1554
1554
}
1555
1555
warn ! (
1556
1556
"Skipping proposal from {} and validator {}: {}" ,
1557
- owner, named_node . name, original_err
1557
+ owner, remote_node . name, original_err
1558
1558
) ;
1559
1559
break ;
1560
1560
}
@@ -1567,7 +1567,7 @@ where
1567
1567
if let LocalNodeError :: WorkerError ( WorkerError :: BlobsNotFound ( blob_ids) ) =
1568
1568
& original_err
1569
1569
{
1570
- blobs = named_node
1570
+ blobs = remote_node
1571
1571
. find_missing_blobs ( blob_ids. clone ( ) , chain_id)
1572
1572
. await ?;
1573
1573
@@ -1577,7 +1577,7 @@ where
1577
1577
}
1578
1578
warn ! (
1579
1579
"Skipping certificate {} from validator {}: {}" ,
1580
- hash, named_node . name, original_err
1580
+ hash, remote_node . name, original_err
1581
1581
) ;
1582
1582
break ;
1583
1583
}
@@ -1590,9 +1590,9 @@ where
1590
1590
async fn update_local_node_with_blob_from (
1591
1591
& self ,
1592
1592
blob_id : BlobId ,
1593
- named_node : & NamedNode < P :: Node > ,
1593
+ remote_node : & RemoteNode < P :: Node > ,
1594
1594
) -> Result < ( ) , ChainClientError > {
1595
- let certificate = named_node . download_certificate_for_blob ( blob_id) . await ?;
1595
+ let certificate = remote_node . download_certificate_for_blob ( blob_id) . await ?;
1596
1596
// This will download all ancestors of the certificate and process all of them locally.
1597
1597
self . receive_certificate ( certificate) . await ?;
1598
1598
Ok ( ( ) )
@@ -1603,10 +1603,10 @@ where
1603
1603
async fn receive_certificate_for_blob ( & self , blob_id : BlobId ) -> Result < ( ) , ChainClientError > {
1604
1604
let validators = self . validator_nodes ( ) . await ?;
1605
1605
let mut tasks = FuturesUnordered :: new ( ) ;
1606
- for named_node in validators {
1607
- let named_node = named_node . clone ( ) ;
1606
+ for remote_node in validators {
1607
+ let remote_node = remote_node . clone ( ) ;
1608
1608
tasks. push ( async move {
1609
- let cert = named_node
1609
+ let cert = remote_node
1610
1610
. download_certificate_for_blob ( blob_id)
1611
1611
. await
1612
1612
. ok ( ) ?;
@@ -2870,10 +2870,10 @@ where
2870
2870
Some ( info. next_block_height )
2871
2871
}
2872
2872
2873
- #[ tracing:: instrument( level = "trace" , skip( named_node , local_node, notification) ) ]
2873
+ #[ tracing:: instrument( level = "trace" , skip( remote_node , local_node, notification) ) ]
2874
2874
async fn process_notification (
2875
2875
& self ,
2876
- named_node : NamedNode < P :: Node > ,
2876
+ remote_node : RemoteNode < P :: Node > ,
2877
2877
mut local_node : LocalNodeClient < S > ,
2878
2878
notification : Notification ,
2879
2879
) {
@@ -2888,7 +2888,7 @@ where
2888
2888
return ;
2889
2889
}
2890
2890
if let Err ( error) = self
2891
- . find_received_certificates_from_validator ( named_node )
2891
+ . find_received_certificates_from_validator ( remote_node )
2892
2892
. await
2893
2893
{
2894
2894
error ! ( "Fail to process notification: {error}" ) ;
@@ -2913,7 +2913,7 @@ where
2913
2913
return ;
2914
2914
}
2915
2915
if let Err ( error) = self
2916
- . try_synchronize_chain_state_from ( & named_node , chain_id)
2916
+ . try_synchronize_chain_state_from ( & remote_node , chain_id)
2917
2917
. await
2918
2918
{
2919
2919
error ! ( "Fail to process notification: {error}" ) ;
@@ -2935,7 +2935,7 @@ where
2935
2935
}
2936
2936
}
2937
2937
if let Err ( error) = self
2938
- . try_synchronize_chain_state_from ( & named_node , chain_id)
2938
+ . try_synchronize_chain_state_from ( & remote_node , chain_id)
2939
2939
. await
2940
2940
{
2941
2941
error ! ( "Fail to process notification: {error}" ) ;
@@ -3062,11 +3062,15 @@ where
3062
3062
} ;
3063
3063
let this = self . clone ( ) ;
3064
3064
let local_node = local_node. clone ( ) ;
3065
- let named_node = NamedNode { name, node } ;
3065
+ let remote_node = RemoteNode { name, node } ;
3066
3066
validator_tasks. push ( async move {
3067
3067
while let Some ( notification) = stream. next ( ) . await {
3068
- this. process_notification ( named_node. clone ( ) , local_node. clone ( ) , notification)
3069
- . await ;
3068
+ this. process_notification (
3069
+ remote_node. clone ( ) ,
3070
+ local_node. clone ( ) ,
3071
+ notification,
3072
+ )
3073
+ . await ;
3070
3074
}
3071
3075
} ) ;
3072
3076
entry. insert ( abort) ;
@@ -3081,12 +3085,12 @@ where
3081
3085
/// We also don't try to synchronize the admin chain.
3082
3086
pub async fn find_received_certificates_from_validator (
3083
3087
& self ,
3084
- named_node : NamedNode < P :: Node > ,
3088
+ remote_node : RemoteNode < P :: Node > ,
3085
3089
) -> Result < ( ) , ChainClientError > {
3086
3090
let chain_id = self . chain_id ;
3087
3091
// Proceed to downloading received certificates.
3088
3092
let ( name, tracker, certificates) = self
3089
- . synchronize_received_certificates_from_validator ( chain_id, & named_node )
3093
+ . synchronize_received_certificates_from_validator ( chain_id, & remote_node )
3090
3094
. await ?;
3091
3095
// Process received certificates. If the client state has changed during the
3092
3096
// network calls, we should still be fine.
0 commit comments