Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion ed25519-program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ edition = { workspace = true }
bytemuck = { workspace = true }
bytemuck_derive = { workspace = true }
ed25519-dalek = { workspace = true }
solana-feature-set = { workspace = true }
solana-feature-set-interface = { workspace = true }
solana-instruction = { workspace = true, features = ["std"] }
solana-precompile-error = { workspace = true }
solana-pubkey = { workspace = true }
solana-sdk-ids = { workspace = true }

[dev-dependencies]
Expand Down
27 changes: 19 additions & 8 deletions ed25519-program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use {
bytemuck::bytes_of,
bytemuck_derive::{Pod, Zeroable},
ed25519_dalek::{ed25519::signature::Signature, Signer, Verifier},
solana_feature_set::{ed25519_precompile_verify_strict, FeatureSet},
solana_feature_set_interface::FeatureSet,
solana_instruction::Instruction,
solana_precompile_error::PrecompileError,
};
Expand All @@ -18,6 +18,11 @@ pub const SIGNATURE_OFFSETS_SERIALIZED_SIZE: usize = 14;
pub const SIGNATURE_OFFSETS_START: usize = 2;
pub const DATA_START: usize = SIGNATURE_OFFSETS_SERIALIZED_SIZE + SIGNATURE_OFFSETS_START;

/// Copy from agave-feature-set
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is exactly what I was trying to avoid in #85. By doing this we are coupling sdk crate versions to runtime releases in a way that will be really tricky to track, especially for rekeys.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep that's totally fair!

mod ed25519_precompile_verify_strict {
solana_pubkey::declare_id!("ed9tNscbWLYBooxWA7FE2B5KHWs8A6sxfY8EzezEcoo");
}

