Skip to content

Commit

Permalink
Bump version (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbogle authored Jun 14, 2023
1 parent 6952c47 commit 17425ba
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 29 deletions.
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 = ["Cardinal Labs <[email protected]>"]
edition = "2021"
name = "solana-geyser-plugin-postgres"
description = "Cardinal geyser plugin."
version = "1.13.5"
version = "1.14.17"
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
Expand All @@ -27,13 +27,13 @@ borsh = "0.9.2"
serde = "1.0.145"
serde_derive = "1.0.145"
serde_json = "1.0.85"
solana-geyser-plugin-interface = { version = "=1.13.5" }
solana-logger = { version = "=1.13.5" }
solana-measure = { version = "=1.13.5" }
solana-metrics = { version = "=1.13.5" }
solana-runtime = { version = "=1.13.5" }
solana-sdk = { version = "=1.13.5" }
solana-transaction-status = { version = "=1.13.5" }
solana-geyser-plugin-interface = { version = "=1.14.17" }
solana-logger = { version = "=1.14.17" }
solana-measure = { version = "=1.14.17" }
solana-metrics = { version = "=1.14.17" }
solana-runtime = { version = "=1.14.17" }
solana-sdk = { version = "=1.14.17" }
solana-transaction-status = { version = "=1.14.17" }
thiserror = "1.0.37"
tokio-postgres = "0.7.7"
tempfile = "3.3.0"
Expand All @@ -45,11 +45,11 @@ libc = "0.2.134"
libloading = "0.7.3"
serial_test = "0.9.0"
socket2 = { version = "0.4.7", features = ["all"] }
solana-account-decoder = { version = "=1.13.5" }
solana-core = { version = "=1.13.5" }
solana-local-cluster = { version = "=1.13.5" }
solana-net-utils = { version = "=1.13.5" }
solana-streamer = { version = "=1.13.5" }
solana-account-decoder = { version = "=1.14.17" }
solana-core = { version = "=1.14.17" }
solana-local-cluster = { version = "=1.14.17" }
solana-net-utils = { version = "=1.14.17" }
solana-streamer = { version = "=1.14.17" }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
14 changes: 12 additions & 2 deletions src/geyser_plugin_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl GeyserPlugin for GeyserPluginPostgres {

let mut measure_all = Measure::start("geyser-plugin-postgres-update-account-main");
match account {
ReplicaAccountInfoVersions::V0_0_1(account) => {
ReplicaAccountInfoVersions::V0_0_2(account) => {
let mut measure_select = Measure::start("geyser-plugin-postgres-update-account-select");
if let Some(accounts_selector) = &self.accounts_selector {
if !accounts_selector.is_account_selected(account.pubkey, account.owner) {
Expand Down Expand Up @@ -122,6 +122,11 @@ impl GeyserPlugin for GeyserPluginPostgres {
});
}
}
_ => {
return Err(GeyserPluginError::AccountsUpdateError {
msg: "Failed to update account. Unsupported format.".to_string(),
});
}
}

measure_all.stop();
Expand Down Expand Up @@ -167,7 +172,7 @@ impl GeyserPlugin for GeyserPluginPostgres {
};

match transaction_info {
ReplicaTransactionInfoVersions::V0_0_1(transaction_info) => {
ReplicaTransactionInfoVersions::V0_0_2(transaction_info) => {
if let Some(transaction_selector) = &self.transaction_selector {
if !transaction_selector.is_transaction_selected(transaction_info.is_vote, Box::new(transaction_info.transaction.message().account_keys().iter())) {
return Ok(());
Expand All @@ -184,6 +189,11 @@ impl GeyserPlugin for GeyserPluginPostgres {
});
}
}
_ => {
return Err(GeyserPluginError::SlotStatusUpdateError {
msg: "Failed to persist the transaction info to the PostgreSQL database. Unsupported format.".to_string(),
});
}
}

Ok(())
Expand Down
8 changes: 4 additions & 4 deletions src/parallel_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use crossbeam_channel::bounded;
use crossbeam_channel::Sender;
use log::*;
use solana_geyser_plugin_interface::geyser_plugin_interface::GeyserPluginError;
use solana_geyser_plugin_interface::geyser_plugin_interface::ReplicaAccountInfo;
use solana_geyser_plugin_interface::geyser_plugin_interface::ReplicaAccountInfoV2;
use solana_geyser_plugin_interface::geyser_plugin_interface::ReplicaBlockInfo;
use solana_geyser_plugin_interface::geyser_plugin_interface::ReplicaTransactionInfo;
use solana_geyser_plugin_interface::geyser_plugin_interface::ReplicaTransactionInfoV2;
use solana_geyser_plugin_interface::geyser_plugin_interface::SlotStatus;
use solana_measure::measure::Measure;
use solana_metrics::*;
Expand Down Expand Up @@ -115,7 +115,7 @@ impl ParallelClient {
Ok(())
}

pub fn update_account(&mut self, account: &ReplicaAccountInfo, slot: u64, is_startup: bool) -> Result<(), GeyserPluginError> {
pub fn update_account(&mut self, account: &ReplicaAccountInfoV2, slot: u64, is_startup: bool) -> Result<(), GeyserPluginError> {
if self.last_report.should_update(30000) {
datapoint_debug!("postgres-plugin-stats", ("message-queue-length", self.sender.len() as i64, i64),);
}
Expand Down Expand Up @@ -178,7 +178,7 @@ impl ParallelClient {
Ok(())
}

pub fn log_transaction_info(&mut self, transaction_info: &ReplicaTransactionInfo, slot: u64) -> Result<(), GeyserPluginError> {
pub fn log_transaction_info(&mut self, transaction_info: &ReplicaTransactionInfoV2, slot: u64) -> Result<(), GeyserPluginError> {
self.transaction_write_version.fetch_add(1, Ordering::Relaxed);
let wrk_item = WorkRequest::LogTransaction(Box::new(LogTransactionRequest {
transaction_info: build_db_transaction(slot, transaction_info, self.transaction_write_version.load(Ordering::Relaxed)),
Expand Down
4 changes: 2 additions & 2 deletions src/postgres_client/accounts/account_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::str::FromStr;
use crate::accounts_selector::AccountHandlerConfig;
use crate::accounts_selector::AccountsSelectorConfig;
use crate::config::GeyserPluginPostgresConfig;
use solana_geyser_plugin_interface::geyser_plugin_interface::ReplicaAccountInfo;
use solana_geyser_plugin_interface::geyser_plugin_interface::ReplicaAccountInfoV2;

use super::metadata_creators_account_handler::MetadataCreatorsAccountHandler;
use super::token_account_handler::TokenAccountHandler;
Expand Down Expand Up @@ -92,7 +92,7 @@ pub struct DbAccountInfo {
}

impl DbAccountInfo {
pub fn new(account: &ReplicaAccountInfo, slot: u64) -> DbAccountInfo {
pub fn new(account: &ReplicaAccountInfoV2, slot: u64) -> DbAccountInfo {
let data = account.data.to_vec();
Self {
pubkey: account.pubkey.to_vec(),
Expand Down
3 changes: 2 additions & 1 deletion src/postgres_client/accounts/token_account_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ impl AccountHandler for TokenAccountHandler {
};
let mint: &Pubkey = bytemuck::from_bytes(&account.data[SPL_TOKEN_ACCOUNT_MINT_OFFSET..SPL_TOKEN_ACCOUNT_MINT_OFFSET + PUBKEY_BYTES]);
let owner: &Pubkey = bytemuck::from_bytes(&account.data[SPL_TOKEN_ACCOUNT_OWNER_OFFSET..SPL_TOKEN_ACCOUNT_OWNER_OFFSET + PUBKEY_BYTES]);
let pubkey = Pubkey::new(&account.pubkey);
let pubkey_bytes: [u8; 32] = account.pubkey[..].try_into().unwrap();
let pubkey = Pubkey::from(pubkey_bytes);
let slot = account.slot;
format!(
"
Expand Down
18 changes: 11 additions & 7 deletions src/postgres_client/transaction_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use postgres::Statement;
use postgres_types::FromSql;
use postgres_types::ToSql;
use solana_geyser_plugin_interface::geyser_plugin_interface::GeyserPluginError;
use solana_geyser_plugin_interface::geyser_plugin_interface::ReplicaTransactionInfo;
use solana_geyser_plugin_interface::geyser_plugin_interface::ReplicaTransactionInfoV2;
use solana_runtime::bank::RewardType;
use solana_sdk::instruction::CompiledInstruction;
use solana_sdk::message::v0::LoadedAddresses;
Expand Down Expand Up @@ -387,7 +387,7 @@ impl From<&TransactionStatusMeta> for DbTransactionStatusMeta {
}
}

pub fn build_db_transaction(slot: u64, transaction_info: &ReplicaTransactionInfo, transaction_write_version: u64) -> DbTransaction {
pub fn build_db_transaction(slot: u64, transaction_info: &ReplicaTransactionInfoV2, transaction_write_version: u64) -> DbTransaction {
DbTransaction {
signature: transaction_info.signature.as_ref().to_vec(),
is_vote: transaction_info.is_vote,
Expand All @@ -397,7 +397,7 @@ pub fn build_db_transaction(slot: u64, transaction_info: &ReplicaTransactionInfo
SanitizedMessage::V0(_) => 1,
},
legacy_message: match transaction_info.transaction.message() {
SanitizedMessage::Legacy(legacy_message) => Some(DbTransactionMessage::from(legacy_message)),
SanitizedMessage::Legacy(legacy_message) => Some(DbTransactionMessage::from(legacy_message.message.as_ref())),
_ => None,
},
v0_loaded_message: match transaction_info.transaction.message() {
Expand Down Expand Up @@ -979,6 +979,8 @@ pub(crate) mod tests {
writable: vec![Pubkey::new_unique(), Pubkey::new_unique()],
readonly: vec![Pubkey::new_unique(), Pubkey::new_unique()],
},
return_data: None,
compute_units_consumed: None,
}
}

Expand Down Expand Up @@ -1142,14 +1144,14 @@ pub(crate) mod tests {
check_loaded_message_v0_equality(&message, &db_message);
}

fn check_transaction(slot: u64, transaction: &ReplicaTransactionInfo, db_transaction: &DbTransaction) {
fn check_transaction(slot: u64, transaction: &ReplicaTransactionInfoV2, db_transaction: &DbTransaction) {
assert_eq!(transaction.signature.as_ref(), db_transaction.signature);
assert_eq!(transaction.is_vote, db_transaction.is_vote);
assert_eq!(slot, db_transaction.slot as u64);
match transaction.transaction.message() {
SanitizedMessage::Legacy(message) => {
assert_eq!(db_transaction.message_type, 0);
check_transaction_message_equality(message, db_transaction.legacy_message.as_ref().unwrap());
check_transaction_message_equality(message.message.as_ref(), db_transaction.legacy_message.as_ref().unwrap());
}
SanitizedMessage::V0(message) => {
assert_eq!(db_transaction.message_type, 1);
Expand Down Expand Up @@ -1187,7 +1189,8 @@ pub(crate) mod tests {
let transaction = SanitizedTransaction::try_create(transaction, message_hash, Some(true), SimpleAddressLoader::Disabled, false).unwrap();

let transaction_status_meta = build_transaction_status_meta();
let transaction_info = ReplicaTransactionInfo {
let transaction_info = ReplicaTransactionInfoV2 {
index: 0,
signature: &signature,
is_vote: false,
transaction: &transaction,
Expand Down Expand Up @@ -1228,7 +1231,8 @@ pub(crate) mod tests {
.unwrap();

let transaction_status_meta = build_transaction_status_meta();
let transaction_info = ReplicaTransactionInfo {
let transaction_info = ReplicaTransactionInfoV2 {
index: 0,
signature: &signature,
is_vote: true,
transaction: &transaction,
Expand Down

0 comments on commit 17425ba

Please sign in to comment.