Skip to content

Commit acdc089

Browse files
committed
rewrite docs with hallucinations
1 parent d47f27a commit acdc089

File tree

8 files changed

+157
-4272
lines changed

8 files changed

+157
-4272
lines changed

poc/runtime/README.md

Lines changed: 9 additions & 241 deletions
Original file line numberDiff line numberDiff line change
@@ -1,252 +1,20 @@
11
# PVQ PoC Runtime
22

3-
<!-- generated by polka.codes -->
3+
FRAME runtime demonstrating PVQ integration used in this repository.
44

5-
A proof-of-concept Substrate runtime demonstrating PVQ (PolkaVM Query) system integration. This runtime serves as a testing environment and reference implementation for integrating PVQ capabilities into Substrate-based blockchains.
5+
### What it exposes
66

7-
## Overview
7+
- Runtime API `PvqApi` with two methods:
8+
- `execute_query(...)`: runs a PVQ program with input bytes and an optional gas limit; if not provided, a default ~2s limit is applied.
9+
- `metadata()`: returns serialized extension metadata bytes (portable type registry + extension functions).
810

9-
This PoC runtime showcases how to:
10-
- Integrate the `PvqApi` runtime API into a Substrate runtime
11-
- Configure PVQ extensions for runtime interaction
12-
- Provide a development environment for testing PVQ queries
13-
- Demonstrate best practices for PVQ integration
11+
### How it’s wired
1412

15-
## Features
13+
- Uses the generated `extensions` module to connect extension traits to runtime pallets.
14+
- Executes programs via `ExtensionsExecutor` with invocation source set to runtime API.
1615

17-
- 🏗️ **Complete Runtime**: Full Substrate runtime with PVQ integration
18-
- 🔌 **Extension Support**: Pre-configured with core PVQ extensions
19-
- 🧪 **Testing Ready**: Optimized for development and testing workflows
20-
- 📡 **Chopsticks Compatible**: Works with Chopsticks for local development
21-
- ⚙️ **Configurable**: Easy to modify and extend for custom use cases
22-
23-
## Architecture
24-
25-
```
26-
┌─────────────────────────────────────────────────┐
27-
│ PoC Runtime │
28-
├─────────────────────────────────────────────────┤
29-
│ Standard Pallets │ PVQ Integration │
30-
│ ├─ Balances │ ├─ PvqApi │
31-
│ ├─ Assets │ ├─ Extensions │
32-
│ ├─ Timestamp │ └─ Executor │
33-
│ ├─ Transaction Payment │ │
34-
│ └─ Sudo │ │
35-
└─────────────────────────────────────────────────┘
36-
```
37-
38-
## Runtime Components
39-
40-
### Standard Pallets
41-
42-
| Pallet | Purpose |
43-
|--------|---------|
44-
| **Balances** | Native token balance management |
45-
| **Assets** | Multi-asset support for fungible tokens |
46-
| **Timestamp** | Block timestamp functionality |
47-
| **Transaction Payment** | Fee calculation and payment |
48-
| **Sudo** | Privileged operations for testing |
49-
50-
### PVQ Integration
51-
52-
| Component | Purpose |
53-
|-----------|---------|
54-
| **PvqApi** | Runtime API for executing PVQ queries |
55-
| **Extensions** | Configured extensions (core, fungibles, swap) |
56-
| **Executor** | PVQ program execution environment |
57-
58-
## Getting Started
59-
60-
### Prerequisites
61-
62-
- Rust toolchain (stable)
63-
- PVQ project dependencies
64-
- Chopsticks (for local development)
65-
66-
### Building the Runtime
67-
68-
```bash
69-
# Build the runtime
70-
cargo build -p poc-runtime --release
71-
72-
# The compiled WASM runtime will be available in target/release/wbuild/
73-
```
74-
75-
### Running with Chopsticks
76-
77-
1. **Start the local development chain:**
78-
```bash
79-
make run
80-
```
81-
82-
2. **The runtime will be available at:**
83-
- HTTP RPC: `http://localhost:8000`
84-
- WebSocket: `ws://localhost:8000`
85-
86-
### Testing PVQ Integration
87-
88-
1. **Build guest programs:**
89-
```bash
90-
make guests
91-
```
92-
93-
2. **Test with PVQ runner:**
94-
```bash
95-
cargo run -p pvq-test-runner -- --program output/guest-total-supply
96-
```
97-
98-
3. **Use with Polkadot JS UI:**
99-
- Connect to `ws://localhost:8000`
100-
- Navigate to Developer → Extrinsics → pvq → executeQuery
101-
- Upload program blob and arguments
102-
103-
## Configuration
104-
105-
### Chopsticks Configuration
106-
107-
The runtime includes a `chopsticks.yml` configuration file:
108-
109-
```yaml
110-
endpoint: wss://acala-rpc-0.aca-api.network
111-
block: latest
112-
runtime-log-level: 5
113-
```
114-
115-
### Runtime Parameters
116-
117-
Key runtime configurations:
118-
119-
```rust
120-
// Maximum execution time for PVQ queries
121-
pub const MAX_EXECUTION_TIME: u64 = 10_000; // 10 seconds
122-
123-
// Maximum memory allocation for guest programs
124-
pub const MAX_MEMORY: u32 = 16 * 1024 * 1024; // 16MB
125-
126-
// Supported extensions
127-
pub const EXTENSIONS: &[&str] = &["core", "fungibles", "swap"];
128-
```
129-
130-
## Development Workflow
131-
132-
### Adding New Pallets
133-
134-
1. **Add dependency to `Cargo.toml`:**
135-
```toml
136-
my-custom-pallet = { version = "1.0.0", default-features = false }
137-
```
138-
139-
2. **Configure in `lib.rs`:**
140-
```rust
141-
impl my_custom_pallet::Config for Runtime {
142-
// Configuration here
143-
}
144-
```
145-
146-
3. **Add to runtime construction:**
147-
```rust
148-
construct_runtime!(
149-
pub struct Runtime {
150-
// ... existing pallets
151-
MyCustomPallet: my_custom_pallet,
152-
}
153-
);
154-
```
155-
156-
### Adding PVQ Extensions
157-
158-
1. **Add extension dependency:**
159-
```toml
160-
my-pvq-extension = { path = "../my-pvq-extension" }
161-
```
162-
163-
2. **Configure in PVQ setup:**
164-
```rust
165-
use my_pvq_extension::ExtensionMyCustom;
166-
167-
// Add to extensions list
168-
```
169-
170-
### Testing Changes
16+
### Build
17117

