Add set treasury two step rotation#607
Open
gloskull wants to merge 2 commits into
Open
Conversation
…plementation feat(revenue-pool): two-step treasury rotation (set_treasury)
Author
|
Done with this issue. |
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.
Motivation
Introduce a dedicated treasury principal for deposit_yield() so yield-deposit authority can be rotated separately from the admin for stronger operational security.
Use a two-step nomination/accept pattern for rotating the treasury to avoid accidental or unilateral changes to deposit authority.
Preserve backward compatibility by defaulting the new treasury slot to the existing admin on initialization.
Description
Add dedicated storage keys and views: TREASURY_KEY / PENDING_TREASURY_KEY, get_treasury(), and get_pending_treasury() and initialize treasury to the admin in init() (changes in contracts/revenue_pool/src/lib.rs).
Implement two-step rotation entrypoints set_treasury(caller, new_treasury), accept_treasury(env, caller), and cancel_treasury_transfer(env, caller) with TTL bumps and events, and update deposit_yield() to require the configured treasury (not implicitly admin) (changes in contracts/revenue_pool/src/lib.rs).
Add event helpers for treasury lifecycle topics and unit tests for their byte identity in contracts/revenue_pool/src/events.rs, plus document new events and update the revenue-pool interface JSON and EVENT_SCHEMA.md to describe the new calls and event shapes.
Add focused unit tests exercising initialization, nomination, acceptance, cancellation, authorization rejections, and post-acceptance behaviour, and small proptest adjustment to maintain invariant checks (changes in contracts/revenue_pool/src/test.rs and contracts/revenue_pool/src/test_proptest.rs).
Testing
Ran cargo test -p callora-revenue-pool which passed locally (101 tests passed).
Ran bash scripts/check-event-shape.sh which verified event publish sites match EVENT_SCHEMA.md and passed.
Ran rustfmt --check on modified revenue pool files which passed formatting checks.
Ran cargo test across the workspace which failed due to unrelated compile errors in the settlement contract (duplicate/mismatched symbols and types outside the revenue-pool changes); these workspace-level failures are pre-existing and not caused by the revenue-pool changes.
Closes #564