Closed
Conversation
Add a new setup module providing a framework for managing multi-party protocol setup steps. Includes SetupStep trait for step lifecycle management, StepPhase enum for state tracking, ExchangeConfig for exchange configuration, and template implementations for keys, nonces, and signatures steps
Add a new setup orchestration system with SetupEngine that provides a state machine-based approach to managing multi-party protocol setup steps. This enables cleaner separation of concerns and allows protocols to opt-in gradually to the new system.
This is the next generation Program implementation that: - Uses SetupEngine for orchestrating setup steps - Delegates aggregation responsibility to protocols - Provides cleaner separation of concerns - Allows protocols to opt-in gradually via UsesSetupSteps trait
…-leaders -> leader -> all non-leaders)
… leader broadcast
…ndler Remove the UsesSetupSteps trait and integrate setup steps functionality directly into the ProtocolHandler trait. This simplifies the architecture by eliminating an extra trait layer
- Removed use_broadcasting from ExchangeConfig struct and Default impl - Updated exchange_config() in KeysStep, NoncesStep, and SignaturesStep
Rename the collaboration protocol to aggregated key protocol to better reflect its purpose of generating aggregated MuSig2 keys.
Rename the template_steps directory to steps for better clarity and consistency.
Add default implementations for optional protocol methods in the ProtocolHandler trait to reduce boilerplate code in simple protocols like AggregatedKeyProtocol.
Replace manual impl Default implementations with #[derive(Default)] for KeysStep, NoncesStep, and SignaturesStep. These are unit structs where the manual implementation was redundant, as it only called new().
…on.rs structure - Remove unused UTXO funding section that was not being used in the test - Remove unused wallet funding initialization - Replace manual bitcoin/bitcoind setup with prepare_bitcoin() helper - Add bitcoind cleanup at test end (matching integration.rs pattern) - Clean up unused imports (Bitcoind, BitcoinClient, Wallet, etc.) - Remove unused MIN_TX_FEE constant
…_steps() - Replace Option<Vec<Box<dyn SetupStep>>> with Option<Vec<SetupStepName>> in ProtocolHandler::setup_steps() - Add SetupStepName enum (Keys, Nonces, Signatures) for type-safe step names - Implement factory function create_setup_step() to create steps from enum - Update SetupEngine::new() to accept Vec<SetupStepName> instead of Vec<Box<dyn SetupStep>> - Remove trait object allocations at protocol definition time - Update all protocol implementations (AggregatedKeyProtocol, default implementation) - Update tests to use enum variants instead of string literals
Move all setup-related logic from ProgramV2 to SetupEngine to improve separation of concerns. ProgramV2 should only care about whether setup is complete or not, not the internal details of setup steps.
…control - Remove duplicate save() call in BitVMX after receive_setup_data() to prevent state overwrites that caused tick() to re-enter build() and send duplicate messages. ProgramV2 now handles saving internally. - Write state to legacy key in ProgramV2::save() so is_active_program() can correctly identify Ready programs and skip them in process_programs(). - Add send_setup_completed() trait method to ProtocolHandler to allow protocols to suppress SetupCompleted messages. AggregatedKeyProtocol returns false to maintain backward compatibility with SetupKey callers that only expect AggregatedPubkey responses. - Clean up aggregated_key test by removing unused helper struct and setup completion assertions that are no longer relevant.
- Remove special-case handling for single-participant protocols in ProgramV2::setup() This allows SetupEngine to handle all cases uniformly through the normal setup flow - Add single-participant handling in AggregatedKeyProtocol::build_protocol() When only one participant exists, use their own key directly instead of attempting MuSig2 aggregation (which requires at least 2 participants) - Add test_aggregated_key_single_participant() test Verifies that single-participant protocols work correctly through SetupEngine without any special-case bypass logic
- Remove deprecated `collaborate` module and all collaboration processing/storage paths - Read aggregated pubkey/keypair derivation from globals (`final_aggregated_key`) - Update aggregated-key single participant test to use `SetupKey` and assert globals match API response
- Remove confirmation_threshold parameter from SubscribeToTransaction and SubscribeToRskPegin API messages - Simplify tick() return type from Result<bool> to Result<()> - Remove unused GracefulShutdown trait implementation - Update imports: use PubKeyHash from bitvmx_broker instead of bitvmx_operator_comms - Add None parameters to TypesToMonitor calls for consistency - Improve test infrastructure: - Add existence checks before removing directories - Add Docker container cleanup logic to prevent conflicts - Update shutdown policy tests to match new tick() signature - Code formatting and cleanup (remove unused imports, improve formatting)
Resolved conflict in tests/common/mod.rs by combining imports: - Added Path from std::path (needed for check_bitvmx_cpu_built) - Kept Command from std::process (needed for Docker cleanup) - Added warn to tracing imports (used in helper functions)
…on duplication Add CooperativeSignatureProtocol with complete MuSig2 signing flow: - Implement CooperativeSignatureProtocol using all three setup steps: * KeysStep: Generate and exchange keys, compute aggregated key * NoncesStep: Generate and exchange nonces for signing * SignaturesStep: Generate and exchange partial signatures - Enhance KeysStep to compute MuSig2 aggregated keys during on_step_complete() - Extend NoncesStep to support message-based nonce generation and add participant nonces to key_manager on step completion - Error on empty computed_aggregated in NoncesStep/SignaturesStep instead of silently skipping - Register PROGRAM_TYPE_COOPERATIVE_SIGNATURE in protocol handler and types - Add cooperative_signature integration test Eliminate MuSig2 aggregation duplication across protocols: - Pass pre-computed aggregated keys from KeysStep through ProgramV2::build_protocol() instead of an empty HashMap - Simplify AggregatedKeyProtocol::build() to use computed_aggregated from KeysStep (~50 lines removed) - Simplify CooperativeSignatureProtocol::build() to use computed_aggregated from KeysStep (~40 lines removed) - Remove redundant aggregated_pub_keys.sort() in KeysStep (MuSig2 new_session() sorts internally)
This commit fixes compatibility issues after rebasing feature/protocol-workflow onto dev branch. Restores dev's API signatures while preserving ProgramV2 implementation changes.
Simplify key extraction by removing intermediate variable and chaining method calls directly. Update comment to accurately reflect that we're getting the public key for the aggregation session.
Remove invalid single-participant case and add validation to ensure at least 2 participants are present before attempting MuSig2 aggregation. Return an error if there are not enough participants, as MuSig2 requires multiple participants to create an aggregated key.
…tocol Remove redundant verification code that checks if the variable was stored correctly. The store is working fine and doesn't need to be tested.
Change storage of final_aggregated_key from VariableTypes::String to VariableTypes::PubKey to preserve the native PublicKey format instead of converting to string. This maintains type safety and avoids unnecessary serialization/deserialization.
Remove storage lookup for "from" identifier and use context.components_config.l2 directly for sending AggregatedPubkey messages. This simplifies the code and removes unnecessary storage operations. Also removed unused imports (Identifier, KeyValueStore).
…tocol-workflow # Conflicts: # src/program/protocols/aggregated_key.rs
- Refactor setup engine and step implementations for better maintainability - Remove unused ExchangeConfig module and related dead code - Simplify setup step data handling and reduce code duplication - Update aggregated key and cooperative signature protocol implementations - Improve test utilities and common test helpers - Enhance protocol handler integration with setup workflow - Update program_v2 and bitvmx.rs for better protocol workflow support This commit squashes 7 checkpoint commits that collectively improve the protocol workflow implementation and clean up the setup engine codebase.
…ine with an enum-based `SetupStepEnum` for zero-heap enum dispatch
…TXOs in ProgramV2
…ges instead of Setup
Remove ProgramV2 as a separate struct and consolidate all program logic into a single Program that uses SetupEngine for multi-step setup orchestration (keys, nonces, signatures). Main changes: - Delete src/program/program_v2.rs entirely - Remove dual-routing (get_program_version) from bitvmx.rs - Remove ProgramVersion enum and version field from ProgramStatus - Remove setup_v2/SetupV2 API variants — all setup goes through Program - Simplify ProgramState: remove SettingUpV2 and SettingUp(payload) variants - Migrate protocol configs (lock, slot, transfer, dispute) to unified API Code quality: - Extract try_send_setup_completed() to deduplicate Monitoring/Ready logic - Extract engine() helper for SetupEngine access - Reduce log verbosity in hot paths (load, process_comms_message, tick) - Add warn! when notify_news() is called with no participant keys - Remove dead StoreKey enum from program.rs - Clean trailing whitespace
Replace manual match-based trait delegation with enum_dispatch macro, consistent with the existing ProtocolHandler/ProtocolType pattern.
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.
No description provided.