Skip to content

Commit

Permalink
upgrade interface to 41
Browse files Browse the repository at this point in the history
  • Loading branch information
austbot committed Dec 9, 2022
1 parent 82d5490 commit fe18e6b
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 340 deletions.
210 changes: 140 additions & 70 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Solana.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ COPY Cargo.lock /rust/
WORKDIR /rust
RUN cargo build --release

FROM solanalabs/solana:v1.10.39
FROM solanalabs/solana:v1.10.41
COPY --from=builder /rust/target/release/libplerkle.so /plugin/plugin.so
COPY ./docker .
RUN chmod +x ./*.sh
Expand Down
14 changes: 7 additions & 7 deletions plerkle/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "plerkle"
description = "Geyser plugin with dynamic config reloading, message bus agnostic abstractions and a whole lot of fun."
version = "1.0.2"
version = "1.1.0"
authors = ["Metaplex Developers <dev@metaplex.com>"]
repository = "https://github.com/metaplex-foundation/digital-asset-validator-plugin"
license = "AGPL-3.0"
Expand All @@ -15,10 +15,10 @@ crate-type = ["cdylib", "rlib"]
log = "0.4.11"
async-trait = "0.1.53"

solana-sdk = { version = "=1.10.39" }
solana-transaction-status = { version = "=1.10.39" }
solana-geyser-plugin-interface = { version = "=1.10.39" }
solana-logger = { version = "=1.10.39" }
solana-sdk = { version = "1.10.41" }
solana-transaction-status = { version = "1.10.41" }
solana-geyser-plugin-interface = { version = "1.10.41" }
solana-logger = { version = "1.10.41" }

thiserror = "1.0.30"
base64 = "0.13.0"
Expand All @@ -33,9 +33,9 @@ cadence-macros = "0.29.0"
chrono = "0.4.19"
tracing = "0.1.35"
hex = "0.4.3"
plerkle_messenger = { path = "../plerkle_messenger", version = "1.0.2", features = ["redis"] }
plerkle_messenger = { path = "../plerkle_messenger", version = "1.1.0", features = ["redis"] }
flatbuffers = "22.10.26"
plerkle_serialization = { path = "../plerkle_serialization", version = "1.0.2" }
plerkle_serialization = { path = "../plerkle_serialization", version = "1.1.0" }
tokio = { version = "1.17.0", features = ["full"] }
figment = { version = "0.10.6", features = ["env", "test"] }

Expand Down
34 changes: 26 additions & 8 deletions plerkle/src/geyser_plugin_nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ use plerkle_serialization::serializer::{
};
use serde::Deserialize;
use solana_geyser_plugin_interface::geyser_plugin_interface::{
GeyserPlugin, GeyserPluginError, ReplicaAccountInfoVersions, ReplicaBlockInfoVersions,
ReplicaTransactionInfo, ReplicaTransactionInfoVersions, Result, SlotStatus,
GeyserPlugin, GeyserPluginError, ReplicaAccountInfoV2, ReplicaAccountInfoVersions,
ReplicaBlockInfoVersions, ReplicaTransactionInfo, ReplicaTransactionInfoV2,
ReplicaTransactionInfoVersions, Result, SlotStatus,
};
use solana_sdk::{message::AccountKeys, pubkey::Pubkey};
use std::{
Expand Down Expand Up @@ -53,7 +54,7 @@ pub struct PluginConfig {
pub config_reload_ttl: Option<i64>,
}

const MSG_BUFFER_SIZE: usize = 100000;
const MSG_BUFFER_SIZE: usize = 1000000;

impl<'a> Plerkle<'a> {
pub fn new() -> Self {
Expand Down Expand Up @@ -266,7 +267,23 @@ impl GeyserPlugin for Plerkle<'static> {
slot: u64,
is_startup: bool,
) -> solana_geyser_plugin_interface::geyser_plugin_interface::Result<()> {
let ReplicaAccountInfoVersions::V0_0_1(account) = account;
let rep: ReplicaAccountInfoV2;
let account = match account {
ReplicaAccountInfoVersions::V0_0_2(ai) => ai,
ReplicaAccountInfoVersions::V0_0_1(ai) => {
rep = ReplicaAccountInfoV2 {
pubkey: ai.pubkey,
lamports: ai.lamports,
owner: ai.owner,
executable: ai.executable,
rent_epoch: ai.rent_epoch,
data: ai.data,
write_version: ai.write_version,
txn_signature: None,
};
&rep
}
};
if let Some(accounts_selector) = &self.accounts_selector {
if !accounts_selector.is_account_selected(account.pubkey, account.owner) {
return Ok(());
Expand Down Expand Up @@ -338,15 +355,16 @@ impl GeyserPlugin for Plerkle<'static> {
transaction_info: ReplicaTransactionInfoVersions,
slot: u64,
) -> solana_geyser_plugin_interface::geyser_plugin_interface::Result<()> {
let rep: ReplicaTransactionInfo;
let rep: ReplicaTransactionInfoV2;
let transaction_info = match transaction_info {
// ReplicaTransactionInfoVersions::V0_0_2(ti) => ti,
ReplicaTransactionInfoVersions::V0_0_2(ti) => ti,
ReplicaTransactionInfoVersions::V0_0_1(ti) => {
rep = ReplicaTransactionInfo {
rep = ReplicaTransactionInfoV2 {
signature: ti.signature,
is_vote: ti.is_vote,
transaction: ti.transaction,
transaction_status_meta: ti.transaction_status_meta,
index: 0,
};
&rep
}
Expand Down Expand Up @@ -374,7 +392,7 @@ impl GeyserPlugin for Plerkle<'static> {
// Serialize data.
let builder = FlatBufferBuilder::new();
let builder = serialize_transaction(builder, transaction_info, slot);
let slt_idx = format!("{}-{}", slot, 0);
let slt_idx = format!("{}-{}", slot, transaction_info.index);
// Send transaction info over channel.
runtime.spawn(async move {
let data = SerializedData {
Expand Down
2 changes: 1 addition & 1 deletion plerkle_messenger/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "plerkle_messenger"
description = "Metaplex Messenger trait for Geyser plugin producer/consumer patterns."
version = "1.0.2"
version = "1.1.0"
authors = ["Metaplex Developers <dev@metaplex.com>"]
repository = "https://github.com/metaplex-foundation/digital-asset-validator-plugin"
license = "AGPL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion plerkle_serialization/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "plerkle_serialization"
description = "Metaplex Flatbuffers Plerkle Serialization for Geyser plugin producer/consumer patterns."
version = "1.0.2"
version = "1.1.0"
authors = ["Metaplex Developers <dev@metaplex.com>"]
repository = "https://github.com/metaplex-foundation/digital-asset-validator-plugin"
license = "AGPL-3.0"
Expand Down
12 changes: 7 additions & 5 deletions plerkle_serialization/src/serializer/serializer_stable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ use crate::{
Reward, RewardArgs, RewardType as FBRewardType, SlotStatusInfo, SlotStatusInfoArgs,
Status as FBSlotStatus, TransactionInfo, TransactionInfoArgs,
};
use chrono::Utc;
use chrono::{Utc, format::format};
use flatbuffers::FlatBufferBuilder;
use solana_geyser_plugin_interface::geyser_plugin_interface::{
ReplicaAccountInfo, ReplicaBlockInfo, ReplicaTransactionInfo, SlotStatus,
ReplicaBlockInfo, SlotStatus, ReplicaTransactionInfoV2, ReplicaAccountInfoV2,
};
use solana_runtime::bank::RewardType;

pub fn serialize_account<'a>(
mut builder: FlatBufferBuilder<'a>,
account: &ReplicaAccountInfo,
account: &ReplicaAccountInfoV2,
slot: u64,
is_startup: bool,
) -> FlatBufferBuilder<'a> {
Expand Down Expand Up @@ -77,7 +77,7 @@ pub fn serialize_slot_status<'a>(

pub fn serialize_transaction<'a>(
mut builder: FlatBufferBuilder<'a>,
transaction_info: &ReplicaTransactionInfo,
transaction_info: &ReplicaTransactionInfoV2,
slot: u64,
) -> FlatBufferBuilder<'a> {
// Flatten and serialize account keys.
Expand Down Expand Up @@ -170,6 +170,8 @@ pub fn serialize_transaction<'a>(
let seen_at = Utc::now();
let txn_sig = transaction_info.signature.to_string();
let signature_offset = builder.create_string(&txn_sig);
let slot_idx = format!("{}_{}", slot, transaction_info.index);
let slot_index_offset = builder.create_string(&slot_idx);
// Serialize everything into Transaction Info table.
let transaction_info_ser = TransactionInfo::create(
&mut builder,
Expand All @@ -180,7 +182,7 @@ pub fn serialize_transaction<'a>(
inner_instructions,
outer_instructions,
slot,
slot_index: None,
slot_index: Some(slot_index_offset),
seen_at: seen_at.timestamp_millis(),
signature: Some(signature_offset),
},
Expand Down
Loading

0 comments on commit fe18e6b

Please sign in to comment.