From fdc65443f62cc0e640a0e265152e8e7c4eef48d0 Mon Sep 17 00:00:00 2001 From: William Smith Date: Fri, 8 Nov 2024 22:31:09 -0800 Subject: [PATCH] WIP --- crates/sui-core/src/authority_server.rs | 49 +++++++++++++++++++++---- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/crates/sui-core/src/authority_server.rs b/crates/sui-core/src/authority_server.rs index 0e9aeb30ee1ef..bdf193887eb92 100644 --- a/crates/sui-core/src/authority_server.rs +++ b/crates/sui-core/src/authority_server.rs @@ -451,6 +451,7 @@ impl ValidatorService { let _handle_tx_metrics_guard = metrics.handle_transaction_latency.start_timer(); let tx_verif_metrics_guard = metrics.tx_verification_latency.start_timer(); + let signers: NonEmpty<_> = transaction.clone().intent_message().value.signers(); let transaction = epoch_store.verify_transaction(transaction).tap_err(|_| { metrics.signature_errors.inc(); })?; @@ -526,6 +527,7 @@ impl ValidatorService { let _handle_tx_metrics_guard = metrics.handle_transaction_v2_latency.start_timer(); let tx_verif_metrics_guard = metrics.tx_verification_latency.start_timer(); + let signers: NonEmpty<_> = transaction.clone().intent_message().value.signers(); let transaction = epoch_store.verify_transaction(transaction).tap_err(|_| { metrics.signature_errors.inc(); })?; @@ -696,14 +698,19 @@ impl ValidatorService { } } - let verified_certificates = { + let verified_certificates_and_senders = { let _timer = self.metrics.cert_verification_latency.start_timer(); - epoch_store + let verified_certs = epoch_store .signature_verifier .multi_verify_certs(certificates.into()) .await .into_iter() - .collect::, _>>()? + .collect::, _>>()?; + let signers = certificates + .iter() + .map(|cert| cert.clone().intent_message().value.signers()) + .collect::>(); + verified_certs.into_iter().zip(signers).collect::>() }; let consensus_transactions = NonEmpty::collect(verified_certificates.iter().map(|certificate| { @@ -1359,13 +1366,14 @@ impl Validator for ValidatorService { request: tonic::Request, ) -> Result, tonic::Status> { let validator_service = self.clone(); + let sender = request.get_ref().intent_message().value.signers(); // Spawns a task which handles the transaction. The task will unconditionally continue // processing in the event that the client connection is dropped. spawn_monitored_task!(async move { // NB: traffic tally wrapping handled within the task rather than on task exit // to prevent an attacker from subverting traffic control by severing the connection - handle_with_decoration!(validator_service, transaction_impl, request) + handle_with_decoration!(validator_service, transaction_impl, request, Some(sender)) }) .await .unwrap() @@ -1376,13 +1384,24 @@ impl Validator for ValidatorService { request: tonic::Request, ) -> Result, tonic::Status> { let validator_service = self.clone(); + let sender = request + .get_ref() + .transaction + .intent_message() + .value + .signers(); // Spawns a task which handles the transaction. The task will unconditionally continue // processing in the event that the client connection is dropped. spawn_monitored_task!(async move { // NB: traffic tally wrapping handled within the task rather than on task exit // to prevent an attacker from subverting traffic control by severing the connection - handle_with_decoration!(validator_service, transaction_v2_impl, request) + handle_with_decoration!( + validator_service, + transaction_v2_impl, + request, + Some(sender) + ) }) .await .unwrap() @@ -1393,13 +1412,19 @@ impl Validator for ValidatorService { request: tonic::Request, ) -> Result, tonic::Status> { let validator_service = self.clone(); + let sender = request.get_ref().intent_message().value.signers(); // Spawns a task which handles the certificate. The task will unconditionally continue // processing in the event that the client connection is dropped. spawn_monitored_task!(async move { // NB: traffic tally wrapping handled within the task rather than on task exit // to prevent an attacker from subverting traffic control by severing the connection. - handle_with_decoration!(validator_service, submit_certificate_impl, request) + handle_with_decoration!( + validator_service, + submit_certificate_impl, + request, + Some(sender) + ) }) .await .unwrap() @@ -1409,14 +1434,22 @@ impl Validator for ValidatorService { &self, request: tonic::Request, ) -> Result, tonic::Status> { - handle_with_decoration!(self, handle_certificate_v2_impl, request) + let sender = request.get_ref().intent_message().value.signers(); + handle_with_decoration!(self, handle_certificate_v2_impl, request, Some(sender)) } async fn handle_certificate_v3( &self, request: tonic::Request, ) -> Result, tonic::Status> { - handle_with_decoration!(self, handle_certificate_v3_impl, request) + let sender = request + .certificate + .transaction + .get_ref() + .intent_message() + .value + .signers(); + handle_with_decoration!(self, handle_certificate_v3_impl, request, Some(sender)) } async fn handle_soft_bundle_certificates_v3(