17218
```bash
173-
# Build and test
174-
cargo build -p poc-runtime
175-
make run
176-
177-
# Test with guest programs
178-
cargo run -p pvq-test-runner -- --program output/guest-example
179-
```
180-
181-
## API Reference
182-
183-
### PVQ Runtime API
184-
185-
The runtime exposes the following PVQ API methods:
186-
187-
#### `execute_query(program: Vec<u8>, args: Vec<u8>) -> Vec<u8>`
188-
189-
Executes a PVQ program with the provided arguments.
190-
191-
**Parameters:**
192-
- `program`: Compiled PVQ program blob
193-
- `args`: Serialized input arguments
194-
195-
**Returns:** Serialized query results
196-
197-
#### `metadata() -> Vec<u8>`
198-
199-
Returns metadata about available PVQ extensions and capabilities.
200-
201-
**Returns:** Serialized metadata information
202-
203-
### Extension APIs
204-
205-
All standard PVQ extensions are available:
206-
207-
- **Core Extension**: Basic functionality and extension discovery
208-
- **Fungibles Extension**: Asset queries and balance information
209-
- **Swap Extension**: DEX interactions and liquidity data
210-
211-
## Troubleshooting
212-
213-
### Common Issues
214-
215-
**Runtime doesn't build:**
216-
```bash
217-
# Clean and rebuild
218-
cargo clean
21919
cargo build -p poc-runtime --release
22020
```
221-
222-
**Chopsticks connection fails:**
223-
```bash
224-
# Check if the endpoint is accessible
225-
curl -X POST -H "Content-Type: application/json" \
226-
--data '{"jsonrpc":"2.0","method":"system_name","id":1}' \
227-
http://localhost:8000
228-
```
229-
230-
**PVQ queries fail:**
231-
- Ensure guest programs are compiled correctly
232-
- Check that required extensions are configured
233-
- Verify argument serialization format
234-
235-
### Debug Mode
236-
237-
Enable debug logging:
238-
239-
```bash
240-
RUST_LOG=debug cargo run -p pvq-test-runner -- --program output/guest-example
241-
```
242-
243-
## Related Components
244-
245-
- [PVQ Executor](../pvq-executor/) - Core execution engine
246-
- [PVQ Runtime API](../pvq-runtime-api/) - API definitions
247-
- [PVQ Extensions](../pvq-extension/) - Extension system
248-
- [Guest Examples](../guest-examples/) - Example programs
249-
250-
---
251-
252-
*This PoC runtime demonstrates PVQ integration patterns and serves as a foundation for production implementations.*

0 commit comments

Comments
 (0)