Skip to content

EventPublisher's 2-topic layout violates the documented 3-topic convention: the "canonical" publisher would emit events indexers cannot parse #519

Description

@usmanimamu17-create

Problem

src/event.rs — the module that claims "Events are always published through this struct to ensure consistent topic layout" — uses a 2-topic layout:

// src/event.rs, EventPublisher::publish_calculation_executed
env.events().publish((topic, input_key), payload);

Every emitted event follows the documented 3-topic convention (name, version, context — see src/event_schema.rs): (EVENT_SLA_CALC, EVENT_VERSION, severity). The dead EventPublisher (companion issue) publishes (topic, input_key) — no version topic.

Consequences:

  • The documented convention and the "canonical" publisher disagree: if a contributor wired the contract to use EventPublisher (the module's stated role), every event it emitted would have 2 topics, breaking indexers that parse the 3-topic schema (topic[1] = version) — the exact consistency the module promises.
  • CalculationExecutedEventV1's payload shape also matches nothing emitted (companion issue): the dead publisher is wrong on both topics and payload, making it a misleading reference implementation.
  • The versioning protocol is bypassable by accident: the 3-topic layout exists so event versions are always present in topic[1]; a 2-topic emit silently drops versioning from those events.

Root cause

EventPublisher was authored before the 3-topic convention was standardized and never updated (it is unwired, so the mismatch is invisible to tests).

Why this is architecturally hard

  1. The fix depends on the EventPublisher decision (companion issue): if the module is kept and wired, publish_calculation_executed must emit (name, EVENT_VERSION, context) and the CalculationExecutedEventV1 struct must be replaced by the real tuple payloads; if it is deleted, the topic-layout authority moves fully to event_schema.rs.
  2. The 3-topic layout is enforced by convention and tests (topic-stability tests), not by the SDK — a 2-topic emit compiles fine, so only a test that asserts topic arity per event would catch the class.
  3. The issue should add (or extend) a test asserting every published event has the documented topic arity, so the convention is mechanical, not memorial.

Acceptance criteria

  • EventPublisher (if kept) emits the documented 3-topic layout with real payload shapes, or the module is removed.
  • A test asserts topic arity (3 topics) for every event the contract emits.
  • The topic convention's authority is stated in one place.

Out of scope

The EventPublisher dead-code resolution (companion issue) and the payload field-order divergence (companion issue).

Getting started

just test

Good first files to read: apexchainx_calculator/src/event.rs, apexchainx_calculator/src/event_schema.rs (topic layout), apexchainx_calculator/src/topic_stability_tests.rs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardStellar WaveIssues in the Stellar wave programThird CampaignCampaign: Third Campaignarea/eventsImported campaign issue labelpriority/mediumImported campaign issue label

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions