Repository navigation
feat(signing)!: introduce pluggable ConsensusSignatureScheme trait - #16
Merged
Merged
Conversation
- Add `ConsensusSignatureScheme` (identity + async sign + static verify) in `src/signing.rs`; decouples the consensus core from Ethereum. - `ConsensusService` gains a `Signer` generic param tracked via PhantomData; `validate_proposal`, `validate_vote`, and session helpers are generic over the scheme. - `EthereumConsensusSigner` (wraps `alloy::signers::local::PrivateKeySigner`) is the default scheme used by `DefaultConsensusService`. - Collapse sign/verify errors into a single `ConsensusSchemeError` thiserror enum (`Sign` / `Verify` variants); drop `MismatchedLength` and `InvalidSignature` from `ConsensusError`. - Add `tests/custom_scheme_tests.rs` exercising the generic path with a non-Ethereum stub scheme. - Bump to 0.3.0; refresh CHANGELOG, README, and lib docs. BREAKING CHANGE: `cast_vote`, `build_vote`, and `validate_proposal` now require a `ConsensusSignatureScheme`. Existing callers that passed a `PrivateKeySigner` should wrap it in `EthereumConsensusSigner::new(...)`.
4 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ConsensusSignatureSchemetrait (identity+ asyncsign+ staticverify) insrc/signing.rs.ConsensusService<Scope, Storage, Event, Signer>now carries the scheme as a generic param viaPhantomData;validate_proposal,validate_vote, andConsensusSessionhelpers are generic overSigner.EthereumConsensusSignerwrapsalloy::signers::local::PrivateKeySignerand is the default scheme used byDefaultConsensusService. Embedders can plug in Ed25519, HSM-backed signers, libchat accounts, or any other scheme.ConsensusSchemeErrorthiserror enum (Sign/Verifyvariants).ConsensusError::MismatchedLengthandInvalidSignatureare removed; scheme-level failures surface viaConsensusError::SignatureScheme(_).tests/custom_scheme_tests.rsexercises the generic path end-to-end with a non-Ethereum stub scheme, proving the abstraction holds.0.3.0with CHANGELOG migration notes and refreshed README.Breaking change
cast_vote,build_vote, andvalidate_proposalnow require aConsensusSignatureScheme. Migrate by wrapping existing signers:validate_proposal::<EthereumConsensusSigner>(&proposal)?;for direct callers.Test plan
cargo fmt --all --checkcargo clippy --all-features --tests -- -D warningscargo test --all-features --tests(all 91 tests pass, including the newcustom_scheme_tests)cargo test --doc