Skip to content

Commit

Permalink
Update chain_id type to BIGINT
Browse files Browse the repository at this point in the history
Just as specified in the EIPs:
ethereum/EIPs#2294
  • Loading branch information
Jurshsmith committed Dec 31, 2023
1 parent 7b1b733 commit f853e27
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion chaindexing/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
8 changes: 4 additions & 4 deletions chaindexing/src/chain_reorg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<chrono::NaiveDateTime>,
inserted_at: chrono::NaiveDateTime,
}
Expand All @@ -44,15 +44,15 @@ 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,
}

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(),
}
}
Expand All @@ -65,7 +65,7 @@ impl ReorgedBlocks {
reorged_blocks
.iter()
.fold(
HashMap::<i32, ReorgedBlock>::new(),
HashMap::<i64, ReorgedBlock>::new(),
|mut reorged_blocks_by_chain, reorged_block| {
let ReorgedBlock { chain_id, .. } = reorged_block;

Expand Down
2 changes: 1 addition & 1 deletion chaindexing/src/contract_states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct ContractStates;
impl ContractStates {
pub async fn backtrack_states<'a>(
state_migrations: &[Arc<dyn ContractStateMigrations>],
chain_id: i32,
chain_id: i64,
block_number: i64,
client: &ChaindexingRepoRawQueryTxnClient<'a>,
) {
Expand Down
2 changes: 1 addition & 1 deletion chaindexing/src/contract_states/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion chaindexing/src/contract_states/state_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<HashMap<String, String>> {
Expand Down
6 changes: 3 additions & 3 deletions chaindexing/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions chaindexing/src/diesels/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -44,7 +44,7 @@ diesel::table! {
chaindexing_reorged_blocks (id) {
id -> Int4,
block_number -> Int8,
chain_id -> Int4,
chain_id -> Int8,
handled_at -> Nullable<Timestamptz>,
inserted_at -> Timestamptz,
}
Expand Down
4 changes: 2 additions & 2 deletions chaindexing/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion chaindexing/src/repos/postgres_repo/raw_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
8 changes: 4 additions & 4 deletions chaindexing/src/repos/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);

Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit f853e27

Please sign in to comment.