Skip to content

align filestorage with constant-size proof verification#373

Draft
dime-squanderer wants to merge 4 commits into
mainfrom
constant-size-proofs
Draft

align filestorage with constant-size proof verification#373
dime-squanderer wants to merge 4 commits into
mainfrom
constant-size-proofs

Conversation

@dime-squanderer
Copy link
Copy Markdown
Contributor

@dime-squanderer dime-squanderer commented Apr 2, 2026

Note

High Risk
High risk because it changes on-chain filestorage contract storage/layout and verify_proof/join/leave APIs, plus modifies the indexer DB schema and ledger reconstruction ordering; mistakes could break proof verification or require state migrations.

Overview
Aligns proof verification with constant-size proofs by removing proof-derived challenge lists and instead verifying against a caller-specified (shard_id, start_seq, end_seq) range of challenges deterministically indexed per prover/shard, with new view APIs to query shard sequences and challenge IDs.

Updates filestorage participation semantics so join_agreement/leave_agreement derive node_id from ctx.signer().to_string(), and extends challenge-data with shard_id/shard_seq while indexing challenges during generation/creation.

Makes indexer file-ledger reconstruction stable by adding a ledger_index column (unique, ordered) to file_metadata, persisting it on insert, and loading rows ordered by ledger_index; updates WIT host bindings/tests accordingly and switches kontor-crypto to a git dependency/branch. Removes static POR proof fixtures and generates proofs inline in E2E tests due to prover-id changes.

Reviewed by Cursor Bugbot for commit f0084f0. Bugbot is set up for automated code reviews on this repo. Configure here.

# Conflicts:
#	core/Cargo.lock
#	core/indexer/Cargo.toml
#	core/indexer/src/bin/generate_por_fixtures.rs
#	core/indexer/src/database/queries.rs
#	core/indexer/src/database/sql/schema.sql
#	core/indexer/tests/contracts/file_storage_tests/proof_verification_e2e.rs
#	core/indexer/tests/database.rs
#	core/indexer/tests/fixtures/por_proof_fixtures.json
#	native-contracts/binaries/filestorage.wasm.br
#	native-contracts/binaries/registry.wasm.br
#	native-contracts/binaries/staking.wasm.br
#	native-contracts/binaries/token.wasm.br
@wilfreddenton
Copy link
Copy Markdown
Contributor

bugbot run

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f0084f0. Configure here.

shard_challenges.update_next_seq(|seq| seq.saturating_add(1));
shard_challenges
.by_seq()
.set(&shard_seq, challenge_id.clone());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated shard initialization logic across two functions

Low Severity

The ~30-line block that initializes ProverChallenges / ShardChallenges, assigns the next shard_seq, increments next_seq, and inserts into by_seq is copy-pasted between generate_challenges_for_block and create_challenge_for_agreement. A shared helper (e.g., taking the model and returning (shard_id, shard_seq)) would reduce maintenance burden and eliminate the risk of one copy diverging from the other during future edits.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f0084f0. Configure here.

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.

2 participants