Move CostModel and CostTracker to its own crate (#32354)
* Move CostModel and CostTracker to its own crate * compile new crate and update imports * update sbf Cargo.lock * fix AbiExample * fix cargo sort * Fix AbiExample
This commit is contained in:
parent
b060f62004
commit
4674b0099f
|
@ -5610,6 +5610,7 @@ dependencies = [
|
|||
"solana-address-lookup-table-program",
|
||||
"solana-bloom",
|
||||
"solana-client",
|
||||
"solana-cost-model",
|
||||
"solana-entry",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
|
@ -5650,6 +5651,31 @@ dependencies = [
|
|||
"trees",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-cost-model"
|
||||
version = "1.17.0"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
"rustc_version 0.4.0",
|
||||
"solana-address-lookup-table-program",
|
||||
"solana-bpf-loader-program",
|
||||
"solana-compute-budget-program",
|
||||
"solana-config-program",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-loader-v4-program",
|
||||
"solana-logger",
|
||||
"solana-metrics",
|
||||
"solana-program-runtime",
|
||||
"solana-sdk",
|
||||
"solana-stake-program",
|
||||
"solana-system-program",
|
||||
"solana-vote-program",
|
||||
"static_assertions",
|
||||
"test-case",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-dos"
|
||||
version = "1.17.0"
|
||||
|
@ -5996,6 +6022,7 @@ dependencies = [
|
|||
"sha2 0.10.7",
|
||||
"solana-account-decoder",
|
||||
"solana-bpf-loader-program",
|
||||
"solana-cost-model",
|
||||
"solana-entry",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
|
@ -6051,6 +6078,7 @@ dependencies = [
|
|||
"solana-clap-utils",
|
||||
"solana-cli-output",
|
||||
"solana-core",
|
||||
"solana-cost-model",
|
||||
"solana-entry",
|
||||
"solana-geyser-plugin-manager",
|
||||
"solana-gossip",
|
||||
|
@ -6688,6 +6716,7 @@ dependencies = [
|
|||
"solana-bucket-map",
|
||||
"solana-compute-budget-program",
|
||||
"solana-config-program",
|
||||
"solana-cost-model",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-loader-v4-program",
|
||||
|
|
|
@ -20,6 +20,7 @@ members = [
|
|||
"client-test",
|
||||
"connection-cache",
|
||||
"core",
|
||||
"cost-model",
|
||||
"dos",
|
||||
"download-utils",
|
||||
"entry",
|
||||
|
@ -312,6 +313,7 @@ solana-client = { path = "client", version = "=1.17.0" }
|
|||
solana-compute-budget-program = { path = "programs/compute-budget", version = "=1.17.0" }
|
||||
solana-config-program = { path = "programs/config", version = "=1.17.0" }
|
||||
solana-core = { path = "core", version = "=1.17.0" }
|
||||
solana-cost-model = { path = "cost-model", version = "=1.17.0" }
|
||||
solana-download-utils = { path = "download-utils", version = "=1.17.0" }
|
||||
solana-entry = { path = "entry", version = "=1.17.0" }
|
||||
solana-faucet = { path = "faucet", version = "=1.17.0" }
|
||||
|
|
|
@ -38,6 +38,7 @@ serde_derive = { workspace = true }
|
|||
solana-address-lookup-table-program = { workspace = true }
|
||||
solana-bloom = { workspace = true }
|
||||
solana-client = { workspace = true }
|
||||
solana-cost-model = { workspace = true }
|
||||
solana-entry = { workspace = true }
|
||||
solana-frozen-abi = { workspace = true }
|
||||
solana-frozen-abi-macro = { workspace = true }
|
||||
|
|
|
@ -736,6 +736,7 @@ mod tests {
|
|||
},
|
||||
crossbeam_channel::{unbounded, Receiver},
|
||||
solana_address_lookup_table_program::state::{AddressLookupTable, LookupTableMeta},
|
||||
solana_cost_model::cost_model::CostModel,
|
||||
solana_entry::entry::{next_entry, next_versioned_entry},
|
||||
solana_ledger::{
|
||||
blockstore::{entries_to_test_shreds, Blockstore},
|
||||
|
@ -748,7 +749,7 @@ mod tests {
|
|||
solana_poh::poh_recorder::{PohRecorder, WorkingBankEntry},
|
||||
solana_program_runtime::timings::ProgramTiming,
|
||||
solana_rpc::transaction_status_service::TransactionStatusService,
|
||||
solana_runtime::{cost_model::CostModel, prioritization_fee_cache::PrioritizationFeeCache},
|
||||
solana_runtime::prioritization_fee_cache::PrioritizationFeeCache,
|
||||
solana_sdk::{
|
||||
account::AccountSharedData,
|
||||
instruction::InstructionError,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use {
|
||||
super::immutable_deserialized_packet::ImmutableDeserializedPacket,
|
||||
solana_perf::packet::Packet,
|
||||
solana_runtime::{
|
||||
solana_cost_model::{
|
||||
block_cost_limits,
|
||||
cost_model::CostModel,
|
||||
cost_tracker::{CostTracker, CostTrackerError},
|
||||
},
|
||||
solana_perf::packet::Packet,
|
||||
solana_sdk::{feature_set::FeatureSet, transaction::SanitizedTransaction},
|
||||
std::sync::Arc,
|
||||
};
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
use {
|
||||
super::{committer::CommitTransactionDetails, BatchedTransactionDetails},
|
||||
crossbeam_channel::{unbounded, Receiver, Sender},
|
||||
solana_cost_model::{cost_model::CostModel, transaction_cost::TransactionCost},
|
||||
solana_measure::measure::Measure,
|
||||
solana_runtime::{bank::Bank, cost_model::CostModel, transaction_cost::TransactionCost},
|
||||
solana_runtime::bank::Bank,
|
||||
solana_sdk::{
|
||||
clock::Slot,
|
||||
feature_set::FeatureSet,
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
[package]
|
||||
name = "solana-cost-model"
|
||||
description = "Solana cost model"
|
||||
documentation = "https://docs.rs/solana-cost-model"
|
||||
version = { workspace = true }
|
||||
authors = { workspace = true }
|
||||
repository = { workspace = true }
|
||||
homepage = { workspace = true }
|
||||
license = { workspace = true }
|
||||
edition = { workspace = true }
|
||||
|
||||
[dependencies]
|
||||
lazy_static = { workspace = true }
|
||||
log = { workspace = true }
|
||||
solana-address-lookup-table-program = { workspace = true }
|
||||
solana-bpf-loader-program = { workspace = true }
|
||||
solana-compute-budget-program = { workspace = true }
|
||||
solana-config-program = { workspace = true }
|
||||
solana-frozen-abi = { workspace = true }
|
||||
solana-frozen-abi-macro = { workspace = true }
|
||||
solana-loader-v4-program = { workspace = true }
|
||||
solana-metrics = { workspace = true }
|
||||
solana-program-runtime = { workspace = true }
|
||||
solana-sdk = { workspace = true }
|
||||
solana-stake-program = { workspace = true }
|
||||
solana-system-program = { workspace = true }
|
||||
solana-vote-program = { workspace = true }
|
||||
|
||||
[lib]
|
||||
crate-type = ["lib"]
|
||||
name = "solana_cost_model"
|
||||
|
||||
[dev-dependencies]
|
||||
solana-logger = { workspace = true }
|
||||
static_assertions = { workspace = true }
|
||||
test-case = { workspace = true }
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[build-dependencies]
|
||||
rustc_version = { workspace = true }
|
|
@ -0,0 +1,27 @@
|
|||
extern crate rustc_version;
|
||||
use rustc_version::{version_meta, Channel};
|
||||
|
||||
fn main() {
|
||||
// Copied and adapted from
|
||||
// https://github.com/Kimundi/rustc-version-rs/blob/1d692a965f4e48a8cb72e82cda953107c0d22f47/README.md#example
|
||||
// Licensed under Apache-2.0 + MIT
|
||||
match version_meta().unwrap().channel {
|
||||
Channel::Stable => {
|
||||
println!("cargo:rustc-cfg=RUSTC_WITHOUT_SPECIALIZATION");
|
||||
}
|
||||
Channel::Beta => {
|
||||
println!("cargo:rustc-cfg=RUSTC_WITHOUT_SPECIALIZATION");
|
||||
}
|
||||
Channel::Nightly => {
|
||||
println!("cargo:rustc-cfg=RUSTC_WITH_SPECIALIZATION");
|
||||
}
|
||||
Channel::Dev => {
|
||||
println!("cargo:rustc-cfg=RUSTC_WITH_SPECIALIZATION");
|
||||
// See https://github.com/solana-labs/solana/issues/11055
|
||||
// We may be running the custom `rust-bpf-builder` toolchain,
|
||||
// which currently needs `#![feature(proc_macro_hygiene)]` to
|
||||
// be applied.
|
||||
println!("cargo:rustc-cfg=RUSTC_NEEDS_PROC_MACRO_HYGIENE");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -207,11 +207,6 @@ impl CostModel {
|
|||
mod tests {
|
||||
use {
|
||||
super::*,
|
||||
crate::{
|
||||
bank::Bank,
|
||||
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
||||
inline_spl_token,
|
||||
},
|
||||
solana_sdk::{
|
||||
compute_budget::{self, ComputeBudgetInstruction},
|
||||
hash::Hash,
|
||||
|
@ -222,19 +217,11 @@ mod tests {
|
|||
system_program, system_transaction,
|
||||
transaction::Transaction,
|
||||
},
|
||||
std::sync::Arc,
|
||||
};
|
||||
|
||||
fn test_setup() -> (Keypair, Hash) {
|
||||
solana_logger::setup();
|
||||
let GenesisConfigInfo {
|
||||
genesis_config,
|
||||
mint_keypair,
|
||||
..
|
||||
} = create_genesis_config(10);
|
||||
let bank = Arc::new(Bank::new_no_wallclock_throttle_for_tests(&genesis_config));
|
||||
let start_hash = bank.last_blockhash();
|
||||
(mint_keypair, start_hash)
|
||||
(Keypair::new(), Hash::new_unique())
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -325,7 +312,7 @@ mod tests {
|
|||
solana_sdk::pubkey::new_rand(),
|
||||
],
|
||||
start_hash,
|
||||
vec![inline_spl_token::id()],
|
||||
vec![Pubkey::new_unique()],
|
||||
instructions,
|
||||
);
|
||||
let token_transaction = SanitizedTransaction::from_transaction_for_tests(tx);
|
||||
|
@ -363,7 +350,7 @@ mod tests {
|
|||
solana_sdk::pubkey::new_rand(),
|
||||
],
|
||||
start_hash,
|
||||
vec![inline_spl_token::id(), compute_budget::id()],
|
||||
vec![Pubkey::new_unique(), compute_budget::id()],
|
||||
instructions,
|
||||
);
|
||||
let token_transaction = SanitizedTransaction::from_transaction_for_tests(tx);
|
||||
|
@ -413,7 +400,7 @@ mod tests {
|
|||
solana_sdk::pubkey::new_rand(),
|
||||
],
|
||||
start_hash,
|
||||
vec![inline_spl_token::id(), compute_budget::id()],
|
||||
vec![Pubkey::new_unique(), compute_budget::id()],
|
||||
instructions,
|
||||
);
|
||||
let token_transaction = SanitizedTransaction::from_transaction_for_tests(tx);
|
|
@ -5,6 +5,7 @@
|
|||
//!
|
||||
use {
|
||||
crate::{block_cost_limits::*, transaction_cost::TransactionCost},
|
||||
solana_metrics::datapoint_info,
|
||||
solana_sdk::{
|
||||
clock::Slot, pubkey::Pubkey, saturating_add_assign, transaction::TransactionError,
|
||||
},
|
||||
|
@ -286,10 +287,6 @@ impl CostTracker {
|
|||
mod tests {
|
||||
use {
|
||||
super::*,
|
||||
crate::{
|
||||
bank::Bank,
|
||||
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
||||
},
|
||||
solana_sdk::{
|
||||
hash::Hash,
|
||||
signature::{Keypair, Signer},
|
||||
|
@ -299,7 +296,7 @@ mod tests {
|
|||
},
|
||||
},
|
||||
solana_vote_program::vote_transaction,
|
||||
std::{cmp, sync::Arc},
|
||||
std::cmp,
|
||||
};
|
||||
|
||||
impl CostTracker {
|
||||
|
@ -323,14 +320,7 @@ mod tests {
|
|||
|
||||
fn test_setup() -> (Keypair, Hash) {
|
||||
solana_logger::setup();
|
||||
let GenesisConfigInfo {
|
||||
genesis_config,
|
||||
mint_keypair,
|
||||
..
|
||||
} = create_genesis_config(10);
|
||||
let bank = Arc::new(Bank::new_no_wallclock_throttle_for_tests(&genesis_config));
|
||||
let start_hash = bank.last_blockhash();
|
||||
(mint_keypair, start_hash)
|
||||
(Keypair::new(), Hash::new_unique())
|
||||
}
|
||||
|
||||
fn build_simple_transaction(
|
|
@ -0,0 +1,10 @@
|
|||
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
|
||||
#![allow(clippy::integer_arithmetic)]
|
||||
|
||||
pub mod block_cost_limits;
|
||||
pub mod cost_model;
|
||||
pub mod cost_tracker;
|
||||
pub mod transaction_cost;
|
||||
|
||||
#[macro_use]
|
||||
extern crate solana_frozen_abi_macro;
|
|
@ -29,6 +29,7 @@ solana-bpf-loader-program = { workspace = true }
|
|||
solana-clap-utils = { workspace = true }
|
||||
solana-cli-output = { workspace = true }
|
||||
solana-core = { workspace = true }
|
||||
solana-cost-model = { workspace = true }
|
||||
solana-entry = { workspace = true }
|
||||
solana-geyser-plugin-manager = { workspace = true }
|
||||
solana-gossip = { workspace = true }
|
||||
|
|
|
@ -30,6 +30,7 @@ use {
|
|||
system_monitor_service::{SystemMonitorService, SystemMonitorStatsReportConfig},
|
||||
validator::BlockVerificationMethod,
|
||||
},
|
||||
solana_cost_model::{cost_model::CostModel, cost_tracker::CostTracker},
|
||||
solana_entry::entry::Entry,
|
||||
solana_ledger::{
|
||||
ancestor_iterator::AncestorIterator,
|
||||
|
@ -50,8 +51,6 @@ use {
|
|||
accounts_index::ScanConfig,
|
||||
bank::{Bank, RewardCalculationEvent, TotalAccountsStats},
|
||||
bank_forks::BankForks,
|
||||
cost_model::CostModel,
|
||||
cost_tracker::CostTracker,
|
||||
hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
|
||||
runtime_config::RuntimeConfig,
|
||||
snapshot_archive_info::SnapshotArchiveInfoGetter,
|
||||
|
|
|
@ -38,6 +38,7 @@ serde_bytes = { workspace = true }
|
|||
sha2 = { workspace = true }
|
||||
solana-account-decoder = { workspace = true }
|
||||
solana-bpf-loader-program = { workspace = true }
|
||||
solana-cost-model = { workspace = true }
|
||||
solana-entry = { workspace = true }
|
||||
solana-frozen-abi = { workspace = true }
|
||||
solana-frozen-abi-macro = { workspace = true }
|
||||
|
|
|
@ -16,6 +16,7 @@ use {
|
|||
rand::{seq::SliceRandom, thread_rng},
|
||||
rayon::{prelude::*, ThreadPool},
|
||||
scopeguard::defer,
|
||||
solana_cost_model::cost_model::CostModel,
|
||||
solana_entry::entry::{
|
||||
self, create_ticks, Entry, EntrySlice, EntryType, EntryVerificationStatus, VerifyRecyclers,
|
||||
},
|
||||
|
@ -32,7 +33,6 @@ use {
|
|||
bank_forks::BankForks,
|
||||
bank_utils,
|
||||
commitment::VOTE_THRESHOLD_SIZE,
|
||||
cost_model::CostModel,
|
||||
epoch_accounts_hash::EpochAccountsHash,
|
||||
prioritization_fee_cache::PrioritizationFeeCache,
|
||||
rent_debits::RentDebits,
|
||||
|
|
|
@ -4750,6 +4750,7 @@ dependencies = [
|
|||
"solana-address-lookup-table-program",
|
||||
"solana-bloom",
|
||||
"solana-client",
|
||||
"solana-cost-model",
|
||||
"solana-entry",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
|
@ -4785,6 +4786,28 @@ dependencies = [
|
|||
"trees",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-cost-model"
|
||||
version = "1.17.0"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
"rustc_version",
|
||||
"solana-address-lookup-table-program",
|
||||
"solana-bpf-loader-program",
|
||||
"solana-compute-budget-program",
|
||||
"solana-config-program",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-loader-v4-program",
|
||||
"solana-metrics",
|
||||
"solana-program-runtime",
|
||||
"solana-sdk",
|
||||
"solana-stake-program",
|
||||
"solana-system-program",
|
||||
"solana-vote-program",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-download-utils"
|
||||
version = "1.17.0"
|
||||
|
@ -5006,6 +5029,7 @@ dependencies = [
|
|||
"sha2 0.10.7",
|
||||
"solana-account-decoder",
|
||||
"solana-bpf-loader-program",
|
||||
"solana-cost-model",
|
||||
"solana-entry",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
|
@ -5474,6 +5498,7 @@ dependencies = [
|
|||
"solana-bucket-map",
|
||||
"solana-compute-budget-program",
|
||||
"solana-config-program",
|
||||
"solana-cost-model",
|
||||
"solana-frozen-abi",
|
||||
"solana-frozen-abi-macro",
|
||||
"solana-loader-v4-program",
|
||||
|
|
|
@ -50,6 +50,7 @@ solana-bpf-loader-program = { workspace = true }
|
|||
solana-bucket-map = { workspace = true }
|
||||
solana-compute-budget-program = { workspace = true }
|
||||
solana-config-program = { workspace = true }
|
||||
solana-cost-model = { workspace = true }
|
||||
solana-frozen-abi = { workspace = true }
|
||||
solana-frozen-abi-macro = { workspace = true }
|
||||
solana-loader-v4-program = { workspace = true }
|
||||
|
|
|
@ -57,8 +57,6 @@ use {
|
|||
bank::metrics::*,
|
||||
blockhash_queue::BlockhashQueue,
|
||||
builtins::{BuiltinPrototype, BUILTINS},
|
||||
cost_model::CostModel,
|
||||
cost_tracker::CostTracker,
|
||||
epoch_accounts_hash::{self, EpochAccountsHash},
|
||||
epoch_rewards_hasher::hash_rewards_into_partitions,
|
||||
epoch_stakes::{EpochStakes, NodeVoteAccounts},
|
||||
|
@ -98,6 +96,7 @@ use {
|
|||
ThreadPool, ThreadPoolBuilder,
|
||||
},
|
||||
solana_bpf_loader_program::syscalls::create_program_runtime_environment,
|
||||
solana_cost_model::{cost_model::CostModel, cost_tracker::CostTracker},
|
||||
solana_measure::{measure, measure::Measure, measure_us},
|
||||
solana_perf::perf_libs,
|
||||
solana_program_runtime::{
|
||||
|
|
|
@ -27,7 +27,6 @@ pub mod bank_client;
|
|||
mod bank_creation_freezing_progress;
|
||||
pub mod bank_forks;
|
||||
pub mod bank_utils;
|
||||
pub mod block_cost_limits;
|
||||
pub mod blockhash_queue;
|
||||
pub mod bucket_map_holder;
|
||||
pub mod bucket_map_holder_stats;
|
||||
|
@ -36,8 +35,6 @@ pub mod cache_hash_data;
|
|||
pub mod cache_hash_data_stats;
|
||||
pub mod commitment;
|
||||
pub mod contains;
|
||||
pub mod cost_model;
|
||||
pub mod cost_tracker;
|
||||
pub mod epoch_accounts_hash;
|
||||
mod epoch_rewards_hasher;
|
||||
pub mod epoch_stakes;
|
||||
|
@ -80,7 +77,6 @@ pub mod status_cache;
|
|||
mod storable_accounts;
|
||||
pub mod tiered_storage;
|
||||
pub mod transaction_batch;
|
||||
pub mod transaction_cost;
|
||||
pub mod transaction_error_metrics;
|
||||
pub mod transaction_priority_details;
|
||||
pub mod transaction_results;
|
||||
|
|
Loading…
Reference in New Issue