diff --git a/cost-model/src/block_cost_limits.rs b/cost-model/src/block_cost_limits.rs index 7fc4b2fe670b39..68a99eb99d1533 100644 --- a/cost-model/src/block_cost_limits.rs +++ b/cost-model/src/block_cost_limits.rs @@ -22,6 +22,8 @@ pub const SECP256K1_VERIFY_COST: u64 = COMPUTE_UNIT_TO_US_RATIO * 223; pub const ED25519_VERIFY_COST: u64 = COMPUTE_UNIT_TO_US_RATIO * 76; /// Number of compute units for one ed25519 strict signature verification. pub const ED25519_VERIFY_STRICT_COST: u64 = COMPUTE_UNIT_TO_US_RATIO * 80; +/// Number of compute units for one secp256r1 signature verification. +pub const SECP256R1_VERIFY_COST: u64 = COMPUTE_UNIT_TO_US_RATIO * 160; /// Number of compute units for one write lock pub const WRITE_LOCK_UNITS: u64 = COMPUTE_UNIT_TO_US_RATIO * 10; /// Number of data bytes per compute units diff --git a/cost-model/src/cost_model.rs b/cost-model/src/cost_model.rs index cce3b1015b1a36..8a44427026fdc7 100644 --- a/cost-model/src/cost_model.rs +++ b/cost-model/src/cost_model.rs @@ -116,6 +116,13 @@ impl CostModel { ED25519_VERIFY_COST }; + let secp256r1_verify_cost = + if feature_set.is_active(&feature_set::enable_secp256r1_precompile::id()) { + SECP256R1_VERIFY_COST + } else { + 0 + }; + signatures_count_detail .num_transaction_signatures() .saturating_mul(SIGNATURE_COST) @@ -129,6 +136,11 @@ impl CostModel { .num_ed25519_instruction_signatures() .saturating_mul(ed25519_verify_cost), ) + .saturating_add( + signatures_count_detail + .num_secp256r1_instruction_signatures() + .saturating_mul(secp256r1_verify_cost), + ) } fn get_writable_accounts(message: &impl SVMMessage) -> impl Iterator { diff --git a/cost-model/src/cost_tracker.rs b/cost-model/src/cost_tracker.rs index 3ca2c84d048b98..429524cfaca201 100644 --- a/cost-model/src/cost_tracker.rs +++ b/cost-model/src/cost_tracker.rs @@ -76,6 +76,7 @@ pub struct CostTracker { /// the tracker, but are still waiting for an update with actual usage or /// removal if the transaction does not end up getting committed. in_flight_transaction_count: usize, + secp256r1_instruction_signature_count: u64, } impl Default for CostTracker { @@ -102,6 +103,7 @@ impl Default for CostTracker { secp256k1_instruction_signature_count: 0, ed25519_instruction_signature_count: 0, in_flight_transaction_count: 0, + secp256r1_instruction_signature_count: 0, } } } @@ -256,6 +258,11 @@ impl CostTracker { self.in_flight_transaction_count, i64 ), + ( + "secp256r1_instruction_signature_count", + self.secp256r1_instruction_signature_count, + i64 + ) ); } @@ -334,6 +341,10 @@ impl CostTracker { self.ed25519_instruction_signature_count, tx_cost.num_ed25519_instruction_signatures() ); + saturating_add_assign!( + self.secp256r1_instruction_signature_count, + tx_cost.num_secp256r1_instruction_signatures() + ); self.add_transaction_execution_cost(tx_cost, tx_cost.sum()) } @@ -353,6 +364,9 @@ impl CostTracker { self.ed25519_instruction_signature_count = self .ed25519_instruction_signature_count .saturating_sub(tx_cost.num_ed25519_instruction_signatures()); + self.secp256r1_instruction_signature_count = self + .secp256r1_instruction_signature_count + .saturating_sub(tx_cost.num_secp256r1_instruction_signatures()); } /// Apply additional actual execution units to cost_tracker diff --git a/cost-model/src/transaction_cost.rs b/cost-model/src/transaction_cost.rs index 2c704394a9ccc5..6692ce830f205e 100644 --- a/cost-model/src/transaction_cost.rs +++ b/cost-model/src/transaction_cost.rs @@ -132,6 +132,16 @@ impl<'a, Tx: TransactionWithMeta> TransactionCost<'a, Tx> { .num_ed25519_instruction_signatures(), } } + + pub fn num_secp256r1_instruction_signatures(&self) -> u64 { + match self { + Self::SimpleVote { .. } => 0, + Self::Transaction(usage_cost) => usage_cost + .transaction + .signature_details() + .num_secp256r1_instruction_signatures(), + } + } } // costs are stored in number of 'compute unit's diff --git a/sdk/feature-set/src/lib.rs b/sdk/feature-set/src/lib.rs index 6725f02212b425..47186111506238 100644 --- a/sdk/feature-set/src/lib.rs +++ b/sdk/feature-set/src/lib.rs @@ -881,7 +881,7 @@ pub mod disable_account_loader_special_case { } pub mod enable_secp256r1_precompile { - solana_pubkey::declare_id!("sr11RdZWgbHTHxSroPALe6zgaT5A1K9LcE4nfsZS4gi"); + solana_pubkey::declare_id!("sryYyFwxzJop1Bh9XpyiVWjZP4nfHExiqNp3Dh71W9i"); } pub mod accounts_lt_hash {