Skip to content

Commit

Permalink
use special feature for mock builtin migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Dec 19, 2024
1 parent 20ebc30 commit d7e816c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion builtins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = { workspace = true }
edition = { workspace = true }

[features]
dev-context-only-utils = []
mock-builtin-migrations = []

[dependencies]
ahash = { workspace = true }
Expand Down
6 changes: 5 additions & 1 deletion builtins/src/cost_modeling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ use {
solana_sdk_ids::{ed25519_program, secp256k1_program},
};

#[cfg(not(feature = "mock-builtin-migrations"))]
/// CONTRIBUTOR: If you change any builtin Core BPF migration configurations
/// in this crate's `BUILTINS` list, you must update this constant to reflect
/// the number of builtin programs that have Core BPF migration configurations.
pub const NUM_COST_MODELED_BUILTINS_WITH_MIGRATIONS: usize = 3;
#[cfg(feature = "mock-builtin-migrations")]
/// CONTRIBUTOR: Under the `mock-builtin-migrations` feature, this value is
/// `BUILTINS.len()`. If a new builtin is added, this should be updated.
pub const NUM_COST_MODELED_BUILTINS_WITH_MIGRATIONS: usize = 11;

/// Configuration for cost modeling of a builtin program.
#[derive(Debug)]
Expand Down Expand Up @@ -172,7 +177,6 @@ pub fn get_builtin_migration_feature_index_from_feature_id(feature_id: &Pubkey)
mod test {
use super::*;

#[cfg(not(feature = "dev-context-only-utils"))]
#[test]
fn test_cost_modeled_builtins_with_migrations_compiles() {
// This test is a compile-time check to ensure that the number of
Expand Down
8 changes: 4 additions & 4 deletions builtins/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ macro_rules! testable_prototype {
$prototype {
name: stringify!($name),
core_bpf_migration_config: {
#[cfg(not(feature = "dev-context-only-utils"))]
#[cfg(not(feature = "mock-builtin-migrations"))]
{
$core_bpf_migration_config
}
#[cfg(feature = "dev-context-only-utils")]
#[cfg(feature = "mock-builtin-migrations")]
{
Some( test_only::$name::CONFIG )
}
Expand Down Expand Up @@ -223,7 +223,7 @@ mod buffer_accounts {
// into the builtins list for both the feature ID and the source program ID.
// These arbitrary IDs can then be used to configure feature-activation runtime
// tests.
#[cfg(any(test, feature = "dev-context-only-utils"))]
#[cfg(any(test, feature = "mock-builtin-migrations"))]
pub mod test_only {
use crate::core_bpf_migration::{CoreBpfMigrationConfig, CoreBpfMigrationTargetType};
pub mod system_program {
Expand Down Expand Up @@ -403,7 +403,7 @@ mod tests {
// Since a macro is used to initialize the test IDs from the `test_only`
// module, best to ensure the lists have the expected values within a test
// context.
#[cfg(feature = "dev-context-only-utils")]
#[cfg(feature = "mock-builtin-migrations")]
#[test]
fn test_testable_prototypes() {
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ memoffset = { workspace = true }
rand0-7 = { package = "rand", version = "0.7" }
rand_chacha = { workspace = true }
solana-accounts-db = { workspace = true, features = ["dev-context-only-utils"] }
solana-builtins = { workspace = true, features = ["dev-context-only-utils"] }
solana-builtins = { workspace = true, features = ["mock-builtin-migrations"] }
solana-logger = { workspace = true }
# See order-crates-for-publishing.py for using this unusual `path = "."`
solana-runtime = { path = ".", features = ["dev-context-only-utils"] }
Expand Down

0 comments on commit d7e816c

Please sign in to comment.