Skip to content

Commit 8d8d11c

Browse files
authored
Merge pull request #67 from firedancer-io/cmoyes/protosolcrate
Crate-ify, major version bump, add README.md
2 parents e7be490 + 37f7449 commit 8d8d11c

File tree

3 files changed

+182
-28
lines changed

3 files changed

+182
-28
lines changed

Cargo.lock

Lines changed: 18 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "protosol"
3-
version = "1.0.1"
3+
version = "2.0.0"
44
edition = "2021"
55
license = "Apache-2.0"
66
description = "Protobuf definitions for the SVM fuzzing project."

README.md

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# Protosol
2+
3+
Protocol buffer definitions for the Solana Virtual Machine (SVM) testing harness in Agave. This crate provides Rust bindings for protobuf schemas used in fuzzing and testing the Solana blockchain's execution environment.
4+
5+
## Overview
6+
7+
Protosol defines the data structures used to capture, serialize, and replay Solana blockchain execution contexts for testing and fuzzing purposes. These protocol buffers represent the complete state and execution flow of Solana transactions, blocks, and virtual machine operations.
8+
9+
## What These Protocol Buffers Represent
10+
11+
### Core Components
12+
13+
- **Transaction Processing**: Complete transaction lifecycle from input to execution effects
14+
- **Block Execution**: Block-level context including transactions, account states, and consensus data
15+
- **Virtual Machine State**: SVM execution context, compute budgets, and program execution
16+
- **Account Management**: Account states, ownership, and data storage
17+
- **Consensus Context**: Slot information, epoch data, and leader schedules
18+
19+
### Key Message Types
20+
21+
#### Transaction Layer (`txn.proto`)
22+
- `SanitizedTransaction`: Complete transaction with message and signatures
23+
- `TransactionMessage`: Transaction payload with accounts and instructions
24+
- `CompiledInstruction`: Individual program instructions with account references
25+
- `MessageHeader`: Transaction metadata (signatures, read-only accounts)
26+
27+
#### Block Layer (`block.proto`)
28+
- `BlockContext`: Input state for block execution (transactions, accounts, block hash queue)
29+
- `BlockEffects`: Output state after block execution (bank hash, costs, leader schedule)
30+
- `BlockFixture`: Complete test fixture combining input context and expected effects
31+
32+
#### Execution Context (`context.proto`)
33+
- `AcctState`: Complete account state (address, lamports, data, owner)
34+
- `FeatureSet`: Enabled Solana features for execution
35+
- `SlotContext`: Slot-specific information (POH, parent hashes)
36+
- `EpochContext`: Epoch-level data (vote accounts, feature sets)
37+
38+
#### Compute Budget (`pack.proto`)
39+
- `PackComputeBudgetContext`: Input for compute budget testing
40+
- `PackComputeBudgetEffects`: Output effects of compute budget execution
41+
42+
## Usage
43+
44+
### As a Dependency
45+
46+
Add to your `Cargo.toml`:
47+
48+
```toml
49+
[dependencies]
50+
protosol = "X.Y.Z"
51+
```
52+
53+
### Basic Usage
54+
55+
```rust
56+
use protosol::protos;
57+
58+
// Create a transaction fixture
59+
let txn = protos::SanitizedTransaction {
60+
message: Some(protos::TransactionMessage {
61+
header: Some(protos::MessageHeader {
62+
num_required_signatures: 1,
63+
num_readonly_signed_accounts: 0,
64+
num_readonly_unsigned_accounts: 0,
65+
}),
66+
account_keys: vec![/* account keys */],
67+
recent_blockhash: vec![/* blockhash */],
68+
instructions: vec![/* instructions */],
69+
address_table_lookups: vec![],
70+
}),
71+
signatures: vec![vec![/* signature bytes */]],
72+
};
73+
74+
// Create account state
75+
let account = protos::AcctState {
76+
address: vec![/* 32-byte address */],
77+
lamports: 1000000,
78+
data: vec![/* account data */],
79+
executable: false,
80+
owner: vec![/* 32-byte owner */],
81+
};
82+
83+
// Create block context for testing
84+
let block_ctx = protos::BlockContext {
85+
txns: vec![txn],
86+
acct_states: vec![account],
87+
blockhash_queue: vec![/* recent blockhashes */],
88+
slot_ctx: Some(protos::SlotContext {
89+
slot: 12345,
90+
poh: vec![/* POH hash */],
91+
parent_bank_hash: vec![/* parent hash */],
92+
parent_lthash: vec![/* parent LT hash */],
93+
}),
94+
epoch_ctx: Some(protos::EpochContext {
95+
epoch: 100,
96+
features: Some(protos::FeatureSet {
97+
features: vec![/* feature flags */],
98+
}),
99+
vote_accounts: vec![],
100+
}),
101+
};
102+
```
103+
104+
### Testing and Fuzzing
105+
106+
These protocol buffers are designed for:
107+
108+
1. **Test Fixture Generation**: Create reproducible test cases with complete blockchain state
109+
2. **Fuzzing**: Generate random but valid blockchain execution contexts
110+
3. **State Capture**: Record actual blockchain execution for later replay
111+
4. **Regression Testing**: Compare execution results across different SVM implementations
112+
113+
### Integration with Agave
114+
115+
This crate is specifically designed for use with the anza-xyz/agave repository's testing infrastructure:
116+
117+
- **SVM Fuzzing**: Generate test cases for the Solana Virtual Machine
118+
- **Execution Testing**: Validate transaction and block execution across different implementations
119+
- **Performance Testing**: Measure execution costs and resource usage
120+
- **Compatibility Testing**: Ensure different SVM implementations produce identical results
121+
122+
## Development
123+
124+
### Building
125+
126+
```bash
127+
cargo build
128+
```
129+
130+
### Running Tests
131+
132+
```bash
133+
cargo test
134+
```
135+
136+
### Regenerating Protobuf Code
137+
138+
The protobuf code is automatically generated during build. To force regeneration:
139+
140+
```bash
141+
cargo clean
142+
cargo build
143+
```
144+
145+
## File Structure
146+
147+
```
148+
proto/
149+
├── block.proto # Block execution context and effects
150+
├── context.proto # Account states and execution context
151+
├── txn.proto # Transaction structures
152+
├── pack.proto # Compute budget testing
153+
├── metadata.proto # Test fixture metadata
154+
└── *.options # Nanopb configuration files
155+
```
156+
157+
## License
158+
159+
Apache-2.0
160+
161+
## Repository
162+
163+
https://github.com/firedancer-io/protosol

0 commit comments

Comments
 (0)