diff --git a/Cargo.lock b/Cargo.lock index 377654cc683eb1..ffb1e84cb93d48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6272,6 +6272,26 @@ dependencies = [ "tempfile", ] +[[package]] +name = "solana-builtins" +version = "2.2.0" +dependencies = [ + "solana-address-lookup-table-program", + "solana-bpf-loader-program", + "solana-compute-budget-program", + "solana-config-program", + "solana-feature-set", + "solana-loader-v4-program", + "solana-program-runtime", + "solana-pubkey", + "solana-sdk-ids", + "solana-stake-program", + "solana-system-program", + "solana-vote-program", + "solana-zk-elgamal-proof-program", + "solana-zk-token-proof-program", +] + [[package]] name = "solana-builtins-default-costs" version = "2.2.0" @@ -8565,11 +8585,10 @@ dependencies = [ "serde_json", "serde_with", "solana-accounts-db", - "solana-address-lookup-table-program", "solana-bpf-loader-program", "solana-bucket-map", + "solana-builtins", "solana-compute-budget", - "solana-compute-budget-program", "solana-config-program", "solana-cost-model", "solana-feature-set", @@ -8578,7 +8597,6 @@ dependencies = [ "solana-frozen-abi-macro", "solana-inline-spl", "solana-lattice-hash", - "solana-loader-v4-program", "solana-logger", "solana-measure", "solana-metrics", @@ -8589,6 +8607,7 @@ dependencies = [ "solana-runtime", "solana-runtime-transaction", "solana-sdk", + "solana-sdk-ids", "solana-stake-program", "solana-svm", "solana-svm-rent-collector", @@ -8599,10 +8618,6 @@ dependencies = [ "solana-version", "solana-vote", "solana-vote-program", - "solana-zk-elgamal-proof-program", - "solana-zk-sdk", - "solana-zk-token-proof-program", - "solana-zk-token-sdk", "static_assertions", "strum", "strum_macros", diff --git a/Cargo.toml b/Cargo.toml index 697c4c9fdc3d98..f523b220afa0a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ members = [ "bench-tps", "bloom", "bucket_map", + "builtins", "builtins-default-costs", "cargo-registry", "clap-utils", @@ -442,6 +443,7 @@ solana-bn254 = { path = "curves/bn254", version = "=2.2.0" } solana-borsh = { path = "sdk/borsh", version = "=2.2.0" } solana-bpf-loader-program = { path = "programs/bpf_loader", version = "=2.2.0" } solana-bucket-map = { path = "bucket_map", version = "=2.2.0" } +solana-builtins = { path = "builtins", version = "=2.2.0" } solana-builtins-default-costs = { path = "builtins-default-costs", version = "=2.2.0" } agave-cargo-registry = { path = "cargo-registry", version = "=2.2.0" } solana-clap-utils = { path = "clap-utils", version = "=2.2.0" } diff --git a/builtins/Cargo.toml b/builtins/Cargo.toml new file mode 100644 index 00000000000000..3cdf7f63e64136 --- /dev/null +++ b/builtins/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "solana-builtins" +description = "Solana builtin programs" +documentation = "https://docs.rs/solana-builtins" +version = { workspace = true } +authors = { workspace = true } +repository = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +edition = { workspace = true } + +[features] +dev-context-only-utils = [] + +[dependencies] +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-feature-set = { workspace = true } +solana-loader-v4-program = { workspace = true } +solana-program-runtime = { workspace = true } +solana-pubkey = { workspace = true } +solana-sdk-ids = { workspace = true } +solana-stake-program = { workspace = true } +solana-system-program = { workspace = true } +solana-vote-program = { workspace = true } +solana-zk-elgamal-proof-program = { workspace = true } +solana-zk-token-proof-program = { workspace = true } + +[lints] +workspace = true diff --git a/builtins/src/core_bpf_migration.rs b/builtins/src/core_bpf_migration.rs new file mode 100644 index 00000000000000..0d1c5b4f7eabf2 --- /dev/null +++ b/builtins/src/core_bpf_migration.rs @@ -0,0 +1,40 @@ +use solana_pubkey::Pubkey; + +/// Identifies the type of built-in program targeted for Core BPF migration. +/// The type of target determines whether the program should have a program +/// account or not, which is checked before migration. +#[allow(dead_code)] // Remove after first migration is configured. +#[derive(Debug, PartialEq)] +pub enum CoreBpfMigrationTargetType { + /// A standard (stateful) builtin program must have a program account. + Builtin, + /// A stateless builtin must not have a program account. + Stateless, +} + +/// Configuration for migrating a built-in program to Core BPF. +#[derive(Debug, PartialEq)] +pub struct CoreBpfMigrationConfig { + /// The address of the source buffer account to be used to replace the + /// builtin. + pub source_buffer_address: Pubkey, + /// The authority to be used as the BPF program's upgrade authority. + /// + /// Note: If this value is set to `None`, then the migration will ignore + /// the source buffer account's authority. If it's set to any `Some(..)` + /// value, then the migration will perform a sanity check to ensure the + /// source buffer account's authority matches the provided value. + pub upgrade_authority_address: Option, + /// The feature gate to trigger the migration to Core BPF. + /// Note: This feature gate should never be the same as any builtin's + /// `enable_feature_id`. It should always be a feature gate that will be + /// activated after the builtin is already enabled. + pub feature_id: Pubkey, + /// The type of target to replace. + pub migration_target: CoreBpfMigrationTargetType, + /// Static message used to emit datapoint logging. + /// This is used to identify the migration in the logs. + /// Should be unique to the migration, ie: + /// "migrate_{builtin/stateless}_to_core_bpf_{program_name}". + pub datapoint_name: &'static str, +} diff --git a/builtins/src/lib.rs b/builtins/src/lib.rs new file mode 100644 index 00000000000000..5ba11fbf1cd937 --- /dev/null +++ b/builtins/src/lib.rs @@ -0,0 +1,419 @@ +//! Solana builtin programs. +//! +//! Warning: This crate is not for public consumption. It will change, and +//! could possibly be removed altogether in the future. For now, it is purely +//! for the purpose of managing the migration of builtins to Core BPF. +//! +//! It serves as a source of truth for: +//! * The list of builtins that a Bank should add. +//! * Which of those builtins have been assigned a feature gate to migrate to +//! Core BPF, as well as whether or not that feature gate has been activated. + +pub mod core_bpf_migration; +pub mod prototype; + +use { + crate::{ + core_bpf_migration::{CoreBpfMigrationConfig, CoreBpfMigrationTargetType}, + prototype::{BuiltinPrototype, StatelessBuiltinPrototype}, + }, + solana_feature_set as feature_set, + solana_sdk_ids::{bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable}, +}; + +macro_rules! testable_prototype { + ($prototype:ident { + core_bpf_migration_config: $core_bpf_migration_config:expr, + name: $name:ident, + $($field:ident : $value:expr),* $(,)? + }) => { + $prototype { + core_bpf_migration_config: { + #[cfg(not(feature = "dev-context-only-utils"))] + { + $core_bpf_migration_config + } + #[cfg(feature = "dev-context-only-utils")] + { + Some( test_only::$name::CONFIG ) + } + }, + name: stringify!($name), + $($field: $value),* + } + }; +} + +/// DEVELOPER: when a builtin is migrated to sbpf, please add its corresponding +/// migration feature ID to solana-builtin-default-costs::BUILTIN_INSTRUCTION_COSTS, +/// so the builtin's default cost can be determined properly based on feature status. +/// When migration completed, and the feature gate is enabled everywhere, please +/// remove that builtin entry from solana-builtin-default-costs::BUILTIN_INSTRUCTION_COSTS. +pub static BUILTINS: &[BuiltinPrototype] = &[ + testable_prototype!(BuiltinPrototype { + core_bpf_migration_config: None, + name: system_program, + enable_feature_id: None, + program_id: solana_system_program::id(), + entrypoint: solana_system_program::system_processor::Entrypoint::vm, + }), + testable_prototype!(BuiltinPrototype { + core_bpf_migration_config: None, + name: vote_program, + enable_feature_id: None, + program_id: solana_vote_program::id(), + entrypoint: solana_vote_program::vote_processor::Entrypoint::vm, + }), + BuiltinPrototype { + core_bpf_migration_config: Some(CoreBpfMigrationConfig { + source_buffer_address: buffer_accounts::stake_program::id(), + upgrade_authority_address: None, + feature_id: solana_feature_set::migrate_stake_program_to_core_bpf::id(), + migration_target: CoreBpfMigrationTargetType::Builtin, + datapoint_name: "migrate_builtin_to_core_bpf_stake_program", + }), + name: "stake_program", + enable_feature_id: None, + program_id: solana_stake_program::id(), + entrypoint: solana_stake_program::stake_instruction::Entrypoint::vm, + }, + BuiltinPrototype { + core_bpf_migration_config: Some(CoreBpfMigrationConfig { + source_buffer_address: buffer_accounts::config_program::id(), + upgrade_authority_address: None, + feature_id: solana_feature_set::migrate_config_program_to_core_bpf::id(), + migration_target: CoreBpfMigrationTargetType::Builtin, + datapoint_name: "migrate_builtin_to_core_bpf_config_program", + }), + name: "config_program", + enable_feature_id: None, + program_id: solana_config_program::id(), + entrypoint: solana_config_program::config_processor::Entrypoint::vm, + }, + testable_prototype!(BuiltinPrototype { + core_bpf_migration_config: None, + name: solana_bpf_loader_deprecated_program, + enable_feature_id: None, + program_id: bpf_loader_deprecated::id(), + entrypoint: solana_bpf_loader_program::Entrypoint::vm, + }), + testable_prototype!(BuiltinPrototype { + core_bpf_migration_config: None, + name: solana_bpf_loader_program, + enable_feature_id: None, + program_id: bpf_loader::id(), + entrypoint: solana_bpf_loader_program::Entrypoint::vm, + }), + testable_prototype!(BuiltinPrototype { + core_bpf_migration_config: None, + name: solana_bpf_loader_upgradeable_program, + enable_feature_id: None, + program_id: bpf_loader_upgradeable::id(), + entrypoint: solana_bpf_loader_program::Entrypoint::vm, + }), + testable_prototype!(BuiltinPrototype { + core_bpf_migration_config: None, + name: compute_budget_program, + enable_feature_id: None, + program_id: solana_sdk_ids::compute_budget::id(), + entrypoint: solana_compute_budget_program::Entrypoint::vm, + }), + BuiltinPrototype { + core_bpf_migration_config: Some(CoreBpfMigrationConfig { + source_buffer_address: buffer_accounts::address_lookup_table_program::id(), + upgrade_authority_address: None, + feature_id: solana_feature_set::migrate_address_lookup_table_program_to_core_bpf::id(), + migration_target: CoreBpfMigrationTargetType::Builtin, + datapoint_name: "migrate_builtin_to_core_bpf_address_lookup_table_program", + }), + name: "address_lookup_table_program", + enable_feature_id: None, + program_id: solana_sdk_ids::address_lookup_table::id(), + entrypoint: solana_address_lookup_table_program::processor::Entrypoint::vm, + }, + testable_prototype!(BuiltinPrototype { + core_bpf_migration_config: None, + name: zk_token_proof_program, + enable_feature_id: Some(feature_set::zk_token_sdk_enabled::id()), + program_id: solana_sdk_ids::zk_token_proof_program::id(), + entrypoint: solana_zk_token_proof_program::Entrypoint::vm, + }), + testable_prototype!(BuiltinPrototype { + core_bpf_migration_config: None, + name: loader_v4, + enable_feature_id: Some(feature_set::enable_program_runtime_v2_and_loader_v4::id()), + program_id: solana_sdk_ids::loader_v4::id(), + entrypoint: solana_loader_v4_program::Entrypoint::vm, + }), + testable_prototype!(BuiltinPrototype { + core_bpf_migration_config: None, + name: zk_elgamal_proof_program, + enable_feature_id: Some(feature_set::zk_elgamal_proof_program_enabled::id()), + program_id: solana_sdk_ids::zk_elgamal_proof_program::id(), + entrypoint: solana_zk_elgamal_proof_program::Entrypoint::vm, + }), +]; + +pub static STATELESS_BUILTINS: &[StatelessBuiltinPrototype] = &[StatelessBuiltinPrototype { + core_bpf_migration_config: Some(CoreBpfMigrationConfig { + source_buffer_address: buffer_accounts::feature_gate_program::id(), + upgrade_authority_address: None, + feature_id: solana_feature_set::migrate_feature_gate_program_to_core_bpf::id(), + migration_target: CoreBpfMigrationTargetType::Stateless, + datapoint_name: "migrate_stateless_to_core_bpf_feature_gate_program", + }), + name: "feature_gate_program", + program_id: solana_sdk_ids::feature::id(), +}]; + +/// Live source buffer accounts for builtin migrations. +mod buffer_accounts { + pub mod address_lookup_table_program { + solana_pubkey::declare_id!("AhXWrD9BBUYcKjtpA3zuiiZG4ysbo6C6wjHo1QhERk6A"); + } + pub mod config_program { + solana_pubkey::declare_id!("BuafH9fBv62u6XjzrzS4ZjAE8963ejqF5rt1f8Uga4Q3"); + } + pub mod feature_gate_program { + solana_pubkey::declare_id!("3D3ydPWvmEszrSjrickCtnyRSJm1rzbbSsZog8Ub6vLh"); + } + pub mod stake_program { + solana_pubkey::declare_id!("8t3vv6v99tQA6Gp7fVdsBH66hQMaswH5qsJVqJqo8xvG"); + } +} + +// This module contains a number of arbitrary addresses used for testing Core +// BPF migrations. +// Since the list of builtins is static, using `declare_id!` with constant +// values is arguably the least-overhead approach to injecting static addresses +// 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"))] +pub mod test_only { + use crate::core_bpf_migration::{CoreBpfMigrationConfig, CoreBpfMigrationTargetType}; + pub mod system_program { + pub mod feature { + solana_pubkey::declare_id!("AnjsdWg7LXFbjDdy78wncCJs9PyTdWpKkFmHAwQU1mQ6"); + } + pub mod source_buffer { + solana_pubkey::declare_id!("EDEhzg1Jk79Wrk4mwpRa7txjgRxcE6igXwd6egFDVhuz"); + } + pub mod upgrade_authority { + solana_pubkey::declare_id!("4d14UK2o1FKKoecEBWhVDZrBBbRuhug75G1j9XYCawC2"); + } + pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { + source_buffer_address: source_buffer::id(), + upgrade_authority_address: Some(upgrade_authority::id()), + feature_id: feature::id(), + migration_target: super::CoreBpfMigrationTargetType::Builtin, + datapoint_name: "migrate_builtin_to_core_bpf_system_program", + }; + } + + pub mod vote_program { + pub mod feature { + solana_pubkey::declare_id!("5wDLHMasPmtrcpfRZX67RVkBXBbSTQ9S4C8EJomD3yAk"); + } + pub mod source_buffer { + solana_pubkey::declare_id!("6T9s4PTcHnpq2AVAqoCbJd4FuHsdD99MjSUEbS7qb1tT"); + } + pub mod upgrade_authority { + solana_pubkey::declare_id!("2N4JfyYub6cWUP9R4JrsFHv6FYKT7JnoRX8GQUH9MdT3"); + } + pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { + source_buffer_address: source_buffer::id(), + upgrade_authority_address: Some(upgrade_authority::id()), + feature_id: feature::id(), + migration_target: super::CoreBpfMigrationTargetType::Builtin, + datapoint_name: "migrate_builtin_to_core_bpf_vote_program", + }; + } + + pub mod solana_bpf_loader_deprecated_program { + pub mod feature { + solana_pubkey::declare_id!("8gpakCv5Pk5PZGv9RUjzdkk2GVQPGx12cNRUDMQ3bP86"); + } + pub mod source_buffer { + solana_pubkey::declare_id!("DveUYB5m9G3ce4zpV3fxg9pCNkvH1wDsyd8XberZ47JL"); + } + pub mod upgrade_authority { + solana_pubkey::declare_id!("8Y5VTHdadnz4rZZWdUA4Qq2m2zWoCwwtb38spPZCXuGU"); + } + pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { + source_buffer_address: source_buffer::id(), + upgrade_authority_address: Some(upgrade_authority::id()), + feature_id: feature::id(), + migration_target: super::CoreBpfMigrationTargetType::Builtin, + datapoint_name: "migrate_builtin_to_core_bpf_bpf_loader_deprecated_program", + }; + } + + pub mod solana_bpf_loader_program { + pub mod feature { + solana_pubkey::declare_id!("8yEdUm4SaP1yNq2MczEVdrM48SucvZCTDSqjcAKfYfL6"); + } + pub mod source_buffer { + solana_pubkey::declare_id!("2EWMYGJPuGLW4TexLLEMeXP2BkB1PXEKBFb698yw6LhT"); + } + pub mod upgrade_authority { + solana_pubkey::declare_id!("3sQ9VZ1Lvuvs6NpFXFV3ByFAf52ajPPdXwuhYERJR3iJ"); + } + pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { + source_buffer_address: source_buffer::id(), + upgrade_authority_address: Some(upgrade_authority::id()), + feature_id: feature::id(), + migration_target: super::CoreBpfMigrationTargetType::Builtin, + datapoint_name: "migrate_builtin_to_core_bpf_bpf_loader_program", + }; + } + + pub mod solana_bpf_loader_upgradeable_program { + pub mod feature { + solana_pubkey::declare_id!("oPQbVjgoQ7SaQmzZiiHW4xqHbh4BJqqrFhxEJZiMiwY"); + } + pub mod source_buffer { + solana_pubkey::declare_id!("6bTmA9iefD57GDoQ9wUjG8SeYkSpRw3EkKzxZCbhkavq"); + } + pub mod upgrade_authority { + solana_pubkey::declare_id!("CuJvJY1K2wx82oLrQGSSWtw4AF7nVifEHupzSC2KEcq5"); + } + pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { + source_buffer_address: source_buffer::id(), + upgrade_authority_address: Some(upgrade_authority::id()), + feature_id: feature::id(), + migration_target: super::CoreBpfMigrationTargetType::Builtin, + datapoint_name: "migrate_builtin_to_core_bpf_bpf_loader_upgradeable_program", + }; + } + + pub mod compute_budget_program { + pub mod feature { + solana_pubkey::declare_id!("D39vUspVfhjPVD7EtMJZrA5j1TSMp4LXfb43nxumGdHT"); + } + pub mod source_buffer { + solana_pubkey::declare_id!("KfX1oLpFC5CwmFeSgXrNcXaouKjFkPuSJ4UsKb3zKMX"); + } + pub mod upgrade_authority { + solana_pubkey::declare_id!("HGTbQhaCXNTbpgpLb2KNjqWSwpJyb2dqDB66Lc3Ph4aN"); + } + pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { + source_buffer_address: source_buffer::id(), + upgrade_authority_address: Some(upgrade_authority::id()), + feature_id: feature::id(), + migration_target: super::CoreBpfMigrationTargetType::Builtin, + datapoint_name: "migrate_builtin_to_core_bpf_compute_budget_program", + }; + } + + pub mod zk_token_proof_program { + pub mod feature { + solana_pubkey::declare_id!("GfeFwUzKP9NmaP5u4VfnFgEvQoeQc2wPgnBFrUZhpib5"); + } + pub mod source_buffer { + solana_pubkey::declare_id!("Ffe9gL8vXraBkiv3HqbLvBqY7i9V4qtZxjH83jYYDe1V"); + } + pub mod upgrade_authority { + solana_pubkey::declare_id!("6zkXWHR8YeCvfMqHwyiz2n7g6hMUKCFhrVccZZTDk4ei"); + } + pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { + source_buffer_address: source_buffer::id(), + upgrade_authority_address: Some(upgrade_authority::id()), + feature_id: feature::id(), + migration_target: super::CoreBpfMigrationTargetType::Builtin, + datapoint_name: "migrate_builtin_to_core_bpf_zk_token_proof_program", + }; + } + + pub mod loader_v4 { + pub mod feature { + solana_pubkey::declare_id!("Cz5JthYp27KR3rwTCtVJhbRgwHCurbwcYX46D8setL22"); + } + pub mod source_buffer { + solana_pubkey::declare_id!("EH45pKy1kzjifB93wEJi91js3S4HETdsteywR7ZCNPn5"); + } + pub mod upgrade_authority { + solana_pubkey::declare_id!("AWbiYRbFts9GVX5uwUkwV46hTFP85PxCAM8e8ir8Hqtq"); + } + pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { + source_buffer_address: source_buffer::id(), + upgrade_authority_address: Some(upgrade_authority::id()), + feature_id: feature::id(), + migration_target: super::CoreBpfMigrationTargetType::Builtin, + datapoint_name: "migrate_builtin_to_core_bpf_loader_v4_program", + }; + } + + pub mod zk_elgamal_proof_program { + pub mod feature { + solana_pubkey::declare_id!("EYtuxScWqGWmcPEDmeUsEt3iPkvWE26EWLfSxUvWP2WN"); + } + pub mod source_buffer { + solana_pubkey::declare_id!("AaVrLPurAUmjw6XRNGr6ezQfHaJWpBGHhcRSJmNjoVpQ"); + } + pub mod upgrade_authority { + solana_pubkey::declare_id!("EyGkQYHgynUdvdNPNiWbJQk9roFCexgdJQMNcWbuvp78"); + } + pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { + source_buffer_address: source_buffer::id(), + upgrade_authority_address: Some(upgrade_authority::id()), + feature_id: feature::id(), + migration_target: super::CoreBpfMigrationTargetType::Builtin, + datapoint_name: "migrate_builtin_to_core_bpf_zk_elgamal_proof_program", + }; + } +} + +#[cfg(test)] +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. + #[test] + fn test_testable_prototypes() { + assert_eq!( + &super::BUILTINS[0].core_bpf_migration_config, + &Some(super::test_only::system_program::CONFIG) + ); + assert_eq!( + &super::BUILTINS[1].core_bpf_migration_config, + &Some(super::test_only::vote_program::CONFIG) + ); + // Stake has a live migration config, so it has no test-only configs + // to test here. + // Config has a live migration config, so it has no test-only configs + // to test here. + assert_eq!( + &super::BUILTINS[4].core_bpf_migration_config, + &Some(super::test_only::solana_bpf_loader_deprecated_program::CONFIG) + ); + assert_eq!( + &super::BUILTINS[5].core_bpf_migration_config, + &Some(super::test_only::solana_bpf_loader_program::CONFIG) + ); + assert_eq!( + &super::BUILTINS[6].core_bpf_migration_config, + &Some(super::test_only::solana_bpf_loader_upgradeable_program::CONFIG) + ); + assert_eq!( + &super::BUILTINS[7].core_bpf_migration_config, + &Some(super::test_only::compute_budget_program::CONFIG) + ); + // Address Lookup Table has a live migration config, so it has no + // test-only configs to test here. + assert_eq!( + &super::BUILTINS[9].core_bpf_migration_config, + &Some(super::test_only::zk_token_proof_program::CONFIG) + ); + assert_eq!( + &super::BUILTINS[10].core_bpf_migration_config, + &Some(super::test_only::loader_v4::CONFIG) + ); + assert_eq!( + &super::BUILTINS[11].core_bpf_migration_config, + &Some(super::test_only::zk_elgamal_proof_program::CONFIG) + ); + // Feature Gate has a live migration config, so it has no test-only + // configs to test here. + } +} diff --git a/runtime/src/bank/builtins/prototypes.rs b/builtins/src/prototype.rs similarity index 61% rename from runtime/src/bank/builtins/prototypes.rs rename to builtins/src/prototype.rs index 403544d4469f97..2b76dd5c353fec 100644 --- a/runtime/src/bank/builtins/prototypes.rs +++ b/builtins/src/prototype.rs @@ -1,14 +1,22 @@ +//! Prototype layouts for builtins. + use { - super::core_bpf_migration::CoreBpfMigrationConfig, - solana_program_runtime::invoke_context::BuiltinFunctionWithContext, solana_sdk::pubkey::Pubkey, + crate::core_bpf_migration::CoreBpfMigrationConfig, + solana_program_runtime::invoke_context::BuiltinFunctionWithContext, solana_pubkey::Pubkey, }; /// Transitions of built-in programs at epoch boundaries when features are activated. pub struct BuiltinPrototype { - pub(crate) core_bpf_migration_config: Option, + /// Configurations for migrating the builtin to Core BPF. + pub core_bpf_migration_config: Option, + /// Feature ID that enables the builtin program. + /// If None, the built-in program is always enabled. pub enable_feature_id: Option, + /// The program's ID. pub program_id: Pubkey, + /// The program's name, ie "system_program". pub name: &'static str, + /// The program's entrypoint function. pub entrypoint: BuiltinFunctionWithContext, } @@ -29,7 +37,10 @@ impl std::fmt::Debug for BuiltinPrototype { /// is reserved. #[derive(Debug)] pub struct StatelessBuiltinPrototype { - pub(crate) core_bpf_migration_config: Option, + /// Configurations for migrating the stateless builtin to Core BPF. + pub core_bpf_migration_config: Option, + /// The program's ID. pub program_id: Pubkey, + /// The program's name, ie "feature_gate_program". pub name: &'static str, } diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index c62e9e36340ab4..4413415c55e15f 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -5157,6 +5157,26 @@ dependencies = [ "tempfile", ] +[[package]] +name = "solana-builtins" +version = "2.2.0" +dependencies = [ + "solana-address-lookup-table-program", + "solana-bpf-loader-program", + "solana-compute-budget-program", + "solana-config-program", + "solana-feature-set", + "solana-loader-v4-program", + "solana-program-runtime", + "solana-pubkey", + "solana-sdk-ids", + "solana-stake-program", + "solana-system-program", + "solana-vote-program", + "solana-zk-elgamal-proof-program", + "solana-zk-token-proof-program", +] + [[package]] name = "solana-builtins-default-costs" version = "2.2.0" @@ -6749,18 +6769,16 @@ dependencies = [ "serde_json", "serde_with", "solana-accounts-db", - "solana-address-lookup-table-program", "solana-bpf-loader-program", "solana-bucket-map", + "solana-builtins", "solana-compute-budget", - "solana-compute-budget-program", "solana-config-program", "solana-cost-model", "solana-feature-set", "solana-fee", "solana-inline-spl", "solana-lattice-hash", - "solana-loader-v4-program", "solana-measure", "solana-metrics", "solana-perf", @@ -6779,10 +6797,6 @@ dependencies = [ "solana-version", "solana-vote", "solana-vote-program", - "solana-zk-elgamal-proof-program", - "solana-zk-sdk", - "solana-zk-token-proof-program", - "solana-zk-token-sdk", "static_assertions", "strum", "strum_macros", diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index dea9431a851f17..91c9c0f0539eed 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -49,11 +49,10 @@ serde_derive = { workspace = true } serde_json = { workspace = true } serde_with = { workspace = true } solana-accounts-db = { workspace = true } -solana-address-lookup-table-program = { workspace = true } solana-bpf-loader-program = { workspace = true } solana-bucket-map = { workspace = true } +solana-builtins = { workspace = true } solana-compute-budget = { workspace = true } -solana-compute-budget-program = { workspace = true } solana-config-program = { workspace = true } solana-cost-model = { workspace = true } solana-feature-set = { workspace = true } @@ -66,7 +65,6 @@ solana-frozen-abi-macro = { workspace = true, optional = true, features = [ ] } solana-inline-spl = { workspace = true } solana-lattice-hash = { workspace = true } -solana-loader-v4-program = { workspace = true } solana-measure = { workspace = true } solana-metrics = { workspace = true } solana-perf = { workspace = true } @@ -79,16 +77,12 @@ solana-stake-program = { workspace = true } solana-svm = { workspace = true } solana-svm-rent-collector = { workspace = true } solana-svm-transaction = { workspace = true } -solana-system-program = { workspace = true } +solana-system-program = { workspace = true, optional = true } solana-timings = { workspace = true } solana-transaction-status-client-types = { workspace = true } solana-version = { workspace = true } solana-vote = { workspace = true } solana-vote-program = { workspace = true } -solana-zk-elgamal-proof-program = { workspace = true } -solana-zk-sdk = { workspace = true } -solana-zk-token-proof-program = { workspace = true } -solana-zk-token-sdk = { workspace = true } static_assertions = { workspace = true } strum = { workspace = true, features = ["derive"] } strum_macros = { workspace = true } @@ -111,6 +105,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-logger = { workspace = true } # See order-crates-for-publishing.py for using this unusual `path = "."` solana-runtime = { path = ".", features = ["dev-context-only-utils"] } @@ -118,6 +113,7 @@ solana-runtime-transaction = { workspace = true, features = [ "dev-context-only-utils", ] } solana-sdk = { workspace = true, features = ["dev-context-only-utils"] } +solana-sdk-ids = { workspace = true } solana-svm = { workspace = true, features = ["dev-context-only-utils"] } static_assertions = { workspace = true } test-case = { workspace = true } @@ -127,6 +123,7 @@ targets = ["x86_64-unknown-linux-gnu"] [features] dev-context-only-utils = [ + "dep:solana-system-program", "solana-svm/dev-context-only-utils", "solana-runtime-transaction/dev-context-only-utils", ] diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index a839b12e0faf10..a18f22167f58d2 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -37,7 +37,6 @@ use { crate::{ account_saver::collect_accounts_to_store, bank::{ - builtins::{BuiltinPrototype, BUILTINS, STATELESS_BUILTINS}, metrics::*, partitioned_epoch_rewards::{EpochRewardStatus, StakeRewards, VoteRewardsAccounts}, }, @@ -95,6 +94,7 @@ use { solana_bpf_loader_program::syscalls::{ create_program_runtime_environment_v1, create_program_runtime_environment_v2, }, + solana_builtins::{prototype::BuiltinPrototype, BUILTINS, STATELESS_BUILTINS}, solana_compute_budget::compute_budget::ComputeBudget, solana_cost_model::cost_tracker::CostTracker, solana_feature_set::{ diff --git a/runtime/src/bank/builtin_programs.rs b/runtime/src/bank/builtin_programs.rs index 85d5083204ccfc..3e22260d9be671 100644 --- a/runtime/src/bank/builtin_programs.rs +++ b/runtime/src/bank/builtin_programs.rs @@ -66,14 +66,16 @@ mod tests { mod tests_core_bpf_migration { use { crate::bank::{ - builtins::{ - core_bpf_migration::{tests::TestContext, CoreBpfMigrationConfig}, - BuiltinPrototype, StatelessBuiltinPrototype, BUILTINS, STATELESS_BUILTINS, - }, + builtins::core_bpf_migration::tests::TestContext, test_utils::goto_end_of_slot, tests::{create_genesis_config, new_bank_from_parent_with_bank_forks}, Bank, }, + solana_builtins::{ + core_bpf_migration::CoreBpfMigrationConfig, + prototype::{BuiltinPrototype, StatelessBuiltinPrototype}, + BUILTINS, STATELESS_BUILTINS, + }, solana_feature_set::FeatureSet, solana_program_runtime::loaded_programs::ProgramCacheEntry, solana_sdk::{ diff --git a/runtime/src/bank/builtins/core_bpf_migration/mod.rs b/runtime/src/bank/builtins/core_bpf_migration/mod.rs index 28308499f3851f..56c58ba6f22522 100644 --- a/runtime/src/bank/builtins/core_bpf_migration/mod.rs +++ b/runtime/src/bank/builtins/core_bpf_migration/mod.rs @@ -7,6 +7,7 @@ use { crate::bank::Bank, error::CoreBpfMigrationError, num_traits::{CheckedAdd, CheckedSub}, + solana_builtins::core_bpf_migration::CoreBpfMigrationConfig, solana_program_runtime::{ invoke_context::{EnvironmentConfig, InvokeContext}, loaded_programs::ProgramCacheForTxBatch, @@ -26,45 +27,6 @@ use { target_core_bpf::TargetCoreBpf, }; -/// Identifies the type of built-in program targeted for Core BPF migration. -/// The type of target determines whether the program should have a program -/// account or not, which is checked before migration. -#[allow(dead_code)] // Remove after first migration is configured. -#[derive(Debug, PartialEq)] -pub(crate) enum CoreBpfMigrationTargetType { - /// A standard (stateful) builtin program must have a program account. - Builtin, - /// A stateless builtin must not have a program account. - Stateless, -} - -/// Configuration for migrating a built-in program to Core BPF. -#[derive(Debug, PartialEq)] -pub(crate) struct CoreBpfMigrationConfig { - /// The address of the source buffer account to be used to replace the - /// builtin. - pub source_buffer_address: Pubkey, - /// The authority to be used as the BPF program's upgrade authority. - /// - /// Note: If this value is set to `None`, then the migration will ignore - /// the source buffer account's authority. If it's set to any `Some(..)` - /// value, then the migration will perform a sanity check to ensure the - /// source buffer account's authority matches the provided value. - pub upgrade_authority_address: Option, - /// The feature gate to trigger the migration to Core BPF. - /// Note: This feature gate should never be the same as any builtin's - /// `enable_feature_id`. It should always be a feature gate that will be - /// activated after the builtin is already enabled. - pub feature_id: Pubkey, - /// The type of target to replace. - pub migration_target: CoreBpfMigrationTargetType, - /// Static message used to emit datapoint logging. - /// This is used to identify the migration in the logs. - /// Should be unique to the migration, ie: - /// "migrate_{builtin/stateless}_to_core_bpf_{program_name}". - pub datapoint_name: &'static str, -} - fn checked_add(a: T, b: T) -> Result { a.checked_add(&b) .ok_or(CoreBpfMigrationError::ArithmeticOverflow) @@ -411,6 +373,7 @@ pub(crate) mod tests { super::*, crate::bank::tests::create_simple_test_bank, assert_matches::assert_matches, + solana_builtins::core_bpf_migration::CoreBpfMigrationTargetType, solana_program_runtime::loaded_programs::{ProgramCacheEntry, ProgramCacheEntryType}, solana_sdk::{ account_utils::StateMut, diff --git a/runtime/src/bank/builtins/core_bpf_migration/target_builtin.rs b/runtime/src/bank/builtins/core_bpf_migration/target_builtin.rs index ad565909ccee7b..5b152b40b9edae 100644 --- a/runtime/src/bank/builtins/core_bpf_migration/target_builtin.rs +++ b/runtime/src/bank/builtins/core_bpf_migration/target_builtin.rs @@ -1,6 +1,7 @@ use { - super::{error::CoreBpfMigrationError, CoreBpfMigrationTargetType}, + super::error::CoreBpfMigrationError, crate::bank::Bank, + solana_builtins::core_bpf_migration::CoreBpfMigrationTargetType, solana_sdk::{ account::{AccountSharedData, ReadableAccount}, bpf_loader_upgradeable::get_program_data_address, @@ -118,11 +119,11 @@ mod tests { Some(feature_set::enable_program_runtime_v2_and_loader_v4::id()) )] #[test_case( - solana_zk_token_sdk::zk_token_proof_program::id(), + solana_sdk_ids::zk_token_proof_program::id(), Some(feature_set::zk_token_sdk_enabled::id()) )] #[test_case( - solana_zk_sdk::zk_elgamal_proof_program::id(), + solana_sdk_ids::zk_elgamal_proof_program::id(), Some(feature_set::zk_elgamal_proof_program_enabled::id()) )] fn test_target_program_builtin(program_address: Pubkey, activation_feature: Option) { diff --git a/runtime/src/bank/builtins/mod.rs b/runtime/src/bank/builtins/mod.rs index 8ea62495ff87b0..36198db9445f84 100644 --- a/runtime/src/bank/builtins/mod.rs +++ b/runtime/src/bank/builtins/mod.rs @@ -1,406 +1 @@ pub(crate) mod core_bpf_migration; -pub mod prototypes; - -pub use prototypes::{BuiltinPrototype, StatelessBuiltinPrototype}; -use { - core_bpf_migration::CoreBpfMigrationConfig, - solana_feature_set as feature_set, - solana_sdk::{bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable}, -}; - -macro_rules! testable_prototype { - ($prototype:ident { - core_bpf_migration_config: $core_bpf_migration_config:expr, - name: $name:ident, - $($field:ident : $value:expr),* $(,)? - }) => { - $prototype { - core_bpf_migration_config: { - #[cfg(not(test))] - { - $core_bpf_migration_config - } - #[cfg(test)] - { - Some( test_only::$name::CONFIG ) - } - }, - name: stringify!($name), - $($field: $value),* - } - }; -} - -/// DEVELOPER: when a builtin is migrated to sbpf, please add its corresponding -/// migration feature ID to solana-builtin-default-costs::BUILTIN_INSTRUCTION_COSTS, -/// so the builtin's default cost can be determined properly based on feature status. -/// When migration completed, and the feature gate is enabled everywhere, please -/// remove that builtin entry from solana-builtin-default-costs::BUILTIN_INSTRUCTION_COSTS. -pub static BUILTINS: &[BuiltinPrototype] = &[ - testable_prototype!(BuiltinPrototype { - core_bpf_migration_config: None, - name: system_program, - enable_feature_id: None, - program_id: solana_system_program::id(), - entrypoint: solana_system_program::system_processor::Entrypoint::vm, - }), - testable_prototype!(BuiltinPrototype { - core_bpf_migration_config: None, - name: vote_program, - enable_feature_id: None, - program_id: solana_vote_program::id(), - entrypoint: solana_vote_program::vote_processor::Entrypoint::vm, - }), - BuiltinPrototype { - core_bpf_migration_config: Some(CoreBpfMigrationConfig { - source_buffer_address: buffer_accounts::stake_program::id(), - upgrade_authority_address: None, - feature_id: solana_feature_set::migrate_stake_program_to_core_bpf::id(), - migration_target: core_bpf_migration::CoreBpfMigrationTargetType::Builtin, - datapoint_name: "migrate_builtin_to_core_bpf_stake_program", - }), - name: "stake_program", - enable_feature_id: None, - program_id: solana_stake_program::id(), - entrypoint: solana_stake_program::stake_instruction::Entrypoint::vm, - }, - BuiltinPrototype { - core_bpf_migration_config: Some(CoreBpfMigrationConfig { - source_buffer_address: buffer_accounts::config_program::id(), - upgrade_authority_address: None, - feature_id: solana_feature_set::migrate_config_program_to_core_bpf::id(), - migration_target: core_bpf_migration::CoreBpfMigrationTargetType::Builtin, - datapoint_name: "migrate_builtin_to_core_bpf_config_program", - }), - name: "config_program", - enable_feature_id: None, - program_id: solana_config_program::id(), - entrypoint: solana_config_program::config_processor::Entrypoint::vm, - }, - testable_prototype!(BuiltinPrototype { - core_bpf_migration_config: None, - name: solana_bpf_loader_deprecated_program, - enable_feature_id: None, - program_id: bpf_loader_deprecated::id(), - entrypoint: solana_bpf_loader_program::Entrypoint::vm, - }), - testable_prototype!(BuiltinPrototype { - core_bpf_migration_config: None, - name: solana_bpf_loader_program, - enable_feature_id: None, - program_id: bpf_loader::id(), - entrypoint: solana_bpf_loader_program::Entrypoint::vm, - }), - testable_prototype!(BuiltinPrototype { - core_bpf_migration_config: None, - name: solana_bpf_loader_upgradeable_program, - enable_feature_id: None, - program_id: bpf_loader_upgradeable::id(), - entrypoint: solana_bpf_loader_program::Entrypoint::vm, - }), - testable_prototype!(BuiltinPrototype { - core_bpf_migration_config: None, - name: compute_budget_program, - enable_feature_id: None, - program_id: solana_sdk::compute_budget::id(), - entrypoint: solana_compute_budget_program::Entrypoint::vm, - }), - BuiltinPrototype { - core_bpf_migration_config: Some(CoreBpfMigrationConfig { - source_buffer_address: buffer_accounts::address_lookup_table_program::id(), - upgrade_authority_address: None, - feature_id: solana_feature_set::migrate_address_lookup_table_program_to_core_bpf::id(), - migration_target: core_bpf_migration::CoreBpfMigrationTargetType::Builtin, - datapoint_name: "migrate_builtin_to_core_bpf_address_lookup_table_program", - }), - name: "address_lookup_table_program", - enable_feature_id: None, - program_id: solana_sdk::address_lookup_table::program::id(), - entrypoint: solana_address_lookup_table_program::processor::Entrypoint::vm, - }, - testable_prototype!(BuiltinPrototype { - core_bpf_migration_config: None, - name: zk_token_proof_program, - enable_feature_id: Some(feature_set::zk_token_sdk_enabled::id()), - program_id: solana_zk_token_sdk::zk_token_proof_program::id(), - entrypoint: solana_zk_token_proof_program::Entrypoint::vm, - }), - testable_prototype!(BuiltinPrototype { - core_bpf_migration_config: None, - name: loader_v4, - enable_feature_id: Some(feature_set::enable_program_runtime_v2_and_loader_v4::id()), - program_id: solana_sdk::loader_v4::id(), - entrypoint: solana_loader_v4_program::Entrypoint::vm, - }), - testable_prototype!(BuiltinPrototype { - core_bpf_migration_config: None, - name: zk_elgamal_proof_program, - enable_feature_id: Some(feature_set::zk_elgamal_proof_program_enabled::id()), - program_id: solana_zk_sdk::zk_elgamal_proof_program::id(), - entrypoint: solana_zk_elgamal_proof_program::Entrypoint::vm, - }), -]; - -pub static STATELESS_BUILTINS: &[StatelessBuiltinPrototype] = &[StatelessBuiltinPrototype { - core_bpf_migration_config: Some(CoreBpfMigrationConfig { - source_buffer_address: buffer_accounts::feature_gate_program::id(), - upgrade_authority_address: None, - feature_id: solana_feature_set::migrate_feature_gate_program_to_core_bpf::id(), - migration_target: core_bpf_migration::CoreBpfMigrationTargetType::Stateless, - datapoint_name: "migrate_stateless_to_core_bpf_feature_gate_program", - }), - name: "feature_gate_program", - program_id: solana_sdk::feature::id(), -}]; - -/// Live source buffer accounts for builtin migrations. -mod buffer_accounts { - pub mod address_lookup_table_program { - solana_sdk::declare_id!("AhXWrD9BBUYcKjtpA3zuiiZG4ysbo6C6wjHo1QhERk6A"); - } - pub mod config_program { - solana_sdk::declare_id!("BuafH9fBv62u6XjzrzS4ZjAE8963ejqF5rt1f8Uga4Q3"); - } - pub mod feature_gate_program { - solana_sdk::declare_id!("3D3ydPWvmEszrSjrickCtnyRSJm1rzbbSsZog8Ub6vLh"); - } - pub mod stake_program { - solana_sdk::declare_id!("8t3vv6v99tQA6Gp7fVdsBH66hQMaswH5qsJVqJqo8xvG"); - } -} - -// This module contains a number of arbitrary addresses used for testing Core -// BPF migrations. -// Since the list of builtins is static, using `declare_id!` with constant -// values is arguably the least-overhead approach to injecting static addresses -// 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(test)] -mod test_only { - use super::core_bpf_migration::{CoreBpfMigrationConfig, CoreBpfMigrationTargetType}; - pub mod system_program { - pub mod feature { - solana_sdk::declare_id!("AnjsdWg7LXFbjDdy78wncCJs9PyTdWpKkFmHAwQU1mQ6"); - } - pub mod source_buffer { - solana_sdk::declare_id!("EDEhzg1Jk79Wrk4mwpRa7txjgRxcE6igXwd6egFDVhuz"); - } - pub mod upgrade_authority { - solana_sdk::declare_id!("4d14UK2o1FKKoecEBWhVDZrBBbRuhug75G1j9XYCawC2"); - } - pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { - source_buffer_address: source_buffer::id(), - upgrade_authority_address: Some(upgrade_authority::id()), - feature_id: feature::id(), - migration_target: super::CoreBpfMigrationTargetType::Builtin, - datapoint_name: "migrate_builtin_to_core_bpf_system_program", - }; - } - - pub mod vote_program { - pub mod feature { - solana_sdk::declare_id!("5wDLHMasPmtrcpfRZX67RVkBXBbSTQ9S4C8EJomD3yAk"); - } - pub mod source_buffer { - solana_sdk::declare_id!("6T9s4PTcHnpq2AVAqoCbJd4FuHsdD99MjSUEbS7qb1tT"); - } - pub mod upgrade_authority { - solana_sdk::declare_id!("2N4JfyYub6cWUP9R4JrsFHv6FYKT7JnoRX8GQUH9MdT3"); - } - pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { - source_buffer_address: source_buffer::id(), - upgrade_authority_address: Some(upgrade_authority::id()), - feature_id: feature::id(), - migration_target: super::CoreBpfMigrationTargetType::Builtin, - datapoint_name: "migrate_builtin_to_core_bpf_vote_program", - }; - } - - pub mod solana_bpf_loader_deprecated_program { - pub mod feature { - solana_sdk::declare_id!("8gpakCv5Pk5PZGv9RUjzdkk2GVQPGx12cNRUDMQ3bP86"); - } - pub mod source_buffer { - solana_sdk::declare_id!("DveUYB5m9G3ce4zpV3fxg9pCNkvH1wDsyd8XberZ47JL"); - } - pub mod upgrade_authority { - solana_sdk::declare_id!("8Y5VTHdadnz4rZZWdUA4Qq2m2zWoCwwtb38spPZCXuGU"); - } - pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { - source_buffer_address: source_buffer::id(), - upgrade_authority_address: Some(upgrade_authority::id()), - feature_id: feature::id(), - migration_target: super::CoreBpfMigrationTargetType::Builtin, - datapoint_name: "migrate_builtin_to_core_bpf_bpf_loader_deprecated_program", - }; - } - - pub mod solana_bpf_loader_program { - pub mod feature { - solana_sdk::declare_id!("8yEdUm4SaP1yNq2MczEVdrM48SucvZCTDSqjcAKfYfL6"); - } - pub mod source_buffer { - solana_sdk::declare_id!("2EWMYGJPuGLW4TexLLEMeXP2BkB1PXEKBFb698yw6LhT"); - } - pub mod upgrade_authority { - solana_sdk::declare_id!("3sQ9VZ1Lvuvs6NpFXFV3ByFAf52ajPPdXwuhYERJR3iJ"); - } - pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { - source_buffer_address: source_buffer::id(), - upgrade_authority_address: Some(upgrade_authority::id()), - feature_id: feature::id(), - migration_target: super::CoreBpfMigrationTargetType::Builtin, - datapoint_name: "migrate_builtin_to_core_bpf_bpf_loader_program", - }; - } - - pub mod solana_bpf_loader_upgradeable_program { - pub mod feature { - solana_sdk::declare_id!("oPQbVjgoQ7SaQmzZiiHW4xqHbh4BJqqrFhxEJZiMiwY"); - } - pub mod source_buffer { - solana_sdk::declare_id!("6bTmA9iefD57GDoQ9wUjG8SeYkSpRw3EkKzxZCbhkavq"); - } - pub mod upgrade_authority { - solana_sdk::declare_id!("CuJvJY1K2wx82oLrQGSSWtw4AF7nVifEHupzSC2KEcq5"); - } - pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { - source_buffer_address: source_buffer::id(), - upgrade_authority_address: Some(upgrade_authority::id()), - feature_id: feature::id(), - migration_target: super::CoreBpfMigrationTargetType::Builtin, - datapoint_name: "migrate_builtin_to_core_bpf_bpf_loader_upgradeable_program", - }; - } - - pub mod compute_budget_program { - pub mod feature { - solana_sdk::declare_id!("D39vUspVfhjPVD7EtMJZrA5j1TSMp4LXfb43nxumGdHT"); - } - pub mod source_buffer { - solana_sdk::declare_id!("KfX1oLpFC5CwmFeSgXrNcXaouKjFkPuSJ4UsKb3zKMX"); - } - pub mod upgrade_authority { - solana_sdk::declare_id!("HGTbQhaCXNTbpgpLb2KNjqWSwpJyb2dqDB66Lc3Ph4aN"); - } - pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { - source_buffer_address: source_buffer::id(), - upgrade_authority_address: Some(upgrade_authority::id()), - feature_id: feature::id(), - migration_target: super::CoreBpfMigrationTargetType::Builtin, - datapoint_name: "migrate_builtin_to_core_bpf_compute_budget_program", - }; - } - - pub mod zk_token_proof_program { - pub mod feature { - solana_sdk::declare_id!("GfeFwUzKP9NmaP5u4VfnFgEvQoeQc2wPgnBFrUZhpib5"); - } - pub mod source_buffer { - solana_sdk::declare_id!("Ffe9gL8vXraBkiv3HqbLvBqY7i9V4qtZxjH83jYYDe1V"); - } - pub mod upgrade_authority { - solana_sdk::declare_id!("6zkXWHR8YeCvfMqHwyiz2n7g6hMUKCFhrVccZZTDk4ei"); - } - pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { - source_buffer_address: source_buffer::id(), - upgrade_authority_address: Some(upgrade_authority::id()), - feature_id: feature::id(), - migration_target: super::CoreBpfMigrationTargetType::Builtin, - datapoint_name: "migrate_builtin_to_core_bpf_zk_token_proof_program", - }; - } - - pub mod loader_v4 { - pub mod feature { - solana_sdk::declare_id!("Cz5JthYp27KR3rwTCtVJhbRgwHCurbwcYX46D8setL22"); - } - pub mod source_buffer { - solana_sdk::declare_id!("EH45pKy1kzjifB93wEJi91js3S4HETdsteywR7ZCNPn5"); - } - pub mod upgrade_authority { - solana_sdk::declare_id!("AWbiYRbFts9GVX5uwUkwV46hTFP85PxCAM8e8ir8Hqtq"); - } - pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { - source_buffer_address: source_buffer::id(), - upgrade_authority_address: Some(upgrade_authority::id()), - feature_id: feature::id(), - migration_target: super::CoreBpfMigrationTargetType::Builtin, - datapoint_name: "migrate_builtin_to_core_bpf_loader_v4_program", - }; - } - - pub mod zk_elgamal_proof_program { - pub mod feature { - solana_sdk::declare_id!("EYtuxScWqGWmcPEDmeUsEt3iPkvWE26EWLfSxUvWP2WN"); - } - pub mod source_buffer { - solana_sdk::declare_id!("AaVrLPurAUmjw6XRNGr6ezQfHaJWpBGHhcRSJmNjoVpQ"); - } - pub mod upgrade_authority { - solana_sdk::declare_id!("EyGkQYHgynUdvdNPNiWbJQk9roFCexgdJQMNcWbuvp78"); - } - pub const CONFIG: super::CoreBpfMigrationConfig = super::CoreBpfMigrationConfig { - source_buffer_address: source_buffer::id(), - upgrade_authority_address: Some(upgrade_authority::id()), - feature_id: feature::id(), - migration_target: super::CoreBpfMigrationTargetType::Builtin, - datapoint_name: "migrate_builtin_to_core_bpf_zk_elgamal_proof_program", - }; - } -} - -#[cfg(test)] -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. - #[test] - fn test_testable_prototypes() { - assert_eq!( - &super::BUILTINS[0].core_bpf_migration_config, - &Some(super::test_only::system_program::CONFIG) - ); - assert_eq!( - &super::BUILTINS[1].core_bpf_migration_config, - &Some(super::test_only::vote_program::CONFIG) - ); - // Stake has a live migration config, so it has no test-only configs - // to test here. - // Config has a live migration config, so it has no test-only configs - // to test here. - assert_eq!( - &super::BUILTINS[4].core_bpf_migration_config, - &Some(super::test_only::solana_bpf_loader_deprecated_program::CONFIG) - ); - assert_eq!( - &super::BUILTINS[5].core_bpf_migration_config, - &Some(super::test_only::solana_bpf_loader_program::CONFIG) - ); - assert_eq!( - &super::BUILTINS[6].core_bpf_migration_config, - &Some(super::test_only::solana_bpf_loader_upgradeable_program::CONFIG) - ); - assert_eq!( - &super::BUILTINS[7].core_bpf_migration_config, - &Some(super::test_only::compute_budget_program::CONFIG) - ); - // Address Lookup Table has a live migration config, so it has no - // test-only configs to test here. - assert_eq!( - &super::BUILTINS[9].core_bpf_migration_config, - &Some(super::test_only::zk_token_proof_program::CONFIG) - ); - assert_eq!( - &super::BUILTINS[10].core_bpf_migration_config, - &Some(super::test_only::loader_v4::CONFIG) - ); - assert_eq!( - &super::BUILTINS[11].core_bpf_migration_config, - &Some(super::test_only::zk_elgamal_proof_program::CONFIG) - ); - // Feature Gate has a live migration config, so it has no test-only - // configs to test here. - } -} diff --git a/runtime/src/serde_snapshot.rs b/runtime/src/serde_snapshot.rs index 7a31a73efd30f2..d80a4ae78c5ec1 100644 --- a/runtime/src/serde_snapshot.rs +++ b/runtime/src/serde_snapshot.rs @@ -2,10 +2,7 @@ use std::ffi::{CStr, CString}; use { crate::{ - bank::{ - builtins::BuiltinPrototype, Bank, BankFieldsToDeserialize, BankFieldsToSerialize, - BankHashStats, BankRc, - }, + bank::{Bank, BankFieldsToDeserialize, BankFieldsToSerialize, BankHashStats, BankRc}, epoch_stakes::{EpochStakes, VersionedEpochStakes}, runtime_config::RuntimeConfig, serde_snapshot::storage::SerializableAccountStorageEntry, @@ -29,6 +26,7 @@ use { blockhash_queue::BlockhashQueue, epoch_accounts_hash::EpochAccountsHash, }, + solana_builtins::prototype::BuiltinPrototype, solana_measure::measure::Measure, solana_sdk::{ clock::{Epoch, Slot, UnixTimestamp}, diff --git a/runtime/src/snapshot_bank_utils.rs b/runtime/src/snapshot_bank_utils.rs index 4d90329a785191..e9fbb0adb5c078 100644 --- a/runtime/src/snapshot_bank_utils.rs +++ b/runtime/src/snapshot_bank_utils.rs @@ -1,6 +1,6 @@ use { crate::{ - bank::{builtins::BuiltinPrototype, Bank, BankFieldsToDeserialize, BankSlotDelta}, + bank::{Bank, BankFieldsToDeserialize, BankSlotDelta}, epoch_stakes::EpochStakes, runtime_config::RuntimeConfig, serde_snapshot::{ @@ -34,6 +34,7 @@ use { accounts_update_notifier_interface::AccountsUpdateNotifier, utils::delete_contents_of_path, }, + solana_builtins::prototype::BuiltinPrototype, solana_measure::{measure::Measure, measure_time}, solana_sdk::{ clock::{Epoch, Slot}, diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index 843ef50e494d0b..e326abd8a08870 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -5008,6 +5008,26 @@ dependencies = [ "tempfile", ] +[[package]] +name = "solana-builtins" +version = "2.2.0" +dependencies = [ + "solana-address-lookup-table-program", + "solana-bpf-loader-program", + "solana-compute-budget-program", + "solana-config-program", + "solana-feature-set", + "solana-loader-v4-program", + "solana-program-runtime", + "solana-pubkey", + "solana-sdk-ids", + "solana-stake-program", + "solana-system-program", + "solana-vote-program", + "solana-zk-elgamal-proof-program", + "solana-zk-token-proof-program", +] + [[package]] name = "solana-builtins-default-costs" version = "2.2.0" @@ -6569,18 +6589,16 @@ dependencies = [ "serde_json", "serde_with", "solana-accounts-db", - "solana-address-lookup-table-program", "solana-bpf-loader-program", "solana-bucket-map", + "solana-builtins", "solana-compute-budget", - "solana-compute-budget-program", "solana-config-program", "solana-cost-model", "solana-feature-set", "solana-fee", "solana-inline-spl", "solana-lattice-hash", - "solana-loader-v4-program", "solana-measure", "solana-metrics", "solana-perf", @@ -6593,16 +6611,11 @@ dependencies = [ "solana-svm", "solana-svm-rent-collector", "solana-svm-transaction", - "solana-system-program", "solana-timings", "solana-transaction-status-client-types", "solana-version", "solana-vote", "solana-vote-program", - "solana-zk-elgamal-proof-program", - "solana-zk-sdk", - "solana-zk-token-proof-program", - "solana-zk-token-sdk", "static_assertions", "strum", "strum_macros",