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

index in block

Reload config with plugin

add logs
  • Loading branch information
quellen-sol authored and thesoftwarejedi committed Aug 26, 2024
1 parent b286211 commit b57c892
Show file tree
Hide file tree
Showing 26 changed files with 417 additions and 27 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
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/
1 change: 1 addition & 0 deletions cli/src/cluster_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,7 @@ pub fn process_transaction_history(
block_time,
slot,
transaction: transaction_with_meta,
index_in_block: _,
} = confirmed_transaction;

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

let decoded_transaction =
Expand Down
11 changes: 9 additions & 2 deletions core/src/banking_stage/committer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ use {
},
solana_measure::measure_us,
solana_runtime::{
bank::{Bank, CommitTransactionCounts, TransactionBalancesSet},
bank::{Bank, CommitTransactionCounts, TransactionBalancesSet, TransactionDatumSet, TransactionOwnersSet},
bank_utils,
prioritization_fee_cache::PrioritizationFeeCache,
program_inclusions::PreOrPostDatum,
transaction_batch::TransactionBatch,
},
solana_sdk::{hash::Hash, pubkey::Pubkey, saturating_add_assign},
Expand All @@ -32,6 +33,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 @@ -142,7 +144,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 @@ -167,6 +170,10 @@ 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 @@ -25,6 +25,7 @@ use {
solana_runtime::{
accounts::validate_fee_payer,
bank::{Bank, LoadAndExecuteTransactionsOutput},
program_inclusions::PreOrPostDatum,
transaction_batch::TransactionBatch,
},
solana_sdk::{
Expand Down Expand Up @@ -570,7 +571,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 @@ -512,6 +512,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 @@ -524,6 +525,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
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 @@ -4,9 +4,11 @@ use {
libloading::Library,
log::*,
solana_geyser_plugin_interface::geyser_plugin_interface::GeyserPlugin,
solana_runtime::program_inclusions::{load_datum_program_inclusions, ProgramDatumInclusions},
std::{
ops::{Deref, DerefMut},
path::Path,
sync::{Arc, RwLock},
},
};

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 @@ -483,7 +494,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 @@ -524,7 +537,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 @@ -548,7 +563,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_runtime::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 @@ -259,9 +259,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 @@ -35,7 +35,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,
bank_utils,
commitment::VOTE_THRESHOLD_SIZE,
Expand Down Expand Up @@ -157,7 +157,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 @@ -203,6 +203,8 @@ pub fn execute_batch(
transactions,
execution_results,
balances,
owners,
datum,
token_balances,
rent_debits,
transaction_indexes.to_vec(),
Expand Down Expand Up @@ -1828,6 +1830,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 @@ -1845,6 +1849,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 @@ -1864,6 +1870,8 @@ impl TransactionStatusSender {
})
.collect(),
balances,
owners,
datum,
token_balances,
rent_debits,
transaction_indexes,
Expand Down Expand Up @@ -3951,6 +3959,8 @@ pub mod tests {
..
},
_balances,
_datums,
_owners,
) = batch.bank().load_execute_and_commit_transactions(
&batch,
MAX_PROCESSING_AGE,
Expand Down
4 changes: 4 additions & 0 deletions rpc-client/src/mock_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,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 @@ -237,6 +240,7 @@ impl RpcSender for MockSender {
}),
},
block_time: Some(1628633791),
index_in_block: 0,
})?,
"getTransactionCount" => json![1234],
"getSlot" => json![0],
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ impl JsonRpcRequestProcessor {

let encode_transaction =
|confirmed_tx_with_meta: ConfirmedTransactionWithStatusMeta| -> Result<EncodedConfirmedTransactionWithStatusMeta> {
Ok(confirmed_tx_with_meta.encode(encoding, max_supported_transaction_version).map_err(RpcCustomError::from)?)
Ok(confirmed_tx_with_meta.encode(encoding, max_supported_transaction_version, 0).map_err(RpcCustomError::from)?)
};

match confirmed_transaction.unwrap_or(None) {
Expand Down
Loading

0 comments on commit b57c892

Please sign in to comment.