Skip to content

Commit 56497c9

Browse files
committed
Suppor validator v1.15.0
1 parent 6c2f111 commit 56497c9

File tree

7 files changed

+64
-44
lines changed

7 files changed

+64
-44
lines changed

Cargo.toml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ authors = ["Solana Maintainers <maintainers@solana.foundation>"]
33
edition = "2021"
44
name = "solana-geyser-plugin-postgres"
55
description = "The Solana AccountsDb plugin for PostgreSQL database."
6-
version = "1.14.17"
6+
version = "1.15.0"
77
repository = "https://github.com/solana-labs/solana"
88
license = "Apache-2.0"
99
homepage = "https://solana.com/"
@@ -25,13 +25,13 @@ postgres-openssl = { version = "0.5.0"}
2525
serde = "1.0.145"
2626
serde_derive = "1.0.145"
2727
serde_json = "1.0.85"
28-
solana-geyser-plugin-interface = { version = "=1.14.17" }
29-
solana-logger = { version = "=1.14.17" }
30-
solana-measure = { version = "=1.14.17" }
31-
solana-metrics = { version = "=1.14.17" }
32-
solana-runtime = { version = "=1.14.17" }
33-
solana-sdk = { version = "=1.14.17" }
34-
solana-transaction-status = { version = "=1.14.17" }
28+
solana-geyser-plugin-interface = { version = "=1.15.0" }
29+
solana-logger = { version = "=1.15.0" }
30+
solana-measure = { version = "=1.15.0" }
31+
solana-metrics = { version = "=1.15.0" }
32+
solana-runtime = { version = "=1.15.0" }
33+
solana-sdk = { version = "=1.15.0" }
34+
solana-transaction-status = { version = "=1.15.0" }
3535
thiserror = "1.0.37"
3636
tokio-postgres = "0.7.7"
3737

@@ -41,11 +41,11 @@ libloading = "0.7.3"
4141
serial_test = "0.9.0"
4242
socket2 = { version = "0.4.7", features = ["all"] }
4343

44-
solana-account-decoder = { version = "=1.14.17" }
45-
solana-core = { version = "=1.14.17" }
46-
solana-local-cluster = { version = "=1.14.17" }
47-
solana-net-utils = { version = "=1.14.17" }
48-
solana-streamer = { version = "=1.14.17" }
44+
solana-account-decoder = { version = "=1.15.0" }
45+
solana-core = { version = "=1.15.0" }
46+
solana-local-cluster = { version = "=1.15.0" }
47+
solana-net-utils = { version = "=1.15.0" }
48+
solana-streamer = { version = "=1.15.0" }
4949
tempfile = "3.3.0"
5050

5151
[package.metadata.docs.rs]

scripts/create_schema.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ Create TYPE "TransactionErrorCode" AS ENUM (
6464
'WouldExceedAccountDataBlockLimit',
6565
'WouldExceedAccountDataTotalLimit',
6666
'DuplicateInstruction',
67-
'InsufficientFundsForRent'
67+
'InsufficientFundsForRent',
68+
'MaxLoadedAccountsDataSizeExceeded'
6869
);
6970

7071
CREATE TYPE "TransactionError" AS (

src/geyser_plugin_postgres.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ impl GeyserPlugin for GeyserPluginPostgres {
414414
)));
415415
}
416416
Some(client) => match block_info {
417-
ReplicaBlockInfoVersions::V0_0_1(block_info) => {
417+
ReplicaBlockInfoVersions::V0_0_2(block_info) => {
418418
let result = client.update_block_metadata(block_info);
419419

420420
if let Err(err) = result {
@@ -423,6 +423,11 @@ impl GeyserPlugin for GeyserPluginPostgres {
423423
});
424424
}
425425
}
426+
ReplicaBlockInfoVersions::V0_0_1(_) => {
427+
return Err(GeyserPluginError::SlotStatusUpdateError{
428+
msg: "Failed to persist the transaction info to the PostgreSQL database. Unsupported format.".to_string()
429+
});
430+
}
426431
},
427432
}
428433

