Skip to content

Contract: rebuild the AdSense claim in the encoding the AdSense API actually produces #76

Closed

Description

@Lin1er

Owner: @Lexirieru, to confirm · Branch: fix/6-claim-date-encoding · Milestone: M3 · Blocks: #61, #17, #5 (on chain)

Split out of #6 so it has an owner and a branch. The provider side is done in #74.

Why

claim.rs rebuilds a claim the AdSense API cannot produce, so every real AdSense proof is refused. Until this lands:

The two encodings that don't match:

The contract expects The AdSense API gives
Dates in the URL startDate=2026-07-01 (3-value template) startDate.year=2026&startDate.month=7&startDate.day=1, unpadded. This is the only form reports:generate accepts.
extractedParameters {currency, endDate, revenueUsd, startDate} {revenueUsd}. The response echoes dates as JSON objects, so one regex group cannot capture 2026-07-01.

What to build

  • Keep the interface and the nullifier as they are. request_advance(…, window_start: "YYYY-MM-DD", window_end, …) and the nullifier over those strings don't change.
  • Split each date inside the contract into unpadded ASCII year, month and day. This is fixed-width parsing of 10 bytes; no JSON is involved.
  • Fill a 7-value template: pub_id, sy, sm, sd, ey, em, ed.
  • Rebuild extractedParameters as {"revenueUsd":"<x>"}.
    • Currency stays enforced by the signed "currencyCode": "USD" match in parameters.
    • The window stays enforced by the signed URL.
  • Update docs/interface.md §3/§8 to match.

The full reasoning is on #6.

Done when


Working agreement

  1. One issue, one owner. 2. Branch per issue, named above — not the GitHub-suggested one. 3. MCP Stellar Raven for any Stellar/Soroban fact that gets written down. 4. Merge through PR review by Axel (PM); no self-merge. If an ACC has not arrived within two days on something already verified, merge and say so in the PR. 5. Deploys need evidence: contract address or tx hash on stellar.expert, recorded in docs/deployments.md. 6. Secrets live in .env, gitignored, chmod 600 — never printed, never committed, never pasted into an issue or PR. Only public G… and C… addresses appear anywhere. 7. Issues, commits and PRs in English.

Activity

  1. added
    M3-appWeek 3 — proof relay and the creator front end
    deliverable-1SOW Deliverable 1 — advance contract
    on Oct 20, 2026
  2. added a commit that references this issue on Oct 20, 2026
  3. added 2 commits that reference this issue on Oct 20, 2026
  4. Lexirieru commented on Oct 20, 2026

    @Lexirieru
    Collaborator

    Taken and merged in #79. @Lin1er — you were right, and I checked it against Google's reference before touching anything rather than taking the report on trust.

    accounts.reports.generate declares startDate and endDate as object (Date), and Date is {year, month, day} as integers. The REST transport flattens that into startDate.year=2026&startDate.month=7&startDate.day=1, unpadded because they are integers. There is no string date form. ?startDate=2026-07-01 is a request Google cannot serve.

    Your proposal is what landed, unchanged:

    • template is 8 parts / 7 values: pub_id, sy, sm, sd, ey, em, ed
    • claim::split_date converts YYYY-MM-DD inside the contract — ten bytes, fixed-width, every byte checked, no JSON
    • extractedParameters is {"revenueUsd":"<x>"} alone
    • request_advance and the nullifier are byte-identical to before

    I also made set_claim_template refuse a four-part template outright, rather than accept it and fail per proof later with a bare ClaimMismatch.

    The window and the currency are not weaker now

    Worth stating plainly, because "we removed two fields from the signed context" reads alarming:

    Was asserted by Now asserted by
    extractedParameters.currency the "currencyCode": "USD" response match
    extractedParameters.startDate / .endDate the URL

    Both live in parameters, which the contract pins and rebuilds. The window is arguably held more tightly: it is now in the thing Google computed the totals from, not in an echo of it.

    Deployment

    Step Tx
    Release v0.3.0, wasm ade4687f… release
    Upload 5323fbf0ef71…
    Propose, production 33d30715d56f…
    Propose, dev 593d91a7fa0a…

    executable_at 2026-10-21 ~08:50 UTC. After execute_upgrade I re-pin the dev template with the eight new parts and re-run the rehearsal end to end, and post both here.

    Heads up on a deliberate gap: the dev contract still has the old four-part template pinned. The moment the new wasm is live its verify_claim refuses everything, until I re-pin. That is intended, not an outage.

    Two things I got wrong, for the record

    The freeze. I froze a claim shape before any real AdSense response existed, knowing it was a gamble, and wrote that the gamble was contained because the template is admin-settable. It wasn't contained: the arity of the template and the keys of the context were baked into the wasm, so the part I thought one storage write could fix needed a code change, a release and a 24-hour timelock. The lesson is narrower than "don't freeze early" — it is that the part of a freeze describing someone else's API is a guess until it is read against that API. Checking it never needed a live account. The reference page was enough, and nobody opened it.

    The fixture. forepay-claim.json was a hand-pasted blob with no generator, so when the encoding went stale there was no mechanism by which anyone would notice — the digest tests would have kept passing against bytes that described nothing. It now comes from tools/make_claim_fixture.py with a CI --check.

    Thanks for finding this by reading the document against the API instead of against our own code. That is the only way it could have surfaced before the first real proof, and it would have surfaced at the demo otherwise.

  5. added 4 commits that reference this issue on Oct 20, 2026
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

    M3-appWeek 3 — proof relay and the creator front enddeliverable-1SOW Deliverable 1 — advance contract

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions