From 00368fc18cd635c29149ae818680d73c53d67e93 Mon Sep 17 00:00:00 2001 From: Lijun Wang <83639177+lijunwangs@users.noreply.github.com> Date: Wed, 18 Oct 2023 12:37:21 -0700 Subject: [PATCH 1/5] Support validator 1.17.2 --- Cargo.toml | 26 +++++++++---------- ci/rust-version.sh | 4 +-- scripts/create_schema.sql | 3 ++- src/geyser_plugin_postgres.rs | 7 ++++- src/postgres_client.rs | 4 +-- .../postgres_client_block_metadata.rs | 6 ++--- .../postgres_client_transaction.rs | 6 ++--- 7 files changed, 31 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 362129c..24c656c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ authors = ["Solana Maintainers "] edition = "2021" name = "solana-geyser-plugin-postgres" description = "The Solana AccountsDb plugin for PostgreSQL database." -version = "1.16.17" +version = "1.17.2" repository = "https://github.com/solana-labs/solana-accountsdb-plugin-postgres" license = "Apache-2.0" homepage = "https://solana.com/" @@ -25,13 +25,13 @@ postgres-openssl = { version = "0.5.0"} serde = "1.0.145" serde_derive = "1.0.145" serde_json = "1.0.85" -solana-geyser-plugin-interface = { version = "=1.16.17" } -solana-logger = { version = "1.16.17" } -solana-measure = { version = "1.16.17" } -solana-metrics = { version = "1.16.17" } -solana-runtime = { version = "1.16.17" } -solana-sdk = { version = "1.16.17" } -solana-transaction-status = { version = "1.16.17" } +solana-geyser-plugin-interface = { version = "=1.17.2" } +solana-logger = { version = "1.17.2" } +solana-measure = { version = "1.17.2" } +solana-metrics = { version = "1.17.2" } +solana-runtime = { version = "1.17.2" } +solana-sdk = { version = "1.17.2" } +solana-transaction-status = { version = "1.17.2" } thiserror = "1.0.37" tokio-postgres = "0.7.7" @@ -41,11 +41,11 @@ libloading = "0.7.3" serial_test = "0.9.0" socket2 = { version = "0.4.7", features = ["all"] } -solana-account-decoder = { version = "1.16.17" } -solana-core = { version = "1.16.17" } -solana-local-cluster = { version = "1.16.17" } -solana-net-utils = { version = "1.16.17" } -solana-streamer = { version = "1.16.17" } +solana-account-decoder = { version = "1.17.2" } +solana-core = { version = "1.17.2" } +solana-local-cluster = { version = "1.17.2" } +solana-net-utils = { version = "1.17.2" } +solana-streamer = { version = "1.17.2" } tempfile = "3.3.0" [package.metadata.docs.rs] diff --git a/ci/rust-version.sh b/ci/rust-version.sh index 88a5616..b8acf11 100644 --- a/ci/rust-version.sh +++ b/ci/rust-version.sh @@ -18,13 +18,13 @@ if [[ -n $RUST_STABLE_VERSION ]]; then stable_version="$RUST_STABLE_VERSION" else - stable_version=1.69.0 + stable_version=1.73.0 fi if [[ -n $RUST_NIGHTLY_VERSION ]]; then nightly_version="$RUST_NIGHTLY_VERSION" else - nightly_version=2023-04-19 + nightly_version=2023-10-05 fi diff --git a/scripts/create_schema.sql b/scripts/create_schema.sql index f531382..15c8129 100644 --- a/scripts/create_schema.sql +++ b/scripts/create_schema.sql @@ -68,7 +68,8 @@ Create TYPE "TransactionErrorCode" AS ENUM ( 'MaxLoadedAccountsDataSizeExceeded', 'InvalidLoadedAccountsDataSizeLimit', 'ResanitizationNeeded', - 'UnbalancedTransaction' + 'UnbalancedTransaction', + 'ProgramExecutionTemporarilyRestricted' ); CREATE TYPE "TransactionError" AS ( diff --git a/src/geyser_plugin_postgres.rs b/src/geyser_plugin_postgres.rs index 5a558b6..a6ec71e 100644 --- a/src/geyser_plugin_postgres.rs +++ b/src/geyser_plugin_postgres.rs @@ -414,7 +414,7 @@ impl GeyserPlugin for GeyserPluginPostgres { ))); } Some(client) => match block_info { - ReplicaBlockInfoVersions::V0_0_2(block_info) => { + ReplicaBlockInfoVersions::V0_0_3(block_info) => { let result = client.update_block_metadata(block_info); if let Err(err) = result { @@ -423,6 +423,11 @@ impl GeyserPlugin for GeyserPluginPostgres { }); } } + ReplicaBlockInfoVersions::V0_0_2(_block_info) => { + return Err(GeyserPluginError::SlotStatusUpdateError{ + msg: "Failed to persist the transaction info to the PostgreSQL database. Unsupported format.".to_string() + }); + } ReplicaBlockInfoVersions::V0_0_1(_) => { return Err(GeyserPluginError::SlotStatusUpdateError{ msg: "Failed to persist the transaction info to the PostgreSQL database. Unsupported format.".to_string() diff --git a/src/postgres_client.rs b/src/postgres_client.rs index b535aee..43f1e50 100644 --- a/src/postgres_client.rs +++ b/src/postgres_client.rs @@ -19,7 +19,7 @@ use { postgres_client_transaction::LogTransactionRequest, postgres_openssl::MakeTlsConnector, solana_geyser_plugin_interface::geyser_plugin_interface::{ - GeyserPluginError, ReplicaAccountInfoV3, ReplicaBlockInfoV2, SlotStatus, + GeyserPluginError, ReplicaAccountInfoV3, ReplicaBlockInfoV3, SlotStatus, }, solana_measure::measure::Measure, solana_metrics::*, @@ -1232,7 +1232,7 @@ impl ParallelPostgresClient { pub fn update_block_metadata( &self, - block_info: &ReplicaBlockInfoV2, + block_info: &ReplicaBlockInfoV3, ) -> Result<(), GeyserPluginError> { if let Err(err) = self.sender.send(DbWorkItem::UpdateBlockMetadata(Box::new( UpdateBlockMetadataRequest { diff --git a/src/postgres_client/postgres_client_block_metadata.rs b/src/postgres_client/postgres_client_block_metadata.rs index b3117be..7ea4bab 100644 --- a/src/postgres_client/postgres_client_block_metadata.rs +++ b/src/postgres_client/postgres_client_block_metadata.rs @@ -9,7 +9,7 @@ use { log::*, postgres::{Client, Statement}, solana_geyser_plugin_interface::geyser_plugin_interface::{ - GeyserPluginError, ReplicaBlockInfoV2, + GeyserPluginError, ReplicaBlockInfoV3, }, }; @@ -22,8 +22,8 @@ pub struct DbBlockInfo { pub block_height: Option, } -impl<'a> From<&ReplicaBlockInfoV2<'a>> for DbBlockInfo { - fn from(block_info: &ReplicaBlockInfoV2) -> Self { +impl<'a> From<&ReplicaBlockInfoV3<'a>> for DbBlockInfo { + fn from(block_info: &ReplicaBlockInfoV3) -> Self { Self { slot: block_info.slot as i64, blockhash: block_info.blockhash.to_string(), diff --git a/src/postgres_client/postgres_client_transaction.rs b/src/postgres_client/postgres_client_transaction.rs index e71a588..1747050 100644 --- a/src/postgres_client/postgres_client_transaction.rs +++ b/src/postgres_client/postgres_client_transaction.rs @@ -352,6 +352,7 @@ pub enum DbTransactionErrorCode { InvalidLoadedAccountsDataSizeLimit, ResanitizationNeeded, UnbalancedTransaction, + ProgramExecutionTemporarilyRestricted, } impl From<&TransactionError> for DbTransactionErrorCode { @@ -409,6 +410,7 @@ impl From<&TransactionError> for DbTransactionErrorCode { } TransactionError::ResanitizationNeeded => Self::ResanitizationNeeded, TransactionError::UnbalancedTransaction => Self::UnbalancedTransaction, + TransactionError::ProgramExecutionTemporarilyRestricted {account_index: _} => Self::ProgramExecutionTemporarilyRestricted, } } } @@ -1388,7 +1390,6 @@ pub(crate) mod tests { message_hash, Some(true), SimpleAddressLoader::Disabled, - false, ) .unwrap(); @@ -1424,7 +1425,7 @@ pub(crate) mod tests { let message_hash = Hash::new_unique(); let transaction = build_test_transaction_v0(); - transaction.sanitize(false).unwrap(); + transaction.sanitize().unwrap(); let transaction = SanitizedTransaction::try_create( transaction, @@ -1434,7 +1435,6 @@ pub(crate) mod tests { writable: vec![Pubkey::new_unique(), Pubkey::new_unique()], readonly: vec![Pubkey::new_unique(), Pubkey::new_unique()], }), - false, ) .unwrap(); From cdf653cfccd867d929618567b7c4bb762d0fff28 Mon Sep 17 00:00:00 2001 From: Lijun Wang <83639177+lijunwangs@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:31:10 -0700 Subject: [PATCH 2/5] try to lock the dependency version --- src/postgres_client.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/postgres_client.rs b/src/postgres_client.rs index 43f1e50..c529631 100644 --- a/src/postgres_client.rs +++ b/src/postgres_client.rs @@ -1,4 +1,4 @@ -#![allow(clippy::integer_arithmetic)] +#![allow(clippy::arithmetic_side_effects)] mod postgres_client_account_index; mod postgres_client_block_metadata; From 6c39275c1cad8c1854be7e3b324082b01d151393 Mon Sep 17 00:00:00 2001 From: Lijun Wang <83639177+lijunwangs@users.noreply.github.com> Date: Wed, 18 Oct 2023 13:20:44 -0700 Subject: [PATCH 3/5] Support validator 1.17.2 --- src/postgres_client/postgres_client_transaction.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/postgres_client/postgres_client_transaction.rs b/src/postgres_client/postgres_client_transaction.rs index 1747050..7d6020b 100644 --- a/src/postgres_client/postgres_client_transaction.rs +++ b/src/postgres_client/postgres_client_transaction.rs @@ -410,7 +410,9 @@ impl From<&TransactionError> for DbTransactionErrorCode { } TransactionError::ResanitizationNeeded => Self::ResanitizationNeeded, TransactionError::UnbalancedTransaction => Self::UnbalancedTransaction, - TransactionError::ProgramExecutionTemporarilyRestricted {account_index: _} => Self::ProgramExecutionTemporarilyRestricted, + TransactionError::ProgramExecutionTemporarilyRestricted { account_index: _ } => { + Self::ProgramExecutionTemporarilyRestricted + } } } } From 66adccdd532d8fc9048f617ee506c2947f05bb16 Mon Sep 17 00:00:00 2001 From: Lijun Wang <83639177+lijunwangs@users.noreply.github.com> Date: Wed, 18 Oct 2023 14:09:54 -0700 Subject: [PATCH 4/5] test update for missing packeges --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 43035bf..adfe1f0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: - if: runner.os == 'Linux' run: | sudo apt-get update - sudo apt-get install -y libudev-dev + sudo apt-get install -y libudev-dev protobuf-compiler libclang-dev - uses: actions-rs/toolchain@v1 with: @@ -58,4 +58,4 @@ jobs: args: --workspace --all-targets -- --deny=warnings - name: Build - run: ./ci/cargo-build-test.sh \ No newline at end of file + run: ./ci/cargo-build-test.sh From e5f262335adda1289a2995c70b74fa282e8fc4e7 Mon Sep 17 00:00:00 2001 From: Lijun Wang <83639177+lijunwangs@users.noreply.github.com> Date: Wed, 18 Oct 2023 14:53:32 -0700 Subject: [PATCH 5/5] clippy attributes --- tests/test_postgres_plugin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_postgres_plugin.rs b/tests/test_postgres_plugin.rs index ec6df01..f9c04a9 100644 --- a/tests/test_postgres_plugin.rs +++ b/tests/test_postgres_plugin.rs @@ -1,4 +1,4 @@ -#![allow(clippy::integer_arithmetic)] +#![allow(clippy::arithmetic_side_effects)] use serde_json::json;