Skip to content

Commit

Permalink
Step Finance patch
Browse files Browse the repository at this point in the history
Co-authored-by: Dana <[email protected]>

bump docker build version

Add account owners array to messages

Cleaner diff

rename to post_owners

slot_second_idx

index in block

Reload config with plugin

add logs

Merge pull request anza-xyz#12 from step-finance/SF-5242-slot-number

Slot second idx -> DEV
  • Loading branch information
quellen-sol authored and JamesMDunn committed Oct 18, 2024
1 parent 4cc7b90 commit 6eab71f
Show file tree
Hide file tree
Showing 31 changed files with 429 additions and 26 deletions.
25 changes: 25 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: 2.1

orbs:
aws-ecr: circleci/[email protected]

executors:
custom:
machine:
image: ubuntu-2204:2022.04.2
resource_class: xlarge

workflows:
run-pipeline:
jobs:
- aws-ecr/build-and-push-image:
executor: custom
dockerfile: _step-finance/Dockerfile
repo: step-solana
region: eu-north-1
tag: ${CIRCLE_BRANCH},${CIRCLE_BRANCH}-<< pipeline.number >>,${CIRCLE_BRANCH}-<< pipeline.number >>-${CIRCLE_SHA1}
context: aws-account
filters:
branches:
only:
- step-release
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions _step-finance/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM rust:1.73-bullseye as builder
RUN apt-get update
RUN apt-get install -y libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang cmake make libprotobuf-dev protobuf-compiler
WORKDIR /solana-build
COPY . .
RUN cargo build --release

FROM debian:bullseye-20230522 as runtime
RUN apt-get update
RUN apt-get install -y bzip2
COPY --from=builder --chmod=700 /solana-build/target/release /usr/local/bin

WORKDIR /solana
ENTRYPOINT ["solana-test-validator"]
2 changes: 2 additions & 0 deletions _step-finance/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
_step-finance/
2 changes: 2 additions & 0 deletions cli/src/cluster_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2160,6 +2160,8 @@ pub fn process_transaction_history(
block_time,
slot,
transaction: transaction_with_meta,
index_in_block: _,
slot_second_idx: _,
} = confirmed_transaction;

let decoded_transaction =
Expand Down
2 changes: 2 additions & 0 deletions cli/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,8 @@ pub fn process_confirm(
block_time,
slot,
transaction: transaction_with_meta,
index_in_block: _,
slot_second_idx: _,
} = confirmed_transaction;

