Skip to content

Commit

Permalink
Step Finance Patch
Browse files Browse the repository at this point in the history
Merge pull request #8 from step-finance/sf-3750-explicit-data-includes

SF-3750: Explicit Data Includes
  • Loading branch information
thesoftwarejedi authored and fanatid committed Jan 12, 2024
1 parent a505523 commit 1a6cd7f
Show file tree
Hide file tree
Showing 19 changed files with 314 additions and 18 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.69-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/
10 changes: 7 additions & 3 deletions core/src/banking_stage/committer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ use {
solana_runtime::{
accounts::TransactionLoadResult,
bank::{
Bank, CommitTransactionCounts, TransactionBalancesSet, TransactionExecutionResult,
TransactionResults,
Bank, CommitTransactionCounts, TransactionBalancesSet, TransactionDatumSet,
TransactionExecutionResult, TransactionResults,
},
bank_utils,
prioritization_fee_cache::PrioritizationFeeCache,
program_inclusions::PreOrPostDatum,
transaction_batch::TransactionBatch,
vote_sender_types::ReplayVoteSender,
},
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 @@ -141,7 +143,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) =
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 @@ -166,6 +169,7 @@ impl Committer {
std::mem::take(&mut pre_balance_info.native),
post_balances,
),
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 @@ -21,6 +21,7 @@ use {
solana_program_runtime::timings::ExecuteTimings,
solana_runtime::{
bank::{Bank, LoadAndExecuteTransactionsOutput, TransactionCheckResult},
program_inclusions::PreOrPostDatum,
transaction_batch::TransactionBatch,
transaction_error_metrics::TransactionErrorMetrics,
},
Expand Down Expand Up @@ -537,7 +538,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
11 changes: 8 additions & 3 deletions ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use {
accounts_index::AccountSecondaryIndexes,
accounts_update_notifier_interface::AccountsUpdateNotifier,
bank::{
Bank, TransactionBalancesSet, TransactionExecutionDetails, TransactionExecutionResult,
TransactionResults,
Bank, TransactionBalancesSet, TransactionDatumSet, TransactionExecutionDetails,
TransactionExecutionResult, TransactionResults,
},
bank_forks::BankForks,
bank_utils,
Expand Down Expand Up @@ -155,7 +155,7 @@ fn execute_batch(
vec![]
};

let (tx_results, balances) = batch.bank().load_execute_and_commit_transactions(
let (tx_results, balances, datum) = batch.bank().load_execute_and_commit_transactions(
batch,
MAX_PROCESSING_AGE,
transaction_status_sender.is_some(),
Expand Down Expand Up @@ -201,6 +201,7 @@ fn execute_batch(
transactions,
execution_results,
balances,
datum,
token_balances,
rent_debits,
transaction_indexes.to_vec(),
Expand Down Expand Up @@ -1744,6 +1745,7 @@ pub struct TransactionStatusBatch {
pub transactions: Vec<SanitizedTransaction>,
pub execution_results: Vec<Option<TransactionExecutionDetails>>,
pub balances: TransactionBalancesSet,
pub datum: TransactionDatumSet,
pub token_balances: TransactionTokenBalancesSet,
pub rent_debits: Vec<RentDebits>,
pub transaction_indexes: Vec<usize>,
Expand All @@ -1761,6 +1763,7 @@ impl TransactionStatusSender {
transactions: Vec<SanitizedTransaction>,
execution_results: Vec<TransactionExecutionResult>,
balances: TransactionBalancesSet,
datum: TransactionDatumSet,
token_balances: TransactionTokenBalancesSet,
rent_debits: Vec<RentDebits>,
transaction_indexes: Vec<usize>,
Expand All @@ -1780,6 +1783,7 @@ impl TransactionStatusSender {
})
.collect(),
balances,
datum,
token_balances,
rent_debits,
transaction_indexes,
Expand Down Expand Up @@ -3863,6 +3867,7 @@ pub mod tests {
..
},
_balances,
_datums,
) = batch.bank().load_execute_and_commit_transactions(
&batch,
MAX_PROCESSING_AGE,
Expand Down
2 changes: 2 additions & 0 deletions rpc-client/src/mock_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ impl RpcSender for MockSender {
fee: 0,
pre_balances: vec![499999999999999950, 50, 1],
post_balances: vec![499999999999999950, 50, 1],
pre_datum: None,
post_datum: None,
inner_instructions: OptionSerializer::None,
log_messages: OptionSerializer::None,
pre_token_balances: OptionSerializer::None,
Expand Down
13 changes: 12 additions & 1 deletion rpc/src/transaction_status_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl TransactionStatusService {
bank,
transactions,
execution_results,
datum,
balances,
token_balances,
rent_debits,
Expand All @@ -81,6 +82,8 @@ impl TransactionStatusService {
execution_result,
pre_balances,
post_balances,
pre_datum,
post_datum,
pre_token_balances,
post_token_balances,
rent_debits,
Expand All @@ -90,6 +93,8 @@ impl TransactionStatusService {
execution_results,
balances.pre_balances,
balances.post_balances,
datum.pre_datum,
datum.post_datum,
token_balances.pre_token_balances,
token_balances.post_token_balances,
rent_debits,
Expand Down Expand Up @@ -159,6 +164,8 @@ impl TransactionStatusService {
fee,
pre_balances,
post_balances,
pre_datum: Some(pre_datum),
post_datum: Some(post_datum),
inner_instructions,
log_messages,
pre_token_balances,
Expand Down Expand Up @@ -228,7 +235,7 @@ pub(crate) mod tests {
solana_account_decoder::parse_token::token_amount_to_ui_amount,
solana_ledger::{genesis_utils::create_genesis_config, get_tmp_ledger_path},
solana_runtime::{
bank::{Bank, NonceFull, NoncePartial, TransactionBalancesSet},
bank::{Bank, NonceFull, NoncePartial, TransactionBalancesSet, TransactionDatumSet},
rent_debits::RentDebits,
},
solana_sdk::{
Expand Down Expand Up @@ -424,6 +431,10 @@ pub(crate) mod tests {
let transaction_index: usize = bank.transaction_count().try_into().unwrap();
let transaction_status_batch = TransactionStatusBatch {
bank,
datum: TransactionDatumSet {
post_datum: vec![vec![Some(vec![0x69])]],
pre_datum: vec![vec![Some(vec![0x04, 0x20])]],
},
transactions: vec![transaction],
execution_results: vec![transaction_result],
balances,
Expand Down
Loading

0 comments on commit 1a6cd7f

Please sign in to comment.