-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit tests for mint anchor transaction pre-commitment output #1418
Draft
ffranr
wants to merge
26
commits into
main
Choose a base branch
from
unit-tests-mint-pre-commit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
Introduce MintingBatch.AddSeedling, a method for attempting to add seedlings to a batch. Future commits will extend this method with validation logic to ensure compatibility of the seedling with others already in the batch.
Add the UniverseCommitments field to the MintingBatch structure, populating it when a seedling is added to the batch. Include validation logic to ensure that for a batch with uni commitment enabled, all seedlings share the same asset group key.
Set the seedling's delegation key as part of the preparation process before batch inclusion.
Modify `prepAssetSeedling` to set the seedling metadata fields `UniverseCommitments` and `DelegationKey`. This is handled here instead of in rpcserver.
Ensure that all candidate seedlings in a batch comply with universe commitment feature restrictions. If the feature is enabled, all seedlings must have a delegation key, and the key must be identical across the batch.
Modified seedling validation to permit enabling the universe commitments feature for new minting tranches.
Clarified that the group internal key is not used as the delegation key by default.
Improve code health/readability.
Seedling metadata validation is now handled in ChainPlanter.prepAssetSeedling, so it is no longer needed in rpcserver.
This allows deriving a pre-commitment output script key when the universe commitment feature is enabled.
Add a check to verify that the change output index is defined after anchor funding. Since the funding request guarantees a change output, the index should be known. Modify the `MockWalletAnchor.FundPsbt` method to compute a reasonable change output index.
Modify anchor transaction construction to include a pre-commitment output when the universe commitments feature is enabled. Add a new type to encapsulate the pre-commitment output metadata along with the funded mint anchor transaction. This allows us to store and retrieve pre-commitment-related information from the database when storing or retrieving the batch mint transaction.
Update the SQL query in BindMintingBatchWithTx to return the batch ID. This ID will be used for populating the universe commitment anchor rows in the database.
Add a new `assets_output_index` column to the `asset_minting_batches` table to store the output index of the asset anchor transaction. Populate this column for existing entries based on the `change_output_index`. Introduce a `universe_commitments` flag column to indicate whether universe commitments are enabled for a minting batch, defaulting to `FALSE`. Create the `mint_anchor_uni_commitments` table to associate a mint batch anchor transaction with its universe commitments, storing the pre-commitment output index, Taproot internal key, and asset group pub key.
Update the MintingBatch.GenesisPacket field to use the FundedMintAnchorPsbt type to include pre-commitment output information.
Refactor BindMintingBatchWithTx into insertMintAnchorTx, which will also handle inserting pre-commitment information into the database. insertMintAnchorTx will also ensure that the genesis point is in the database.
Add unit tests for the SQL queries `UpsertMintAnchorUniCommitment` and `FetchMintAnchorUniCommitment`.
Separate the mint anchor transaction fee rate calculation from fundGenesisPsbt into anchorTxFeeRate. This refactor is part of a broader effort to simplify calling fundGenesisPsbt from unit tests.
Extract the wallet funding call into a closure that is passed as an argument. This prepares fundGenesisPsbt to become a standalone function, making it easier to call in unit tests.
Pass the pending batch into fundGenesisPsbt and convert it into a standalone function rather than a method on ChainPlanter. This change makes it easier to call fundGenesisPsbt from unit tests.
The batch key was only used for logging. This commit moves the log messages outside fundGenesisPsbt, simplifying the function for better code health.
Use the standalone function fundGenesisPsbt when generating a mock batch genesis (mint anchor tx) funded PSBT. This change will allow us to seamlessly include pre-commitment outputs in the mock process later.
Pull Request Test Coverage Report for Build 13633528219Details
💛 - Coveralls |
Refactor RandSeedlingMintingBatch for generalization: - Rename to RandMintingBatch. - Change argument to `options...` pattern for extendability. The next commit will introduce additional options, enabling the creation of more specific mint batches.
d41d194
to
83ba31c
Compare
a2263f6
to
cef2567
Compare
Needs rebase. |
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.
Add unit tests to provide coverage for the changes made in #1325
Depends on #1325 which should be merged first.