0.1.0-pre.004

This commit is contained in:
2026-07-23 18:25:10 +02:00
parent 0da75c1311
commit 149d4c6ef6
85 changed files with 25696 additions and 227 deletions

19
kb-program-ids/README.md Normal file
View File

@@ -0,0 +1,19 @@
<!-- file: kb-program-ids/README.md -->
<!-- version: 1 -->
# kb-program-ids
`kb-program-ids` est la source unique des identifiants de programmes Solana et des comptes natifs connus utilisés par le workspace.
La tranche `0.1.0-pre.004` expose les 18 surfaces exécutables nécessaires au décodeur Solana Core, les comptes natifs associés utilisés par leurs contrats et lidentifiant SPL Token classique employé par les tests de frontière. Les identifiants SPL et protocolaires supplémentaires seront ajoutés avec leurs tranches de migration respectives.
## API publique
- les constantes `*_PROGRAM_ID` et `STAKE_CONFIG_ACCOUNT_ID` exposent les adresses Base58 canoniques ;
- `ProgramIdEntry` conserve un code stable et une adresse, accessibles par les champs compatibles `name`/`address` et par `code()`/`program_id()` ;
- `native_program_ids()` retourne exactement les 18 surfaces exécutables de Solana Core ;
- `native_well_known_account_ids()` sépare les comptes natifs non exécutables ;
- `registered_program_ids()` et son alias de compatibilité `entries()` retournent le registre actuellement migré ;
- `find_registered_program_id()` effectue une recherche exacte par adresse.
`STAKE_CONFIG_PROGRAM_ID` reste uniquement un alias de compatibilité historique. Ladresse correspondante est un compte de configuration Stake connu, pas un programme exécutable.

View File

