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
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,18 @@ where
providers
}

/// Fetch and parse blockchain providers (sourceType=0)
/// Fetch and parse relayer-backed providers (sourceType=0, sourceType=3, ...)
/// Uses shared OracleTaskClient for task enumeration
fn fetch_blockchain_providers(
fn fetch_relayer_providers(
&self,
block_id: BlockId,
) -> Vec<gravity_api_types::on_chain_config::jwks::OIDCProvider> {
let task_uris = self.oracle_client().fetch_blockchain_task_uris(block_id);
let task_uris = self.oracle_client().fetch_relayer_task_uris(block_id);

task_uris
.into_iter()
.map(|(uri, nonce)| {
info!(uri = %uri, nonce = nonce, "Found blockchain monitoring task");
info!(uri = %uri, nonce = nonce, "Found relayer-backed oracle task");
gravity_api_types::on_chain_config::jwks::OIDCProvider {
name: uri.clone(),
config_url: uri,
Expand All @@ -125,8 +125,8 @@ where
// 1. Fetch JWK providers (sourceType=1)
all_providers.extend(self.fetch_jwk_providers(block_id));

// 2. Fetch blockchain providers (sourceType=0)
all_providers.extend(self.fetch_blockchain_providers(block_id));
// 2. Fetch providers implemented by the relayer (sourceType=0, sourceType=3, ...)
all_providers.extend(self.fetch_relayer_providers(block_id));

info!(provider_count = all_providers.len(), "Fetched oracle task providers");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ use tracing::{info, warn};
/// Source type for blockchain events in NativeOracle
pub const SOURCE_TYPE_BLOCKCHAIN: u32 = 0;

/// Source type for deterministic price-feed rounds.
pub const SOURCE_TYPE_PRICE_FEED: u32 = 3;

/// Source types implemented by this relayer build.
///
/// Provider PRs extend this list together with their runtime dispatch. Keeping
/// discovery and execution support in one list prevents publishing tasks that
/// the local relayer cannot execute.
pub const RELAYER_BACKED_SOURCE_TYPES: &[u32] = &[SOURCE_TYPE_BLOCKCHAIN];
pub const RELAYER_BACKED_SOURCE_TYPES: &[u32] = &[SOURCE_TYPE_BLOCKCHAIN, SOURCE_TYPE_PRICE_FEED];

fn has_valid_task_cardinality(source_type: u32, task_count: usize) -> bool {
!RELAYER_BACKED_SOURCE_TYPES.contains(&source_type) || task_count == 1
Expand All @@ -43,6 +46,8 @@ mod tests {

#[test]
fn relayer_backed_sources_require_exactly_one_task() {
assert_eq!(RELAYER_BACKED_SOURCE_TYPES, &[SOURCE_TYPE_BLOCKCHAIN, SOURCE_TYPE_PRICE_FEED]);

for source_type in RELAYER_BACKED_SOURCE_TYPES {
assert!(!has_valid_task_cardinality(*source_type, 0));
assert!(has_valid_task_cardinality(*source_type, 1));
Expand Down
Loading