Skip to content

Commit 42539b9

Browse files
authored
Merge pull request solana-labs#55 from lijunwangs/support_validator_v1.15.2
Support validator v1.15.2
2 parents 6c2f111 + 910e7f2 commit 42539b9

File tree

8 files changed

+76
-56
lines changed

8 files changed

+76
-56
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.2"
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.2" }
29+
solana-logger = { version = "=1.15.2" }
30+
solana-measure = { version = "=1.15.2" }
31+
solana-metrics = { version = "=1.15.2" }
32+
solana-runtime = { version = "=1.15.2" }
33+
solana-sdk = { version = "=1.15.2" }
34+
solana-transaction-status = { version = "=1.15.2" }
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.2" }
45+
solana-core = { version = "=1.15.2" }
46+
solana-local-cluster = { version = "=1.15.2" }
47+
solana-net-utils = { version = "=1.15.2" }
48+
solana-streamer = { version = "=1.15.2" }
4949
tempfile = "3.3.0"
5050

5151
[package.metadata.docs.rs]

ci/rust-version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
if [[ -n $RUST_STABLE_VERSION ]]; then
1919
stable_version="$RUST_STABLE_VERSION"
2020
else
21-
stable_version=1.63.0
21+
stable_version=1.66.1
2222
fi
2323

2424
if [[ -n $RUST_NIGHTLY_VERSION ]]; then

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: 8 additions & 8 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::*,
@@ -112,10 +112,10 @@ impl DbAccountInfo {
112112
let data = account.data().to_vec();
113113
Self {
114114
pubkey: account.pubkey().to_vec(),
115-
lamports: account.lamports() as i64,
115+
lamports: account.lamports(),
116116
owner: account.owner().to_vec(),
117117
executable: account.executable(),
118-
rent_epoch: account.rent_epoch() as i64,
118+
rent_epoch: account.rent_epoch(),
119119
data,
120120
slot: slot as i64,
121121
write_version: account.write_version(),
@@ -506,8 +506,8 @@ impl SimplePostgresClient {
506506
statement: &Statement,
507507
client: &mut Client,
508508
) -> Result<(), GeyserPluginError> {
509-
let lamports = account.lamports() as i64;
510-
let rent_epoch = account.rent_epoch() as i64;
509+
let lamports = account.lamports();
510+
let rent_epoch = account.rent_epoch();
511511
let updated_on = Utc::now().naive_utc();
512512
let result = client.execute(
513513
statement,
@@ -545,8 +545,8 @@ impl SimplePostgresClient {
545545
insert_token_owner_index_stmt: &Option<Statement>,
546546
insert_token_mint_index_stmt: &Option<Statement>,
547547
) -> Result<(), GeyserPluginError> {
548-
let lamports = account.lamports() as i64;
549-
let rent_epoch = account.rent_epoch() as i64;
548+
let lamports = account.lamports();
549+
let rent_epoch = account.rent_epoch();
550550
let updated_on = Utc::now().naive_utc();
551551
let result = client.execute(
552552
statement,
@@ -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: 37 additions & 20 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
}
@@ -301,7 +301,7 @@ impl From<&Reward> for DbReward {
301301
fn from(reward: &Reward) -> Self {
302302
Self {
303303
pubkey: reward.pubkey.clone(),
304-
lamports: reward.lamports as i64,
304+
lamports: reward.lamports,
305305
post_balance: reward.post_balance as i64,
306306
reward_type: get_reward_type(&reward.reward_type),
307307
commission: reward
@@ -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(
@@ -681,7 +686,7 @@ pub(crate) mod tests {
681686
for i in 0..compiled_instruction.data.len() {
682687
assert_eq!(
683688
compiled_instruction.data[i],
684-
db_compiled_instruction.data[i] as u8
689+
db_compiled_instruction.data[i]
685690
)
686691
}
687692
}
@@ -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: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ 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,
44-
epoch_schedule::MINIMUM_SLOTS_PER_EPOCH, hash::Hash,
44+
epoch_schedule::MINIMUM_SLOTS_PER_EPOCH,
4545
},
4646
solana_streamer::socket::SocketAddrSpace,
4747
std::{
@@ -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,
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,
@@ -225,8 +224,8 @@ fn test_local_cluster_start_and_exit_with_config(socket_addr_space: SocketAddrSp
225224
node_stakes: vec![3; NUM_NODES],
226225
cluster_lamports: 100,
227226
ticks_per_slot: 8,
228-
slots_per_epoch: MINIMUM_SLOTS_PER_EPOCH as u64,
229-
stakers_slot_offset: MINIMUM_SLOTS_PER_EPOCH as u64,
227+
slots_per_epoch: MINIMUM_SLOTS_PER_EPOCH,
228+
stakers_slot_offset: MINIMUM_SLOTS_PER_EPOCH,
230229
..ClusterConfig::default()
231230
};
232231
let cluster = LocalCluster::new(&mut config, socket_addr_space);
@@ -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)