Skip to content

Commit 041b92b

Browse files
authored
feat(storage): add validated storage with WASM-based consensus (#10)
Add per-challenge storage system where validators must reach consensus before data is accepted. This prevents abuse by requiring WASM-defined validation logic and cryptographic signatures on all proposals and votes. Core implementation in distributed-storage crate: - ValidatedStorage: main struct managing proposals, votes, and commits - StorageWriteProposal: represents a write request with value hash - StorageWriteVote: validator vote with optional WASM validation result - ConsensusResult: tracks consensus state and commitment status - WasmStorageValidator trait: interface for WASM validation logic - DefaultWasmValidator: passthrough implementation for testing - ValidatedStorageConfig: configurable quorum size and timeouts WASM runtime interface integration: - ChallengeStorage: high-level API for WASM modules to access storage - ChallengeStorageConfig: per-challenge storage configuration - Full async support with proposal/vote/commit lifecycle Key features: - Configurable quorum size for consensus requirements - Proposal expiration with automatic cleanup - Duplicate and conflicting vote detection - Cryptographic hashing of values (SHA256) - Comprehensive test coverage for all operations Dependencies: - Added sha2 to wasm-runtime-interface for hashing
1 parent 6061a4c commit 041b92b

6 files changed

Lines changed: 1672 additions & 1 deletion

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/distributed-storage/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ pub mod replication;
9393
pub mod state_consensus;
9494
pub mod store;
9595
pub mod submission;
96+
pub mod validated_storage;
9697
pub mod weights;
9798

9899
// Re-export main types for convenience
@@ -129,6 +130,13 @@ pub use state_consensus::{
129130
StateRootConsensus, StateRootConsensusError, StateRootProposal, StateRootVote,
130131
};
131132

133+
// Validated storage with WASM consensus
134+
pub use validated_storage::{
135+
ConsensusResult as ValidatedConsensusResult, DefaultWasmValidator, StorageWriteProposal,
136+
StorageWriteVote, ValidatedStorage, ValidatedStorageConfig, ValidatedStorageError,
137+
WasmStorageValidator, WasmValidationResult,
138+
};
139+
132140
#[cfg(test)]
133141
mod integration_tests {
134142
use super::*;

0 commit comments

Comments
 (0)