Skip to content

Commit 5ff67c3

Browse files
tizocdannywillems
authored andcommitted
chore(handover): Format markdown
1 parent a913f79 commit 5ff67c3

File tree

3 files changed

+57
-22
lines changed

3 files changed

+57
-22
lines changed

core/summary.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,53 @@
11
# Core Crate Summary
22

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.
3+
The core crate contains foundational infrastructure and shared utilities that
4+
all other crates depend on. We use this crate for shared types, utilities, and
5+
abstractions that need to be accessible across the entire project.
46

57
## What This Crate Contains
68

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
9+
- **Substate System** (`src/substate.rs`): Type-safe access patterns for Redux
10+
state slicing and mutation control
11+
- **WASM Threading** (`src/thread.rs`): Main thread task delegation system
12+
needed for browser environments
13+
- **Network Configuration** (`src/network.rs`): Static network constants and
14+
config for mainnet/devnet
15+
- **Core Domain Types**: Basic blockchain types (blocks, SNARKs, requests,
16+
consensus) that everything uses
1117
- `src/block/` - Block structures and validation
1218
- `src/snark/` - SNARK work and job management
1319
- `src/transaction/` - Transaction helper types and metadata
1420
- `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
21+
- **Request Management** (`src/requests/`): Type-safe request ID generation and
22+
lifecycle tracking
23+
- **Channel Wrappers** (`src/channels.rs`): Abstractions over flume channels for
24+
message passing
25+
- **Distributed Pool** (`src/distributed_pool.rs`): BTreeMap-based data
26+
structure for network-synchronized state
1827

1928
## Technical Debt and Issues
2029

2130
### Medium Priority
2231

2332
**Hardcoded Network Constants**
33+
2434
- Fork constants are hardcoded in the `NetworkConfig` struct
2535
- Impact: Can't deploy flexibly, need code changes for network updates
2636

2737
### Low Priority
2838

2939
**Unsafe Redux Access**
40+
3041
- `unsafe_get_state()` method in `Substate` struct breaks Redux safety
3142
- Only used by the transaction pool state machine which requires refactoring
3243

3344
**Inconsistent Error Handling**
45+
3446
- Various instances of `panic!`, `unwrap()`, or `expect()` calls throughout core
3547

3648
## Known Limitations
3749

38-
1. **Network Config**: Can't dynamically configure network parameters without code changes
39-
2. **WASM Constraints**: Browser limitations require specialized threading patterns
50+
1. **Network Config**: Can't dynamically configure network parameters without
51+
code changes
52+
2. **WASM Constraints**: Browser limitations require specialized threading
53+
patterns

docs/handover/ledger-crate.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ zkApp functionality, providing a direct port of the OCaml implementation. For
88
developers familiar with the OCaml codebase, this maintains the same
99
architecture and business logic while adapting to Rust idioms.
1010

11-
For technical debt and critical issues, see [`ledger/summary.md`](../../ledger/summary.md).
11+
For technical debt and critical issues, see
12+
[`ledger/summary.md`](../../ledger/summary.md).
1213

1314
## Architecture
1415

@@ -25,7 +26,8 @@ For technical debt and critical issues, see [`ledger/summary.md`](../../ledger/s
2526

2627
- Port of OCaml's `Ledger.Mask` with identical copy-on-write semantics
2728
- Provides layered ledger views for efficient state management
28-
- Uses `Arc<Mutex<MaskImpl>>` for cheap reference counting; `Mask::clone()` is fast
29+
- Uses `Arc<Mutex<MaskImpl>>` for cheap reference counting; `Mask::clone()` is
30+
fast
2931
- Used extensively in transaction processing to create temporary ledger states
3032

3133
**Database** (`src/database/`)

ledger/summary.md

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,79 @@
11
# Ledger Crate Summary
22

3-
The ledger crate is the most complex component in the codebase. For architecture overview and design details, see [docs/handover/ledger-crate.md](../docs/handover/ledger-crate.md).
3+
The ledger crate is the most complex component in the codebase. For architecture
4+
overview and design details, see
5+
[docs/handover/ledger-crate.md](../docs/handover/ledger-crate.md).
46

57
## Quick Reference
68

79
**Core Ledger**
10+
811
- `src/base.rs` - BaseLedger trait (fundamental interface)
912
- `src/database/` - In-memory account storage
1013
- `src/mask/` - Layered ledger views with Arc-based sharing
1114
- `src/tree.rs` - Merkle tree operations
1215

1316
**Transaction Processing**
17+
1418
- `src/transaction_pool.rs` - Mempool with fee-based ordering
1519
- `src/staged_ledger/` - Block validation and transaction application
1620
- `src/scan_state/` - SNARK work coordination and parallel scan
1721

1822
**Proof System**
23+
1924
- `src/proofs/` - Transaction, block, and zkApp proof generation/verification
2025
- `src/sparse_ledger/` - Minimal ledger representation for proofs
2126
- `src/zkapps/` - zkApp transaction processing
2227

2328
**Account Management**
29+
2430
- `src/account/` - Account structures, balances, permissions
2531

2632
## Critical Issues
2733

2834
**Error Handling**
29-
- Too many `.unwrap()` and `.expect()` calls in production code paths (excluding tests)
35+
36+
- Too many `.unwrap()` and `.expect()` calls in production code paths (excluding
37+
tests)
3038
- Critical transaction processing paths could panic the node
3139
- Inconsistent error handling across modules
32-
- Verification key lookup bug fix from upstream Mina Protocol needs to be ported (https://github.com/MinaProtocol/mina/pull/16699)
40+
- Verification key lookup bug fix from upstream Mina Protocol needs to be ported
41+
(https://github.com/MinaProtocol/mina/pull/16699)
3342

3443
**Monolithic Structure**
44+
3545
- Single massive crate with files exceeding 6,000+ lines
3646
- Deep coupling between components that should be independent
3747
- Hard to maintain, test, and develop in parallel
3848

3949
**Performance**
50+
4051
- Excessive cloning of large structures in hot paths:
41-
- `SparseLedger::of_ledger_subset_exn()` calls `oledger.copy()` creating unnecessary deep clones for sparse ledger construction
42-
- Transaction pool operations clone transaction objects with acknowledged TODO comments about performance
43-
- No memory pooling or reuse strategies (could help with memory fragmentation in WASM)
52+
- `SparseLedger::of_ledger_subset_exn()` calls `oledger.copy()` creating
53+
unnecessary deep clones for sparse ledger construction
54+
- Transaction pool operations clone transaction objects with acknowledged TODO
55+
comments about performance
56+
- No memory pooling or reuse strategies (could help with memory fragmentation in
57+
WASM)
4458

4559
**Memory Management**
60+
4661
- Memory-only implementation, no persistence for production
47-
- There's an unused `ondisk` implementation but we were planning a more comprehensive global solution (see persistence.md)
62+
- There's an unused `ondisk` implementation but we were planning a more
63+
comprehensive global solution (see persistence.md)
4864
- Thread-local caching holds memory indefinitely
4965

5066
## Refactoring Plan
5167

5268
**Phase 1: Safety**
69+
5370
- Replace `.unwrap()` with proper error propagation in production code
5471
- Reduce cloning in hot paths
5572
- Standardize error types
5673

57-
**Phase 2: Decomposition**
58-
Break into focused crates: `mina-account`, `mina-ledger`, `mina-transaction-logic`, `mina-scan-state`, `mina-transaction-pool`, `mina-proofs`
74+
**Phase 2: Decomposition** Break into focused crates: `mina-account`,
75+
`mina-ledger`, `mina-transaction-logic`, `mina-scan-state`,
76+
`mina-transaction-pool`, `mina-proofs`
5977

60-
Changes must maintain strict OCaml compatibility while improving performance for production.
78+
Changes must maintain strict OCaml compatibility while improving performance for
79+
production.

0 commit comments

Comments
 (0)