#[derive(Default, Debug, Copy, Clone, Zeroable, Pod, Eq, PartialEq)]
#[repr(C)]
pub struct Ed25519SignatureOffsets {
Expand Down Expand Up @@ -220,13 +225,19 @@ pub mod test {
ed25519_dalek::Signer as EdSigner,
hex,
rand0_7::{thread_rng, Rng},
solana_feature_set::FeatureSet,
solana_feature_set_interface::FeatureSet,
solana_hash::Hash,
solana_keypair::Keypair,
solana_sdk::transaction::Transaction,
solana_signer::Signer,
};

fn feature_set_with_strict() -> FeatureSet {
let mut feature_set = FeatureSet::default();
feature_set.activate(&ed25519_precompile_verify_strict::id(), 0);
feature_set
}

pub fn new_ed25519_instruction_raw(
pubkey: &[u8],
signature: &[u8],
Expand Down Expand Up @@ -297,7 +308,7 @@ pub mod test {
verify(
&instruction_data,
&[&[0u8; 100]],
&FeatureSet::all_enabled(),
&feature_set_with_strict(),
)
}

Expand All @@ -315,7 +326,7 @@ pub mod test {
verify(
&instruction_data,
&[&[0u8; 100]],
&FeatureSet::all_enabled(),
&feature_set_with_strict(),
),
Err(PrecompileError::InvalidInstructionDataSize)
);
Expand Down Expand Up @@ -441,7 +452,7 @@ pub mod test {
let message_arr = b"hello";
let mut instruction = new_ed25519_instruction(&privkey, message_arr);
let mint_keypair = Keypair::new();
let feature_set = FeatureSet::all_enabled();
let feature_set = feature_set_with_strict();

let tx = Transaction::new_signed_with_payer(
&[instruction.clone()],
Expand Down Expand Up @@ -512,7 +523,7 @@ pub mod test {
}

let mint_keypair = Keypair::new();
let feature_set = FeatureSet::all_enabled();
let feature_set = feature_set_with_strict();

let tx = Transaction::new_signed_with_payer(
&[instruction.clone()],
Expand Down Expand Up @@ -560,7 +571,7 @@ pub mod test {
let feature_set = FeatureSet::default();
assert!(tx.verify_precompiles(&feature_set).is_ok());

let feature_set = FeatureSet::all_enabled();
let feature_set = feature_set_with_strict();
assert!(tx.verify_precompiles(&feature_set).is_ok());

// malleable sig: verify_strict does NOT pass
Expand All @@ -583,7 +594,7 @@ pub mod test {
let feature_set = FeatureSet::default();
assert!(tx.verify_precompiles(&feature_set).is_ok());

let feature_set = FeatureSet::all_enabled();
let feature_set = feature_set_with_strict();
assert!(tx.verify_precompiles(&feature_set).is_err()); // verify_strict does NOT pass
}
}
2 changes: 1 addition & 1 deletion feature-set-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use {

/// `FeatureSet` holds the set of currently active/inactive runtime features
#[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))]
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Default, Clone, Eq, PartialEq)]
pub struct FeatureSet {
pub active: AHashMap<Pubkey, u64>,
pub inactive: AHashSet<Pubkey>,
Expand Down
1 change: 1 addition & 0 deletions feature-set/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ edition = { workspace = true }
ahash = { workspace = true }
lazy_static = { workspace = true }
solana-epoch-schedule = { workspace = true }
solana-feature-set-interface = { workspace = true }
solana-frozen-abi = { workspace = true, optional = true, features = [
"frozen-abi",
] }
Expand Down
14 changes: 14 additions & 0 deletions feature-set/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,10 +1225,13 @@ lazy_static! {
/// `FeatureSet` holds the set of currently active/inactive runtime features
#[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))]
#[derive(Debug, Clone, Eq, PartialEq)]
#[deprecated]
#[allow(deprecated)]
pub struct FeatureSet {
pub active: AHashMap<Pubkey, u64>,
pub inactive: AHashSet<Pubkey>,
}
#[allow(deprecated)]
impl Default for FeatureSet {
fn default() -> Self {
// All features disabled
Expand All @@ -1238,6 +1241,7 @@ impl Default for FeatureSet {
}
}
}
#[allow(deprecated)]
impl FeatureSet {
pub fn is_active(&self, feature_id: &Pubkey) -> bool {
self.active.contains_key(feature_id)
Expand Down Expand Up @@ -1291,8 +1295,18 @@ impl FeatureSet {
.map(|slot| epoch_schedule.get_epoch(slot))
}
}
#[allow(deprecated)]
impl From<FeatureSet> for solana_feature_set_interface::FeatureSet {
fn from(feature_set: FeatureSet) -> Self {
Self {
active: feature_set.active,
inactive: feature_set.inactive,
}
}
}

#[cfg(test)]
#[allow(deprecated)]
mod test {
use super::*;

Expand Down
2 changes: 1 addition & 1 deletion precompiles/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = { workspace = true }
[dependencies]
lazy_static = { workspace = true }
solana-ed25519-program = { workspace = true }
solana-feature-set = { workspace = true }
solana-feature-set-interface = { workspace = true }
solana-message = { workspace = true }
solana-precompile-error = { workspace = true }
solana-pubkey = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions precompiles/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
use {
lazy_static::lazy_static, solana_feature_set::FeatureSet,
lazy_static::lazy_static, solana_feature_set_interface::FeatureSet,
solana_message::compiled_instruction::CompiledInstruction,
solana_precompile_error::PrecompileError, solana_pubkey::Pubkey,
};
Expand Down Expand Up @@ -61,7 +61,7 @@ lazy_static! {
),
Precompile::new(
solana_sdk_ids::secp256r1_program::id(),
Some(solana_feature_set::enable_secp256r1_precompile::id()),
Some(solana_secp256r1_program::enable_secp256r1_precompile::id()),
solana_secp256r1_program::verify,
)
];
Expand Down
2 changes: 1 addition & 1 deletion reserved-account-keys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = { workspace = true }

[dependencies]
lazy_static = { workspace = true }
solana-feature-set = { workspace = true }
solana-feature-set-interface = { workspace = true }
solana-frozen-abi = { workspace = true, optional = true, features = [
"frozen-abi",
] }
Expand Down
32 changes: 20 additions & 12 deletions reserved-account-keys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
use {
lazy_static::lazy_static,
solana_feature_set::{self as feature_set, FeatureSet},
solana_feature_set_interface::FeatureSet,
solana_pubkey::Pubkey,
solana_sdk_ids::{
address_lookup_table, bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable,
Expand Down Expand Up @@ -135,39 +135,47 @@ impl ReservedAccount {
}
}

mod add_new_reserved_account_keys {
solana_pubkey::declare_id!("8U4skmMVnF6k2kMvrWbQuRUT3qQSiTYpSjqmhmgfthZu");
}

pub mod enable_secp256r1_precompile {
solana_pubkey::declare_id!("srremy31J5Y25FrAApwVb9kZcfXbusYMMsvTK9aWv5q");
}

// New reserved accounts should be added in alphabetical order and must specify
// a feature id for activation. Reserved accounts cannot be removed from this
// list without breaking consensus.
lazy_static! {
static ref RESERVED_ACCOUNTS: Vec<ReservedAccount> = [
// builtin programs
ReservedAccount::new_pending(address_lookup_table::id(), feature_set::add_new_reserved_account_keys::id()),
ReservedAccount::new_pending(address_lookup_table::id(), add_new_reserved_account_keys::id()),
ReservedAccount::new_active(bpf_loader::id()),
ReservedAccount::new_active(bpf_loader_deprecated::id()),
ReservedAccount::new_active(bpf_loader_upgradeable::id()),
ReservedAccount::new_pending(compute_budget::id(), feature_set::add_new_reserved_account_keys::id()),
ReservedAccount::new_pending(compute_budget::id(), add_new_reserved_account_keys::id()),
ReservedAccount::new_active(config::id()),
ReservedAccount::new_pending(ed25519_program::id(), feature_set::add_new_reserved_account_keys::id()),
ReservedAccount::new_pending(ed25519_program::id(), add_new_reserved_account_keys::id()),
ReservedAccount::new_active(feature::id()),
ReservedAccount::new_pending(loader_v4::id(), feature_set::add_new_reserved_account_keys::id()),
ReservedAccount::new_pending(secp256k1_program::id(), feature_set::add_new_reserved_account_keys::id()),
ReservedAccount::new_pending(secp256r1_program::id(), feature_set::enable_secp256r1_precompile::id()),
ReservedAccount::new_pending(loader_v4::id(), add_new_reserved_account_keys::id()),
ReservedAccount::new_pending(secp256k1_program::id(), add_new_reserved_account_keys::id()),
ReservedAccount::new_pending(secp256r1_program::id(), enable_secp256r1_precompile::id()),
#[allow(deprecated)]
ReservedAccount::new_active(stake::config::id()),
ReservedAccount::new_active(stake::id()),
ReservedAccount::new_active(system_program::id()),
ReservedAccount::new_active(vote::id()),
ReservedAccount::new_pending(zk_elgamal_proof_program::id(), feature_set::add_new_reserved_account_keys::id()),
ReservedAccount::new_pending(zk_token_proof_program::id(), feature_set::add_new_reserved_account_keys::id()),
ReservedAccount::new_pending(zk_elgamal_proof_program::id(), add_new_reserved_account_keys::id()),
ReservedAccount::new_pending(zk_token_proof_program::id(), add_new_reserved_account_keys::id()),

// sysvars
ReservedAccount::new_active(sysvar::clock::id()),
ReservedAccount::new_pending(sysvar::epoch_rewards::id(), feature_set::add_new_reserved_account_keys::id()),
ReservedAccount::new_pending(sysvar::epoch_rewards::id(), add_new_reserved_account_keys::id()),
ReservedAccount::new_active(sysvar::epoch_schedule::id()),
#[allow(deprecated)]
ReservedAccount::new_active(sysvar::fees::id()),
ReservedAccount::new_active(sysvar::instructions::id()),
ReservedAccount::new_pending(sysvar::last_restart_slot::id(), feature_set::add_new_reserved_account_keys::id()),
ReservedAccount::new_pending(sysvar::last_restart_slot::id(), add_new_reserved_account_keys::id()),
#[allow(deprecated)]
ReservedAccount::new_active(sysvar::recent_blockhashes::id()),
ReservedAccount::new_active(sysvar::rent::id()),
Expand All @@ -178,7 +186,7 @@ lazy_static! {

// other
ReservedAccount::new_active(native_loader::id()),
ReservedAccount::new_pending(sysvar::id(), feature_set::add_new_reserved_account_keys::id()),
ReservedAccount::new_pending(sysvar::id(), add_new_reserved_account_keys::id()),
].to_vec();
}

Expand Down
2 changes: 2 additions & 0 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ dev-context-only-utils = [
"solana-transaction/dev-context-only-utils",
]
frozen-abi = [
"solana-feature-set-interface/frozen-abi",
"solana-feature-set/frozen-abi",
"solana-fee-structure/frozen-abi",
"solana-account/frozen-abi",
Expand Down Expand Up @@ -103,6 +104,7 @@ solana-ed25519-program = { workspace = true, optional = true }
solana-epoch-info = { workspace = true, features = ["serde"] }
solana-epoch-rewards-hasher = { workspace = true }
solana-feature-set = { workspace = true }
solana-feature-set-interface = { workspace = true }
solana-fee-structure = { workspace = true, features = ["serde"] }
solana-genesis-config = { workspace = true, features = [
"serde"
Expand Down
Loading