Skip to content

Commit

Permalink
Merge pull request #62 from lijunwangs/v1.16.0-support
Browse files Browse the repository at this point in the history
Support v1.17.2
  • Loading branch information
lijunwangs authored Oct 18, 2023
2 parents 68a4471 + e5f2623 commit a8ade77
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -58,4 +58,4 @@ jobs:
args: --workspace --all-targets -- --deny=warnings

- name: Build
run: ./ci/cargo-build-test.sh
run: ./ci/cargo-build-test.sh
26 changes: 13 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ["Solana Maintainers <[email protected]>"]
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/"
Expand All @@ -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"

Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions ci/rust-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
3 changes: 2 additions & 1 deletion scripts/create_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ Create TYPE "TransactionErrorCode" AS ENUM (
'MaxLoadedAccountsDataSizeExceeded',
'InvalidLoadedAccountsDataSizeLimit',
'ResanitizationNeeded',
'UnbalancedTransaction'
'UnbalancedTransaction',
'ProgramExecutionTemporarilyRestricted'
);

CREATE TYPE "TransactionError" AS (
Expand Down
7 changes: 6 additions & 1 deletion src/geyser_plugin_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions src/postgres_client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]

mod postgres_client_account_index;
mod postgres_client_block_metadata;
Expand All @@ -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::*,
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/postgres_client/postgres_client_block_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use {
log::*,
postgres::{Client, Statement},
solana_geyser_plugin_interface::geyser_plugin_interface::{
GeyserPluginError, ReplicaBlockInfoV2,
GeyserPluginError, ReplicaBlockInfoV3,
},
};

Expand All @@ -22,8 +22,8 @@ pub struct DbBlockInfo {
pub block_height: Option<i64>,
}

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(),
Expand Down
8 changes: 5 additions & 3 deletions src/postgres_client/postgres_client_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ pub enum DbTransactionErrorCode {
InvalidLoadedAccountsDataSizeLimit,
ResanitizationNeeded,
UnbalancedTransaction,
ProgramExecutionTemporarilyRestricted,
}

impl From<&TransactionError> for DbTransactionErrorCode {
Expand Down Expand Up @@ -409,6 +410,9 @@ impl From<&TransactionError> for DbTransactionErrorCode {
}
TransactionError::ResanitizationNeeded => Self::ResanitizationNeeded,
TransactionError::UnbalancedTransaction => Self::UnbalancedTransaction,
TransactionError::ProgramExecutionTemporarilyRestricted { account_index: _ } => {
Self::ProgramExecutionTemporarilyRestricted
}
}
}
}
Expand Down Expand Up @@ -1388,7 +1392,6 @@ pub(crate) mod tests {
message_hash,
Some(true),
SimpleAddressLoader::Disabled,
false,
)
.unwrap();

Expand Down Expand Up @@ -1424,7 +1427,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,
Expand All @@ -1434,7 +1437,6 @@ pub(crate) mod tests {
writable: vec![Pubkey::new_unique(), Pubkey::new_unique()],
readonly: vec![Pubkey::new_unique(), Pubkey::new_unique()],
}),
false,
)
.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion tests/test_postgres_plugin.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]

use serde_json::json;

Expand Down

0 comments on commit a8ade77

Please sign in to comment.