Skip to content

Support validator v1.15.2 #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <maintainers@solana.foundation>"]
edition = "2021"
name = "solana-geyser-plugin-postgres"
description = "The Solana AccountsDb plugin for PostgreSQL database."
version = "1.14.17"
version = "1.15.2"
repository = "https://github.com/solana-labs/solana"
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.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" }
solana-geyser-plugin-interface = { version = "=1.15.2" }
solana-logger = { version = "=1.15.2" }
solana-measure = { version = "=1.15.2" }
solana-metrics = { version = "=1.15.2" }
solana-runtime = { version = "=1.15.2" }
solana-sdk = { version = "=1.15.2" }
solana-transaction-status = { version = "=1.15.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.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" }
solana-account-decoder = { version = "=1.15.2" }
solana-core = { version = "=1.15.2" }
solana-local-cluster = { version = "=1.15.2" }
solana-net-utils = { version = "=1.15.2" }
solana-streamer = { version = "=1.15.2" }
tempfile = "3.3.0"

[package.metadata.docs.rs]
Expand Down
2 changes: 1 addition & 1 deletion ci/rust-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
if [[ -n $RUST_STABLE_VERSION ]]; then
stable_version="$RUST_STABLE_VERSION"
else
stable_version=1.63.0
stable_version=1.66.1
fi

if [[ -n $RUST_NIGHTLY_VERSION ]]; then
Expand Down
3 changes: 2 additions & 1 deletion scripts/create_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ Create TYPE "TransactionErrorCode" AS ENUM (
'WouldExceedAccountDataBlockLimit',
'WouldExceedAccountDataTotalLimit',
'DuplicateInstruction',
'InsufficientFundsForRent'
'InsufficientFundsForRent',
'MaxLoadedAccountsDataSizeExceeded'
);

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_1(block_info) => {
ReplicaBlockInfoVersions::V0_0_2(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_1(_) => {
return Err(GeyserPluginError::SlotStatusUpdateError{
msg: "Failed to persist the transaction info to the PostgreSQL database. Unsupported format.".to_string()
});
}
},
}

