generated from midnightntwrk/midnight-template-repo
-
Notifications
You must be signed in to change notification settings - Fork 16
feat: treasury initialization for mainnet genesis #563
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
Open
m2ux
wants to merge
10
commits into
main
Choose a base branch
from
mike/feat/treasury-initialization
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.
+359
−5
Conversation
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
Add change file documenting the upcoming treasury initialization feature for the mainnet genesis block. JIRA: PM-20981
Add support for initializing the Midnight treasury from observed cNight deposits in the ICS (Illiquid Circulation Supply) contract on Cardano. - Add CnightTreasuryConfig type with validation for config files - Add --cnight-treasury-config CLI argument to generate-genesis command - Add fund_treasury() method using DistributeReserve and PayBlockRewardsToTreasury - Integrate treasury funding early in genesis flow (before wallet distribution) - Add example config files for dev and preview environments
Add #[allow(clippy::too_many_arguments)] to init() method. The parameter count is a pre-existing issue; refactoring to a config struct is deferred.
Add test_genesis_with_treasury_config that verifies end-to-end treasury funding during genesis generation. The test creates a treasury config with multiple UTxOs, passes it to GenesisGenerator, and verifies the resulting state.treasury contains the expected NIGHT balance.
Merged ledger-parameters-config feature with treasury-config feature. Both CLI arguments are now supported: - --cnight-treasury-config: Initialize treasury from ICS observations - --ledger-parameters-config: Custom ledger parameters
Contributor
Updated treasury.json to cnight-treasury-config.json to match the actual implementation.
Removed 4 tests that provided minimal value: - test_error_message_total_mismatch: only tests Display impl - test_treasury_amount: trivial accessor test - test_validate_total_matches_sum: redundant with test_parse_valid_config - test_validate_zero_total_empty_utxos: trivial edge case Remaining tests (3 unit + 1 integration) cover critical paths.
- Added #[allow(clippy::too_many_arguments)] to GenesisGenerator::new() - Removed 4 low-value tests from treasury_config.rs
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.








Overview
Implement treasury initialization for the Midnight mainnet genesis block. The treasury is initialized from observed cNight deposits in the ICS (Illiquid Circulation Supply) contract on Cardano, configured through a new
cnight-treasury-config.jsonfile.JIRA: PM-20981
Epic: PM-20554 - Mainnet Genesis Block
Changes
New Files
util/toolkit/src/treasury_config.rsres/dev/cnight-treasury-config.jsonres/preview/cnight-treasury-config.jsonModified Files
util/toolkit/src/lib.rstreasury_configmoduleutil/toolkit/src/genesis_generator.rsfund_treasury()method, integration testutil/toolkit/src/commands/generate_genesis.rs--cnight-treasury-configCLI argumentImplementation Details
Configuration file (
cnight-treasury-config.json):ics_contract_address: ICS contract address on Cardanoutxos[]: List of UTxOs withtx_hash,output_index,expected_amounttotal_night_amount: Must equal sum of UTxO amountsTwo-step transfer via block reward pool:
DistributeReserve(amount)- Move from reserve pool to block_reward_poolPayBlockRewardsToTreasury { amount }- Move from block_reward_pool to treasuryValidation:
🗹 TODO before merging
📌 Submission Checklist
🧪 Testing Evidence
🔱 Fork Strategy
Links