Fix ed25519 builtin program handling (#23182)

* Fix ed25519 builtin program handling

* Fix tests

* Add integration tests for processing transactions with ed25519 ixs

* Fix another test

* fix formatting
This commit is contained in:
Justin Starry
2022-02-17 02:48:55 +08:00
committed by GitHub
parent de30699fa5
commit 813725dfec
9 changed files with 177 additions and 13 deletions

View File

@ -13013,25 +13013,25 @@ pub(crate) mod tests {
if bank.slot == 0 {
assert_eq!(
bank.hash().to_string(),
"2VLeMNvmpPEDy7sWw48gUVzjMa3WmgoegjavyhLTCnq7"
"HREoNvUAuqqGdJxYTgnFqjTxsuuBVUFFDNLGR2cdrtMf"
);
}
if bank.slot == 32 {
assert_eq!(
bank.hash().to_string(),
"AYnKo6pV8WJy5yXiSkYk79LWnCUCG714fQG7Xq2EizLv"
"J8kjxLMMrpEVQUbX54zDALkXidjdXyFSL5wD2d7xUaWL"
);
}
if bank.slot == 64 {
assert_eq!(
bank.hash().to_string(),
"37iX2uYecqAzxwyeWL8FCFeWg31B8u9hQhCRF76atrWy"
"yPCTEPtNi2DJb8KyqPKgBK7HCfiEpH2oS3Nn12LPBHm"
);
}
if bank.slot == 128 {
assert_eq!(
bank.hash().to_string(),
"4TDaCAvTJJg1YZ6aDhoM33Hk2cDzaraaxtGMJCmXG4wf"
"2oG1rmA59tmr457oK4oF6C6TcM2gyy2ZAKeJoUhMNb1L"
);
break;
}
@ -13260,7 +13260,7 @@ pub(crate) mod tests {
// No more slots should be shrunk
assert_eq!(bank2.shrink_candidate_slots(), 0);
// alive_counts represents the count of alive accounts in the three slots 0,1,2
assert_eq!(alive_counts, vec![10, 1, 7]);
assert_eq!(alive_counts, vec![11, 1, 7]);
}
#[test]
@ -13308,7 +13308,7 @@ pub(crate) mod tests {
.map(|_| bank.process_stale_slot_with_budget(0, force_to_return_alive_account))
.sum();
// consumed_budgets represents the count of alive accounts in the three slots 0,1,2
assert_eq!(consumed_budgets, 11);
assert_eq!(consumed_budgets, 12);
}
#[test]

View File

@ -129,10 +129,15 @@ fn genesis_builtins() -> Vec<Builtin> {
solana_sdk::secp256k1_program::id(),
dummy_process_instruction,
),
Builtin::new(
"ed25519_program",
solana_sdk::ed25519_program::id(),
dummy_process_instruction,
),
]
}
/// place holder for secp256k1, remove when the precompile program is deactivated via feature activation
/// place holder for precompile programs, remove when the precompile program is deactivated via feature activation
fn dummy_process_instruction(
_first_instruction_account: usize,
_data: &[u8],
@ -172,6 +177,18 @@ fn feature_builtins() -> Vec<(Builtin, Pubkey, ActivationType)> {
feature_set::prevent_calling_precompiles_as_programs::id(),
ActivationType::RemoveProgram,
),
// TODO when feature `prevent_calling_precompiles_as_programs` is
// cleaned up also remove "ed25519_program" from the main builtins
// list
(
Builtin::new(
"ed25519_program",
solana_sdk::ed25519_program::id(),
dummy_process_instruction,
),
feature_set::prevent_calling_precompiles_as_programs::id(),
ActivationType::RemoveProgram,
),
(
Builtin::new(
"address_lookup_table_program",

View File

@ -26,7 +26,7 @@ pub fn bootstrap_validator_stake_lamports() -> u64 {
// Number of lamports automatically used for genesis accounts
pub const fn genesis_sysvar_and_builtin_program_lamports() -> u64 {
const NUM_BUILTIN_PROGRAMS: u64 = 5;
const NUM_BUILTIN_PROGRAMS: u64 = 6;
const FEES_SYSVAR_MIN_BALANCE: u64 = 946_560;
const STAKE_HISTORY_MIN_BALANCE: u64 = 114_979_200;
const CLOCK_SYSVAR_MIN_BALANCE: u64 = 1_169_280;