0.1.0
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
# file: kb_executor_spl_single_pool/Cargo.toml
|
||||
# version: 2
|
||||
|
||||
[package]
|
||||
name = "kb_executor_spl_single_pool"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish.workspace = true
|
||||
|
||||
[dependencies]
|
||||
kb_core = { path = "../kb_core" }
|
||||
kb_execution_api = { path = "../kb_execution_api" }
|
||||
kb_model = { path = "../kb_model" }
|
||||
kb_program_ids = { path = "../kb_program_ids" }
|
||||
serde_json.workspace = true
|
||||
tracing.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
@@ -0,0 +1,14 @@
|
||||
<!-- file: kb_executor_spl_single_pool/README.md -->
|
||||
<!-- version: 1 -->
|
||||
|
||||
# kb_executor_spl_single_pool
|
||||
|
||||
Ce crate réserve l’exécuteur pour le programme SPL Single Pool.
|
||||
|
||||
## Rôle
|
||||
|
||||
Il construira des instructions ou plans d’exécution indépendamment du décodeur correspondant. Le scaffold actuel ne signe, ne simule et n’envoie aucune transaction.
|
||||
|
||||
## Statut
|
||||
|
||||
L’exécuteur reconnaît uniquement ses program IDs vérifiés et retourne un plan réservé contenant zéro instruction. Les builders, contrôles de comptes, simulations et garde-fous seront ajoutés dans la version SPL dédiée du `ROADMAP.md`.
|
||||
@@ -0,0 +1,7 @@
|
||||
// file: kb_executor_spl_single_pool/src/constants.rs
|
||||
// version: 2
|
||||
|
||||
//! Local constants for the `kb_executor_spl_single_pool` crate. Program identifiers live in `kb_program_ids`.
|
||||
|
||||
/// Canonical tracing target for this crate.
|
||||
pub(crate) const TRACING_TARGET: &str = "kb_executor_spl_single_pool";
|
||||
@@ -0,0 +1,92 @@
|
||||
// file: kb_executor_spl_single_pool/src/executor.rs
|
||||
// version: 5
|
||||
|
||||
//! Reserved executor for the `spl_single_pool` surface.
|
||||
|
||||
/// Reserved executor implementation for the verified program surface.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct SplSinglePoolExecutor;
|
||||
|
||||
impl kb_execution_api::InstructionExecutor for crate::SplSinglePoolExecutor {
|
||||
fn executor_name(&self) -> &'static str {
|
||||
return "kb_executor_spl_single_pool";
|
||||
}
|
||||
|
||||
fn executor_version(&self) -> &'static str {
|
||||
return env!("CARGO_PKG_VERSION");
|
||||
}
|
||||
|
||||
fn program_ids(&self) -> &'static [&'static str] {
|
||||
return &[kb_program_ids::SPL_SINGLE_POOL_PROGRAM_ID];
|
||||
}
|
||||
|
||||
fn supports_request(
|
||||
&self,
|
||||
request: &kb_execution_api::ExecutionRequest,
|
||||
) -> kb_execution_api::ExecutionSupport {
|
||||
if kb_execution_api::InstructionExecutor::handles_program_id(self, &request.program_id) {
|
||||
return kb_execution_api::ExecutionSupport::Maybe;
|
||||
}
|
||||
return kb_execution_api::ExecutionSupport::No;
|
||||
}
|
||||
|
||||
fn build_plan(
|
||||
&self,
|
||||
request: &kb_execution_api::ExecutionRequest,
|
||||
) -> kb_core::Result<kb_execution_api::ExecutionPlan> {
|
||||
tracing::debug!(
|
||||
target: crate::TRACING_TARGET,
|
||||
action = "build_reserved_execution_plan",
|
||||
executor_name = "kb_executor_spl_single_pool",
|
||||
program_id = %request.program_id.0.as_str(),
|
||||
operation_code = %request.operation_code,
|
||||
instruction_count = 0_usize,
|
||||
"build reserved SPL execution plan"
|
||||
);
|
||||
return std::result::Result::Ok(kb_execution_api::ExecutionPlan {
|
||||
executor_name: std::string::String::from("kb_executor_spl_single_pool"),
|
||||
instruction_count: 0,
|
||||
payload_json: match kb_execution_api::serialize_payload_json(
|
||||
&serde_json::json!({"status":"reserved_executor","surface":"spl_single_pool"}),
|
||||
) {
|
||||
std::result::Result::Ok(serialized) => serialized,
|
||||
std::result::Result::Err(error) => return std::result::Result::Err(error),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
fn request(program_id: &str) -> kb_execution_api::ExecutionRequest {
|
||||
return kb_execution_api::ExecutionRequest {
|
||||
program_id: kb_model::ProgramId(program_id.to_string()),
|
||||
operation_code: "reserved".to_string(),
|
||||
payload_json: "{}".to_string(),
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exposes_only_registered_program_ids() {
|
||||
let executor = crate::SplSinglePoolExecutor;
|
||||
let program_ids = kb_execution_api::InstructionExecutor::program_ids(&executor);
|
||||
assert_eq!(program_ids.len(), 1);
|
||||
for program_id in program_ids {
|
||||
assert!(kb_program_ids::find_registered_program_id(program_id).is_some());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reserved_plan_never_contains_instructions() {
|
||||
let executor = crate::SplSinglePoolExecutor;
|
||||
let program_id = kb_execution_api::InstructionExecutor::program_ids(&executor)[0];
|
||||
let result =
|
||||
kb_execution_api::InstructionExecutor::build_plan(&executor, &request(program_id));
|
||||
let plan = match result {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => panic!("reserved plan failed: {error}"),
|
||||
};
|
||||
assert_eq!(plan.instruction_count, 0);
|
||||
assert!(plan.payload_json.contains("reserved_executor"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// file: kb_executor_spl_single_pool/src/lib.rs
|
||||
// version: 3
|
||||
|
||||
//! Executor crate for `spl_single_pool`.
|
||||
#![warn(missing_docs)]
|
||||
#![deny(unreachable_pub)]
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
mod constants;
|
||||
mod executor;
|
||||
|
||||
/// Canonical tracing target for this crate.
|
||||
pub(crate) use crate::constants::TRACING_TARGET;
|
||||
|
||||
/// Exposes the reserved executor type implemented by this crate.
|
||||
pub use crate::executor::SplSinglePoolExecutor;
|
||||
Reference in New Issue
Block a user