Skip to content

Commit

Permalink
v1.16: Fix - enable_alt_bn128_syscall (backport of #32083) (#32087)
Browse files Browse the repository at this point in the history
Fix - `enable_alt_bn128_syscall` (#32083)

* Fixes test_runtime_feature_enable_with_program_cache.

* Adds enable_alt_bn128_syscall to FEATURES_AFFECTING_RBPF.

(cherry picked from commit d0ae8c3)

Co-authored-by: Alexander Meißner <AlexanderMeissner@gmx.net>
  • Loading branch information
mergify[bot] and Lichtso committed Jun 12, 2023
1 parent fa97441 commit 6aaaefd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
1 change: 1 addition & 0 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7574,6 +7574,7 @@ impl Bank {
feature_set::reject_callx_r10::id(),
feature_set::switch_to_new_elf_parser::id(),
feature_set::bpf_account_data_direct_mapping::id(),
feature_set::enable_alt_bn128_syscall::id(),
];
if !only_apply_transitions_for_new_features
|| FEATURES_AFFECTING_RBPF
Expand Down
41 changes: 16 additions & 25 deletions runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ use {
entrypoint::MAX_PERMITTED_DATA_INCREASE,
epoch_schedule::{EpochSchedule, MINIMUM_SLOTS_PER_EPOCH},
feature::{self, Feature},
feature_set::{self, reject_callx_r10, FeatureSet},
feature_set::{self, FeatureSet},
fee::FeeStructure,
fee_calculator::FeeRateGovernor,
genesis_config::{create_genesis_config, ClusterType, GenesisConfig},
Expand Down Expand Up @@ -12352,7 +12352,6 @@ fn test_runtime_feature_enable_with_program_cache() {

// Execute before feature is enabled to get program into the cache.
let result_without_feature_enabled = bank.process_transaction(&transaction1);
// Should fail when executing here
assert_eq!(
result_without_feature_enabled,
Err(TransactionError::InstructionError(
Expand All @@ -12362,31 +12361,23 @@ fn test_runtime_feature_enable_with_program_cache() {
);

// Activate feature
bank.activate_feature(&reject_callx_r10::id());
let feature_account_balance =
std::cmp::max(genesis_config.rent.minimum_balance(Feature::size_of()), 1);
bank.store_account(
&feature_set::reject_callx_r10::id(),
&feature::create_account(&Feature { activated_at: None }, feature_account_balance),
);
bank.apply_feature_activations(ApplyFeatureActivationsCaller::NewFromParent, false);

// Execute after feature is enabled
// Execute after feature is enabled to check it was pruned and reverified.
let result_with_feature_enabled = bank.process_transaction(&transaction2);
// Feature should have been activated thus causing the TX to fail at
// verification. It should fail here with new Executor Cache because feature
// activations should force the program to recompile with the new feature,
// and in this case the feature should cause the TX to fail at verification.
// Note: `ProgramFailedToComplete` error appearing again means the account
// was not recompiled by the cache upon feature activation and thus fails in
// the same way.
match &result_with_feature_enabled {
Err(x) => {
if *x
== TransactionError::InstructionError(0, InstructionError::ProgramFailedToComplete)
{
println!("ERROR: Program was not recompiled after runtime feature was enabled.");
}
}
Ok(_) => println!("ERROR: Program should fail during execution."),
}
// assert_eq!(
// result_with_feature_enabled,
// Err(TransactionError::InstructionError(0, InstructionError::InvalidAccountData))
// );
assert_eq!(
result_with_feature_enabled,
Err(TransactionError::InstructionError(
0,
InstructionError::InvalidAccountData
))
);
}

#[test]
Expand Down

0 comments on commit 6aaaefd

Please sign in to comment.