Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bin/dipper-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,9 @@ pub struct DipsAgreementConfig {
pub max_grt_per_billion_entities_per_30_days: f64,

/// Number of days to look back for declined indexers (standard exclusion). Covers
/// CanceledByIndexer, expiries whose offer reached the chain, and structurally
/// persistent rejections (UNSUPPORTED_NETWORK, MANIFEST_TOO_LARGE). Default: 30 days.
/// CanceledByIndexer, AbandonedByIndexer, expiries whose offer reached the chain, and
/// structurally persistent rejections (UNSUPPORTED_NETWORK, MANIFEST_TOO_LARGE). Default: 30
/// days.
#[serde(default = "default_declined_indexer_lookback_days")]
pub declined_indexer_lookback_days: i32,

Expand Down
7 changes: 4 additions & 3 deletions bin/dipper-service/src/registry/agreement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@ pub trait AgreementRegistry {
indexer_ids: &[IndexerId],
) -> RegistryResult<std::collections::HashMap<DeploymentId, Vec<IndexerId>>>;

/// Get declined `CanceledByIndexer`/`Expired`/`Rejected` indexers grouped by
/// deployment. Each rejection reason gets its own exclusion window, as does an
/// expiry that never had an offer transaction; see the query for the details.
/// Get declined `CanceledByIndexer`/`Expired`/`Rejected` indexers, and those whose agreement
/// dipper ended `AbandonedByIndexer`, grouped by deployment. Each rejection reason gets its
/// own exclusion window, as does an expiry that never had an offer transaction; see the query
/// for the details.
async fn get_declined_indexers_by_deployment(
&self,
default_lookback_days: i32,
Expand Down
10 changes: 6 additions & 4 deletions dipper-pgregistry/src/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,10 @@ impl PgRegistry {
.collect())
}

/// Get declined `CanceledByIndexer`/`Expired`/`Rejected` indexers grouped by
/// deployment (deployment id -> indexer ids). Each rejection reason gets its own
/// exclusion window, as does an expiry that never had an offer transaction.
/// Get declined `CanceledByIndexer`/`Expired`/`Rejected` indexers, and those whose agreement
/// dipper ended `AbandonedByIndexer`, grouped by deployment (deployment id -> indexer ids).
/// Each rejection reason gets its own exclusion window, as does an expiry that never had an
/// offer transaction.
pub async fn get_declined_indexers_by_deployment(
&self,
default_lookback_days: i32,
Expand All @@ -761,7 +762,7 @@ impl PgRegistry {
deployment_id,
array_agg(DISTINCT indexer_id) as indexer_ids
FROM dipper_reg_indexing_agreements
WHERE status IN ($1, $2, $3)
WHERE status IN ($1, $2, $3, $20)
AND (
-- PRICE_TOO_LOW: shorter lookback (until next IISA refresh)
(rejection_reason = $6
Expand Down Expand Up @@ -816,6 +817,7 @@ impl PgRegistry {
.bind(uncertain_lookback_days) // $17
.bind(SENDER_NOT_TRUSTED) // $18
.bind(UNSPECIFIED) // $19
.bind(IndexingAgreementStatus::AbandonedByIndexer) // $20
.fetch_all(&self.pool)
.await?;

Expand Down
46 changes: 46 additions & 0 deletions dipper-pgregistry/tests/it_registry_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,52 @@ async fn get_declined_indexers_by_deployment_returns_rejected() {
assert!(declined_5e.contains(&indexer_c));
}

#[tokio::test]
async fn get_declined_indexers_by_deployment_includes_an_indexer_that_abandoned_it() {
// Otherwise the reassessment that replaces it could pick the same indexer straight back.
let (db, _temp_db) = temp_registry_db().await;
run_fixture(&db, include_str!("fixtures/0002_indexing_agreements.sql"))
.await
.expect("Failed to run fixture");
let registry = PgRegistry::new(db);
// Fixture 0002's accepted agreement.
let agreement_id =
IndexingAgreementId::from_bytes([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3]);
let deployment: DeploymentId = "QmUzRg2HHMpbgf6Q4VHKNDbtBEJnyp5JWCh2gUX9AV6jXv"
.parse()
.unwrap();
let indexer = indexer_id!("d609e9fdd6ce53e5a26278c50486dd6791d4d705");
registry
.mark_indexing_agreement_as_abandoning(&agreement_id)
.await
.expect("abandon");
registry
.mark_indexing_agreement_as_canceled_by_requester(&agreement_id)
.await
.expect("ended abandoned");

let within = registry
.get_declined_indexers_by_deployment(30, 1, 5, 1)
.await
.expect("Failed to get declined indexers");
let past = registry
.get_declined_indexers_by_deployment(0, 1, 5, 1)
.await
.expect("Failed to get declined indexers");

assert!(
within
.get(&deployment)
.is_some_and(|ids| ids.contains(&indexer))
);
assert!(
!past
.get(&deployment)
.is_some_and(|ids| ids.contains(&indexer)),
"only for the standard lookback"
);
}

#[tokio::test]
async fn get_declined_indexers_by_deployment_empty_when_no_declines() {
//* Given
Expand Down
Loading