src/postgres_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use {
1919
postgres_client_transaction::LogTransactionRequest,
2020
postgres_openssl::MakeTlsConnector,
2121
solana_geyser_plugin_interface::geyser_plugin_interface::{
22-
GeyserPluginError, ReplicaAccountInfoV2, ReplicaBlockInfo, SlotStatus,
22+
GeyserPluginError, ReplicaAccountInfoV2, ReplicaBlockInfoV2, SlotStatus,
2323
},
2424
solana_measure::measure::Measure,
2525
solana_metrics::*,
@@ -1232,7 +1232,7 @@ impl ParallelPostgresClient {
12321232

12331233
pub fn update_block_metadata(
12341234
&mut self,
1235-
block_info: &ReplicaBlockInfo,
1235+
block_info: &ReplicaBlockInfoV2,
12361236
) -> Result<(), GeyserPluginError> {
12371237
if let Err(err) = self.sender.send(DbWorkItem::UpdateBlockMetadata(Box::new(
12381238
UpdateBlockMetadataRequest {

src/postgres_client/postgres_client_block_metadata.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use {
99
log::*,
1010
postgres::{Client, Statement},
1111
solana_geyser_plugin_interface::geyser_plugin_interface::{
12-
GeyserPluginError, ReplicaBlockInfo,
12+
GeyserPluginError, ReplicaBlockInfoV2,
1313
},
1414
};
1515

@@ -22,8 +22,8 @@ pub struct DbBlockInfo {
2222
pub block_height: Option<i64>,
2323
}
2424

25-
impl<'a> From<&ReplicaBlockInfo<'a>> for DbBlockInfo {
26-
fn from(block_info: &ReplicaBlockInfo) -> Self {
25+
impl<'a> From<&ReplicaBlockInfoV2<'a>> for DbBlockInfo {
26+
fn from(block_info: &ReplicaBlockInfoV2) -> Self {
2727
Self {
2828
slot: block_info.slot as i64,
2929
blockhash: block_info.blockhash.to_string(),

src/postgres_client/postgres_client_transaction.rs

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl From<&InnerInstructions> for DbInnerInstructions {
276276
instructions: instructions
277277
.instructions
278278
.iter()
279-
.map(DbCompiledInstruction::from)
279+
.map(|instruction| DbCompiledInstruction::from(&instruction.instruction))
280280
.collect(),
281281
}
282282
}
@@ -348,6 +348,7 @@ pub enum DbTransactionErrorCode {
348348
WouldExceedAccountDataTotalLimit,
349349
DuplicateInstruction,
350350
InsufficientFundsForRent,
351+
MaxLoadedAccountsDataSizeExceeded,
351352
}
352353

353354
impl From<&TransactionError> for DbTransactionErrorCode {
@@ -397,6 +398,9 @@ impl From<&TransactionError> for DbTransactionErrorCode {
397398
TransactionError::InsufficientFundsForRent { account_index: _ } => {
398399
Self::InsufficientFundsForRent
399400
}
401+
TransactionError::MaxLoadedAccountsDataSizeExceeded => {
402+
Self::MaxLoadedAccountsDataSizeExceeded
403+
}
400404
}
401405
}
402406
}
@@ -653,6 +657,7 @@ pub(crate) mod tests {
653657
SanitizedTransaction, SimpleAddressLoader, Transaction, VersionedTransaction,
654658
},
655659
},
660+
solana_transaction_status::InnerInstruction,
656661
};
657662

658663
fn check_compiled_instruction_equality(
@@ -710,7 +715,7 @@ pub(crate) mod tests {
710715

711716
for i in 0..inner_instructions.instructions.len() {
712717
check_compiled_instruction_equality(
713-
&inner_instructions.instructions[i],
718+
&inner_instructions.instructions[i].instruction,
714719
&db_inner_instructions.instructions[i],
715720
)
716721
}
@@ -721,15 +726,21 @@ pub(crate) mod tests {
721726
let inner_instructions = InnerInstructions {
722727
index: 0,
723728
instructions: vec![
724-
CompiledInstruction {
725-
program_id_index: 0,
726-
accounts: vec![1, 2, 3],
727-
data: vec![4, 5, 6],
729+
InnerInstruction {
730+
instruction: CompiledInstruction {
731+
program_id_index: 0,
732+
accounts: vec![1, 2, 3],
733+
data: vec![4, 5, 6],
734+
},
735+
stack_height: None,
728736
},
729-
CompiledInstruction {
730-
program_id_index: 1,
731-
accounts: vec![12, 13, 14],
732-
data: vec![24, 25, 26],
737+
InnerInstruction {
738+
instruction: CompiledInstruction {
739+
program_id_index: 1,
740+
accounts: vec![12, 13, 14],
741+
data: vec![24, 25, 26],
742+
},
743+
stack_height: None,
733744
},
734745
],
735746
};
@@ -996,15 +1007,21 @@ pub(crate) mod tests {
9961007
inner_instructions: Some(vec![InnerInstructions {
9971008
index: 0,
9981009
instructions: vec![
999-
CompiledInstruction {
1000-
program_id_index: 0,
1001-
accounts: vec![1, 2, 3],
1002-
data: vec![4, 5, 6],
1010+
InnerInstruction {
1011+
instruction: CompiledInstruction {
1012+
program_id_index: 0,
1013+
accounts: vec![1, 2, 3],
1014+
data: vec![4, 5, 6],
1015+
},
1016+
stack_height: None,
10031017
},
1004-
CompiledInstruction {
1005-
program_id_index: 1,
1006-
accounts: vec![12, 13, 14],
1007-
data: vec![24, 25, 26],
1018+
InnerInstruction {
1019+
instruction: CompiledInstruction {
1020+
program_id_index: 1,
1021+
accounts: vec![12, 13, 14],
1022+
data: vec![24, 25, 26],
1023+
},
1024+
stack_height: None,
10081025
},
10091026
],
10101027
}]),

tests/test_postgres_plugin.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use {
3737
},
3838
solana_runtime::{
3939
snapshot_archive_info::SnapshotArchiveInfoGetter, snapshot_config::SnapshotConfig,
40-
snapshot_utils,
40+
snapshot_hash::SnapshotHash, snapshot_utils,
4141
},
4242
solana_sdk::{
4343
client::SyncClient, clock::Slot, commitment_config::CommitmentConfig,
@@ -61,7 +61,7 @@ const RUST_LOG_FILTER: &str =
6161
fn wait_for_next_snapshot(
6262
cluster: &LocalCluster,
6363
snapshot_archives_dir: &Path,
64-
) -> (PathBuf, (Slot, Hash)) {
64+
) -> (PathBuf, (Slot, SnapshotHash)) {
6565
// Get slot after which this was generated
6666
let client = cluster
6767
.get_validator_client(&cluster.entry_point_info.id)
@@ -196,9 +196,8 @@ fn setup_snapshot_validator_config(
196196

197197
// Create the validator config
198198
let validator_config = ValidatorConfig {
199-
snapshot_config: Some(snapshot_config),
199+
snapshot_config: snapshot_config,
200200
account_paths: account_storage_paths,
201-
accounts_db_caching_enabled: true,
202201
accounts_hash_interval_slots: snapshot_interval_slots,
203202
geyser_plugin_config_files,
204203
enforce_ulimit_nofile: false,
@@ -313,8 +312,6 @@ fn test_postgres_plugin() {
313312
let snapshot_archives_dir = &leader_snapshot_test_config
314313
.validator_config
315314
.snapshot_config
316-
.as_ref()
317-
.unwrap()
318315
.full_snapshot_archives_dir;
319316
info!("Waiting for snapshot");
320317
let (archive_filename, archive_snapshot_hash) =

0 commit comments

Comments
 (0)