Skip to content

Commit b3cc066

Browse files
quakeCopilot
andcommitted
refactor: converge identity on pubkey
- remove PeerId from most RPC and actor command/event surfaces - persist saved peer addresses by Pubkey and clean pending saves on dial errors - drop obsolete PeerId helpers and update tests/migrations - add .github/copilot-instructions.md for future sessions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 38162c4 commit b3cc066

27 files changed

+977
-991
lines changed

.github/copilot-instructions.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copilot Instructions for Fiber Network Node (FNN)
2+
3+
## Build, test, and lint commands
4+
5+
- Toolchain: Rust `1.93.0` (`rust-toolchain.toml`), default workspace members are `fnn` and `fiber-bin`.
6+
- Build:
7+
- `cargo build --locked`
8+
- `cargo build --release --locked`
9+
- `make check` (CI-style check matrix: debug/release/no-default-features + migrate crate check)
10+
- Tests (prefer `nextest`):
11+
- `cargo nextest run --no-fail-fast`
12+
- `RUST_TEST_THREADS=2 cargo nextest run --no-fail-fast` (matches CI and `.config/nextest.toml` expectations)
13+
- `cargo nextest run -p fnn -p fiber-bin`
14+
- Single test: `cargo nextest run test_name`
15+
- Single test pattern: `cargo nextest run 'tests::channel::test_name'`
16+
- Fallback when needed: `RUST_LOG=off cargo test -p fnn -p fiber-bin`
17+
- Lint/format:
18+
- `cargo fmt --all -- --check`
19+
- `cargo clippy --all-targets --all-features -p fnn -p fiber-bin -- -D warnings`
20+
- `make clippy` (also checks wasm crates)
21+
- `typos`
22+
23+
## High-level architecture
24+
25+
- Runtime bootstrap is in `crates/fiber-bin/src/main.rs`:
26+
1. Parse config and open `Store`.
27+
2. Start root actor/task tracking.
28+
3. Start CKB chain actor and initialize contracts/chain hash.
29+
4. Build `NetworkGraph` and start `NetworkActor` via `start_network`.
30+
5. Start built-in watchtower actor (or standalone watchtower RPC client), depending on config.
31+
6. Start JSON-RPC server (`rpc::server::start_rpc`) with enabled modules.
32+
- Core responsibilities in `crates/fiber-lib`:
33+
- `fiber/`: payment-channel protocol actors and flows (`network`, `channel`, `payment`, `gossip`, `graph`).
34+
- `ckb/`: CKB integration and on-chain transaction handling.
35+
- `rpc/`: jsonrpsee RPC modules (`info`, `peer`, `channel`, `payment`, `invoice`, `graph`, etc.).
36+
- `store/`: persistence traits/impl/schema.
37+
- Data compatibility flow:
38+
- Persistent key schema lives in `crates/fiber-lib/src/store/schema.rs`.
39+
- Storage migrations live in `migrate/src/migrations/` and are validated in CI.
40+
41+
## Key conventions specific to this repository
42+
43+
- Identity boundary: prefer `Pubkey` for business logic and RPC input/output; keep `PeerId` at p2p transport boundaries (multiaddr/session handling).
44+
- Actor-first design: cross-component interactions should go through actor message enums (`NetworkActorCommand`, `NetworkActorMessage`, service events) rather than direct shared-state mutation.
45+
- RPC documentation is generated and CI-checked: after RPC API/doc comment changes, run `make gen-rpc-doc` and ensure `make check-dirty-rpc-doc` passes.
46+
- Persistence changes require migration discipline: when storage structures/keys change, update migration code and run `make check-migrate`.
47+
- WASM is a first-class target for shared code paths; when touching cross-platform code in `fiber-lib`, keep `cfg` guards intact and run wasm-target clippy via `make clippy`.
48+
- Test execution is tuned by `.config/nextest.toml` overrides; prefer `nextest` over plain `cargo test` for reliability and CI parity.

AGENTS.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ make update-migrate-check
122122
```rust
123123
#[derive(Error, Debug)]
124124
pub enum Error {
125-
#[error("Peer not found error: {0:?}")]
126-
PeerNotFound(PeerId),
127125
#[error("Channel not found error: {0:?}")]
128126
ChannelNotFound(Hash256),
129127
#[error("Invalid parameter: {0}")]

crates/fiber-lib/src/errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use ckb_sdk::RpcError;
22
use ractor::{MessagingErr, SpawnErr};
3-
use tentacle::{error::SendErrorKind, secio::PeerId};
3+
use tentacle::error::SendErrorKind;
44
use thiserror::Error;
55

66
use crate::{
77
ckb::FundingError,
88
fiber::{
99
channel::{ChannelActorMessage, ProcessingChannelError},
1010
graph::PathFindError,
11-
types::Hash256,
11+
types::{Hash256, Pubkey},
1212
InFlightCkbTxActorMessage, NetworkActorMessage,
1313
},
1414
};
@@ -20,7 +20,7 @@ pub enum Error {
2020
#[error("IO error: {0}")]
2121
IO(#[from] std::io::Error),
2222
#[error("Peer not found error: {0:?}")]
23-
PeerNotFound(PeerId),
23+
PeerNotFound(Pubkey),
2424
#[error("Channel not found error: {0:?}")]
2525
ChannelNotFound(Hash256),
2626
#[error("Failed to send tentacle message: {0}")]

0 commit comments

Comments
 (0)