diff --git a/.maintain/add-prepush-hook.sh b/.maintain/add-prepush-hook.sh index 1ac90c730..060399eb6 100755 --- a/.maintain/add-prepush-hook.sh +++ b/.maintain/add-prepush-hook.sh @@ -10,10 +10,11 @@ echo "Running clippy checks" set +e echo "Running clippy for main targets" -cargo clippy --all-features -- -W clippy::all -A clippy::style -A clippy::forget_copy -A clippy::forget_ref +chmod +x ./scripts/cmd-all +./scripts/cmd-all clippy "clippy --lib --bins" "-- -W clippy::all -A clippy::style -A forgetting_copy_types -A forgetting_references" echo "Running clippy for all targets" -cargo clippy --all-features --all-targets -- -A clippy::all -W clippy::correctness -A clippy::forget_copy -A clippy::forget_ref +cargo +nightly-2024-02-09 clippy --all-features --all-targets -- -A clippy::all -W clippy::correctness -A clippy::forget_copy -A clippy::forget_ref CLIPPY_EXIT_CODE=$? diff --git a/clients/stellar-relay-lib/resources/config/mainnet/stellar_relay_config_mainnet_iowa.json b/clients/stellar-relay-lib/resources/config/mainnet/stellar_relay_config_mainnet_iowa.json index e470a4c39..099297c28 100644 --- a/clients/stellar-relay-lib/resources/config/mainnet/stellar_relay_config_mainnet_iowa.json +++ b/clients/stellar-relay-lib/resources/config/mainnet/stellar_relay_config_mainnet_iowa.json @@ -11,6 +11,11 @@ "is_pub_net": true }, "stellar_history_archive_urls": [ - "http://history.stellar.org/prd/core-live/core_live_001" + "http://history.stellar.org/prd/core-live/core_live_001", + "http://history.stellar.org/prd/core-live/core_live_002", + "http://history.stellar.org/prd/core-live/core_live_003", + "https://stellar-history-de-fra.satoshipay.io", + "https://stellar-history-sg-sin.satoshipay.io", + "https://stellar-history-us-iowa.satoshipay.io" ] } \ No newline at end of file diff --git a/clients/stellar-relay-lib/resources/config/testnet/stellar_relay_config_sdftest1.json b/clients/stellar-relay-lib/resources/config/testnet/stellar_relay_config_sdftest1.json index 5111786e9..ca38e7b79 100644 --- a/clients/stellar-relay-lib/resources/config/testnet/stellar_relay_config_sdftest1.json +++ b/clients/stellar-relay-lib/resources/config/testnet/stellar_relay_config_sdftest1.json @@ -10,5 +10,9 @@ "version_str": "stellar-core 20.2.0.rc3 (34d82fc00426643e16b7ad59c9fde169b778eb4b)", "is_pub_net": false }, - "stellar_history_archive_urls": [] + "stellar_history_archive_urls": [ + "http://history.stellar.org/prd/core-testnet/core_testnet_001", + "http://history.stellar.org/prd/core-testnet/core_testnet_002", + "http://history.stellar.org/prd/core-testnet/core_testnet_003" + ] } \ No newline at end of file diff --git a/clients/stellar-relay-lib/resources/config/testnet/stellar_relay_config_sdftest2.json b/clients/stellar-relay-lib/resources/config/testnet/stellar_relay_config_sdftest2.json index bda018169..5452e9627 100644 --- a/clients/stellar-relay-lib/resources/config/testnet/stellar_relay_config_sdftest2.json +++ b/clients/stellar-relay-lib/resources/config/testnet/stellar_relay_config_sdftest2.json @@ -10,5 +10,9 @@ "version_str": "stellar-core 20.2.0.rc3 (34d82fc00426643e16b7ad59c9fde169b778eb4b)", "is_pub_net": false }, - "stellar_history_archive_urls": [] + "stellar_history_archive_urls": [ + "http://history.stellar.org/prd/core-testnet/core_testnet_001", + "http://history.stellar.org/prd/core-testnet/core_testnet_002", + "http://history.stellar.org/prd/core-testnet/core_testnet_003" + ] } \ No newline at end of file diff --git a/clients/stellar-relay-lib/resources/config/testnet/stellar_relay_config_sdftest3.json b/clients/stellar-relay-lib/resources/config/testnet/stellar_relay_config_sdftest3.json index 8f2643ad6..e45690cdd 100644 --- a/clients/stellar-relay-lib/resources/config/testnet/stellar_relay_config_sdftest3.json +++ b/clients/stellar-relay-lib/resources/config/testnet/stellar_relay_config_sdftest3.json @@ -10,5 +10,9 @@ "version_str": "stellar-core 20.2.0.rc3 (34d82fc00426643e16b7ad59c9fde169b778eb4b)", "is_pub_net": false }, - "stellar_history_archive_urls": [] + "stellar_history_archive_urls": [ + "http://history.stellar.org/prd/core-testnet/core_testnet_001", + "http://history.stellar.org/prd/core-testnet/core_testnet_002", + "http://history.stellar.org/prd/core-testnet/core_testnet_003" + ] } \ No newline at end of file diff --git a/clients/vault/resources/config/mainnet/stellar_relay_config_frankfurt.json b/clients/vault/resources/config/mainnet/stellar_relay_config_frankfurt.json index 33de56f48..bb74b5509 100644 --- a/clients/vault/resources/config/mainnet/stellar_relay_config_frankfurt.json +++ b/clients/vault/resources/config/mainnet/stellar_relay_config_frankfurt.json @@ -11,6 +11,9 @@ "is_pub_net": true }, "stellar_history_archive_urls": [ + "http://history.stellar.org/prd/core-live/core_live_001", + "http://history.stellar.org/prd/core-live/core_live_002", + "http://history.stellar.org/prd/core-live/core_live_003", "https://stellar-history-de-fra.satoshipay.io", "https://stellar-history-sg-sin.satoshipay.io", "https://stellar-history-us-iowa.satoshipay.io" diff --git a/clients/vault/resources/config/mainnet/stellar_relay_config_iowa.json b/clients/vault/resources/config/mainnet/stellar_relay_config_iowa.json index e470a4c39..099297c28 100644 --- a/clients/vault/resources/config/mainnet/stellar_relay_config_iowa.json +++ b/clients/vault/resources/config/mainnet/stellar_relay_config_iowa.json @@ -11,6 +11,11 @@ "is_pub_net": true }, "stellar_history_archive_urls": [ - "http://history.stellar.org/prd/core-live/core_live_001" + "http://history.stellar.org/prd/core-live/core_live_001", + "http://history.stellar.org/prd/core-live/core_live_002", + "http://history.stellar.org/prd/core-live/core_live_003", + "https://stellar-history-de-fra.satoshipay.io", + "https://stellar-history-sg-sin.satoshipay.io", + "https://stellar-history-us-iowa.satoshipay.io" ] } \ No newline at end of file diff --git a/clients/vault/resources/config/mainnet/stellar_relay_config_singapore.json b/clients/vault/resources/config/mainnet/stellar_relay_config_singapore.json index cc79df90d..90daa5920 100644 --- a/clients/vault/resources/config/mainnet/stellar_relay_config_singapore.json +++ b/clients/vault/resources/config/mainnet/stellar_relay_config_singapore.json @@ -11,8 +11,11 @@ "is_pub_net": true }, "stellar_history_archive_urls": [ + "http://history.stellar.org/prd/core-live/core_live_001", + "http://history.stellar.org/prd/core-live/core_live_002", + "http://history.stellar.org/prd/core-live/core_live_003", + "https://stellar-history-de-fra.satoshipay.io", "https://stellar-history-sg-sin.satoshipay.io", - "https://stellar-history-us-iowa.satoshipay.io", - "https://stellar-history-de-fra.satoshipay.io" + "https://stellar-history-us-iowa.satoshipay.io" ] } \ No newline at end of file diff --git a/clients/vault/resources/config/testnet/stellar_relay_config_sdftest1.json b/clients/vault/resources/config/testnet/stellar_relay_config_sdftest1.json index 5111786e9..ca38e7b79 100644 --- a/clients/vault/resources/config/testnet/stellar_relay_config_sdftest1.json +++ b/clients/vault/resources/config/testnet/stellar_relay_config_sdftest1.json @@ -10,5 +10,9 @@ "version_str": "stellar-core 20.2.0.rc3 (34d82fc00426643e16b7ad59c9fde169b778eb4b)", "is_pub_net": false }, - "stellar_history_archive_urls": [] + "stellar_history_archive_urls": [ + "http://history.stellar.org/prd/core-testnet/core_testnet_001", + "http://history.stellar.org/prd/core-testnet/core_testnet_002", + "http://history.stellar.org/prd/core-testnet/core_testnet_003" + ] } \ No newline at end of file diff --git a/clients/vault/resources/config/testnet/stellar_relay_config_sdftest2.json b/clients/vault/resources/config/testnet/stellar_relay_config_sdftest2.json index bda018169..5452e9627 100644 --- a/clients/vault/resources/config/testnet/stellar_relay_config_sdftest2.json +++ b/clients/vault/resources/config/testnet/stellar_relay_config_sdftest2.json @@ -10,5 +10,9 @@ "version_str": "stellar-core 20.2.0.rc3 (34d82fc00426643e16b7ad59c9fde169b778eb4b)", "is_pub_net": false }, - "stellar_history_archive_urls": [] + "stellar_history_archive_urls": [ + "http://history.stellar.org/prd/core-testnet/core_testnet_001", + "http://history.stellar.org/prd/core-testnet/core_testnet_002", + "http://history.stellar.org/prd/core-testnet/core_testnet_003" + ] } \ No newline at end of file diff --git a/clients/vault/resources/config/testnet/stellar_relay_config_sdftest3.json b/clients/vault/resources/config/testnet/stellar_relay_config_sdftest3.json index 8f2643ad6..e45690cdd 100644 --- a/clients/vault/resources/config/testnet/stellar_relay_config_sdftest3.json +++ b/clients/vault/resources/config/testnet/stellar_relay_config_sdftest3.json @@ -10,5 +10,9 @@ "version_str": "stellar-core 20.2.0.rc3 (34d82fc00426643e16b7ad59c9fde169b778eb4b)", "is_pub_net": false }, - "stellar_history_archive_urls": [] + "stellar_history_archive_urls": [ + "http://history.stellar.org/prd/core-testnet/core_testnet_001", + "http://history.stellar.org/prd/core-testnet/core_testnet_002", + "http://history.stellar.org/prd/core-testnet/core_testnet_003" + ] } \ No newline at end of file diff --git a/clients/vault/src/oracle/collector/proof_builder.rs b/clients/vault/src/oracle/collector/proof_builder.rs index 1594fb155..4f1d74523 100644 --- a/clients/vault/src/oracle/collector/proof_builder.rs +++ b/clients/vault/src/oracle/collector/proof_builder.rs @@ -106,15 +106,6 @@ impl ScpMessageCollector { /// fetches envelopes from the archive async fn ask_archive_for_envelopes(&self, slot: Slot) { - if !self.is_public() { - // Fetch from archives only on public network since no archive nodes - // are available on testnet - tracing::debug!( - "ask_archive_for_envelopes(): Proof Building for slot {slot}: Cannot fetch envelopes from archive for test network" - ); - return - } - tokio::spawn(self.get_envelopes_from_horizon_archive(slot)); } diff --git a/clients/vault/src/oracle/storage/impls.rs b/clients/vault/src/oracle/storage/impls.rs index b86cc6f94..835798634 100644 --- a/clients/vault/src/oracle/storage/impls.rs +++ b/clients/vault/src/oracle/storage/impls.rs @@ -417,6 +417,41 @@ mod test { fs::remove_file(file).expect("should be able to remove the newly added file."); } + #[tokio::test] + async fn get_scp_archive_testnet_works() { + let is_mainnet = false; + let config_testnet = random_stellar_relay_config(is_mainnet); + let testnet_archive_url = config_testnet + .stellar_history_archive_urls() + .first() + .expect("should have an archive url") + .clone(); + let scp_archive_storage = ScpArchiveStorage(testnet_archive_url); + let slot_index = 235001; + + let scp_archive = scp_archive_storage + .get_archive(slot_index) + .await + .expect("should find the archive"); + + let slot_index_u32: u32 = slot_index.try_into().unwrap(); + scp_archive + .get_vec() + .iter() + .find(|&scp_entry| { + if let ScpHistoryEntry::V0(scp_entry_v0) = scp_entry { + scp_entry_v0.ledger_messages.ledger_seq == slot_index_u32 + } else { + false + } + }) + .expect("slot index should be in archive"); + + let (_, file) = scp_archive_storage.get_url_and_file_name(slot_index); + + fs::remove_file(file).expect("should be able to remove the newly added file."); + } + #[tokio::test] async fn get_transactions_archive_works() { let tx_archive_storage = TransactionsArchiveStorage::default(); @@ -439,4 +474,34 @@ mod test { fs::remove_file(file).expect("should be able to remove the newly added file."); } + + #[tokio::test] + async fn get_transactions_archive_testnet_works() { + let is_mainnet = false; + let config_testnet = random_stellar_relay_config(is_mainnet); + let testnet_archive_url = config_testnet + .stellar_history_archive_urls() + .first() + .expect("should have an archive url") + .clone(); + let tx_archive_storage = TransactionsArchiveStorage(testnet_archive_url); + + //arrange + let slot_index = 235001; + let (_url, ref filename) = tx_archive_storage.get_url_and_file_name(slot_index); + + //act + let _transactions_archive = tx_archive_storage + .get_archive(slot_index) + .await + .expect("should find the archive"); + + //assert + TransactionsArchiveStorage::read_file_xdr(filename) + .expect("File with transactions should exists"); + + let (_, file) = tx_archive_storage.get_url_and_file_name(slot_index); + + fs::remove_file(file).expect("should be able to remove the newly added file."); + } } diff --git a/clients/vault/src/oracle/storage/traits.rs b/clients/vault/src/oracle/storage/traits.rs index 1eaf648e8..c3050dbeb 100644 --- a/clients/vault/src/oracle/storage/traits.rs +++ b/clients/vault/src/oracle/storage/traits.rs @@ -116,7 +116,8 @@ pub trait ArchiveStorage { fn get_url_and_file_name(&self, slot_index: Slot) -> (String, String) { let slot_index = self.find_last_slot_index_in_batch(slot_index); - let hex_string = format!("0{:x}", slot_index); + let hex_string = format!("{:08x}", slot_index); + let file_name = format!("{hex_string}.xdr"); let base_url = self.stellar_history_base_url(); let url = format!( diff --git a/clients/vault/tests/vault_integration_tests.rs b/clients/vault/tests/vault_integration_tests.rs index a10a599fc..755740ab5 100644 --- a/clients/vault/tests/vault_integration_tests.rs +++ b/clients/vault/tests/vault_integration_tests.rs @@ -606,8 +606,20 @@ async fn test_issue_cancel_succeeds() { #[tokio::test(flavor = "multi_thread")] #[ntest::timeout(1_200_000)] // timeout at 20 minutes #[serial] -async fn test_issue_execution_succeeds_from_archive() { +async fn test_issue_execution_succeeds_from_archive_on_mainnet() { let is_public_network = true; + test_issue_execution_succeeds_from_archive_on_network(is_public_network).await; +} + +#[tokio::test(flavor = "multi_thread")] +#[ntest::timeout(1_200_000)] // timeout at 20 minutes +#[serial] +async fn test_issue_execution_succeeds_from_archive_on_testnet() { + let is_public_network = false; + test_issue_execution_succeeds_from_archive_on_network(is_public_network).await; +} + +async fn test_issue_execution_succeeds_from_archive_on_network(is_public_network: bool) { test_with_vault( is_public_network, |client, _vault_wallet, user_wallet, _oracle_agent, vault_id, vault_provider| async move { diff --git a/scripts/cmd-all b/scripts/cmd-all old mode 100644 new mode 100755