Plan driven strategy#88
Draft
arminsabouri wants to merge 10 commits into
Draft
Conversation
The existing MultipartyStrategy recomputed input selection and change
decomposition inline on every enumeration call. There was no persistent
record of which action sequences were still viable, so the wallet redid
the same BNB and change math every wake cycle and had no way to rank
competing paths against each other before committing to one.
Introduce the core plan tree types:
- StepAction: a single RegisterInput or RegisterOutput event
- PlanNode: one tree node carrying an action and its continuations
- PlanTree: the full tree with a depth counter that tracks how many
actions have been committed so far
generate_input_candidates produces up to k disjoint input sets by
running BNB iteratively, excluding previously selected coins each round,
and falling back to spend-all when BNB finds nothing.
build_plan_tree assembles a PlanTree from pre-computed input sets:
sorts inputs by denomination fit, builds a linear RegisterInput chain,
prepends fixed payment outputs, then attaches the branching change
decomposition produced by DenominationMenu (introduced in the parent
commit).
Adds commit() to advance the cursor to a chosen StepAction (pruning all siblings), next_actions() to enumerate live choices at the current depth, reachable_leaves() to collect all root-to-leaf action paths from the cursor, and committed_inputs() to compute outpoints present on every reachable path. Includes CommitError for invalid commit attempts and full test coverage.
Introduces PeerState to carry observed participant inputs and outputs from the bulletin board. Adds score_leaves() to re-rank all reachable leaf paths using CompositeScorer, and plan_from_path() to reconstruct a Plan from a leaf action sequence plus peer state for scoring purposes.
Adds wallet_plan_tree and selected_plan_branch fields to WalletData. Advances the tree cursor as outputs and inputs are registered during session participation, and resets both fields when a session completes so a fresh plan is built on the next wake.
Adds an optional pre_enumerate() method to Strategy, called once per wake_up before action enumeration, for strategies to build or update persistent state such as a plan tree. When a selected_plan_branch is already set, wake_up skips scoring and takes the first non-Wait action directly.
Rewrites enumerate_candidate_actions to use the wallet_plan_tree and selected_plan_branch from WalletData instead of recomputing coin selection inline. Idle step now registers only the branch's committed inputs and proposes cospend using those UTXOs. Output contribution uses change amounts derived from the selected branch when available, falling back to the previous heuristic. Removes CostBracket and bracket(). Renames the strategy to PlanDrivenStrategy throughout.
Replaces MultipartyStrategy with PlanDrivenStrategy in the allowlist and adds missing min_fallback_plans fields to the example config.
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.
I'll get a more comprehensive description up. Drafting this for now. Some of these commits may get subdivided further into other Prs