From e0a919d2ee8819d73e454b2d7f21240a763f1302 Mon Sep 17 00:00:00 2001 From: Mark Logan <103447440+mystenmark@users.noreply.github.com> Date: Wed, 26 Jun 2024 17:19:52 -0700 Subject: [PATCH] Only store cert signatures for certs handled by AuthorityServer (#18417) The main behavior change caused here is that we will no longer store signatures of certificates that arrive via consensus. However, once a certificate has been committed in consensus, there is little need for quorum driver to be able to obtain a certificate via the `transaction` API --- crates/sui-core/src/authority.rs | 3 +-- .../src/authority/authority_per_epoch_store.rs | 18 +++++++++++++----- crates/sui-core/src/authority_server.rs | 1 + crates/sui-core/src/checkpoints/mod.rs | 3 +-- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/crates/sui-core/src/authority.rs b/crates/sui-core/src/authority.rs index ec59e32798b38..e73e3d957cff5 100644 --- a/crates/sui-core/src/authority.rs +++ b/crates/sui-core/src/authority.rs @@ -1433,10 +1433,9 @@ impl AuthorityState { // The insertion to epoch_store is not atomic with the insertion to the perpetual store. This is OK because // we insert to the epoch store first. And during lookups we always look up in the perpetual store first. - epoch_store.insert_tx_cert_and_effects_signature( + epoch_store.insert_tx_key_and_effects_signature( &tx_key, tx_digest, - certificate.certificate_sig(), effects_sig.as_ref(), )?; diff --git a/crates/sui-core/src/authority/authority_per_epoch_store.rs b/crates/sui-core/src/authority/authority_per_epoch_store.rs index 80a88190280c2..6455f0696f492 100644 --- a/crates/sui-core/src/authority/authority_per_epoch_store.rs +++ b/crates/sui-core/src/authority/authority_per_epoch_store.rs @@ -1152,18 +1152,26 @@ impl AuthorityPerEpochStore { } #[instrument(level = "trace", skip_all)] - pub fn insert_tx_cert_and_effects_signature( + pub fn insert_tx_cert_sig( + &self, + tx_digest: &TransactionDigest, + cert_sig: &AuthorityStrongQuorumSignInfo, + ) -> SuiResult { + let tables = self.tables()?; + Ok(tables + .transaction_cert_signatures + .insert(tx_digest, cert_sig)?) + } + + #[instrument(level = "trace", skip_all)] + pub fn insert_tx_key_and_effects_signature( &self, tx_key: &TransactionKey, tx_digest: &TransactionDigest, - cert_sig: Option<&AuthorityStrongQuorumSignInfo>, effects_signature: Option<&AuthoritySignInfo>, ) -> SuiResult { let tables = self.tables()?; let mut batch = self.tables()?.effects_signatures.batch(); - if let Some(cert_sig) = cert_sig { - batch.insert_batch(&tables.transaction_cert_signatures, [(tx_digest, cert_sig)])?; - } if self.executed_in_epoch_table_enabled() { batch.insert_batch(&tables.executed_in_epoch, [(tx_digest, ())])?; diff --git a/crates/sui-core/src/authority_server.rs b/crates/sui-core/src/authority_server.rs index 7b386eec796bf..17d09e401a170 100644 --- a/crates/sui-core/src/authority_server.rs +++ b/crates/sui-core/src/authority_server.rs @@ -592,6 +592,7 @@ impl ValidatorService { .and_then(Result::ok); let signed_effects = self.state.sign_effects(effects, epoch_store)?; + epoch_store.insert_tx_cert_sig(certificate.digest(), certificate.auth_sig())?; Ok::<_, SuiError>(HandleCertificateResponseV3 { effects: signed_effects.into_inner(), diff --git a/crates/sui-core/src/checkpoints/mod.rs b/crates/sui-core/src/checkpoints/mod.rs index db569ffa28c74..ffd5d4e009678 100644 --- a/crates/sui-core/src/checkpoints/mod.rs +++ b/crates/sui-core/src/checkpoints/mod.rs @@ -2762,10 +2762,9 @@ mod tests { let effects = e(digest, dependencies, gas_used); store.insert(digest, effects.clone()); epoch_store - .insert_tx_cert_and_effects_signature( + .insert_tx_key_and_effects_signature( &TransactionKey::Digest(digest), &digest, - None, Some(&AuthoritySignInfo::new( epoch_store.epoch(), &effects,