Skip to content

Commit

Permalink
Fix conflicts manually
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-stones committed Jan 9, 2025
1 parent fd66b0f commit 5550a8c
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 202 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions builtins-default-costs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ 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-frozen-abi = { workspace = true, optional = true, features = [
"frozen-abi",
] }
Expand Down
11 changes: 6 additions & 5 deletions builtins-default-costs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use {
ahash::AHashMap,
lazy_static::lazy_static,
solana_feature_set::{self as feature_set, FeatureSet},
solana_sdk::{
address_lookup_table, bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable,
compute_budget, ed25519_program, loader_v4, pubkey::Pubkey, secp256k1_program,
Expand Down Expand Up @@ -108,23 +109,23 @@ static_assertions::const_assert_eq!(

pub const MIGRATING_BUILTINS_COSTS: &[(Pubkey, BuiltinCost)] = &[
(
stake::id(),
solana_stake_program::id(),
BuiltinCost::Migrating(MigratingBuiltinCost {
native_cost: solana_stake_program::stake_instruction::DEFAULT_COMPUTE_UNITS,
core_bpf_migration_feature: feature_set::migrate_stake_program_to_core_bpf::id(),
position: 0,
}),
),
(
config::id(),
solana_config_program::id(),
BuiltinCost::Migrating(MigratingBuiltinCost {
native_cost: solana_config_program::config_processor::DEFAULT_COMPUTE_UNITS,
core_bpf_migration_feature: feature_set::migrate_config_program_to_core_bpf::id(),
position: 1,
}),
),
(
address_lookup_table::id(),
address_lookup_table::program::id(),
BuiltinCost::Migrating(MigratingBuiltinCost {
native_cost: solana_address_lookup_table_program::processor::DEFAULT_COMPUTE_UNITS,
core_bpf_migration_feature:
Expand All @@ -136,13 +137,13 @@ pub const MIGRATING_BUILTINS_COSTS: &[(Pubkey, BuiltinCost)] = &[

pub const NON_MIGRATING_BUILTINS_COSTS: &[(Pubkey, BuiltinCost)] = &[
(
vote::id(),
solana_vote_program::id(),
BuiltinCost::NotMigrating(NotMigratingBuiltinCost {
native_cost: solana_vote_program::vote_processor::DEFAULT_COMPUTE_UNITS,
}),
),
(
system_program::id(),
solana_system_program::id(),
BuiltinCost::NotMigrating(NotMigratingBuiltinCost {
native_cost: solana_system_program::system_processor::DEFAULT_COMPUTE_UNITS,
}),
Expand Down
43 changes: 0 additions & 43 deletions compute-budget-instruction/Cargo.toml

This file was deleted.

148 changes: 0 additions & 148 deletions compute-budget-instruction/src/builtin_programs_filter.rs

This file was deleted.

53 changes: 47 additions & 6 deletions runtime-transaction/src/builtin_programs_filter.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
use {
agave_transaction_view::static_account_keys_frame::MAX_STATIC_ACCOUNTS_PER_PACKET as FILTER_SIZE,
solana_builtins_default_costs::{is_builtin_program, MAYBE_BUILTIN_KEY},
solana_builtins_default_costs::{
get_builtin_migration_feature_index, BuiltinMigrationFeatureIndex, MAYBE_BUILTIN_KEY,
},
solana_sdk::pubkey::Pubkey,
};

#[derive(Clone, Copy, Debug, PartialEq)]
pub(crate) enum ProgramKind {
NotBuiltin,
Builtin,
// Builtin program maybe in process of being migrated to core bpf,
// if core_bpf_migration_feature is activated, then the migration has
// completed and it should no longer be considered as builtin
MigratingBuiltin {
core_bpf_migration_feature_index: usize,
},
}

pub(crate) struct BuiltinProgramsFilter {
Expand Down Expand Up @@ -38,17 +46,24 @@ impl BuiltinProgramsFilter {
return ProgramKind::NotBuiltin;
}

if is_builtin_program(program_id) {
ProgramKind::Builtin
} else {
ProgramKind::NotBuiltin
match get_builtin_migration_feature_index(program_id) {
BuiltinMigrationFeatureIndex::NotBuiltin => ProgramKind::NotBuiltin,
BuiltinMigrationFeatureIndex::BuiltinNoMigrationFeature => ProgramKind::Builtin,
BuiltinMigrationFeatureIndex::BuiltinWithMigrationFeature(
core_bpf_migration_feature_index,
) => ProgramKind::MigratingBuiltin {
core_bpf_migration_feature_index,
},
}
}
}

#[cfg(test)]
mod test {
use super::*;
use {
super::*, solana_builtins_default_costs::get_migration_feature_position,
solana_sdk::feature_set,
};

const DUMMY_PROGRAM_ID: &str = "dummmy1111111111111111111111111111111111111";

Expand Down Expand Up @@ -90,6 +105,32 @@ mod test {
test_store.get_program_kind(index, &solana_sdk::compute_budget::id()),
ProgramKind::Builtin,
);

// migrating builtins
for (migrating_builtin_pubkey, migration_feature_id) in [
(
solana_sdk::stake::program::id(),
feature_set::migrate_stake_program_to_core_bpf::id(),
),
(
solana_sdk::config::program::id(),
feature_set::migrate_config_program_to_core_bpf::id(),
),
(
solana_sdk::address_lookup_table::program::id(),
feature_set::migrate_address_lookup_table_program_to_core_bpf::id(),
),
] {
index += 1;
assert_eq!(
test_store.get_program_kind(index, &migrating_builtin_pubkey),
ProgramKind::MigratingBuiltin {
core_bpf_migration_feature_index: get_migration_feature_position(
&migration_feature_id
),
}
);
}
}

#[test]
Expand Down

0 comments on commit 5550a8c

Please sign in to comment.