|
| 1 | +# Core Crate Summary |
| 2 | + |
| 3 | +The core crate contains foundational infrastructure and shared utilities that all other crates depend on. We use this crate for shared types, utilities, and abstractions that need to be accessible across the entire project. |
| 4 | + |
| 5 | +## What This Crate Contains |
| 6 | + |
| 7 | +- **Substate System** (`src/substate.rs`): Type-safe access patterns for Redux state slicing and mutation control |
| 8 | +- **WASM Threading** (`src/thread.rs`): Main thread task delegation system needed for browser environments |
| 9 | +- **Network Configuration** (`src/network.rs`): Static network constants and config for mainnet/devnet |
| 10 | +- **Core Domain Types**: Basic blockchain types (blocks, SNARKs, requests, consensus) that everything uses |
| 11 | + - `src/block/` - Block structures and validation |
| 12 | + - `src/snark/` - SNARK work and job management |
| 13 | + - `src/transaction/` - Transaction helper types and metadata |
| 14 | + - `src/consensus.rs` - Consensus types and fork decision logic |
| 15 | +- **Request Management** (`src/requests/`): Type-safe request ID generation and lifecycle tracking |
| 16 | +- **Channel Wrappers** (`src/channels.rs`): Abstractions over flume channels for message passing |
| 17 | +- **Distributed Pool** (`src/distributed_pool.rs`): BTreeMap-based data structure for network-synchronized state |
| 18 | + |
| 19 | +## Technical Debt and Issues |
| 20 | + |
| 21 | +### Medium Priority |
| 22 | + |
| 23 | +**Hardcoded Network Constants** |
| 24 | +- Fork constants are hardcoded in the `NetworkConfig` struct |
| 25 | +- Impact: Can't deploy flexibly, need code changes for network updates |
| 26 | + |
| 27 | +### Low Priority |
| 28 | + |
| 29 | +**Unsafe Redux Access** |
| 30 | +- `unsafe_get_state()` method in `Substate` struct breaks Redux safety |
| 31 | +- Only used by the transaction pool state machine which requires refactoring |
| 32 | + |
| 33 | +**Inconsistent Error Handling** |
| 34 | +- Various instances of `panic!`, `unwrap()`, or `expect()` calls throughout core |
| 35 | + |
| 36 | +## Known Limitations |
| 37 | + |
| 38 | +1. **Network Config**: Can't dynamically configure network parameters without code changes |
| 39 | +2. **WASM Constraints**: Browser limitations require specialized threading patterns |
0 commit comments