diff --git a/hubble/.sqlx/query-c5f3ec72c60b255774169f6fd66c50abcba57c05596a06980f8fa7a5c166d437.json b/hubble/.sqlx/query-2b8671fae8d787b0815d58fac90c8cc344b4d2d666acba2ee980b3d7fce6b2f1.json similarity index 69% rename from hubble/.sqlx/query-c5f3ec72c60b255774169f6fd66c50abcba57c05596a06980f8fa7a5c166d437.json rename to hubble/.sqlx/query-2b8671fae8d787b0815d58fac90c8cc344b4d2d666acba2ee980b3d7fce6b2f1.json index 189e00fa9d..1ba7498425 100644 --- a/hubble/.sqlx/query-c5f3ec72c60b255774169f6fd66c50abcba57c05596a06980f8fa7a5c166d437.json +++ b/hubble/.sqlx/query-2b8671fae8d787b0815d58fac90c8cc344b4d2d666acba2ee980b3d7fce6b2f1.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n DELETE FROM hubble.block_status\n WHERE label = $1 AND height = $2\n RETURNING hash\n ", + "query": "\n DELETE FROM hubble.block_status\n WHERE indexer_id = $1 AND height = $2\n RETURNING hash\n ", "describe": { "columns": [ { @@ -19,5 +19,5 @@ false ] }, - "hash": "c5f3ec72c60b255774169f6fd66c50abcba57c05596a06980f8fa7a5c166d437" + "hash": "2b8671fae8d787b0815d58fac90c8cc344b4d2d666acba2ee980b3d7fce6b2f1" } diff --git a/hubble/.sqlx/query-3435ec7d5e598f85a4730b3118125690ff8db6ac78a4b3885d5cde65c13bf3eb.json b/hubble/.sqlx/query-5456a84ffdf5ebecc099b99333561c6999c4dbebb73e39d6532d03951dad244a.json similarity index 66% rename from hubble/.sqlx/query-3435ec7d5e598f85a4730b3118125690ff8db6ac78a4b3885d5cde65c13bf3eb.json rename to hubble/.sqlx/query-5456a84ffdf5ebecc099b99333561c6999c4dbebb73e39d6532d03951dad244a.json index a8ceb89f9f..10bbb1dccf 100644 --- a/hubble/.sqlx/query-3435ec7d5e598f85a4730b3118125690ff8db6ac78a4b3885d5cde65c13bf3eb.json +++ b/hubble/.sqlx/query-5456a84ffdf5ebecc099b99333561c6999c4dbebb73e39d6532d03951dad244a.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT height height\n FROM hubble.block_status\n WHERE label = $1 AND height > $2\n ORDER BY updated_at\n ", + "query": "\n SELECT height height\n FROM hubble.block_status\n WHERE indexer_id = $1 AND height > $2\n ORDER BY updated_at\n ", "describe": { "columns": [ { @@ -19,5 +19,5 @@ false ] }, - "hash": "3435ec7d5e598f85a4730b3118125690ff8db6ac78a4b3885d5cde65c13bf3eb" + "hash": "5456a84ffdf5ebecc099b99333561c6999c4dbebb73e39d6532d03951dad244a" } diff --git a/hubble/.sqlx/query-5aab290591b154e6c62251223eaa4e89f41542fd1d1eb6ee197228d54cde1883.json b/hubble/.sqlx/query-59bfa1ad1e07273027c8569988beef9f0b0d3eafb44d987130d06a38c034fef6.json similarity index 56% rename from hubble/.sqlx/query-5aab290591b154e6c62251223eaa4e89f41542fd1d1eb6ee197228d54cde1883.json rename to hubble/.sqlx/query-59bfa1ad1e07273027c8569988beef9f0b0d3eafb44d987130d06a38c034fef6.json index ed5520d9c7..e9c2608377 100644 --- a/hubble/.sqlx/query-5aab290591b154e6c62251223eaa4e89f41542fd1d1eb6ee197228d54cde1883.json +++ b/hubble/.sqlx/query-59bfa1ad1e07273027c8569988beef9f0b0d3eafb44d987130d06a38c034fef6.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT height\n FROM hubble.chain_status\n WHERE label = $1\n LIMIT 1\n ", + "query": "\n SELECT height\n FROM hubble.indexer_status\n WHERE indexer_id = $1\n LIMIT 1\n ", "describe": { "columns": [ { @@ -18,5 +18,5 @@ false ] }, - "hash": "5aab290591b154e6c62251223eaa4e89f41542fd1d1eb6ee197228d54cde1883" + "hash": "59bfa1ad1e07273027c8569988beef9f0b0d3eafb44d987130d06a38c034fef6" } diff --git a/hubble/.sqlx/query-62a11ac67a6ae78d97e5def80246f232ed27b27024dd2b72ae495edc17ef1a7d.json b/hubble/.sqlx/query-64266fb4ad7fa4dfe3489573740897685c23f7ffdb423457747f6e38c984035a.json similarity index 72% rename from hubble/.sqlx/query-62a11ac67a6ae78d97e5def80246f232ed27b27024dd2b72ae495edc17ef1a7d.json rename to hubble/.sqlx/query-64266fb4ad7fa4dfe3489573740897685c23f7ffdb423457747f6e38c984035a.json index b0f1da72fd..a956b9174a 100644 --- a/hubble/.sqlx/query-62a11ac67a6ae78d97e5def80246f232ed27b27024dd2b72ae495edc17ef1a7d.json +++ b/hubble/.sqlx/query-64266fb4ad7fa4dfe3489573740897685c23f7ffdb423457747f6e38c984035a.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT MIN(height) min_height, MAX(height) max_height\n FROM hubble.block_status\n WHERE label = $1\n ", + "query": "\n SELECT MIN(height) min_height, MAX(height) max_height\n FROM hubble.block_status\n WHERE indexer_id = $1\n ", "describe": { "columns": [ { @@ -24,5 +24,5 @@ null ] }, - "hash": "62a11ac67a6ae78d97e5def80246f232ed27b27024dd2b72ae495edc17ef1a7d" + "hash": "64266fb4ad7fa4dfe3489573740897685c23f7ffdb423457747f6e38c984035a" } diff --git a/hubble/.sqlx/query-863351bacd9ed57d485b919eb8a00a001d8ac3846aaace0bba680369b6f78ce7.json b/hubble/.sqlx/query-863351bacd9ed57d485b919eb8a00a001d8ac3846aaace0bba680369b6f78ce7.json deleted file mode 100644 index 74d2877479..0000000000 --- a/hubble/.sqlx/query-863351bacd9ed57d485b919eb8a00a001d8ac3846aaace0bba680369b6f78ce7.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO hubble.block_status (label, height, hash, timestamp)\n VALUES ($1, $2, $3, $4)\n ON CONFLICT (label, height) DO \n UPDATE SET\n hash = excluded.hash,\n timestamp = excluded.timestamp\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Text", - "Int8", - "Text", - "Timestamptz" - ] - }, - "nullable": [] - }, - "hash": "863351bacd9ed57d485b919eb8a00a001d8ac3846aaace0bba680369b6f78ce7" -} diff --git a/hubble/.sqlx/query-8720e0b358cd12588bcf09347a506229f032457d0159324bc7d9f476ffa9e4b9.json b/hubble/.sqlx/query-8720e0b358cd12588bcf09347a506229f032457d0159324bc7d9f476ffa9e4b9.json new file mode 100644 index 0000000000..722b5e7268 --- /dev/null +++ b/hubble/.sqlx/query-8720e0b358cd12588bcf09347a506229f032457d0159324bc7d9f476ffa9e4b9.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO hubble.block_status (indexer_id, height, hash, timestamp)\n VALUES ($1, $2, $3, $4)\n ON CONFLICT (indexer_id, height) DO \n UPDATE SET\n hash = excluded.hash,\n timestamp = excluded.timestamp\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Int8", + "Text", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "8720e0b358cd12588bcf09347a506229f032457d0159324bc7d9f476ffa9e4b9" +} diff --git a/hubble/.sqlx/query-833466ae02e36a730fa3cc1169cf5ca15fd5b19667681c6e318099bf1453bf18.json b/hubble/.sqlx/query-8b2d541673102e4e7010d5ed81c6f9f30476642596872a2d1abe1d13a7fde266.json similarity index 72% rename from hubble/.sqlx/query-833466ae02e36a730fa3cc1169cf5ca15fd5b19667681c6e318099bf1453bf18.json rename to hubble/.sqlx/query-8b2d541673102e4e7010d5ed81c6f9f30476642596872a2d1abe1d13a7fde266.json index 81a04f6384..82bbdc9662 100644 --- a/hubble/.sqlx/query-833466ae02e36a730fa3cc1169cf5ca15fd5b19667681c6e318099bf1453bf18.json +++ b/hubble/.sqlx/query-8b2d541673102e4e7010d5ed81c6f9f30476642596872a2d1abe1d13a7fde266.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT hash FROM hubble.block_status\n WHERE label = $1 AND height = $2\n ", + "query": "\n SELECT hash FROM hubble.block_status\n WHERE indexer_id = $1 AND height = $2\n ", "describe": { "columns": [ { @@ -19,5 +19,5 @@ false ] }, - "hash": "833466ae02e36a730fa3cc1169cf5ca15fd5b19667681c6e318099bf1453bf18" + "hash": "8b2d541673102e4e7010d5ed81c6f9f30476642596872a2d1abe1d13a7fde266" } diff --git a/hubble/.sqlx/query-d7bd3a8550dd532755fedb002f87be7bd2ff363f1b76794094690c6e022bec1c.json b/hubble/.sqlx/query-d7bd3a8550dd532755fedb002f87be7bd2ff363f1b76794094690c6e022bec1c.json new file mode 100644 index 0000000000..9502324410 --- /dev/null +++ b/hubble/.sqlx/query-d7bd3a8550dd532755fedb002f87be7bd2ff363f1b76794094690c6e022bec1c.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO hubble.indexer_status (indexer_id, height, timestamp)\n VALUES ($1, $2, $3)\n ON CONFLICT (indexer_id) DO \n UPDATE SET\n height = excluded.height,\n timestamp = excluded.timestamp\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Int8", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "d7bd3a8550dd532755fedb002f87be7bd2ff363f1b76794094690c6e022bec1c" +} diff --git a/hubble/.sqlx/query-ff4b9c5f1c270d4c9a4376598d562f8a133725083b8a76fa9c1f6db88f255bf0.json b/hubble/.sqlx/query-ff4b9c5f1c270d4c9a4376598d562f8a133725083b8a76fa9c1f6db88f255bf0.json deleted file mode 100644 index 00c894706f..0000000000 --- a/hubble/.sqlx/query-ff4b9c5f1c270d4c9a4376598d562f8a133725083b8a76fa9c1f6db88f255bf0.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO hubble.chain_status (label, height, timestamp)\n VALUES ($1, $2, $3)\n ON CONFLICT (label) DO \n UPDATE SET\n height = excluded.height,\n timestamp = excluded.timestamp\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Text", - "Int8", - "Timestamptz" - ] - }, - "nullable": [] - }, - "hash": "ff4b9c5f1c270d4c9a4376598d562f8a133725083b8a76fa9c1f6db88f255bf0" -} diff --git a/hubble/src/cli.rs b/hubble/src/cli.rs index dc51e27d12..a8475db28d 100644 --- a/hubble/src/cli.rs +++ b/hubble/src/cli.rs @@ -94,8 +94,8 @@ impl IndexerConfig { Self::EthFork(cfg) => &cfg.label, Self::Arb(cfg) => &cfg.label, Self::Scroll(cfg) => &cfg.label, - Self::DummyFetcher(cfg) => &cfg.label, - Self::EthFetcher(cfg) => &cfg.label, + Self::DummyFetcher(cfg) => &cfg.indexer_id, + Self::EthFetcher(cfg) => &cfg.indexer_id, } } } diff --git a/hubble/src/fetcher/dummy/config.rs b/hubble/src/fetcher/dummy/config.rs index 263bea88dd..eca6269ece 100644 --- a/hubble/src/fetcher/dummy/config.rs +++ b/hubble/src/fetcher/dummy/config.rs @@ -1,20 +1,21 @@ use color_eyre::eyre::Report; use sqlx::PgPool; +use unionlabs::aptos::block_info::BlockHeight; use super::dummy::{DummyContext, DummyFetcherClient}; -use crate::fetcher::fetcher::Indexer; +use crate::fetcher::fetcher::{Indexer, IndexerId}; #[derive(Clone, Debug, serde::Deserialize)] pub struct Config { - pub label: String, - pub start_height: u64, + pub indexer_id: IndexerId, + pub start_height: BlockHeight, } impl Config { pub async fn build(self, pg_pool: PgPool) -> Result, Report> { Ok(Indexer::new( pg_pool, - self.label, + self.indexer_id, self.start_height, 5, DummyContext { bla: 42 }, diff --git a/hubble/src/fetcher/eth/config.rs b/hubble/src/fetcher/eth/config.rs index 298b774406..d587dcd532 100644 --- a/hubble/src/fetcher/eth/config.rs +++ b/hubble/src/fetcher/eth/config.rs @@ -3,14 +3,14 @@ use sqlx::PgPool; use url::Url; use super::eth::{EthContext, EthFetcherClient}; -use crate::fetcher::fetcher::{BlockHeight, Indexer}; +use crate::fetcher::fetcher::{BlockHeight, Indexer, IndexerId}; const DEFAULT_CHUNK_SIZE: usize = 200; #[derive(Clone, Debug, serde::Deserialize)] pub struct Config { - pub label: String, - pub start_height: u64, + pub indexer_id: IndexerId, + pub start_height: BlockHeight, pub chunk_size: Option, pub urls: Vec, pub internal_chain_id: Option, @@ -19,7 +19,7 @@ pub struct Config { impl Config { pub async fn build(self, pg_pool: PgPool) -> Result, Report> { - // temporary safety-measure to fetch the start height from the contracts table, + // temporary safety-measure to fetch the start height from the contracts table, // because there will be no chain_state record after migrations let start_height = match self.internal_chain_id { @@ -54,7 +54,7 @@ impl Config { Ok(Indexer::new( pg_pool, - self.label, + self.indexer_id, start_height, self.chunk_size.unwrap_or(DEFAULT_CHUNK_SIZE), EthContext { urls: self.urls }, diff --git a/hubble/src/fetcher/fetcher.rs b/hubble/src/fetcher/fetcher.rs index e432844d3a..afd44348f7 100644 --- a/hubble/src/fetcher/fetcher.rs +++ b/hubble/src/fetcher/fetcher.rs @@ -27,6 +27,7 @@ pub enum FetcherError { NoBlock(BlockHeight), } +pub type IndexerId = String; pub type BlockHeight = u64; pub type BlockHash = String; pub type BlockTimestamp = OffsetDateTime; @@ -106,7 +107,7 @@ pub enum FetchMessage { #[derive(Clone)] pub struct Indexer { pg_pool: sqlx::PgPool, - label: String, + indexer_id: IndexerId, start_height: BlockHeight, chunk_size: usize, context: T::Context, @@ -115,14 +116,14 @@ pub struct Indexer { impl Indexer { pub fn new( pg_pool: sqlx::PgPool, - label: String, + indexer_id: IndexerId, start_height: BlockHeight, chunk_size: usize, context: T::Context, ) -> Self { Indexer { pg_pool, - label, + indexer_id, start_height, chunk_size, context, @@ -279,7 +280,7 @@ impl Indexer { update_current_height( &mut tx, - self.label.clone(), + self.indexer_id.clone(), block_handle.height()?, block_handle.timestamp()?, ) @@ -330,7 +331,7 @@ impl Indexer { debug!("{}: update height", block_handle.height()?); update_current_height( &mut tx, - self.label.clone(), + self.indexer_id.clone(), block_handle.height()?, block_handle.timestamp()?, ) @@ -339,7 +340,7 @@ impl Indexer { debug!("{}: update status", block_handle.height()?); update_block_status( &mut tx, - self.label.clone(), + self.indexer_id.clone(), block_handle.height()?, block_handle.hash()?, block_handle.timestamp()?, @@ -482,10 +483,12 @@ impl Indexer { if let Some(old_hash) = match finalized { true => { - delete_block_status(&mut tx, self.label.clone(), block_height).await? + delete_block_status(&mut tx, self.indexer_id.clone(), block_height) + .await? } false => { - get_block_status_hash(&mut tx, self.label.clone(), block_height).await? + get_block_status_hash(&mut tx, self.indexer_id.clone(), block_height) + .await? } } { if old_hash != block_handle.hash()? { @@ -505,7 +508,7 @@ impl Indexer { debug!("{}: update status", block_height); update_block_status( &mut tx, - self.label.clone(), + self.indexer_id.clone(), block_height, block_handle.hash()?, block_handle.timestamp()?, @@ -538,7 +541,7 @@ impl Indexer { async fn block_range_to_finalize(&self) -> Result, Report> { let mut tx = self.pg_pool.begin().await?; - let result = get_block_range_to_finalize(&mut tx, self.label.clone()).await?; + let result = get_block_range_to_finalize(&mut tx, self.indexer_id.clone()).await?; tx.commit().await?; Ok(result) @@ -550,7 +553,7 @@ impl Indexer { ) -> Result, Report> { let mut tx = self.pg_pool.begin().await?; let result = - get_next_block_to_refresh(&mut tx, self.label.clone(), consensus_height).await?; + get_next_block_to_refresh(&mut tx, self.indexer_id.clone(), consensus_height).await?; tx.commit().await?; Ok(result) @@ -673,7 +676,7 @@ impl Indexer { async fn block_range_to_fix(&self) -> Result, Report> { let mut tx = self.pg_pool.begin().await?; - let result = get_block_range_to_fix(&mut tx, self.label.clone()).await?; + let result = get_block_range_to_fix(&mut tx, self.indexer_id.clone()).await?; tx.commit().await?; Ok(result) @@ -681,7 +684,7 @@ impl Indexer { async fn remove_blocks_to_fix(&self, range: BlockRange) -> Result<(), Report> { let mut tx = self.pg_pool.begin().await?; - update_block_range_to_fix(&mut tx, self.label.clone(), range).await?; + update_block_range_to_fix(&mut tx, self.indexer_id.clone(), range).await?; tx.commit().await?; Ok(()) @@ -689,7 +692,7 @@ impl Indexer { async fn next_height(&self) -> Result { let mut tx = self.pg_pool.begin().await?; - let result = get_current_height(&mut tx, self.label.clone()) + let result = get_current_height(&mut tx, self.indexer_id.clone()) .await? .map(|current_height| current_height + 1) // we store the last indexed height, so next is one heigher .unwrap_or(self.start_height); @@ -708,16 +711,16 @@ impl Indexer { Ok(Err(err)) => { error!( "{}: error: {:?}. re-initialize (client: {}, context: {})", - self.label, err, fetcher_client, self.context + self.indexer_id, err, fetcher_client, self.context ); join_set.abort_all(); sleep(Duration::from_secs(1)).await; - info!("{}: restarting", self.label); + info!("{}: restarting", self.indexer_id); return Ok(EndOfRunResult::Restart); } Err(err) => return Err(err.into()), Ok(Ok(_)) => { - info!("{}: indexer exited gracefully", self.label); + info!("{}: indexer exited gracefully", self.indexer_id); } } } diff --git a/hubble/src/postgres.rs b/hubble/src/postgres.rs index ab6583c75c..6519d1efbc 100644 --- a/hubble/src/postgres.rs +++ b/hubble/src/postgres.rs @@ -9,7 +9,7 @@ use time::OffsetDateTime; use tracing::info; use valuable::Valuable; -use crate::fetcher::fetcher::{BlockHash, BlockHeight, BlockRange}; +use crate::fetcher::fetcher::{BlockHash, BlockHeight, BlockRange, IndexerId}; /// A trait to describe the different parameters of a chain, used to instantiate types for insertion. pub trait ChainType { @@ -599,17 +599,16 @@ pub async fn get_max_consensus_height<'a, A: Acquire<'a, Database = Postgres>>( pub async fn get_current_height( tx: &mut sqlx::Transaction<'_, Postgres>, - label: String, + indexer_id: IndexerId, ) -> sqlx::Result> { - // fetch chain status, or create one if it not exists let record = sqlx::query!( " SELECT height - FROM hubble.chain_status - WHERE label = $1 + FROM hubble.indexer_status + WHERE indexer_id = $1 LIMIT 1 ", - label, + indexer_id, ) .fetch_optional(tx.as_mut()) .await?; @@ -619,20 +618,20 @@ pub async fn get_current_height( pub async fn update_current_height( tx: &mut sqlx::Transaction<'_, Postgres>, - label: String, + indexer_id: IndexerId, height: BlockHeight, timestamp: OffsetDateTime, ) -> sqlx::Result<()> { sqlx::query!( " - INSERT INTO hubble.chain_status (label, height, timestamp) + INSERT INTO hubble.indexer_status (indexer_id, height, timestamp) VALUES ($1, $2, $3) - ON CONFLICT (label) DO + ON CONFLICT (indexer_id) DO UPDATE SET height = excluded.height, timestamp = excluded.timestamp ", - label, + indexer_id, height as i64, timestamp, ) @@ -644,15 +643,15 @@ pub async fn update_current_height( pub async fn get_block_range_to_finalize( tx: &mut sqlx::Transaction<'_, Postgres>, - label: String, + indexer_id: IndexerId, ) -> sqlx::Result> { let record = sqlx::query!( " SELECT MIN(height) min_height, MAX(height) max_height FROM hubble.block_status - WHERE label = $1 + WHERE indexer_id = $1 ", - label, + indexer_id, ) .fetch_one(tx.as_mut()) .await?; @@ -669,17 +668,17 @@ pub async fn get_block_range_to_finalize( pub async fn get_next_block_to_refresh( tx: &mut sqlx::Transaction<'_, Postgres>, - label: String, + indexer_id: IndexerId, consensus_height: BlockHeight, ) -> sqlx::Result> { let record = sqlx::query!( " SELECT height height FROM hubble.block_status - WHERE label = $1 AND height > $2 + WHERE indexer_id = $1 AND height > $2 ORDER BY updated_at ", - label, + indexer_id, consensus_height as i64, ) .fetch_optional(tx.as_mut()) @@ -753,16 +752,16 @@ pub async fn update_block_range_to_fix( pub async fn delete_block_status( tx: &mut sqlx::Transaction<'_, Postgres>, - label: String, + indexer_id: IndexerId, height: BlockHeight, ) -> sqlx::Result> { let record = sqlx::query!( " DELETE FROM hubble.block_status - WHERE label = $1 AND height = $2 + WHERE indexer_id = $1 AND height = $2 RETURNING hash ", - label, + indexer_id, height as i64, ) .fetch_optional(tx.as_mut()) @@ -773,15 +772,15 @@ pub async fn delete_block_status( pub async fn get_block_status_hash( tx: &mut sqlx::Transaction<'_, Postgres>, - label: String, + indexer_id: IndexerId, height: BlockHeight, ) -> sqlx::Result> { let record = sqlx::query!( " SELECT hash FROM hubble.block_status - WHERE label = $1 AND height = $2 + WHERE indexer_id = $1 AND height = $2 ", - label, + indexer_id, height as i64, ) .fetch_optional(tx.as_mut()) @@ -792,21 +791,21 @@ pub async fn get_block_status_hash( pub async fn update_block_status( tx: &mut sqlx::Transaction<'_, Postgres>, - label: String, + indexer_id: IndexerId, height: BlockHeight, hash: BlockHash, timestamp: OffsetDateTime, ) -> sqlx::Result<()> { sqlx::query!( " - INSERT INTO hubble.block_status (label, height, hash, timestamp) + INSERT INTO hubble.block_status (indexer_id, height, hash, timestamp) VALUES ($1, $2, $3, $4) - ON CONFLICT (label, height) DO + ON CONFLICT (indexer_id, height) DO UPDATE SET hash = excluded.hash, timestamp = excluded.timestamp ", - label, + indexer_id, height as i64, hash, timestamp,