1 unstable release
Uses new Rust 2024
| 0.1.1 | Jul 24, 2025 |
|---|---|
| 0.1.0 |
|
#1106 in Algorithms
31KB
344 lines
Verdyce
A time-decay threshold consensus engine for decentralized voting and governance.
This library provides a pure Rust implementation of consensus mechanisms with configurable decay models and dynamic approval thresholds, allowing developers to build decentralized governance systems that encourage early participation while maintaining security through escalating scrutiny over time.
Components
Library
The following modules provide the core functionality:
engineprovides the main consensus coordinator for managing proposals and votesmodelscontains the core data structures for proposals and votesdecayimplements time-decay models for vote weight calculationthresholdprovides threshold progression functionswindowmanages voting window state and timing
Using as a library
Add verdyce to your project to access all components:
[dependencies]
verdyce = "0.1.0"
A simple example of use follows. For more details, please visit the documentation.
use verdyce::{
engine::Engine,
models::{proposal::Proposal, vote::{Vote, VoteChoice}},
decay::DecayModel,
threshold::ThresholdModel,
};
use uuid::Uuid;
use chrono::Utc;
let mut engine = Engine::new();
let proposal = Proposal::new(
"Protocol Upgrade".to_string(),
"Upgrade to version 2.0".to_string(),
3600, // 1 hour voting period
DecayModel::Linear,
ThresholdModel::Linear(0.0001, 0.5),
);
let proposal_id = proposal.id;
engine.add_proposal(proposal);
let vote = Vote {
validator_id: Uuid::new_v4(),
choice: VoteChoice::Yes,
timestamp: Utc::now(),
revision: 0,
reason: None,
};
engine.cast_vote(proposal_id, vote);
engine.evaluate_all(Utc::now());
Features
Time-Decay Voting
Vote weights decrease over time to encourage early participation:
- Linear - Steady decline from 1.0 to 0.1
- Exponential - Rapid early decline with configurable rate
- Stepped - Discrete weight levels across voting phases
Dynamic Thresholds
Approval thresholds increase over time for higher scrutiny:
- Linear - Steady increase:
threshold = t × rate + start - Exponential - Asymptotic growth with configurable parameters
- Sigmoid - S-curve progression for smooth transitions
Smart Voting Windows
- Configurable duration with grace periods
- Auto-extension when near threshold and time expiry
- State tracking through the proposal lifecycle
Revision Penalties
Vote changes are penalized to discourage manipulation while allowing legitimate updates.
Building
You can use Cargo to build the library:
cargo build
Minimum supported Rust version is 1.70.0.
Testing
Run the test suite:
cargo test
Generate and view documentation:
cargo doc --open
Contributing
This project is under active development. Contributions are welcome! Please ensure:
- All tests pass:
cargo test - Code is properly formatted:
cargo fmt - No clippy warnings:
cargo clippy - Documentation is updated for public APIs
See the contributor guidelines for more details.
License
Licensed under the MIT license (LICENSE or http://opensource.org/licenses/MIT).
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be licensed as above, without any additional terms or conditions.
Dependencies
~4–6MB
~101K SLoC