From c9c624ca730be5dc462ba68eaa9fad9a958e3796 Mon Sep 17 00:00:00 2001 From: oxade <93547199+oxade@users.noreply.github.com> Date: Mon, 20 Nov 2023 08:56:52 -0800 Subject: [PATCH] [typed-store/graphql] add util to sync all read only tables (#14910) --- .../src/simulator_persisted_store.rs | 40 +------------------ crates/typed-store-derive/src/lib.rs | 9 +++++ 2 files changed, 10 insertions(+), 39 deletions(-) diff --git a/crates/sui-transactional-test-runner/src/simulator_persisted_store.rs b/crates/sui-transactional-test-runner/src/simulator_persisted_store.rs index b49bdfd06bdd7..ff928ab13181b 100644 --- a/crates/sui-transactional-test-runner/src/simulator_persisted_store.rs +++ b/crates/sui-transactional-test-runner/src/simulator_persisted_store.rs @@ -659,46 +659,8 @@ impl NodeStateGetter for PersistedStoreInnerReadOnlyWrapper { impl PersistedStoreInnerReadOnlyWrapper { pub fn sync(&self) { - // Todo: add macro utility for this in typed store derive self.inner - .checkpoint_digest_to_sequence_number - .try_catch_up_with_primary() - .expect("Fatal: DB sync failed"); - self.inner - .checkpoints - .try_catch_up_with_primary() - .expect("Fatal: DB sync failed"); - self.inner - .effects - .try_catch_up_with_primary() - .expect("Fatal: DB sync failed"); - self.inner - .epoch_to_committee - .try_catch_up_with_primary() - .expect("Fatal: DB sync failed"); - self.inner - .events - .try_catch_up_with_primary() - .expect("Fatal: DB sync failed"); - self.inner - .events_tx_digest_index - .try_catch_up_with_primary() - .expect("Fatal: DB sync failed"); - self.inner - .live_objects - .try_catch_up_with_primary() - .expect("Fatal: DB sync failed"); - self.inner - .objects - .try_catch_up_with_primary() - .expect("Fatal: DB sync failed"); - self.inner - .transactions - .try_catch_up_with_primary() - .expect("Fatal: DB sync failed"); - self.inner - .checkpoint_contents - .try_catch_up_with_primary() + .try_catch_up_with_primary_all() .expect("Fatal: DB sync failed"); } } diff --git a/crates/typed-store-derive/src/lib.rs b/crates/typed-store-derive/src/lib.rs index 113691b4b39d1..57fe51fd1c3b8 100644 --- a/crates/typed-store-derive/src/lib.rs +++ b/crates/typed-store-derive/src/lib.rs @@ -600,6 +600,15 @@ pub fn derive_dbmap_utils_general(input: TokenStream) -> TokenStream { (stringify!(#field_names).to_owned(), (stringify!(#key_names).to_owned(), stringify!(#value_names).to_owned())), )*].into_iter().collect() } + + /// Try catch up with primary for all tables. This can be a slow operation + /// Tables must be opened in read only mode using `open_tables_read_only` + pub fn try_catch_up_with_primary_all(&self) -> eyre::Result<()> { + #( + typed_store::traits::Map::try_catch_up_with_primary(&self.#field_names)?; + )* + Ok(()) + } } impl <