From f853e27ecc3d98150ed76fd7306d0ab31051bca5 Mon Sep 17 00:00:00 2001 From: Joshua Oladele Date: Sun, 31 Dec 2023 23:06:48 +0100 Subject: [PATCH] Update chain_id type to BIGINT Just as specified in the EIPs: https://github.com/ethereum/EIPs/issues/2294 --- chaindexing/Cargo.toml | 2 +- chaindexing/src/chain_reorg.rs | 8 ++++---- chaindexing/src/contract_states.rs | 2 +- chaindexing/src/contract_states/migrations.rs | 2 +- chaindexing/src/contract_states/state_versions.rs | 2 +- chaindexing/src/contracts.rs | 6 +++--- chaindexing/src/diesels/schema.rs | 6 +++--- chaindexing/src/events.rs | 4 ++-- chaindexing/src/repos/postgres_repo/raw_queries.rs | 2 +- chaindexing/src/repos/repo.rs | 8 ++++---- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/chaindexing/Cargo.toml b/chaindexing/Cargo.toml index a6be757..6ad7354 100644 --- a/chaindexing/Cargo.toml +++ b/chaindexing/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chaindexing" -version = "0.1.23" +version = "0.1.24" edition = "2021" description = "Access EVM chain data with SQL" license = "MIT OR Apache-2.0" diff --git a/chaindexing/src/chain_reorg.rs b/chaindexing/src/chain_reorg.rs index 0553216..e80f361 100644 --- a/chaindexing/src/chain_reorg.rs +++ b/chaindexing/src/chain_reorg.rs @@ -35,7 +35,7 @@ pub enum Execution<'a> { pub struct ReorgedBlock { pub id: i32, pub block_number: i64, - pub chain_id: i32, + pub chain_id: i64, handled_at: Option, inserted_at: chrono::NaiveDateTime, } @@ -44,7 +44,7 @@ pub struct ReorgedBlock { #[diesel(table_name = chaindexing_reorged_blocks)] pub struct UnsavedReorgedBlock { pub block_number: i64, - pub chain_id: i32, + pub chain_id: i64, inserted_at: chrono::NaiveDateTime, } @@ -52,7 +52,7 @@ impl UnsavedReorgedBlock { pub fn new(block_number: i64, chain: &Chain) -> Self { Self { block_number, - chain_id: *chain as i32, + chain_id: *chain as i64, inserted_at: chrono::Utc::now().naive_utc(), } } @@ -65,7 +65,7 @@ impl ReorgedBlocks { reorged_blocks .iter() .fold( - HashMap::::new(), + HashMap::::new(), |mut reorged_blocks_by_chain, reorged_block| { let ReorgedBlock { chain_id, .. } = reorged_block; diff --git a/chaindexing/src/contract_states.rs b/chaindexing/src/contract_states.rs index e99b21a..55c32a3 100644 --- a/chaindexing/src/contract_states.rs +++ b/chaindexing/src/contract_states.rs @@ -19,7 +19,7 @@ pub struct ContractStates; impl ContractStates { pub async fn backtrack_states<'a>( state_migrations: &[Arc], - chain_id: i32, + chain_id: i64, block_number: i64, client: &ChaindexingRepoRawQueryTxnClient<'a>, ) { diff --git a/chaindexing/src/contract_states/migrations.rs b/chaindexing/src/contract_states/migrations.rs index a3a0607..095761a 100644 --- a/chaindexing/src/contract_states/migrations.rs +++ b/chaindexing/src/contract_states/migrations.rs @@ -220,7 +220,7 @@ impl DefaultMigration { pub fn get() -> String { "state_version_group_id UUID NOT NULL, contract_address VARCHAR NOT NULL, - chain_id INTEGER NOT NULL, + chain_id BIGINT NOT NULL, block_hash VARCHAR NOT NULL, block_number BIGINT NOT NULL, transaction_hash VARCHAR NOT NULL, diff --git a/chaindexing/src/contract_states/state_versions.rs b/chaindexing/src/contract_states/state_versions.rs index 42153b6..765310e 100644 --- a/chaindexing/src/contract_states/state_versions.rs +++ b/chaindexing/src/contract_states/state_versions.rs @@ -17,7 +17,7 @@ pub struct StateVersions; impl StateVersions { pub async fn get<'a>( from_block_number: i64, - chain_id: i32, + chain_id: i64, state_table_name: &str, client: &ChaindexingRepoRawQueryTxnClient<'a>, ) -> Vec> { diff --git a/chaindexing/src/contracts.rs b/chaindexing/src/contracts.rs index 39b775d..d73869b 100644 --- a/chaindexing/src/contracts.rs +++ b/chaindexing/src/contracts.rs @@ -165,7 +165,7 @@ impl Contracts { pub struct UnsavedContractAddress { pub contract_name: String, address: String, - pub chain_id: i32, + pub chain_id: i64, start_block_number: i64, next_block_number_to_ingest_from: i64, next_block_number_to_handle_from: i64, @@ -176,7 +176,7 @@ impl UnsavedContractAddress { UnsavedContractAddress { contract_name: contract_name.to_string(), address: address.to_lowercase().to_string(), - chain_id: *chain as i32, + chain_id: *chain as i64, start_block_number, next_block_number_to_ingest_from: start_block_number, next_block_number_to_handle_from: start_block_number, @@ -198,7 +198,7 @@ impl ContractAddressID { #[diesel(primary_key(id))] pub struct ContractAddress { pub id: i32, - chain_id: i32, + chain_id: i64, pub next_block_number_to_ingest_from: i64, pub next_block_number_to_handle_from: i64, pub start_block_number: i64, diff --git a/chaindexing/src/diesels/schema.rs b/chaindexing/src/diesels/schema.rs index fdb5581..2a2c5d2 100644 --- a/chaindexing/src/diesels/schema.rs +++ b/chaindexing/src/diesels/schema.rs @@ -3,7 +3,7 @@ diesel::table! { chaindexing_contract_addresses (id) { id -> Int4, - chain_id -> Int4, + chain_id -> Int8, next_block_number_to_ingest_from -> Int8, next_block_number_to_handle_from -> Int8, start_block_number -> Int8, @@ -15,7 +15,7 @@ diesel::table! { diesel::table! { chaindexing_events (id) { id -> Uuid, - chain_id -> Int4, + chain_id -> Int8, contract_address -> VarChar, contract_name -> VarChar, abi -> Text, @@ -44,7 +44,7 @@ diesel::table! { chaindexing_reorged_blocks (id) { id -> Int4, block_number -> Int8, - chain_id -> Int4, + chain_id -> Int8, handled_at -> Nullable, inserted_at -> Timestamptz, } diff --git a/chaindexing/src/events.rs b/chaindexing/src/events.rs index ba56e0a..db4e643 100644 --- a/chaindexing/src/events.rs +++ b/chaindexing/src/events.rs @@ -17,7 +17,7 @@ use serde::Deserialize; #[diesel(table_name = chaindexing_events)] pub struct Event { pub id: Uuid, - pub chain_id: i32, + pub chain_id: i64, pub contract_address: String, pub contract_name: String, pub abi: String, @@ -38,7 +38,7 @@ pub struct Event { #[derive(Debug, Deserialize, Clone, Eq, PartialEq)] pub struct PartialEvent { pub id: Uuid, - pub chain_id: i32, + pub chain_id: i64, pub contract_address: String, pub contract_name: String, pub block_hash: String, diff --git a/chaindexing/src/repos/postgres_repo/raw_queries.rs b/chaindexing/src/repos/postgres_repo/raw_queries.rs index 6e84b51..b6b5cb3 100644 --- a/chaindexing/src/repos/postgres_repo/raw_queries.rs +++ b/chaindexing/src/repos/postgres_repo/raw_queries.rs @@ -55,7 +55,7 @@ impl ExecutesWithRawQuery for PostgresRepo { async fn update_every_next_block_number_to_handle_from_in_txn<'a>( client: &Self::RawQueryTxnClient<'a>, - chain_id: i32, + chain_id: i64, block_number: i64, ) { let query = format!( diff --git a/chaindexing/src/repos/repo.rs b/chaindexing/src/repos/repo.rs index c839c1a..b9dfea6 100644 --- a/chaindexing/src/repos/repo.rs +++ b/chaindexing/src/repos/repo.rs @@ -101,7 +101,7 @@ pub trait ExecutesWithRawQuery: HasRawQueryClient { async fn update_every_next_block_number_to_handle_from_in_txn<'a>( client: &Self::RawQueryTxnClient<'a>, - chain_id: i32, + chain_id: i64, block_number: i64, ); @@ -195,7 +195,7 @@ impl SQLikeMigrations { id SERIAL PRIMARY KEY, address VARCHAR NOT NULL, contract_name VARCHAR NOT NULL, - chain_id INTEGER NOT NULL, + chain_id BIGINT NOT NULL, start_block_number BIGINT NOT NULL, next_block_number_to_ingest_from BIGINT NOT NULL, next_block_number_to_handle_from BIGINT NOT NULL @@ -212,7 +212,7 @@ impl SQLikeMigrations { &[ "CREATE TABLE IF NOT EXISTS chaindexing_events ( id uuid PRIMARY KEY, - chain_id INTEGER NOT NULL, + chain_id BIGINT NOT NULL, contract_address VARCHAR NOT NULL, contract_name VARCHAR NOT NULL, abi TEXT NOT NULL, @@ -241,7 +241,7 @@ impl SQLikeMigrations { pub fn create_reorged_blocks() -> &'static [&'static str] { &["CREATE TABLE IF NOT EXISTS chaindexing_reorged_blocks ( id SERIAL PRIMARY KEY, - chain_id INTEGER NOT NULL, + chain_id BIGINT NOT NULL, block_number BIGINT NOT NULL, handled_at TIMESTAMPTZ, inserted_at TIMESTAMPTZ NOT NULL DEFAULT NOW()