Expand Down
16 changes: 8 additions & 8 deletions src/postgres_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use {
postgres_client_transaction::LogTransactionRequest,
postgres_openssl::MakeTlsConnector,
solana_geyser_plugin_interface::geyser_plugin_interface::{
GeyserPluginError, ReplicaAccountInfoV2, ReplicaBlockInfo, SlotStatus,
GeyserPluginError, ReplicaAccountInfoV2, ReplicaBlockInfoV2, SlotStatus,
},
solana_measure::measure::Measure,
solana_metrics::*,
Expand Down Expand Up @@ -112,10 +112,10 @@ impl DbAccountInfo {
let data = account.data().to_vec();
Self {
pubkey: account.pubkey().to_vec(),
lamports: account.lamports() as i64,
lamports: account.lamports(),
owner: account.owner().to_vec(),
executable: account.executable(),
rent_epoch: account.rent_epoch() as i64,
rent_epoch: account.rent_epoch(),
data,
slot: slot as i64,
write_version: account.write_version(),
Expand Down Expand Up @@ -506,8 +506,8 @@ impl SimplePostgresClient {
statement: &Statement,
client: &mut Client,
) -> Result<(), GeyserPluginError> {
let lamports = account.lamports() as i64;
let rent_epoch = account.rent_epoch() as i64;
let lamports = account.lamports();
let rent_epoch = account.rent_epoch();
let updated_on = Utc::now().naive_utc();
let result = client.execute(
statement,
Expand Down Expand Up @@ -545,8 +545,8 @@ impl SimplePostgresClient {
insert_token_owner_index_stmt: &Option<Statement>,
insert_token_mint_index_stmt: &Option<Statement>,
) -> Result<(), GeyserPluginError> {
let lamports = account.lamports() as i64;
let rent_epoch = account.rent_epoch() as i64;
let lamports = account.lamports();
let rent_epoch = account.rent_epoch();
let updated_on = Utc::now().naive_utc();
let result = client.execute(
statement,
Expand Down Expand Up @@ -1232,7 +1232,7 @@ impl ParallelPostgresClient {

pub fn update_block_metadata(
&mut self,
block_info: &ReplicaBlockInfo,
block_info: &ReplicaBlockInfoV2,
) -> 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, ReplicaBlockInfo,
GeyserPluginError, ReplicaBlockInfoV2,
},
};

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

impl<'a> From<&ReplicaBlockInfo<'a>> for DbBlockInfo {
fn from(block_info: &ReplicaBlockInfo) -> Self {
impl<'a> From<&ReplicaBlockInfoV2<'a>> for DbBlockInfo {
fn from(block_info: &ReplicaBlockInfoV2) -> Self {
Self {
slot: block_info.slot as i64,
blockhash: block_info.blockhash.to_string(),
Expand Down
57 changes: 37 additions & 20 deletions src/postgres_client/postgres_client_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl From<&InnerInstructions> for DbInnerInstructions {
instructions: instructions
.instructions
.iter()
.map(DbCompiledInstruction::from)
.map(|instruction| DbCompiledInstruction::from(&instruction.instruction))
.collect(),
}
}
Expand All @@ -301,7 +301,7 @@ impl From<&Reward> for DbReward {
fn from(reward: &Reward) -> Self {
Self {
pubkey: reward.pubkey.clone(),
lamports: reward.lamports as i64,
lamports: reward.lamports,
post_balance: reward.post_balance as i64,
reward_type: get_reward_type(&reward.reward_type),
commission: reward
Expand Down Expand Up @@ -348,6 +348,7 @@ pub enum DbTransactionErrorCode {
WouldExceedAccountDataTotalLimit,
DuplicateInstruction,
InsufficientFundsForRent,
MaxLoadedAccountsDataSizeExceeded,
}

impl From<&TransactionError> for DbTransactionErrorCode {
Expand Down Expand Up @@ -397,6 +398,9 @@ impl From<&TransactionError> for DbTransactionErrorCode {
TransactionError::InsufficientFundsForRent { account_index: _ } => {
Self::InsufficientFundsForRent
}
TransactionError::MaxLoadedAccountsDataSizeExceeded => {
Self::MaxLoadedAccountsDataSizeExceeded
}
}
}
}
Expand Down Expand Up @@ -653,6 +657,7 @@ pub(crate) mod tests {
SanitizedTransaction, SimpleAddressLoader, Transaction, VersionedTransaction,
},
},
solana_transaction_status::InnerInstruction,
};

fn check_compiled_instruction_equality(
Expand Down Expand Up @@ -681,7 +686,7 @@ pub(crate) mod tests {
for i in 0..compiled_instruction.data.len() {
assert_eq!(
compiled_instruction.data[i],
db_compiled_instruction.data[i] as u8
db_compiled_instruction.data[i]
)
}
}
Expand Down Expand Up @@ -710,7 +715,7 @@ pub(crate) mod tests {

for i in 0..inner_instructions.instructions.len() {
check_compiled_instruction_equality(
&inner_instructions.instructions[i],
&inner_instructions.instructions[i].instruction,
&db_inner_instructions.instructions[i],
)
}
Expand All @@ -721,15 +726,21 @@ pub(crate) mod tests {
let inner_instructions = InnerInstructions {
index: 0,
instructions: vec![
CompiledInstruction {
program_id_index: 0,
accounts: vec![1, 2, 3],
data: vec![4, 5, 6],
InnerInstruction {
instruction: CompiledInstruction {
program_id_index: 0,
accounts: vec![1, 2, 3],
data: vec![4, 5, 6],
},
stack_height: None,
},
CompiledInstruction {
program_id_index: 1,
accounts: vec![12, 13, 14],
data: vec![24, 25, 26],
InnerInstruction {
instruction: CompiledInstruction {
program_id_index: 1,
accounts: vec![12, 13, 14],
data: vec![24, 25, 26],
},
stack_height: None,
},
],
};
Expand Down Expand Up @@ -996,15 +1007,21 @@ pub(crate) mod tests {
inner_instructions: Some(vec![InnerInstructions {
index: 0,
instructions: vec![
CompiledInstruction {
program_id_index: 0,
accounts: vec![1, 2, 3],
data: vec![4, 5, 6],
InnerInstruction {
instruction: CompiledInstruction {
program_id_index: 0,
accounts: vec![1, 2, 3],
data: vec![4, 5, 6],
},
stack_height: None,
},
CompiledInstruction {
program_id_index: 1,
accounts: vec![12, 13, 14],
data: vec![24, 25, 26],
InnerInstruction {
instruction: CompiledInstruction {
program_id_index: 1,
accounts: vec![12, 13, 14],
data: vec![24, 25, 26],
},
stack_height: None,
},
],
}]),
Expand Down
15 changes: 6 additions & 9 deletions tests/test_postgres_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ use {
},
solana_runtime::{
snapshot_archive_info::SnapshotArchiveInfoGetter, snapshot_config::SnapshotConfig,
snapshot_utils,
snapshot_hash::SnapshotHash, snapshot_utils,
},
solana_sdk::{
client::SyncClient, clock::Slot, commitment_config::CommitmentConfig,
epoch_schedule::MINIMUM_SLOTS_PER_EPOCH, hash::Hash,
epoch_schedule::MINIMUM_SLOTS_PER_EPOCH,
},
solana_streamer::socket::SocketAddrSpace,
std::{
Expand All @@ -61,7 +61,7 @@ const RUST_LOG_FILTER: &str =
fn wait_for_next_snapshot(
cluster: &LocalCluster,
snapshot_archives_dir: &Path,
) -> (PathBuf, (Slot, Hash)) {
) -> (PathBuf, (Slot, SnapshotHash)) {
// Get slot after which this was generated
let client = cluster
.get_validator_client(&cluster.entry_point_info.id)
Expand Down Expand Up @@ -196,9 +196,8 @@ fn setup_snapshot_validator_config(

// Create the validator config
let validator_config = ValidatorConfig {
snapshot_config: Some(snapshot_config),
snapshot_config,
account_paths: account_storage_paths,
accounts_db_caching_enabled: true,
accounts_hash_interval_slots: snapshot_interval_slots,
geyser_plugin_config_files,
enforce_ulimit_nofile: false,
Expand All @@ -225,8 +224,8 @@ fn test_local_cluster_start_and_exit_with_config(socket_addr_space: SocketAddrSp
node_stakes: vec![3; NUM_NODES],
cluster_lamports: 100,
ticks_per_slot: 8,
slots_per_epoch: MINIMUM_SLOTS_PER_EPOCH as u64,
stakers_slot_offset: MINIMUM_SLOTS_PER_EPOCH as u64,
slots_per_epoch: MINIMUM_SLOTS_PER_EPOCH,
stakers_slot_offset: MINIMUM_SLOTS_PER_EPOCH,
..ClusterConfig::default()
};
let cluster = LocalCluster::new(&mut config, socket_addr_space);
Expand Down Expand Up @@ -313,8 +312,6 @@ fn test_postgres_plugin() {
let snapshot_archives_dir = &leader_snapshot_test_config
.validator_config
.snapshot_config
.as_ref()
.unwrap()
.full_snapshot_archives_dir;
info!("Waiting for snapshot");
let (archive_filename, archive_snapshot_hash) =
Expand Down