Skip to content

fix(antd): honor is_public on FileCostRequest#56

Merged
Nic-dorman merged 1 commit into
mainfrom
fix/antd-cost-honors-is-public
May 6, 2026
Merged

fix(antd): honor is_public on FileCostRequest#56
Nic-dorman merged 1 commit into
mainfrom
fix/antd-cost-honors-is-public

Conversation

@Nic-dorman
Copy link
Copy Markdown
Collaborator

@Nic-dorman Nic-dorman commented May 5, 2026

Summary

Closes the no-op is_public flag on FileCostRequest. The flag was on the wire shape (REST + gRPC) and all 14 SDKs already emit it, but the Rust handlers ignored it. A public upload bundles one extra chunk — the serialized DataMap chunk — into the same payment batch, so the cost estimate has been under-reporting public uploads by exactly 1 chunk and the equivalent storage cost.

Independent of the public-uploads visibility wiring (#57); can ship today.

Change

  • New helper adjust_for_public_upload(chunk_count, storage_cost_atto) -> (usize, String) in antd/src/types.rs. Bumps chunk_count by 1 and scales storage_cost_atto by the average per-chunk cost. Uses ant-core's re-exported U256 (ant_core::data::U256) so atto values larger than u64 round-trip correctly — a 10K-ANT estimate is already 1e22 atto.
  • Wired into rest::files::file_cost and grpc::service::get_file_cost. The is_public field on FileCostRequest no longer carries #[allow(dead_code)].

Behavior change

is_public Before After
true (explicit, default in REST DTO) data-only chunk count + cost (under-reported) +1 chunk + scaled cost (correct)
false data-only chunk count + cost unchanged

Callers explicitly passing is_public: true will see slightly higher numbers — that's the bug being fixed. Callers passing is_public: false are unaffected.

Test plan

  • cargo test — 25 pass (6 new tests for the helper + existing)
  • New tests cover: even division, uneven division (rounding), large U256 atto values, zero-chunks defensive, unparseable cost, already-stored zero-cost round-trip

Notes

  • Gas cost (estimated_gas_cost_wei) is intentionally unchanged. Adding 1 chunk to a wave-batch usually doesn't add a transaction — gas already includes the per-tx-budget heuristic with explicit caveats in ant-core.
  • This PR does not touch /v1/files/upload/public or /v1/dirs/upload/public — those endpoints already do the right thing on the upload side via the two-call dance. Only the cost endpoint was lying.
  • Indirectly validated by the mainnet run that proved feat(antd): wire visibility through /v1/upload/prepare #57: the 4-payment public prepare for a 3-chunk file confirmed +1 chunk semantics on the upload side; this PR just makes the cost estimate match.

🤖 Generated with Claude Code

The is_public flag was on the wire shape (REST + gRPC, all 14 SDKs
already emit it) but the Rust handlers ignored it. A public upload
bundles one extra chunk — the serialized DataMap — into the same
payment batch, so the cost estimate must reflect that.

Add adjust_for_public_upload(chunk_count, storage_cost_atto) to types.rs
which bumps chunk_count by 1 and scales storage_cost_atto by the
average per-chunk cost. Wire it into both the REST handler at
rest::files::file_cost and the gRPC handler at
grpc::service::get_file_cost. Use ant-core's re-exported U256 to keep
arithmetic correct for atto values larger than u64 (a 10K-ANT estimate
is already 1e22 atto).

Behavior change: callers explicitly passing is_public=true previously
received the data-only chunk count and cost; they now receive the
public-correct +1 chunk equivalent. Callers passing is_public=false
are unaffected.

Tests cover even/uneven division, large U256 atto values, the
already-stored zero-cost case, and unparseable input.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Nic-dorman Nic-dorman force-pushed the fix/antd-cost-honors-is-public branch from b4d5e43 to f9e3028 Compare May 6, 2026 16:12
@Nic-dorman Nic-dorman merged commit 81e7e55 into main May 6, 2026
3 checks passed
@Nic-dorman Nic-dorman deleted the fix/antd-cost-honors-is-public branch May 6, 2026 16:18
Nic-dorman added a commit that referenced this pull request May 6, 2026
Cuts v0.6.1 atop v0.6.0. Adds the public-uploads chain:

- feat(antd): wire visibility through /v1/upload/prepare (#57)
  - visibility: Option<String> on PrepareUploadRequest / PrepareDataUploadRequest
  - data_map_address: Option<String> on FinalizeUploadResponse
  - prepare_upload now calls file_prepare_upload_with_visibility — public
    prepare bundles the serialized DataMap chunk into the same external-
    signer payment batch (one EVM tx covers chunks + DataMap)
  - /v1/data/prepare returns 501 for visibility:"public" until upstream
    data_prepare_upload_with_visibility lands
- fix(antd): honor is_public on FileCostRequest (#56)
  - cost endpoint adds +1 chunk and proportional storage cost when
    is_public=true (was a no-op before)

Validated end-to-end on Arbitrum One mainnet against this dep set:
external-signer wave-batch public upload of a 10 KB file, atomic
payForQuotes for 4 quotes (3 data + 1 DataMap), finalize returned
data_map_address, /v1/files/download/public via that address round-
tripped byte-for-byte. ~0.047 ANT cost.

Same ant-core / evmlib pin as v0.6.0 (ant-cli-v0.2.2, evmlib 0.8.1).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant