This plan outlines a linear, dependency-aware workflow for an AI agent to bring the BitCell codebase to RC1 readiness. Execute these steps in order.
Goal: Enable users to create real transactions.
Files: crates/bitcell-wallet-gui/src/main.rs
Action:
- Locate
on_send_transactioncallback. - Replace the
mock_txstring formatting with actualTransactionstruct construction. - Use
rpc_client.get_nonce(from_address)to get the correct nonce. - Sign the transaction using the wallet's private key.
- Serialize the transaction (bincode/hex).
- Call
rpc_client.send_raw_transaction(hex_tx).
Goal: Process incoming raw transactions.
Files: crates/bitcell-node/src/rpc.rs
Action:
- In
bitcell_sendRawTransaction: - Decode the hex string into bytes.
- Deserialize bytes into
Transactionstruct. - Validate signature and nonce.
- Add to
TxPool(vianode.tx_pool). - Return the transaction hash.
Goal: Return real account balances.
Files: crates/bitcell-node/src/rpc.rs
Action:
- In
eth_getBalance: - Parse the address (PublicKey).
- Access
node.blockchain.state. - Call
state.get_account(address). - Return
account.balance(or 0 if not found).
Goal: Persist state across restarts.
Files: crates/bitcell-state/src/storage.rs, crates/bitcell-state/Cargo.toml
Action:
- Add
rocksdbdependency tobitcell-state. - Implement
Storagetrait using RocksDB. - Store
AccountandBondStatedata serialized. - Update
StateManagerto use this persistent storage instead ofHashMap.
Goal: Randomize block proposer selection.
Files: crates/bitcell-node/src/blockchain.rs, crates/bitcell-crypto/src/vrf.rs (create if needed)
Action:
- Implement ECVRF (Elliptic Curve Verifiable Random Function) using
schnorrkelor similar. - In
produce_block:- Generate VRF output using previous block's VRF output as input.
- Store
vrf_outputandvrf_proofinBlockHeader.
- In
validate_block:- Verify the
vrf_proofagainst the proposer's public key.
- Verify the
Goal: Verify battle outcomes cryptographically.
Files: crates/bitcell-zkp/src/battle_circuit.rs, crates/bitcell-zkp/src/lib.rs
Action:
- Update
Groth16Proofstruct to hold real proof data (Bellman/Arkworks). - In
BattleCircuit:- Define constraints for CA evolution (start state -> end state).
- Even a simplified version checking hash consistency is better than mock.
- Update
generate_proofto actually run the setup and prove. - Update
verifyto run the verifier.
Goal: Efficient block/tx propagation.
Files: crates/bitcell-network/src/transport.rs, crates/bitcell-network/Cargo.toml
Action:
- Ensure
libp2pfeaturesgossipsubare enabled. - Initialize
Gossipsubbehaviour in the swarm. - Subscribe to topics:
blocks,transactions,consensus. - Implement
broadcast_blockandbroadcast_transactionto publish to these topics. - Handle incoming gossip messages in the event loop.
Goal: Populate admin dashboard with real data.
Files: crates/bitcell-admin/src/api/metrics.rs
Action:
- Inject
Arc<Node>orArc<MetricsRegistry>into the admin API state. - In
get_metrics:- Read
uptimefrom node start time. - Read
block_heightfrom blockchain. - Read
peer_countfrom network manager. - Calculate
average_block_timefrom recent blocks.
- Read
Goal: Show real chain data.
Files: crates/bitcell-admin/src/api/blocks.rs
Action:
- In
get_blocks:- Iterate backwards from current height.
- Fetch blocks from
blockchain. - Map to API response format.
- In
get_block_by_hash:- Lookup block in
blockchain.
- Lookup block in
Goal: Robust error handling.
Files: crates/bitcell-ca/src/grid.rs, crates/bitcell-state/src/bonds.rs
Action:
- Search for
panic!. - Change function signature to return
Result<T, Error>. - Propagate errors up the stack.
Goal: Complete RPC API.
Files: crates/bitcell-node/src/rpc.rs
Action:
- In
getNodeInfo, return actuallocal_peer_id. - Implement
bitcell_getReputationby queryingTournamentManager.
Goal: Clean code.
Files: crates/bitcell-node/src/rpc.rs
Action:
- Use
hex::decodeconsistently instead of manual string slicing. - Add proper error handling for invalid hex strings.
- Sequential Execution: Follow the phases in order (1 -> 5).
- Verification: Run
cargo testafter each major component implementation. - Integration: Run the full node and wallet to verify end-to-end functionality (e.g., send a tx and see it in the explorer).