-
Notifications
You must be signed in to change notification settings - Fork 5
SPDD validation test #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
SPDD validation test #261
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
99676f4
test: add SPDD validation test
whankinsiv ee70a96
fix: simplify epoch stakes config
whankinsiv 17c2580
fix: improve README and fix elided lifetime warnings
whankinsiv 17f4a19
fix: remove package-lock.json from root directory
whankinsiv 6cc58af
fix: initialize spdd_store with retation_epochs=1 for test
whankinsiv a27d95e
merge upstream/main
whankinsiv e02a3dc
fix: add explict types to spdd rest response generation and remove in…
whankinsiv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| use crate::state::State; | ||
| use acropolis_common::serialization::Bech32WithHrp; | ||
| use acropolis_common::DelegatedStake; | ||
| use acropolis_common::{extract_strict_query_params, messages::RESTResponse}; | ||
| use anyhow::Result; | ||
| use std::{collections::HashMap, sync::Arc}; | ||
| use tokio::sync::Mutex; | ||
|
|
||
| /// Handles /spdd | ||
| pub async fn handle_spdd( | ||
| state: Arc<Mutex<State>>, | ||
| params: HashMap<String, String>, | ||
| ) -> Result<RESTResponse> { | ||
| let locked = state.lock().await; | ||
|
|
||
| extract_strict_query_params!(params, { | ||
| "epoch" => epoch: Option<u64>, | ||
| }); | ||
|
|
||
| let spdd_opt = match epoch { | ||
| Some(epoch) => match locked.get_epoch(epoch) { | ||
| Some(spdd) => Some(spdd), | ||
| None => { | ||
| return Ok(RESTResponse::with_text( | ||
| 404, | ||
| &format!("SPDD not found for epoch {}", epoch), | ||
| )); | ||
| } | ||
| }, | ||
| None => locked.get_latest(), | ||
| }; | ||
|
|
||
| if let Some(spdd) = spdd_opt { | ||
| let spdd: HashMap<String, DelegatedStake> = spdd | ||
| .iter() | ||
| .map(|(k, v)| { | ||
| ( | ||
| k.to_bech32_with_hrp("pool").unwrap_or_else(|_| hex::encode(k)), | ||
| *v, | ||
| ) | ||
| }) | ||
| .collect(); | ||
|
|
||
| match serde_json::to_string(&spdd) { | ||
| Ok(body) => Ok(RESTResponse::with_json(200, &body)), | ||
| Err(e) => Ok(RESTResponse::with_text( | ||
| 500, | ||
| &format!( | ||
| "Internal server error retrieving stake pool delegation distribution: {e}" | ||
| ), | ||
| )), | ||
| } | ||
| } else { | ||
| Ok(RESTResponse::with_json(200, "{}")) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| MAINNET_DBSYNC_URL= | ||
| ACROPOLIS_REST_URL=http://127.0.0.1:4340 | ||
| SPDD_VALIDATION_START_EPOCH=208 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| node_modules/ | ||
| package-lock.json | ||
| .env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Running the SPDD validation test | ||
| 1. Install dependencies | ||
| ```bash | ||
| npm install | ||
| ``` | ||
|
|
||
| 2. Set environment variables | ||
| Create a `.env` file in the `tests/integration/` with the following values: | ||
| ```env | ||
| MAINNET_DBSYNC_URL=postgres://user:password@host:port/dbname | ||
| ACROPOLIS_REST_URL=https://your-acropolis-endpoint | ||
| SPDD_VALIDATION_START_EPOCH=208 | ||
| ``` | ||
| If you do not currently operate a mainnet DB Sync server, Demeter provides free access to an instance | ||
|
|
||
| 3. Enable SPDD storage in `omnibus.toml` | ||
| ```toml | ||
| [module.spdd-state] | ||
| store-spdd = true | ||
| ``` | ||
|
|
||
| 4. Start Omnibus process and wait for sync | ||
| ```bash | ||
| cd ~/acropolis/processes/omnibus | ||
| cargo run --release --bin acropolis_process_omnibus | ||
| ``` | ||
|
|
||
| 5. Run the validator | ||
| ```bash | ||
| npm run test:spdd | ||
| ``` | ||
|
|
||
| 6. Observe output | ||
| This validator will: | ||
| * Compare Acropolis SPDD data with DB Sync epoch stake data | ||
| * Display total stake and per-pool differences | ||
| * Pause for review when mismatches are detected | ||
| * Stop automatically when Acropolis stops returning data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "name": "acropolis-integration-tests", | ||
| "version": "1.0.0", | ||
| "type": "module", | ||
| "private": true, | ||
| "scripts": { | ||
| "test:spdd": "ts-node spdd.test.ts" | ||
| }, | ||
| "dependencies": { | ||
| "axios": "^1.12.2", | ||
| "dotenv": "^17.2.3", | ||
| "pg": "^8.16.3" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/node": "^22.5.2", | ||
| "@types/pg": "^8.15.5", | ||
| "ts-node": "^10.9.2", | ||
| "typescript": "^5.9.3" | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.