Skip to content

Commit 16b697a

Browse files
committed
fix: Remove problematic has_contract check causing node failures
The has_contract check was causing a race condition where the contract handler might not have finished processing the PUT when the check was made, leading to node failures. The subscription should work without this verification step.
1 parent 2f98743 commit 16b697a

File tree

2 files changed

+41
-17
lines changed

2 files changed

+41
-17
lines changed

AGENTS.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Modules
4+
- `crates/core` (crate: `freenet`): core node and the `freenet` binary.
5+
- `crates/fdev` (crate: `fdev`): developer CLI for packaging, running, and tooling.
6+
- `apps/*`: example apps and contracts (e.g., `apps/freenet-ping`).
7+
- `tests/*`: integration test crates and app/contract fixtures.
8+
- `scripts/`: local network helpers, deployment, and setup guides.
9+
- `.github/workflows`: CI for build, test, clippy, and fmt.
10+
11+
## Build, Test, and Dev
12+
- Init submodules (required): `git submodule update --init --recursive`.
13+
- Build all: `cargo build --workspace --locked`.
14+
- Run core: `cargo run -p freenet --bin freenet`.
15+
- Install binaries: `cargo install --path crates/core` and `cargo install --path crates/fdev`.
16+
- Test (workspace): `cargo test --workspace --no-default-features --features trace,websocket,redb`.
17+
- Example app build: `make -C apps/freenet-ping -f run-ping.mk build`.
18+
- Optional target for contracts: `rustup target add wasm32-unknown-unknown`.
19+
20+
## Coding Style & Naming
21+
- Rust 2021, toolchain ≥ 1.80.
22+
- Format: `cargo fmt` (CI enforces `cargo fmt -- --check`).
23+
- Lint: `cargo clippy -- -D warnings` (no warnings in PRs).
24+
- Naming: crates/modules `snake_case`; types/enums `PascalCase`; constants `SCREAMING_SNAKE_CASE`.
25+
- Keep features explicit (e.g., `--no-default-features --features trace,websocket,redb`).
26+
27+
## Testing Guidelines
28+
- Unit tests in-module with `#[cfg(test)]`; integration tests under `tests/*` crates.
29+
- Prefer meaningful coverage for changed public behavior and error paths.
30+
- Deterministic tests only; avoid external network unless mocked.
31+
- Run: `cargo test --workspace` before pushing.
32+
33+
## Commits & Pull Requests
34+
- Commit style: conventional prefixes (`feat:`, `fix:`, `chore:`, `refactor:`, `docs:`, `release:`). Example: `fix: prevent node crash on channel close`.
35+
- PRs should include: clear description, rationale, linked issues, and test notes; attach logs or screenshots for app/UI changes.
36+
- CI must pass: build, tests, `clippy`, and `fmt`.
37+
38+
## Security & Configuration
39+
- Config and secrets use platform app dirs (via `directories`). Default config/secrets are created on first run; avoid committing them.
40+
- Review changes touching networking, keys, or persistence; prefer least-privilege defaults and explicit feature gates.

crates/core/src/operations/put.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -535,23 +535,7 @@ impl Operation for PutOp {
535535
"Starting subscription for contract after successful PUT"
536536
);
537537

538-
// The contract should now be stored locally. We need to:
539-
// 1. Verify the contract is queryable locally
540-
// 2. Start a subscription request to register with peers
541-
542-
// Verify contract is stored and queryable
543-
let has_contract =
544-
super::has_contract(op_manager, key).await.unwrap_or(false);
545-
546-
if !has_contract {
547-
tracing::warn!(
548-
tx = %id,
549-
%key,
550-
"Contract not queryable after PUT storage, attempting subscription anyway"
551-
);
552-
}
553-
554-
// Start subscription request
538+
// Start subscription request to register with peers
555539
super::start_subscription_request(op_manager, key).await;
556540

557541
// Also ensure we're registered as a subscriber locally

0 commit comments

Comments
 (0)