Skip to content

Commit

Permalink
482 add stellar testnet archive urls to vault client config (#524)
Browse files Browse the repository at this point in the history
* add testnet archive configurations and tests, allow vault to fetch from testnet archive instead of skipping

Signed-off-by: Gianfranco <[email protected]>

* adapt pre-push hook to new build script

Signed-off-by: Gianfranco <[email protected]>

* fix incorrect pointing to archive url

Signed-off-by: Gianfranco <[email protected]>

* format

Signed-off-by: Gianfranco <[email protected]>

* Revert "format"

This reverts commit 320c1c3.

* fix https://github.com/pendulum-chain/spacewalk/actions/runs/9016595369/job/24777832063#step:13:15

* https://github.com/pendulum-chain/spacewalk/actions/runs/9057879176/job/24882561006?pr=524#step:13:15

* duplicate issue execution test from archive for testnet also

* Update clients/vault/tests/vault_integration_tests.rs

Co-authored-by: Marcel Ebert <[email protected]>

* add full list of archive urls to config files

* more modifications to archive urls

* remove testing log dependency

* fmt modified file

---------

Signed-off-by: Gianfranco <[email protected]>
Co-authored-by: b-yap <[email protected]>
Co-authored-by: Marcel Ebert <[email protected]>
  • Loading branch information
3 people authored May 16, 2024
1 parent e7a672b commit badbbfc
Show file tree
Hide file tree
Showing 16 changed files with 133 additions and 23 deletions.
5 changes: 3 additions & 2 deletions .maintain/add-prepush-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=$?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
9 changes: 0 additions & 9 deletions clients/vault/src/oracle/collector/proof_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
65 changes: 65 additions & 0 deletions clients/vault/src/oracle/storage/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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.");
}
}
3 changes: 2 additions & 1 deletion clients/vault/src/oracle/storage/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
14 changes: 13 additions & 1 deletion clients/vault/tests/vault_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Empty file modified scripts/cmd-all
100644 → 100755
Empty file.

0 comments on commit badbbfc

Please sign in to comment.