feat: reject pegin flow#493
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
Adds a new “reject pegin” user/member workflow end-to-end (CLI → user-api → coordinator flow → transaction-dispatcher contract call), and wires coordinator pegin flows to close as Rejected when the on-chain RejectPeginRegistered event is confirmed.
Changes:
- Introduces
RejectPeginFlow/RejectPeginProcessorand persists them via the coordinator store. - Adds
POST /member/reject-peginto user-api and a corresponding CLI command. - Adds transaction-dispatcher support for
PeginManager.rejectPegin, plus event decoding/handling to close pegin flows as rejected.
Reviewed changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| user-api/src/server.rs | Adds /member/reject-pegin endpoint and request payload type. |
| user-api/Cargo.toml | Adds bitcoin dependency for Txid. |
| transaction-dispatcher/src/types.rs | Adds RejectPeginInput/Output aliases. |
| transaction-dispatcher/src/rsk_gateway.rs | Adds reject_pegin gateway API + wiring to new invoke. |
| transaction-dispatcher/src/contracts/pegin_manager.rs | Exposes RejectPeginInvoke + contract method wrapper. |
| transaction-dispatcher/src/contracts/interactions/reject_pegin.rs | Implements RejectPeginInvoke interaction. |
| transaction-dispatcher/src/contracts/interactions/mod.rs | Registers reject_pegin interaction module. |
| coordinator/src/user_requests.rs | Adds RejectPeginRequest + serialization/deserialization tests. |
| coordinator/src/types.rs | Adds RejectPeginRegistered event decoding and user request variant. |
| coordinator/src/store.rs | Adds store keys/prefixes for reject-pegin flows. |
| coordinator/src/main.rs | Passes reject-pegin flow config into Coordinator::new. |
| coordinator/src/flows/reject_pegin/reject_pegin_processor.rs | New processor to drive reject-pegin flow and confirm RSK events. |
| coordinator/src/flows/reject_pegin/reject_pegin_flow.rs | New state machine for reject-pegin BitVMX + RSK registration. |
| coordinator/src/flows/reject_pegin/mod.rs | Exposes reject-pegin flow/processor module API. |
| coordinator/src/flows/pegin/pegin_processor.rs | Handles RejectPeginRegistered to close active pegin flows. |
| coordinator/src/flows/pegin/pegin_flow.rs | Adds rejected completion outcome and transitions to Done on rejection. |
| coordinator/src/flows/mod.rs | Registers reject_pegin module. |
| coordinator/src/flows/funding_info_flow.rs | Explicitly ignores UserRequests::RejectPegin. |
| coordinator/src/flows/common/context.rs | Adds clippy allow for GlobalContext field naming lint. |
| coordinator/src/flows/committee/setup_committee_processor.rs | Explicitly ignores UserRequests::RejectPegin. |
| coordinator/src/coordinator.rs | Wires RejectPeginProcessor into coordinator processor set + mocks. |
| coordinator/src/config.rs | Adds [flows.reject_pegin] config section and defaults. |
| config/base.toml | Adds [flows.reject_pegin] defaults in base configuration. |
| common/src/types.rs | Adds serde helpers for decimal-string CommitteeId and 0x-optional Txid. |
| common/src/msg_broker/bitvmx_types.rs | Adds BitVMX constants and RejectPeginData payload type. |
| cli/README.md | Documents new reject-pegin CLI usage and module file. |
| cli/operations/src/reject_pegin.rs | Implements CLI operation calling /member/reject-pegin with validation. |
| cli/operations/src/main.rs | Adds user reject-pegin CLI subcommand wiring. |
| cli-operations.sh | Documents the new user reject-pegin usage. |
| Cargo.lock | Records dependency graph changes from added bitcoin dependency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| self.state.log_id | ||
| ); | ||
| } | ||
| } | ||
| self.write_completion_marker()?; |
There was a problem hiding this comment.
I think there might be a small race: RejectPeginRegistered is accepted from any non-Done pegin step, but bitvmx_protocol_id is only set after the flow processes PeginRequested. If the reject event is processed before that local step, the flow transitions to Done with bitvmx_protocol_id = None, and write_completion_marker() fails. The "risk" is that the rejected pegin does not close cleanly and may require intervention, restart, or admin cleanup. Do you think this case is worth covering, or can we be more relaxed since this is not a productive feature? If so, we should either delay the reject event until PeginRequested has been applied, or reject this transition until the protocol id exists.
Adds a new reject-pegin path so a member can explicitly reject a pegin request and close the corresponding pegin flow when the on-chain `RejectPeginRegistered` event is observed. - coordinator: new `RejectPeginFlow` and `RejectPeginProcessor`, plus pegin-flow integration that transitions to `Done` with a `Rejected` completion outcome on confirmed `RejectPeginRegistered`. - user-api: new `POST /member/reject-pegin` endpoint. - transaction-dispatcher: new `rejectPegin` interaction on PeginManager. - cli: `cli-operations.sh user reject-pegin` command. - config: `[flows.reject_pegin]` section with `min_tx_confirmations` and `blocks_delay_for_tx_check`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0da8d41 to
5e65590
Compare
| processor.flows = restore_flows(store.as_ref(), StorePrefix::RejectPeginFlow, flow_factory) | ||
| .expect("Failed to load reject pegin flows from store"); |
| } | ||
|
|
||
| fn test_store() -> Rc<CoordinatorStore> { | ||
| let path = std::env::temp_dir().join(format!("reject-pegin-flow-test-{}", Uuid::new_v4())); |
|
|
||
| fn test_store() -> Rc<CoordinatorStore> { | ||
| let path = | ||
| std::env::temp_dir().join(format!("reject-pegin-processor-test-{}", Uuid::new_v4())); |
Adds a new reject-pegin path so a member can explicitly reject a pegin request and close the corresponding pegin flow when the on-chain
RejectPeginRegisteredevent is observed.RejectPeginFlowandRejectPeginProcessor, plus pegin-flow integration that transitions toDonewith aRejectedcompletion outcome on confirmedRejectPeginRegistered.POST /member/reject-peginendpoint.rejectPegininteraction on PeginManager.cli-operations.sh user reject-pegincommand.[flows.reject_pegin]section withmin_tx_confirmationsandblocks_delay_for_tx_check.Description
Motivation and Context
How Has This Been Tested?
Types of changes