@@ -0,0 +1,252 @@
// file: kb-program-ids/src/constants.rs
// version: 1
//! Canonical Solana program and well-known account identifiers.
/// Address Lookup Table program identifier.
pub const ADDRESS_LOOKUP_TABLE_PROGRAM_ID: &str = "AddressLookupTab1e1111111111111111111111111";
/// Deprecated BPF Loader program identifier.
pub const BPF_LOADER_DEPRECATED_PROGRAM_ID: &str = "BPFLoader1111111111111111111111111111111111";
/// BPF Loader version 2 program identifier.
pub const BPF_LOADER_PROGRAM_ID: &str = "BPFLoader2111111111111111111111111111111111";
/// Upgradeable BPF Loader program identifier.
pub const BPF_LOADER_UPGRADEABLE_PROGRAM_ID: &str = "BPFLoaderUpgradeab1e11111111111111111111111";
/// Compute Budget program identifier.
pub const COMPUTE_BUDGET_PROGRAM_ID: &str = "ComputeBudget111111111111111111111111111111";
/// Config program identifier.
pub const CONFIG_PROGRAM_ID: &str = "Config1111111111111111111111111111111111111";
/// Ed25519 precompile program identifier.
pub const ED25519_PROGRAM_ID: &str = "Ed25519SigVerify111111111111111111111111111";
/// Feature program identifier.
pub const FEATURE_PROGRAM_ID: &str = "Feature111111111111111111111111111111111111";
/// Incinerator well-known account identifier.
pub const INCINERATOR_PROGRAM_ID: &str = "1nc1nerator11111111111111111111111111111111";
/// Loader version 4 program identifier.
pub const LOADER_V4_PROGRAM_ID: &str = "LoaderV411111111111111111111111111111111111";
/// Native Loader program identifier.
pub const NATIVE_LOADER_PROGRAM_ID: &str = "NativeLoader1111111111111111111111111111111";
/// Secp256k1 precompile program identifier.
pub const SECP256K1_PROGRAM_ID: &str = "KeccakSecp256k11111111111111111111111111111";
/// Secp256r1 precompile program identifier.
pub const SECP256R1_PROGRAM_ID: &str = "Secp256r1SigVerify1111111111111111111111111";
/// Enshrined stateless Slashing program identifier.
pub const SLASHING_PROGRAM_ID: &str = "S1ashing11111111111111111111111111111111111";
/// Classic SPL Token program identifier.
pub const SPL_TOKEN_PROGRAM_ID: &str = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
/// Historical Stake configuration account identifier.
pub const STAKE_CONFIG_ACCOUNT_ID: &str = "StakeConfig11111111111111111111111111111111";
/// Compatibility alias for the historical Stake configuration account identifier.
pub const STAKE_CONFIG_PROGRAM_ID: &str = crate::STAKE_CONFIG_ACCOUNT_ID;
/// Stake program identifier.
pub const STAKE_PROGRAM_ID: &str = "Stake11111111111111111111111111111111111111";
/// System program identifier.
pub const SYSTEM_PROGRAM_ID: &str = "11111111111111111111111111111111";
/// Clock sysvar account identifier.
pub const SYSVAR_CLOCK_PROGRAM_ID: &str = "SysvarC1ock11111111111111111111111111111111";
/// Instructions sysvar account identifier.
pub const SYSVAR_INSTRUCTIONS_PROGRAM_ID: &str = "Sysvar1nstructions1111111111111111111111111";
/// Rent sysvar account identifier.
pub const SYSVAR_RENT_PROGRAM_ID: &str = "SysvarRent111111111111111111111111111111111";
/// Slot Hashes sysvar account identifier.
pub const SYSVAR_SLOT_HASHES_PROGRAM_ID: &str = "SysvarS1otHashes111111111111111111111111111";
/// Stake History sysvar account identifier.
pub const SYSVAR_STAKE_HISTORY_PROGRAM_ID: &str = "SysvarStakeHistory1111111111111111111111111";
/// Vote program identifier.
pub const VOTE_PROGRAM_ID: &str = "Vote111111111111111111111111111111111111111";
/// ZK ElGamal Proof program identifier.
pub const ZK_ELGAMAL_PROOF_PROGRAM_ID: &str = "ZkE1Gama1Proof11111111111111111111111111111";
/// ZK Token Proof program identifier.
pub const ZK_TOKEN_PROOF_PROGRAM_ID: &str = "ZkTokenProof1111111111111111111111111111111";
pub(crate) const NATIVE_PROGRAM_ID_ENTRIES: &[crate::ProgramIdEntry] = &[
crate::ProgramIdEntry {
name: "address_lookup_table",
address: crate::ADDRESS_LOOKUP_TABLE_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "bpf_loader_deprecated",
address: crate::BPF_LOADER_DEPRECATED_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "bpf_loader",
address: crate::BPF_LOADER_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "bpf_loader_upgradeable",
address: crate::BPF_LOADER_UPGRADEABLE_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "compute_budget",
address: crate::COMPUTE_BUDGET_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "config",
address: crate::CONFIG_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "ed25519",
address: crate::ED25519_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "feature",
address: crate::FEATURE_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "loader_v4",
address: crate::LOADER_V4_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "native_loader",
address: crate::NATIVE_LOADER_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "secp256k1",
address: crate::SECP256K1_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "secp256r1",
address: crate::SECP256R1_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "slashing",
address: crate::SLASHING_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "stake",
address: crate::STAKE_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "system",
address: crate::SYSTEM_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "vote",
address: crate::VOTE_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "zk_elgamal_proof",
address: crate::ZK_ELGAMAL_PROOF_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "zk_token_proof",
address: crate::ZK_TOKEN_PROOF_PROGRAM_ID,
},
];
pub(crate) const NATIVE_WELL_KNOWN_ACCOUNT_ID_ENTRIES: &[crate::ProgramIdEntry] = &[
crate::ProgramIdEntry {
name: "incinerator",
address: crate::INCINERATOR_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "stake_config",
address: crate::STAKE_CONFIG_ACCOUNT_ID,
},
];
pub(crate) const PROGRAM_ID_ENTRIES: &[crate::ProgramIdEntry] = &[
crate::ProgramIdEntry {
name: "address_lookup_table",
address: crate::ADDRESS_LOOKUP_TABLE_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "bpf_loader_deprecated",
address: crate::BPF_LOADER_DEPRECATED_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "bpf_loader",
address: crate::BPF_LOADER_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "bpf_loader_upgradeable",
address: crate::BPF_LOADER_UPGRADEABLE_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "compute_budget",
address: crate::COMPUTE_BUDGET_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "config",
address: crate::CONFIG_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "ed25519",
address: crate::ED25519_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "feature",
address: crate::FEATURE_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "incinerator",
address: crate::INCINERATOR_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "loader_v4",
address: crate::LOADER_V4_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "native_loader",
address: crate::NATIVE_LOADER_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "secp256k1",
address: crate::SECP256K1_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "secp256r1",
address: crate::SECP256R1_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "slashing",
address: crate::SLASHING_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "spl_token",
address: crate::SPL_TOKEN_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "stake_config",
address: crate::STAKE_CONFIG_ACCOUNT_ID,
},
crate::ProgramIdEntry {
name: "stake",
address: crate::STAKE_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "system",
address: crate::SYSTEM_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "sysvar_clock",
address: crate::SYSVAR_CLOCK_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "sysvar_instructions",
address: crate::SYSVAR_INSTRUCTIONS_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "sysvar_rent",
address: crate::SYSVAR_RENT_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "sysvar_slot_hashes",
address: crate::SYSVAR_SLOT_HASHES_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "sysvar_stake_history",
address: crate::SYSVAR_STAKE_HISTORY_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "vote",
address: crate::VOTE_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "zk_elgamal_proof",
address: crate::ZK_ELGAMAL_PROOF_PROGRAM_ID,
},
crate::ProgramIdEntry {
name: "zk_token_proof",
address: crate::ZK_TOKEN_PROOF_PROGRAM_ID,
},
];

