Skip to content

examples/delegate.rs does not compile, and nothing builds it #103

Description

@sanity

examples/delegate.rs at the repo root implements DelegateInterface::process with a five-parameter signature taking a &mut SecretsStore:

fn process(
    ctx: &mut DelegateCtx,
    secrets: &mut SecretsStore,
    _parameters: Parameters<'static>,
    _attested: Option<&'static [u8]>,
    _messages: InboundDelegateMsg,
) -> Result<Vec<OutboundDelegateMsg>, DelegateError>

The trait takes four and has no SecretsStore parameter (rust/src/delegate_interface.rs):

fn process(
    ctx: &mut DelegateCtx,
    parameters: Parameters<'static>,
    origin: Option<MessageOrigin>,
    message: InboundDelegateMsg,
) -> Result<Vec<OutboundDelegateMsg>, DelegateError>

Secrets moved onto DelegateCtx (ctx.get_secret, ctx.set_secret, ctx.has_secret), and origin replaced attested. The example fails with E0050 (wrong parameter count) and E0425.

The actionable half: nothing catches it

The file is at the repo root, outside the rust/ package, and is not declared as an [[example]] in any Cargo.toml. So no CI job compiles it — not the build matrix, not clippy, not the test job. It can rot indefinitely with every check green.

That makes it worse than having no example. It is among the first things someone writing a delegate reads, it is wrong, and there is no signal anywhere that it is wrong. I hit this directly: I copied its signature to build a throwaway delegate and got a compile error before realising the example was stale rather than my usage.

examples/contract.rs sits in the same directory under the same conditions and should be checked at the same time.

Suggested fix

Correct the signature, then wire the examples into a Cargo target so the build matrix compiles them — otherwise the same drift recurs the next time the trait changes, and the next reader pays for it again. If they are meant purely as documentation snippets rather than compilable code, say so in the file and reference the real trait, so a reader knows not to copy from it.

Found while working on #98; not fixed there because it is unrelated to that change and the fix should come with the CI wiring rather than without it.

[AI-assisted - Claude]

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions