feat: py-libp2p-style peer discovery networking service#38
feat: py-libp2p-style peer discovery networking service#38arunabha003 wants to merge 37 commits intoStabilityNexus:mainfrom
Conversation
|
Caution Review failedFailed to post review comments WalkthroughThis pull request introduces a complete blockchain implementation (MiniChain) with core components for transaction processing, block validation, chain management with consensus, peer-to-peer networking with discovery, transaction mempool, SQLite persistence, and a command-line interface for node operations. Includes comprehensive test coverage and development tooling. Changes
Sequence Diagram(s)sequenceDiagram
participant User as User/CLI
participant Node as MiniChainNode
participant Mempool as Mempool
participant ChainMgr as ChainManager
participant Storage as SQLiteStorage
participant Consensus as Consensus
User->>Node: submit_transaction(tx)
Node->>Mempool: add_transaction(tx, state)
Mempool-->>Node: transaction_id
Node-->>User: Transaction queued
User->>Node: mine_one_block()
Node->>Mempool: get_transactions_for_mining(state, limit)
Mempool-->>Node: [ready_txs]
Node->>Consensus: build_candidate_block(chain, mempool, miner_addr)
Consensus-->>Node: Block template
Node->>Consensus: mine_candidate_block(template)
Consensus-->>Node: Mined block with nonce
Node->>ChainMgr: add_block(block)
ChainMgr->>ChainMgr: validate_consensus(block)
ChainMgr->>ChainMgr: replay_state_for_tip()
ChainMgr-->>Node: Block accepted
Node->>Mempool: remove_confirmed_transactions(block.txs)
Node->>Storage: persist_block_state_and_metadata()
Storage-->>Node: Persisted
Node-->>User: Block mined at height N
sequenceDiagram
participant NodeA as Node A
participant Net as Network/MDNS
participant NodeB as Node B
NodeA->>Net: start_mdns_discovery()
NodeB->>Net: start_mdns_discovery()
Net-->>NodeA: Discovered NodeB
Net-->>NodeB: Discovered NodeA
NodeA->>NodeB: connect_to_peer(peer_address)
NodeA->>NodeB: _hello_payload(node_id, address)
NodeB-->>NodeA: hello_response
NodeB->>NodeA: _hello_payload(node_id, address)
NodeA-->>NodeB: hello_response
NodeA->>NodeB: _peer_list_payload(known_peers)
NodeB-->>NodeA: peer_list_response
NodeA->>NodeB: _peer_reader_loop()
NodeB->>NodeA: _peer_reader_loop()
Note over NodeA,NodeB: Mutual peer exchange<br/>and connection established
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Superseded by #39. Closing this PR to keep review history in one place. |
Addressed Issues:
Part of #8
Depends on #37
Summary
Validation
Checklist
AI Usage Disclosure
Check one of the checkboxes below:
I have used the following AI models and tools: TODO
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact.
Summary by CodeRabbit
Release Notes
New Features
Chores