v0.1.0-pre.062
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
// file: kb-lib/src/materializer/admin/constants.rs
|
||||
// version: 2
|
||||
// version: 3
|
||||
|
||||
//! Local constants for the native and SPL administration materializer.
|
||||
|
||||
/// Canonical processor name for this component.
|
||||
pub(crate) const MT_ADMIN_PROCESSOR_NAME: &str = "solana_native_admin";
|
||||
pub(crate) const MT_ADMIN_PROCESSOR_NAME: &str = "materializer.admin";
|
||||
/// Canonical tracing target for this component.
|
||||
pub(crate) const TRACING_TARGET_MATERIALIZER_ADMIN: &str = "kb-lib.materializer.admin";
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
// file: kb-lib/src/materializer/admin/core.rs
|
||||
// version: 19
|
||||
// version: 20
|
||||
|
||||
//! Stable administrative projections derived from exact committed observations.
|
||||
|
||||
const ACCEPTED_FAMILIES: &[crate::MdEventFamily] =
|
||||
&[crate::MdEventFamily::Admin, crate::MdEventFamily::TokenAccount];
|
||||
const SYSTEM_SURFACE: &str = "solana_native_system";
|
||||
const SYSTEM_SURFACE: &str = "solana.core.system";
|
||||
const SYSTEM_ENTRIES: &[&str] = &["assign", "assign_with_seed"];
|
||||
const CONFIG_SURFACE: &str = "solana_native_config";
|
||||
const CONFIG_SURFACE: &str = "solana.core.config";
|
||||
const CONFIG_ENTRIES: &[&str] = &["store"];
|
||||
const BPF_LOADER_UPGRADEABLE_SURFACE: &str = "solana_native_bpf_loader_upgradeable";
|
||||
const BPF_LOADER_UPGRADEABLE_SURFACE: &str = "solana.core.bpf_loader_upgradeable";
|
||||
const BPF_LOADER_UPGRADEABLE_ENTRIES: &[&str] = &["set_authority", "set_authority_checked"];
|
||||
const LOADER_V4_SURFACE: &str = "solana_native_loader_v4";
|
||||
const LOADER_V4_SURFACE: &str = "solana.core.loader_v4";
|
||||
const LOADER_V4_ENTRIES: &[&str] = &["transfer_authority"];
|
||||
const SPL_TOKEN_SURFACE: &str = "spl_token";
|
||||
const SPL_TOKEN_2022_SURFACE: &str = "spl_token_2022";
|
||||
const SPL_ELGAMAL_REGISTRY_SURFACE: &str = "spl_elgamal_registry";
|
||||
const SPL_TOKEN_SURFACE: &str = "spl.token";
|
||||
const SPL_TOKEN_2022_SURFACE: &str = "spl.token_2022";
|
||||
const SPL_ELGAMAL_REGISTRY_SURFACE: &str = "spl.elgamal_registry";
|
||||
const SPL_ELGAMAL_REGISTRY_ENTRIES: &[&str] = &["create_registry", "update_registry"];
|
||||
const SPL_TOKEN_AUTHORITY_ENTRIES: &[&str] = &[
|
||||
"set_authority",
|
||||
@@ -56,7 +56,7 @@ impl ProjectionKind {
|
||||
Self::ProgramLoaderAuthority(_) => "program_loader_authority",
|
||||
Self::SplTokenAuthority => "spl_token_authority",
|
||||
Self::SplTokenMultisig => "spl_token_multisig",
|
||||
Self::SplElgamalRegistry => "spl_elgamal_registry",
|
||||
Self::SplElgamalRegistry => "spl.elgamal_registry",
|
||||
Self::SplToken2022ExtensionAdmin => "spl_token_2022_extension_admin",
|
||||
};
|
||||
}
|
||||
@@ -118,7 +118,7 @@ impl crate::MtMaterializer for crate::MtAdminMaterializer {
|
||||
impl crate::MtApiEventMaterializer for crate::MtAdminMaterializer {
|
||||
fn identity(&self) -> crate::MtApiMaterializerIdentity {
|
||||
return crate::MtApiMaterializerIdentity {
|
||||
name: "solana_native_admin".to_string(),
|
||||
name: "materializer.admin".to_string(),
|
||||
version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
};
|
||||
}
|
||||
@@ -505,7 +505,7 @@ mod tests {
|
||||
slot: crate::MdSlot(42),
|
||||
instruction_path: crate::MdInstructionPath("0".to_string()),
|
||||
program_id: crate::MdProgramId("program-id".to_string()),
|
||||
protocol_code: crate::MdProtocolCode("solana_native".to_string()),
|
||||
protocol_code: crate::MdProtocolCode("solana.core".to_string()),
|
||||
surface_code: crate::MdSurfaceCode(surface_code.to_string()),
|
||||
event_code: crate::MdEventCode(format!("{surface_code}.{entry_code}")),
|
||||
event_name: crate::MdEventName(entry_code.to_string()),
|
||||
@@ -717,7 +717,7 @@ mod tests {
|
||||
#[test]
|
||||
fn ata_instructions_do_not_create_admin_outputs() {
|
||||
let mut observation = observation(
|
||||
"spl_associated_token_account",
|
||||
"spl.associated_token_account",
|
||||
"create",
|
||||
false,
|
||||
serde_json::json!([]),
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// file: kb-lib/src/materializer/compliance/audit.rs
|
||||
// version: 9
|
||||
// version: 10
|
||||
|
||||
//! Stable compliance-audit projections for committed native bytecode mutations and execution profiles.
|
||||
|
||||
const ACCEPTED_FAMILIES: &[crate::MdEventFamily] = &[crate::MdEventFamily::Audit];
|
||||
const COMPUTE_BUDGET_SURFACE: &str = "solana_native_compute_budget";
|
||||
const COMPUTE_BUDGET_SURFACE: &str = "solana.core.compute_budget";
|
||||
const COMPUTE_BUDGET_ENTRIES: &[&str] = &[
|
||||
"request_units_deprecated",
|
||||
"request_heap_frame",
|
||||
@@ -12,10 +12,10 @@ const COMPUTE_BUDGET_ENTRIES: &[&str] = &[
|
||||
"set_compute_unit_price",
|
||||
"set_loaded_accounts_data_size_limit",
|
||||
];
|
||||
const BPF_LOADER_DEPRECATED_SURFACE: &str = "solana_native_bpf_loader_deprecated";
|
||||
const BPF_LOADER_SURFACE: &str = "solana_native_bpf_loader";
|
||||
const BPF_LOADER_UPGRADEABLE_SURFACE: &str = "solana_native_bpf_loader_upgradeable";
|
||||
const LOADER_V4_SURFACE: &str = "solana_native_loader_v4";
|
||||
const BPF_LOADER_DEPRECATED_SURFACE: &str = "solana.core.bpf_loader_deprecated";
|
||||
const BPF_LOADER_SURFACE: &str = "solana.core.bpf_loader";
|
||||
const BPF_LOADER_UPGRADEABLE_SURFACE: &str = "solana.core.bpf_loader_upgradeable";
|
||||
const LOADER_V4_SURFACE: &str = "solana.core.loader_v4";
|
||||
const WRITE_ENTRIES: &[&str] = &["write"];
|
||||
const LOADER_V4_COPY_ENTRIES: &[&str] = &["copy"];
|
||||
|
||||
@@ -77,7 +77,7 @@ impl crate::MtMaterializer for crate::MtComplianceAuditMaterializer {
|
||||
impl crate::MtApiEventMaterializer for crate::MtComplianceAuditMaterializer {
|
||||
fn identity(&self) -> crate::MtApiMaterializerIdentity {
|
||||
return crate::MtApiMaterializerIdentity {
|
||||
name: "solana_native_compliance_audit".to_string(),
|
||||
name: "materializer.compliance.audit".to_string(),
|
||||
version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
};
|
||||
}
|
||||
@@ -357,7 +357,7 @@ mod tests {
|
||||
slot: crate::MdSlot(42),
|
||||
instruction_path: crate::MdInstructionPath("0".to_string()),
|
||||
program_id: crate::MdProgramId("program-id".to_string()),
|
||||
protocol_code: crate::MdProtocolCode("solana_native".to_string()),
|
||||
protocol_code: crate::MdProtocolCode("solana.core".to_string()),
|
||||
surface_code: crate::MdSurfaceCode(surface_code.to_string()),
|
||||
event_code: crate::MdEventCode(format!("{surface_code}.{entry_code}")),
|
||||
event_name: crate::MdEventName(entry_code.to_string()),
|
||||
@@ -438,7 +438,7 @@ mod tests {
|
||||
let result = crate::MtApiEventMaterializer::materialize(&materializer, &observation);
|
||||
assert_eq!(
|
||||
result.outputs[0].output_key,
|
||||
"program_loader_code:solana_native_loader_v4:copy:0"
|
||||
"program_loader_code:solana.core.loader_v4:copy:0"
|
||||
);
|
||||
assert_eq!(
|
||||
result.outputs[0].payload_json["projection"]["sourceProgramAccount"],
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// file: kb-lib/src/materializer/fees/core.rs
|
||||
// version: 4
|
||||
// version: 5
|
||||
|
||||
//! Stable fee projections derived from exact committed Token-2022 observations.
|
||||
|
||||
const ACCEPTED_FAMILIES: &[crate::MdEventFamily] = &[crate::MdEventFamily::Fee];
|
||||
const SPL_TOKEN_2022_SURFACE: &str = "spl_token_2022";
|
||||
const SPL_TOKEN_2022_SURFACE: &str = "spl.token_2022";
|
||||
const TOKEN_2022_FEE_ENTRIES: &[&str] = &[
|
||||
"initialize_transfer_fee_config",
|
||||
"set_transfer_fee",
|
||||
@@ -46,7 +46,7 @@ impl crate::MtMaterializer for crate::MtFeesMaterializer {
|
||||
impl crate::MtApiEventMaterializer for crate::MtFeesMaterializer {
|
||||
fn identity(&self) -> crate::MtApiMaterializerIdentity {
|
||||
return crate::MtApiMaterializerIdentity {
|
||||
name: "fees".to_string(),
|
||||
name: "materializer.fees".to_string(),
|
||||
version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
};
|
||||
}
|
||||
@@ -218,7 +218,7 @@ pub fn materializer_fees_materialize_token_2022_state_snapshots(
|
||||
"confidentialValuesDecrypted": false,
|
||||
"finalAccountStateCaptured": true,
|
||||
"provenance": {
|
||||
"processorName": "fees",
|
||||
"processorName": "materializer.fees",
|
||||
"processorVersion": env!("CARGO_PKG_VERSION"),
|
||||
"source": "bounded_token_2022_state_parser"
|
||||
}
|
||||
@@ -243,7 +243,7 @@ mod tests {
|
||||
slot: crate::MdSlot(42),
|
||||
instruction_path: crate::MdInstructionPath("0".to_string()),
|
||||
program_id: crate::MdProgramId(program_id.to_string()),
|
||||
protocol_code: crate::MdProtocolCode("spl_token_2022".to_string()),
|
||||
protocol_code: crate::MdProtocolCode("spl.token_2022".to_string()),
|
||||
surface_code: crate::MdSurfaceCode(surface_code.to_string()),
|
||||
event_code: crate::MdEventCode(format!("{surface_code}.{entry_code}")),
|
||||
event_name: crate::MdEventName(entry_code.to_string()),
|
||||
@@ -304,7 +304,7 @@ mod tests {
|
||||
#[test]
|
||||
fn classic_token_and_program_surface_mismatches_are_ignored() {
|
||||
let classic = observation(
|
||||
"spl_token",
|
||||
"spl.token",
|
||||
kb_program_ids::SPL_TOKEN_PROGRAM_ID,
|
||||
"set_transfer_fee",
|
||||
false,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: kb-lib/src/materializer/lifecycle/core.rs
|
||||
// version: 15
|
||||
// version: 16
|
||||
|
||||
//! Stable lifecycle projections derived from exact decoded observations.
|
||||
|
||||
@@ -8,7 +8,7 @@ const ACCEPTED_FAMILIES: &[crate::MdEventFamily] = &[
|
||||
crate::MdEventFamily::Admin,
|
||||
crate::MdEventFamily::Audit,
|
||||
];
|
||||
const ADDRESS_LOOKUP_TABLE_SURFACE: &str = "solana_native_address_lookup_table";
|
||||
const ADDRESS_LOOKUP_TABLE_SURFACE: &str = "solana.core.address_lookup_table";
|
||||
const ADDRESS_LOOKUP_TABLE_ENTRIES: &[&str] = &[
|
||||
"create_lookup_table",
|
||||
"freeze_lookup_table",
|
||||
@@ -16,11 +16,11 @@ const ADDRESS_LOOKUP_TABLE_ENTRIES: &[&str] = &[
|
||||
"deactivate_lookup_table",
|
||||
"close_lookup_table",
|
||||
];
|
||||
const BPF_LOADER_DEPRECATED_SURFACE: &str = "solana_native_bpf_loader_deprecated";
|
||||
const BPF_LOADER_SURFACE: &str = "solana_native_bpf_loader";
|
||||
const BPF_LOADER_UPGRADEABLE_SURFACE: &str = "solana_native_bpf_loader_upgradeable";
|
||||
const LOADER_V4_SURFACE: &str = "solana_native_loader_v4";
|
||||
const FEATURE_SURFACE: &str = "solana_native_feature";
|
||||
const BPF_LOADER_DEPRECATED_SURFACE: &str = "solana.core.bpf_loader_deprecated";
|
||||
const BPF_LOADER_SURFACE: &str = "solana.core.bpf_loader";
|
||||
const BPF_LOADER_UPGRADEABLE_SURFACE: &str = "solana.core.bpf_loader_upgradeable";
|
||||
const LOADER_V4_SURFACE: &str = "solana.core.loader_v4";
|
||||
const FEATURE_SURFACE: &str = "solana.core.feature";
|
||||
const FEATURE_ENTRIES: &[&str] = &["revoke_pending_activation"];
|
||||
const IMMUTABLE_LOADER_ENTRIES: &[&str] = &["finalize"];
|
||||
const UPGRADEABLE_LOADER_ENTRIES: &[&str] = &[
|
||||
@@ -31,9 +31,9 @@ const UPGRADEABLE_LOADER_ENTRIES: &[&str] = &[
|
||||
"extend_program",
|
||||
];
|
||||
const LOADER_V4_ENTRIES: &[&str] = &["set_program_length", "deploy", "retract", "finalize"];
|
||||
const SLASHING_SURFACE: &str = "solana_native_slashing";
|
||||
const SLASHING_SURFACE: &str = "solana.core.slashing";
|
||||
const SLASHING_ENTRIES: &[&str] = &["close_violation_report", "duplicate_block_proof"];
|
||||
const SYSTEM_SURFACE: &str = "solana_native_system";
|
||||
const SYSTEM_SURFACE: &str = "solana.core.system";
|
||||
const SYSTEM_ACCOUNT_ENTRIES: &[&str] = &[
|
||||
"create_account",
|
||||
"create_account_with_seed",
|
||||
@@ -48,7 +48,7 @@ const SYSTEM_NONCE_ENTRIES: &[&str] = &[
|
||||
"authorize_nonce_account",
|
||||
"upgrade_nonce_account",
|
||||
];
|
||||
const ZK_ELGAMAL_PROOF_SURFACE: &str = "solana_native_zk_elgamal_proof";
|
||||
const ZK_ELGAMAL_PROOF_SURFACE: &str = "solana.core.zk_elgamal_proof";
|
||||
const ZK_ELGAMAL_CLOSE_ENTRIES: &[&str] = &["close_context_state"];
|
||||
const ZK_ELGAMAL_VERIFY_ENTRIES: &[&str] = &[
|
||||
"verify_zero_ciphertext",
|
||||
@@ -152,7 +152,7 @@ impl crate::MtMaterializer for crate::MtLifecycleMaterializer {
|
||||
impl crate::MtApiEventMaterializer for crate::MtLifecycleMaterializer {
|
||||
fn identity(&self) -> crate::MtApiMaterializerIdentity {
|
||||
return crate::MtApiMaterializerIdentity {
|
||||
name: "solana_native_lifecycle".to_string(),
|
||||
name: "materializer.lifecycle".to_string(),
|
||||
version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
};
|
||||
}
|
||||
@@ -491,7 +491,7 @@ mod tests {
|
||||
slot: crate::MdSlot(42),
|
||||
instruction_path: crate::MdInstructionPath("0".to_string()),
|
||||
program_id: crate::MdProgramId("program-id".to_string()),
|
||||
protocol_code: crate::MdProtocolCode("solana_native".to_string()),
|
||||
protocol_code: crate::MdProtocolCode("solana.core".to_string()),
|
||||
surface_code: crate::MdSurfaceCode(surface_code.to_string()),
|
||||
event_code: crate::MdEventCode(format!("{surface_code}.{entry_code}")),
|
||||
event_name: crate::MdEventName(entry_code.to_string()),
|
||||
@@ -656,7 +656,7 @@ mod tests {
|
||||
assert_eq!(result.status, crate::MtApiMaterializerOutcomeStatus::Inserted);
|
||||
assert_eq!(
|
||||
result.outputs[0].output_key,
|
||||
"program_loader:solana_native_bpf_loader_upgradeable:deploy_with_max_data_len:0"
|
||||
"program_loader:solana.core.bpf_loader_upgradeable:deploy_with_max_data_len:0"
|
||||
);
|
||||
assert_eq!(result.outputs[0].payload_json["domain"], "program_loader");
|
||||
assert_eq!(
|
||||
@@ -879,7 +879,7 @@ mod tests {
|
||||
fn historical_zk_token_proof_is_not_materialized() {
|
||||
let materializer = crate::MtLifecycleMaterializer;
|
||||
let observation = observation_with_payload(
|
||||
"solana_native_zk_token_proof",
|
||||
"solana.core.zk_token_proof",
|
||||
"close_context_state",
|
||||
crate::MdEventFamily::Audit,
|
||||
false,
|
||||
@@ -915,7 +915,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn ata_lifecycle_is_owned_by_token_accounts_materializer_only() {
|
||||
let mut observation = observation("spl_associated_token_account", "create", false);
|
||||
let mut observation = observation("spl.associated_token_account", "create", false);
|
||||
observation.event.program_id =
|
||||
crate::MdProgramId(kb_program_ids::ASSOCIATED_TOKEN_PROGRAM_ID.to_string());
|
||||
assert!(!crate::MtApiEventMaterializer::accepts_observation(
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// file: kb-lib/src/materializer/risk/constants.rs
|
||||
// version: 2
|
||||
// version: 3
|
||||
|
||||
//! Local constants for fact-only risk projections.
|
||||
|
||||
/// Stable processor name persisted by the replay ledger.
|
||||
pub(crate) const MT_RISK_PROCESSOR_NAME: &str = "spl_token_risk";
|
||||
pub(crate) const MT_RISK_PROCESSOR_NAME: &str = "materializer.risk";
|
||||
/// Stable projection payload contract version.
|
||||
pub(crate) const MT_RISK_PROJECTION_VERSION: u32 = 2;
|
||||
/// Canonical tracing target for this component.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: kb-lib/src/materializer/risk/core.rs
|
||||
// version: 5
|
||||
// version: 6
|
||||
|
||||
//! Stable fact-only risk projections for committed SPL Token and ATA observations.
|
||||
|
||||
@@ -168,9 +168,9 @@ impl crate::MtApiEventMaterializer for crate::MtRiskMaterializer {
|
||||
|
||||
fn accepts_event(event: &crate::MdDecodedProtocolEvent) -> bool {
|
||||
let token_program = (event.program_id.0 == kb_program_ids::SPL_TOKEN_PROGRAM_ID
|
||||
&& event.surface_code.0 == "spl_token")
|
||||
&& event.surface_code.0 == "spl.token")
|
||||
|| (event.program_id.0 == kb_program_ids::SPL_TOKEN_2022_PROGRAM_ID
|
||||
&& event.surface_code.0 == "spl_token_2022");
|
||||
&& event.surface_code.0 == "spl.token_2022");
|
||||
let token_risk = token_program && RISK_ENTRIES.contains(&event.event_name.0.as_str());
|
||||
return ACCEPTED_FAMILIES.contains(&event.event_family)
|
||||
&& (token_risk || is_ata_recovery(event));
|
||||
@@ -178,7 +178,7 @@ fn accepts_event(event: &crate::MdDecodedProtocolEvent) -> bool {
|
||||
|
||||
fn is_ata_recovery(event: &crate::MdDecodedProtocolEvent) -> bool {
|
||||
return event.program_id.0 == kb_program_ids::ASSOCIATED_TOKEN_PROGRAM_ID
|
||||
&& event.surface_code.0 == "spl_associated_token_account"
|
||||
&& event.surface_code.0 == "spl.associated_token_account"
|
||||
&& event.event_family == crate::MdEventFamily::Lifecycle
|
||||
&& event.event_name.0 == "recover_nested";
|
||||
}
|
||||
@@ -312,9 +312,9 @@ mod tests {
|
||||
slot: crate::MdSlot(1),
|
||||
instruction_path: crate::MdInstructionPath("0".to_string()),
|
||||
program_id: crate::MdProgramId(kb_program_ids::SPL_TOKEN_PROGRAM_ID.to_string()),
|
||||
protocol_code: crate::MdProtocolCode("spl_token".to_string()),
|
||||
surface_code: crate::MdSurfaceCode("spl_token".to_string()),
|
||||
event_code: crate::MdEventCode(format!("spl_token.{entry}")),
|
||||
protocol_code: crate::MdProtocolCode("spl.token".to_string()),
|
||||
surface_code: crate::MdSurfaceCode("spl.token".to_string()),
|
||||
event_code: crate::MdEventCode(format!("spl.token.{entry}")),
|
||||
event_name: crate::MdEventName(entry.to_string()),
|
||||
event_family: family,
|
||||
source_kind: crate::MdEventSourceKind::Instruction,
|
||||
@@ -341,9 +341,9 @@ mod tests {
|
||||
let mut observation = observation(entry, family, parameters, failed);
|
||||
observation.event.program_id =
|
||||
crate::MdProgramId(kb_program_ids::SPL_TOKEN_2022_PROGRAM_ID.to_string());
|
||||
observation.event.protocol_code = crate::MdProtocolCode("spl_token_2022".to_string());
|
||||
observation.event.surface_code = crate::MdSurfaceCode("spl_token_2022".to_string());
|
||||
observation.event.event_code = crate::MdEventCode(format!("spl_token_2022.{entry}"));
|
||||
observation.event.protocol_code = crate::MdProtocolCode("spl.token_2022".to_string());
|
||||
observation.event.surface_code = crate::MdSurfaceCode("spl.token_2022".to_string());
|
||||
observation.event.event_code = crate::MdEventCode(format!("spl.token_2022.{entry}"));
|
||||
observation.event_key = format!("token_2022:{entry}:0");
|
||||
return observation;
|
||||
}
|
||||
@@ -358,10 +358,10 @@ mod tests {
|
||||
program_id: crate::MdProgramId(
|
||||
kb_program_ids::ASSOCIATED_TOKEN_PROGRAM_ID.to_string(),
|
||||
),
|
||||
protocol_code: crate::MdProtocolCode("spl_associated_token_account".to_string()),
|
||||
surface_code: crate::MdSurfaceCode("spl_associated_token_account".to_string()),
|
||||
protocol_code: crate::MdProtocolCode("spl.associated_token_account".to_string()),
|
||||
surface_code: crate::MdSurfaceCode("spl.associated_token_account".to_string()),
|
||||
event_code: crate::MdEventCode(
|
||||
"spl_associated_token_account.recover_nested".to_string(),
|
||||
"spl.associated_token_account.recover_nested".to_string(),
|
||||
),
|
||||
event_name: crate::MdEventName("recover_nested".to_string()),
|
||||
event_family: crate::MdEventFamily::Lifecycle,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: kb-lib/src/materializer/staking/core.rs
|
||||
// version: 9
|
||||
// version: 10
|
||||
|
||||
//! Instruction-level staking projections for native Stake and Vote observations.
|
||||
|
||||
@@ -9,8 +9,8 @@ const ACCEPTED_FAMILIES: &[crate::MdEventFamily] = &[
|
||||
crate::MdEventFamily::Staking,
|
||||
crate::MdEventFamily::Reward,
|
||||
];
|
||||
const STAKE_SURFACE: &str = "solana_native_stake";
|
||||
const VOTE_SURFACE: &str = "solana_native_vote";
|
||||
const STAKE_SURFACE: &str = "solana.core.stake";
|
||||
const VOTE_SURFACE: &str = "solana.core.vote";
|
||||
const STAKE_ACCOUNT_ENTRIES: &[&str] = &[
|
||||
"initialize",
|
||||
"initialize_checked",
|
||||
@@ -126,7 +126,7 @@ impl crate::MtMaterializer for crate::MtStakingMaterializer {
|
||||
impl crate::MtApiEventMaterializer for crate::MtStakingMaterializer {
|
||||
fn identity(&self) -> crate::MtApiMaterializerIdentity {
|
||||
return crate::MtApiMaterializerIdentity {
|
||||
name: "solana_native_staking".to_string(),
|
||||
name: "materializer.staking".to_string(),
|
||||
version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
};
|
||||
}
|
||||
@@ -605,7 +605,7 @@ mod tests {
|
||||
slot: crate::MdSlot(42),
|
||||
instruction_path: crate::MdInstructionPath("0".to_string()),
|
||||
program_id: crate::MdProgramId("program-id".to_string()),
|
||||
protocol_code: crate::MdProtocolCode("solana_native".to_string()),
|
||||
protocol_code: crate::MdProtocolCode("solana.core".to_string()),
|
||||
surface_code: crate::MdSurfaceCode(surface_code.to_string()),
|
||||
event_code: crate::MdEventCode(format!("{surface_code}.{entry_code}")),
|
||||
event_name: crate::MdEventName(entry_code.to_string()),
|
||||
@@ -821,7 +821,7 @@ mod tests {
|
||||
fn unrelated_or_disabled_observations_are_ignored() {
|
||||
let materializer = crate::MtStakingMaterializer;
|
||||
let unrelated = observation(
|
||||
"solana_native_system",
|
||||
"solana.core.system",
|
||||
"create_account",
|
||||
crate::MdEventFamily::Lifecycle,
|
||||
false,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: kb-lib/src/materializer/token/accounts.rs
|
||||
// version: 6
|
||||
// version: 7
|
||||
|
||||
//! Stable committed SPL Token mutation and ATA lifecycle projections.
|
||||
|
||||
@@ -174,9 +174,9 @@ impl crate::MtApiEventMaterializer for crate::MtTokenAccountsMaterializer {
|
||||
|
||||
fn accepts_event(event: &crate::MdDecodedProtocolEvent) -> bool {
|
||||
let token_program = (event.program_id.0 == kb_program_ids::SPL_TOKEN_PROGRAM_ID
|
||||
&& event.surface_code.0 == "spl_token")
|
||||
&& event.surface_code.0 == "spl.token")
|
||||
|| (event.program_id.0 == kb_program_ids::SPL_TOKEN_2022_PROGRAM_ID
|
||||
&& event.surface_code.0 == "spl_token_2022");
|
||||
&& event.surface_code.0 == "spl.token_2022");
|
||||
let token_mutation = token_program && MUTATION_ENTRIES.contains(&event.event_name.0.as_str());
|
||||
let ata = is_ata_event(event);
|
||||
return ACCEPTED_FAMILIES.contains(&event.event_family) && (token_mutation || ata);
|
||||
@@ -184,7 +184,7 @@ fn accepts_event(event: &crate::MdDecodedProtocolEvent) -> bool {
|
||||
|
||||
fn is_ata_event(event: &crate::MdDecodedProtocolEvent) -> bool {
|
||||
return event.program_id.0 == kb_program_ids::ASSOCIATED_TOKEN_PROGRAM_ID
|
||||
&& event.surface_code.0 == "spl_associated_token_account"
|
||||
&& event.surface_code.0 == "spl.associated_token_account"
|
||||
&& event.event_family == crate::MdEventFamily::Lifecycle
|
||||
&& ATA_LIFECYCLE_ENTRIES
|
||||
.iter()
|
||||
@@ -474,9 +474,9 @@ mod tests {
|
||||
slot: crate::MdSlot(42),
|
||||
instruction_path: crate::MdInstructionPath("1/0".to_string()),
|
||||
program_id: crate::MdProgramId(kb_program_ids::SPL_TOKEN_PROGRAM_ID.to_string()),
|
||||
protocol_code: crate::MdProtocolCode("spl_token".to_string()),
|
||||
surface_code: crate::MdSurfaceCode("spl_token".to_string()),
|
||||
event_code: crate::MdEventCode(format!("spl_token.{entry}")),
|
||||
protocol_code: crate::MdProtocolCode("spl.token".to_string()),
|
||||
surface_code: crate::MdSurfaceCode("spl.token".to_string()),
|
||||
event_code: crate::MdEventCode(format!("spl.token.{entry}")),
|
||||
event_name: crate::MdEventName(entry.to_string()),
|
||||
event_family: family,
|
||||
source_kind: crate::MdEventSourceKind::InnerInstruction,
|
||||
@@ -510,9 +510,9 @@ mod tests {
|
||||
let mut observation = observation(entry, family, failed);
|
||||
observation.event.program_id =
|
||||
crate::MdProgramId(kb_program_ids::SPL_TOKEN_2022_PROGRAM_ID.to_string());
|
||||
observation.event.protocol_code = crate::MdProtocolCode("spl_token_2022".to_string());
|
||||
observation.event.surface_code = crate::MdSurfaceCode("spl_token_2022".to_string());
|
||||
observation.event.event_code = crate::MdEventCode(format!("spl_token_2022.{entry}"));
|
||||
observation.event.protocol_code = crate::MdProtocolCode("spl.token_2022".to_string());
|
||||
observation.event.surface_code = crate::MdSurfaceCode("spl.token_2022".to_string());
|
||||
observation.event.event_code = crate::MdEventCode(format!("spl.token_2022.{entry}"));
|
||||
observation.event_key = format!("token_2022:{entry}:0");
|
||||
return observation;
|
||||
}
|
||||
@@ -554,9 +554,9 @@ mod tests {
|
||||
program_id: crate::MdProgramId(
|
||||
kb_program_ids::ASSOCIATED_TOKEN_PROGRAM_ID.to_string(),
|
||||
),
|
||||
protocol_code: crate::MdProtocolCode("spl_associated_token_account".to_string()),
|
||||
surface_code: crate::MdSurfaceCode("spl_associated_token_account".to_string()),
|
||||
event_code: crate::MdEventCode(format!("spl_associated_token_account.{entry}")),
|
||||
protocol_code: crate::MdProtocolCode("spl.associated_token_account".to_string()),
|
||||
surface_code: crate::MdSurfaceCode("spl.associated_token_account".to_string()),
|
||||
event_code: crate::MdEventCode(format!("spl.associated_token_account.{entry}")),
|
||||
event_name: crate::MdEventName(entry.to_string()),
|
||||
event_family: crate::MdEventFamily::Lifecycle,
|
||||
source_kind: crate::MdEventSourceKind::Instruction,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// file: kb-lib/src/materializer/token/constants.rs
|
||||
// version: 2
|
||||
// version: 3
|
||||
|
||||
//! Local constants for classic SPL Token account projections.
|
||||
|
||||
/// Stable processor name persisted by the replay ledger.
|
||||
pub(crate) const MT_TOKEN_ACCOUNTS_PROCESSOR_NAME: &str = "spl_token_accounts";
|
||||
pub(crate) const MT_TOKEN_ACCOUNTS_PROCESSOR_NAME: &str = "materializer.token.accounts";
|
||||
/// Stable projection payload contract version.
|
||||
pub(crate) const MT_TOKEN_ACCOUNTS_PROJECTION_VERSION: u32 = 3;
|
||||
/// Canonical tracing target for this component.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: kb-lib/src/materializer/transaction/annotations.rs
|
||||
// version: 4
|
||||
// version: 5
|
||||
|
||||
//! Exact committed SPL Memo transaction annotation projection.
|
||||
|
||||
@@ -16,17 +16,17 @@ enum MemoGeneration {
|
||||
impl MemoGeneration {
|
||||
fn from_event(event: &crate::MdDecodedProtocolEvent) -> std::option::Option<Self> {
|
||||
if event.program_id.0 == kb_program_ids::SPL_MEMO_V1_PROGRAM_ID
|
||||
&& event.surface_code.0 == "spl_memo_v1"
|
||||
&& event.surface_code.0 == "spl.memo.v1"
|
||||
{
|
||||
return std::option::Option::Some(Self::V1);
|
||||
}
|
||||
if event.program_id.0 == kb_program_ids::SPL_MEMO_V3_PROGRAM_ID
|
||||
&& event.surface_code.0 == "spl_memo_v3"
|
||||
&& event.surface_code.0 == "spl.memo.v3"
|
||||
{
|
||||
return std::option::Option::Some(Self::V3);
|
||||
}
|
||||
if event.program_id.0 == kb_program_ids::SPL_MEMO_V4_PROGRAM_ID
|
||||
&& event.surface_code.0 == "spl_memo_v4"
|
||||
&& event.surface_code.0 == "spl.memo.v4"
|
||||
{
|
||||
return std::option::Option::Some(Self::V4);
|
||||
}
|
||||
@@ -147,7 +147,7 @@ impl crate::MtApiEventMaterializer for crate::MtTransactionAnnotationMaterialize
|
||||
payload_json: serde_json::json!({
|
||||
"projectionVersion": crate::MT_TRANSACTION_ANNOTATIONS_PROJECTION_VERSION,
|
||||
"domain": "transaction_annotation",
|
||||
"annotationKind": "spl_memo",
|
||||
"annotationKind": "spl.memo",
|
||||
"idempotenceKey": idempotence_key,
|
||||
"signature": observation.event.signature.0.clone(),
|
||||
"slot": observation.event.slot.0,
|
||||
@@ -199,7 +199,7 @@ impl crate::MtApiEventMaterializer for crate::MtTransactionAnnotationMaterialize
|
||||
|
||||
fn accepts_event(event: &crate::MdDecodedProtocolEvent) -> bool {
|
||||
return event.event_family == crate::MdEventFamily::Audit
|
||||
&& event.protocol_code.0 == "spl_memo"
|
||||
&& event.protocol_code.0 == "spl.memo"
|
||||
&& (event.source_kind == crate::MdEventSourceKind::Instruction
|
||||
|| event.source_kind == crate::MdEventSourceKind::InnerInstruction)
|
||||
&& MemoGeneration::from_event(event).is_some()
|
||||
@@ -416,7 +416,7 @@ mod tests {
|
||||
slot: crate::MdSlot(42),
|
||||
instruction_path: crate::MdInstructionPath("1/0".to_string()),
|
||||
program_id: crate::MdProgramId(program_id.to_string()),
|
||||
protocol_code: crate::MdProtocolCode("spl_memo".to_string()),
|
||||
protocol_code: crate::MdProtocolCode("spl.memo".to_string()),
|
||||
surface_code: crate::MdSurfaceCode(surface_code.to_string()),
|
||||
event_code: crate::MdEventCode(format!("{surface_code}.{event_name}")),
|
||||
event_name: crate::MdEventName(event_name.to_string()),
|
||||
@@ -465,7 +465,7 @@ mod tests {
|
||||
fn v4() -> crate::DcApiDecodedObservation {
|
||||
return observation(
|
||||
kb_program_ids::SPL_MEMO_V4_PROGRAM_ID,
|
||||
"spl_memo_v4",
|
||||
"spl.memo.v4",
|
||||
"v4",
|
||||
"add_memo",
|
||||
false,
|
||||
@@ -498,9 +498,9 @@ mod tests {
|
||||
#[test]
|
||||
fn exact_v1_v3_and_v4_surfaces_are_accepted() {
|
||||
for (program_id, surface, generation) in [
|
||||
(kb_program_ids::SPL_MEMO_V1_PROGRAM_ID, "spl_memo_v1", "v1"),
|
||||
(kb_program_ids::SPL_MEMO_V3_PROGRAM_ID, "spl_memo_v3", "v3"),
|
||||
(kb_program_ids::SPL_MEMO_V4_PROGRAM_ID, "spl_memo_v4", "v4"),
|
||||
(kb_program_ids::SPL_MEMO_V1_PROGRAM_ID, "spl.memo.v1", "v1"),
|
||||
(kb_program_ids::SPL_MEMO_V3_PROGRAM_ID, "spl.memo.v3", "v3"),
|
||||
(kb_program_ids::SPL_MEMO_V4_PROGRAM_ID, "spl.memo.v4", "v4"),
|
||||
] {
|
||||
let observation = observation(
|
||||
program_id,
|
||||
@@ -523,7 +523,7 @@ mod tests {
|
||||
fn v1_observed_accounts_are_not_claimed_as_runtime_verified() {
|
||||
let observation = observation(
|
||||
kb_program_ids::SPL_MEMO_V1_PROGRAM_ID,
|
||||
"spl_memo_v1",
|
||||
"spl.memo.v1",
|
||||
"v1",
|
||||
"add_memo",
|
||||
false,
|
||||
@@ -546,7 +546,7 @@ mod tests {
|
||||
fn failed_or_uncommitted_memo_is_refused_without_output() {
|
||||
let observation = observation(
|
||||
kb_program_ids::SPL_MEMO_V4_PROGRAM_ID,
|
||||
"spl_memo_v4",
|
||||
"spl.memo.v4",
|
||||
"v4",
|
||||
"memo_intent",
|
||||
true,
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// file: kb-lib/src/materializer/transaction/constants.rs
|
||||
// version: 2
|
||||
// version: 3
|
||||
|
||||
//! Local constants for the transaction annotation materializer.
|
||||
|
||||
/// Maximum Memo payload accepted from the decoded contract.
|
||||
pub(crate) const MT_TRANSACTION_ANNOTATIONS_MAX_MEMO_PAYLOAD_BYTES: u64 = 4_096;
|
||||
/// Stable materializer processor name.
|
||||
pub(crate) const MT_TRANSACTION_ANNOTATIONS_PROCESSOR_NAME: &str = "transaction_annotations";
|
||||
pub(crate) const MT_TRANSACTION_ANNOTATIONS_PROCESSOR_NAME: &str =
|
||||
"materializer.transaction.annotations";
|
||||
/// Stable projection contract version.
|
||||
pub(crate) const MT_TRANSACTION_ANNOTATIONS_PROJECTION_VERSION: u32 = 1;
|
||||
/// Canonical tracing target for this component.
|
||||
|
||||
Reference in New Issue
Block a user