From d7e816c12bc78d2b46396e7ec24be5493c505f94 Mon Sep 17 00:00:00 2001 From: Joe Caulfield Date: Thu, 19 Dec 2024 17:53:40 +0800 Subject: [PATCH] use special feature for mock builtin migrations --- builtins/Cargo.toml | 2 +- builtins/src/cost_modeling.rs | 6 +++++- builtins/src/lib.rs | 8 ++++---- runtime/Cargo.toml | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/builtins/Cargo.toml b/builtins/Cargo.toml index 637a4af083012c..7c416c4a36fc43 100644 --- a/builtins/Cargo.toml +++ b/builtins/Cargo.toml @@ -10,7 +10,7 @@ license = { workspace = true } edition = { workspace = true } [features] -dev-context-only-utils = [] +mock-builtin-migrations = [] [dependencies] ahash = { workspace = true } diff --git a/builtins/src/cost_modeling.rs b/builtins/src/cost_modeling.rs index 8049db142192da..942773e2b3fd3a 100644 --- a/builtins/src/cost_modeling.rs +++ b/builtins/src/cost_modeling.rs @@ -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)] @@ -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 diff --git a/builtins/src/lib.rs b/builtins/src/lib.rs index dc6b17825d9857..05a4cf36515703 100644 --- a/builtins/src/lib.rs +++ b/builtins/src/lib.rs @@ -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 ) } @@ -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 { @@ -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!( diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 0bec4f1ea64660..3f0e57830791e1 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -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"] }