let decoded_transaction =
Expand Down
12 changes: 10 additions & 2 deletions core/src/banking_stage/committer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ use {
},
solana_measure::measure_us,
solana_runtime::{
bank::{Bank, ExecutedTransactionCounts, TransactionBalancesSet},
bank::{
Bank, ExecutedTransactionCounts, TransactionBalancesSet, TransactionDatumSet,
TransactionOwnersSet,
},
bank_utils,
prioritization_fee_cache::PrioritizationFeeCache,
transaction_batch::TransactionBatch,
Expand All @@ -15,6 +18,7 @@ use {
solana_sdk::{hash::Hash, pubkey::Pubkey, saturating_add_assign},
solana_svm::{
account_loader::TransactionLoadResult,
program_inclusions::PreOrPostDatum,
transaction_results::{TransactionExecutionResult, TransactionResults},
},
solana_transaction_status::{
Expand All @@ -35,6 +39,7 @@ pub enum CommitTransactionDetails {
#[derive(Default)]
pub(super) struct PreBalanceInfo {
pub native: Vec<Vec<u64>>,
pub datum: Vec<Vec<Option<Vec<u8>>>>,
pub token: Vec<Vec<TransactionTokenBalance>>,
pub mint_decimals: HashMap<Pubkey, u8>,
}
Expand Down Expand Up @@ -154,7 +159,8 @@ impl Committer {
) {
if let Some(transaction_status_sender) = &self.transaction_status_sender {
let txs = batch.sanitized_transactions().to_vec();
let post_balances = bank.collect_balances(batch);
let (post_balances, post_datum, owners) =
bank.collect_balances_and_datum(batch, PreOrPostDatum::PostDatum);
let post_token_balances =
collect_token_balances(bank, batch, &mut pre_balance_info.mint_decimals);
let mut transaction_index = starting_transaction_index.unwrap_or_default();
Expand All @@ -179,6 +185,8 @@ impl Committer {
std::mem::take(&mut pre_balance_info.native),
post_balances,
),
TransactionOwnersSet { owners },
TransactionDatumSet::new(std::mem::take(&mut pre_balance_info.datum), post_datum),
TransactionTokenBalancesSet::new(
std::mem::take(&mut pre_balance_info.token),
post_token_balances,
Expand Down
4 changes: 3 additions & 1 deletion core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use {
},
solana_svm::{
account_loader::{validate_fee_payer, TransactionCheckResult},
program_inclusions::PreOrPostDatum,
transaction_error_metrics::TransactionErrorMetrics,
transaction_processor::{ExecutionRecordingConfig, TransactionProcessingConfig},
},
Expand Down Expand Up @@ -566,7 +567,8 @@ impl Consumer {
// If the extra meta-data services are enabled for RPC, collect the
// pre-balances for native and token programs.
if transaction_status_sender_enabled {
pre_balance_info.native = bank.collect_balances(batch);
(pre_balance_info.native, pre_balance_info.datum, ..) =
bank.collect_balances_and_datum(batch, PreOrPostDatum::PreDatum);
pre_balance_info.token =
collect_token_balances(bank, batch, &mut pre_balance_info.mint_decimals)
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ impl Validator {
let mut bank_notification_senders = Vec::new();

let exit = Arc::new(AtomicBool::new(false));
let inclusions_copy = config.runtime_config.program_datum_inclusions.clone();

let geyser_plugin_service =
if let Some(geyser_plugin_config_files) = &config.on_start_geyser_plugin_config_files {
Expand All @@ -545,6 +546,7 @@ impl Validator {
confirmed_bank_receiver,
geyser_plugin_config_files,
rpc_to_plugin_manager_receiver_and_exit,
inclusions_copy,
)
.map_err(|err| format!("Failed to load the Geyser plugin: {err:?}"))?,
)
Expand Down
1 change: 1 addition & 0 deletions geyser-plugin-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ solana-metrics = { workspace = true }
solana-rpc = { workspace = true }
solana-runtime = { workspace = true }
solana-sdk = { workspace = true }
solana-svm = { workspace = true }
solana-transaction-status = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
Expand Down
25 changes: 21 additions & 4 deletions geyser-plugin-manager/src/geyser_plugin_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ use {
jsonrpc_core::{ErrorCode, Result as JsonRpcResult},
libloading::Library,
log::*,
solana_svm::program_inclusions::{load_datum_program_inclusions, ProgramDatumInclusions},
std::{
ops::{Deref, DerefMut},
path::Path,
sync::{Arc, RwLock},
},
tokio::sync::oneshot::Sender as OneShotSender,
};
Expand Down Expand Up @@ -47,13 +49,15 @@ impl DerefMut for LoadedGeyserPlugin {
pub struct GeyserPluginManager {
pub plugins: Vec<LoadedGeyserPlugin>,
libs: Vec<Library>,
inclusions: Arc<RwLock<ProgramDatumInclusions>>,
}

impl GeyserPluginManager {
pub fn new() -> Self {
pub fn new(inclusions: Arc<RwLock<ProgramDatumInclusions>>) -> Self {
GeyserPluginManager {
plugins: Vec::default(),
libs: Vec::default(),
inclusions,
}
}

Expand Down Expand Up @@ -239,6 +243,13 @@ impl GeyserPluginManager {
Ok(()) => {
self.plugins.push(new_plugin);
self.libs.push(new_lib);

// Reload datum inclusions
log::info!("Reloading datum inclusions");
let mut inclusions_write_lock = self.inclusions.write().unwrap();
*inclusions_write_lock =
load_datum_program_inclusions(&Some(vec![config_file.into()]));
log::info!("Reloaded datum inclusions");
}

// On failure, return error
Expand Down Expand Up @@ -487,7 +498,9 @@ mod tests {
#[test]
fn test_geyser_reload() {
// Initialize empty manager
let plugin_manager = Arc::new(RwLock::new(GeyserPluginManager::new()));
let plugin_manager = Arc::new(RwLock::new(GeyserPluginManager::new(Arc::new(
RwLock::new(Default::default()),
))));

// No plugins are loaded, this should fail
let mut plugin_manager_lock = plugin_manager.write().unwrap();
Expand Down Expand Up @@ -528,7 +541,9 @@ mod tests {
#[test]
fn test_plugin_list() {
// Initialize empty manager
let plugin_manager = Arc::new(RwLock::new(GeyserPluginManager::new()));
let plugin_manager = Arc::new(RwLock::new(GeyserPluginManager::new(Arc::new(
RwLock::new(Default::default()),
))));
let mut plugin_manager_lock = plugin_manager.write().unwrap();

// Load two plugins
Expand All @@ -552,7 +567,9 @@ mod tests {
#[test]
fn test_plugin_load_unload() {
// Initialize empty manager
let plugin_manager = Arc::new(RwLock::new(GeyserPluginManager::new()));
let plugin_manager = Arc::new(RwLock::new(GeyserPluginManager::new(Arc::new(
RwLock::new(Default::default()),
))));
let mut plugin_manager_lock = plugin_manager.write().unwrap();

// Load rpc call
Expand Down
12 changes: 10 additions & 2 deletions geyser-plugin-manager/src/geyser_plugin_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use {
optimistically_confirmed_bank_tracker::SlotNotification,
transaction_notifier_interface::TransactionNotifierArc,
},
solana_svm::program_inclusions::ProgramDatumInclusions,
std::{
path::{Path, PathBuf},
sync::{
Expand Down Expand Up @@ -55,8 +56,14 @@ impl GeyserPluginService {
pub fn new(
confirmed_bank_receiver: Receiver<SlotNotification>,
geyser_plugin_config_files: &[PathBuf],
inclusions: Arc<RwLock<ProgramDatumInclusions>>,
) -> Result<Self, GeyserPluginServiceError> {
Self::new_with_receiver(confirmed_bank_receiver, geyser_plugin_config_files, None)
Self::new_with_receiver(
confirmed_bank_receiver,
geyser_plugin_config_files,
None,
inclusions,
)
}

pub fn new_with_receiver(
Expand All @@ -66,12 +73,13 @@ impl GeyserPluginService {
Receiver<GeyserPluginManagerRequest>,
Arc<AtomicBool>,
)>,
inclusions: Arc<RwLock<ProgramDatumInclusions>>,
) -> Result<Self, GeyserPluginServiceError> {
info!(
"Starting GeyserPluginService from config files: {:?}",
geyser_plugin_config_files
);
let mut plugin_manager = GeyserPluginManager::new();
let mut plugin_manager = GeyserPluginManager::new(inclusions);

for geyser_plugin_config_file in geyser_plugin_config_files {
Self::load_plugin(&mut plugin_manager, geyser_plugin_config_file)?;
Expand Down
13 changes: 10 additions & 3 deletions ledger-tool/src/ledger_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,16 @@ pub fn load_and_process_ledger(

let (confirmed_bank_sender, confirmed_bank_receiver) = unbounded();
drop(confirmed_bank_sender);
let geyser_service =
GeyserPluginService::new(confirmed_bank_receiver, &geyser_config_files)
.map_err(LoadAndProcessLedgerError::GeyserServiceSetup)?;
let inclusions_copy = process_options
.runtime_config
.program_datum_inclusions
.clone();
let geyser_service = GeyserPluginService::new(
confirmed_bank_receiver,
&geyser_config_files,
inclusions_copy,
)
.map_err(LoadAndProcessLedgerError::GeyserServiceSetup)?;
(
geyser_service.get_accounts_update_notifier(),
geyser_service.get_transaction_notifier(),
Expand Down
14 changes: 12 additions & 2 deletions ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use {
solana_rayon_threadlimit::{get_max_thread_count, get_thread_count},
solana_runtime::{
accounts_background_service::{AbsRequestSender, SnapshotRequestKind},
bank::{Bank, TransactionBalancesSet},
bank::{Bank, TransactionBalancesSet, TransactionDatumSet, TransactionOwnersSet},
bank_forks::{BankForks, SetRootError},
bank_utils,
commitment::VOTE_THRESHOLD_SIZE,
Expand Down Expand Up @@ -167,7 +167,7 @@ pub fn execute_batch(
vec![]
};

let (tx_results, balances) = batch.bank().load_execute_and_commit_transactions(
let (tx_results, balances, datum, owners) = batch.bank().load_execute_and_commit_transactions(
batch,
MAX_PROCESSING_AGE,
transaction_status_sender.is_some(),
Expand Down Expand Up @@ -233,6 +233,8 @@ pub fn execute_batch(
transactions,
execution_results,
balances,
owners,
datum,
token_balances,
rent_debits,
transaction_indexes.to_vec(),
Expand Down Expand Up @@ -2142,6 +2144,8 @@ pub struct TransactionStatusBatch {
pub transactions: Vec<SanitizedTransaction>,
pub execution_results: Vec<Option<TransactionExecutionDetails>>,
pub balances: TransactionBalancesSet,
pub owners: TransactionOwnersSet,
pub datum: TransactionDatumSet,
pub token_balances: TransactionTokenBalancesSet,
pub rent_debits: Vec<RentDebits>,
pub transaction_indexes: Vec<usize>,
Expand All @@ -2159,6 +2163,8 @@ impl TransactionStatusSender {
transactions: Vec<SanitizedTransaction>,
execution_results: Vec<TransactionExecutionResult>,
balances: TransactionBalancesSet,
owners: TransactionOwnersSet,
datum: TransactionDatumSet,
token_balances: TransactionTokenBalancesSet,
rent_debits: Vec<RentDebits>,
transaction_indexes: Vec<usize>,
Expand All @@ -2178,6 +2184,8 @@ impl TransactionStatusSender {
})
.collect(),
balances,
owners,
datum,
token_balances,
rent_debits,
transaction_indexes,
Expand Down Expand Up @@ -4279,6 +4287,8 @@ pub mod tests {
..
},
_balances,
_datums,
_owners,
) = batch.bank().load_execute_and_commit_transactions(
&batch,
MAX_PROCESSING_AGE,
Expand Down
5 changes: 5 additions & 0 deletions rpc-client/src/mock_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ impl RpcSender for MockSender {
fee: 0,
pre_balances: vec![499999999999999950, 50, 1],
post_balances: vec![499999999999999950, 50, 1],
post_owners: None,
pre_datum: None,
post_datum: None,
inner_instructions: OptionSerializer::None,
log_messages: OptionSerializer::None,
pre_token_balances: OptionSerializer::None,
Expand All @@ -204,6 +207,8 @@ impl RpcSender for MockSender {
}),
},
block_time: Some(1628633791),
index_in_block: 0,
slot_second_idx: None,
})?,
"getTransactionCount" => json![1234],
"getSlot" => json![0],
Expand Down
Loading

0 comments on commit 6eab71f

Please sign in to comment.