View File

@@ -1,22 +1,190 @@
// file: kb-program-ids/src/lib.rs
// version: 1
// version: 2
#![forbid(unsafe_code)]
#![deny(unreachable_pub)]
#![warn(missing_docs)]
//! Program identifier registry.
//! Shared canonical Solana program identifiers.
/// One program identifier entry.
#[derive(Clone, Debug, Eq, PartialEq)]
mod constants;
/// Address Lookup Table program identifier.
pub use constants::ADDRESS_LOOKUP_TABLE_PROGRAM_ID;
/// Deprecated BPF Loader program identifier.
pub use constants::BPF_LOADER_DEPRECATED_PROGRAM_ID;
/// BPF Loader version 2 program identifier.
pub use constants::BPF_LOADER_PROGRAM_ID;
/// Upgradeable BPF Loader program identifier.
pub use constants::BPF_LOADER_UPGRADEABLE_PROGRAM_ID;
/// Compute Budget program identifier.
pub use constants::COMPUTE_BUDGET_PROGRAM_ID;
/// Config program identifier.
pub use constants::CONFIG_PROGRAM_ID;
/// Ed25519 precompile program identifier.
pub use constants::ED25519_PROGRAM_ID;
/// Feature program identifier.
pub use constants::FEATURE_PROGRAM_ID;
/// Incinerator well-known account identifier.
pub use constants::INCINERATOR_PROGRAM_ID;
/// Loader version 4 program identifier.
pub use constants::LOADER_V4_PROGRAM_ID;
/// Native Loader program identifier.
pub use constants::NATIVE_LOADER_PROGRAM_ID;
/// Internal list of executable native programs.
pub(crate) use constants::NATIVE_PROGRAM_ID_ENTRIES;
/// Internal list of native well-known accounts.
pub(crate) use constants::NATIVE_WELL_KNOWN_ACCOUNT_ID_ENTRIES;
/// Internal list of currently registered identifiers.
pub(crate) use constants::PROGRAM_ID_ENTRIES;
/// Secp256k1 precompile program identifier.
pub use constants::SECP256K1_PROGRAM_ID;
/// Secp256r1 precompile program identifier.
pub use constants::SECP256R1_PROGRAM_ID;
/// Enshrined stateless Slashing program identifier.
pub use constants::SLASHING_PROGRAM_ID;
/// Classic SPL Token program identifier.
pub use constants::SPL_TOKEN_PROGRAM_ID;
/// Historical Stake configuration account identifier.
pub use constants::STAKE_CONFIG_ACCOUNT_ID;
/// Compatibility alias for the historical Stake configuration account identifier.
pub use constants::STAKE_CONFIG_PROGRAM_ID;
/// Stake program identifier.
pub use constants::STAKE_PROGRAM_ID;
/// System program identifier.
pub use constants::SYSTEM_PROGRAM_ID;
/// Clock sysvar account identifier.
pub use constants::SYSVAR_CLOCK_PROGRAM_ID;
/// Instructions sysvar account identifier.
pub use constants::SYSVAR_INSTRUCTIONS_PROGRAM_ID;
/// Rent sysvar account identifier.
pub use constants::SYSVAR_RENT_PROGRAM_ID;
/// Slot Hashes sysvar account identifier.
pub use constants::SYSVAR_SLOT_HASHES_PROGRAM_ID;
/// Stake History sysvar account identifier.
pub use constants::SYSVAR_STAKE_HISTORY_PROGRAM_ID;
/// Vote program identifier.
pub use constants::VOTE_PROGRAM_ID;
/// ZK ElGamal Proof program identifier.
pub use constants::ZK_ELGAMAL_PROOF_PROGRAM_ID;
/// ZK Token Proof program identifier.
pub use constants::ZK_TOKEN_PROOF_PROGRAM_ID;
/// One enumerable program identifier entry.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct ProgramIdEntry {
/// Stable symbolic name.
/// Stable lower snake case registry code.
pub name: &'static str,
/// Base58 program identifier.
/// Base58 Solana program identifier.
pub address: &'static str,
}
/// Returns the initial canonical program registry.
pub fn entries() -> &'static [crate::ProgramIdEntry] {
return &[];
impl ProgramIdEntry {
/// Returns the stable lower snake case registry code.
pub const fn code(&self) -> &'static str {
return self.name;
}
/// Returns the Base58 Solana program identifier.
pub const fn program_id(&self) -> &'static str {
return self.address;
}
}
/// Returns every program identifier currently registered by this crate.
pub fn entries() -> &'static [crate::ProgramIdEntry] {
return crate::PROGRAM_ID_ENTRIES;
}
/// Returns every program identifier currently registered by this crate.
pub fn registered_program_ids() -> &'static [crate::ProgramIdEntry] {
return crate::PROGRAM_ID_ENTRIES;
}
/// Returns every executable runtime-native, loader, precompile and historical native program identifier.
pub fn native_program_ids() -> &'static [crate::ProgramIdEntry] {
return crate::NATIVE_PROGRAM_ID_ENTRIES;
}
/// Returns native well-known accounts that are not executable programs.
pub fn native_well_known_account_ids() -> &'static [crate::ProgramIdEntry] {
return crate::NATIVE_WELL_KNOWN_ACCOUNT_ID_ENTRIES;
}
/// Finds one registered program or well-known account by exact Base58 identifier.
pub fn find_registered_program_id(
program_id: &str,
) -> std::option::Option<&'static crate::ProgramIdEntry> {
return crate::PROGRAM_ID_ENTRIES
.iter()
.find(|entry| return entry.address == program_id);
}
#[cfg(test)]
mod tests {
#[test]
fn registry_entries_are_unique_and_non_empty() {
let mut codes = std::collections::BTreeSet::new();
let mut program_ids = std::collections::BTreeSet::new();
for entry in crate::registered_program_ids() {
assert!(!entry.code().is_empty());
assert!(!entry.program_id().is_empty());
assert!(codes.insert(entry.code()));
assert!(program_ids.insert(entry.program_id()));
}
assert_eq!(crate::registered_program_ids().len(), 26);
}
#[test]
fn native_registry_contains_exactly_every_solana_core_surface() {
let codes = crate::native_program_ids()
.iter()
.map(crate::ProgramIdEntry::code)
.collect::<std::collections::BTreeSet<_>>();
assert!(codes.contains("vote"));
assert!(codes.contains("slashing"));
assert!(codes.contains("bpf_loader_deprecated"));
assert!(codes.contains("bpf_loader"));
assert!(codes.contains("bpf_loader_upgradeable"));
assert!(codes.contains("loader_v4"));
assert_eq!(codes.len(), 18);
assert_eq!(codes.len(), crate::native_program_ids().len());
}
#[test]
fn stake_config_is_a_well_known_account_not_an_executable_program() {
assert!(crate::native_well_known_account_ids().iter().any(|entry| {
return entry.program_id() == crate::STAKE_CONFIG_ACCOUNT_ID;
}));
assert!(!crate::native_program_ids().iter().any(|entry| {
return entry.program_id() == crate::STAKE_CONFIG_ACCOUNT_ID;
}));
}
#[test]
fn registry_lookup_finds_system_program() {
let entry = crate::find_registered_program_id(crate::SYSTEM_PROGRAM_ID);
assert_eq!(entry.map(crate::ProgramIdEntry::code), std::option::Option::Some("system"));
}
#[test]
fn compatibility_api_and_core_constants_are_complete() {
assert_eq!(crate::entries(), crate::registered_program_ids());
assert_eq!(crate::STAKE_CONFIG_PROGRAM_ID, crate::STAKE_CONFIG_ACCOUNT_ID);
let expected = [
crate::ADDRESS_LOOKUP_TABLE_PROGRAM_ID,
crate::COMPUTE_BUDGET_PROGRAM_ID,
crate::CONFIG_PROGRAM_ID,
crate::FEATURE_PROGRAM_ID,
crate::SYSTEM_PROGRAM_ID,
crate::VOTE_PROGRAM_ID,
crate::STAKE_PROGRAM_ID,
crate::SLASHING_PROGRAM_ID,
crate::ZK_ELGAMAL_PROOF_PROGRAM_ID,
crate::ZK_TOKEN_PROOF_PROGRAM_ID,
];
for program_id in expected {
assert!(crate::find_registered_program_id(program_id).is_some());
}
}
}