Skip to content

feat: flag to disallow asset management changes#875

Merged
rflechtner merged 9 commits intobonded-coins-audit-fixesfrom
audit-issue-5
Mar 18, 2025
Merged

feat: flag to disallow asset management changes#875
rflechtner merged 9 commits intobonded-coins-audit-fixesfrom
audit-issue-5

Conversation

@rflechtner
Copy link
Contributor

@rflechtner rflechtner commented Mar 11, 2025

re/ KILTProtocol/ticket#3800

Addresses potential centralisation concerns around manager permissions. Having this additional flag could make the extent of centralisation of powers in a pool more transparent. If it is set to false the reset_team() transaction cannot be used on this pool, in which case the manager has much more limited privileges (locking/unlocking and initiating refunding). This flag can only be set on pool creation and not changed.

Checklist:

  • I have verified that the code works
    • No panics! (checked arithmetic ops, no indexing array[3] use get(3), ...)
  • I have verified that the code is easy to understand
    • If not, I have left a well-balanced amount of inline comments
  • I have left the code in a better state
  • I have documented the changes (where applicable)
    • Either PR or Ticket to update the Docs
    • Link the PR/Ticket here

@rflechtner
Copy link
Contributor Author

@ntn-x2 & @abdulmth what do you think about this idea? Unnecessary or helpful?

@rflechtner rflechtner requested review from abdulmth and ntn-x2 March 11, 2025 16:36
@ntn-x2
Copy link
Contributor

ntn-x2 commented Mar 11, 2025

I think it makes sense, but there start to be too many bool for the different permissions. I would encapsulate these in an (extensible) struct that includes the different permissions needed, similar to what we do in the delegation pallet. If we adopt that approach, I am fine with having two and potentially more permission types in the future.

@rflechtner
Copy link
Contributor Author

I think it makes sense, but there start to be too many bool for the different permissions. I would encapsulate these in an (extensible) struct that includes the different permissions needed

I was thinking the same thing. The delegation pallet uses bitflags, which has terrible client-side handling, but a regular struct containing booleans should work just as well? If you think this should be 'extensible' in the sense that we reserve additional bits for future use without migrations, we could probably add dummy fields to it. Alternatively we could use bitflags on the storage level but structs in extrinsics and runtime calls.

@ntn-x2
Copy link
Contributor

ntn-x2 commented Mar 12, 2025

Yes either use bitflags in storage and provide a From impl from the input param, or use directly the input param in storage. New fields for booleans are false by default, so that is probably to keep in mind when planning for extensibility, on how to name fields. But it sounds good to me.

@abdulmth
Copy link
Contributor

can't say much about the implementation details, but I think the idea is good, having the option to disable the manager from having complete control over the tokens in all accounts can help.

@rflechtner
Copy link
Contributor Author

Yes either use bitflags in storage and provide a From impl from the input param, or use directly the input param in storage. New fields for booleans are false by default, so that is probably to keep in mind when planning for extensibility, on how to name fields. But it sounds good to me.

I experimented with nesting all immutable settings relating to bonded currencies in a struct, what do you think about that? 7c3c127

@ntn-x2
Copy link
Contributor

ntn-x2 commented Mar 12, 2025

Yes this looks already better, and harder to misuse because of the named properties.

@rflechtner rflechtner mentioned this pull request Mar 13, 2025
6 tasks
@rflechtner rflechtner marked this pull request as ready for review March 13, 2025 17:55
Comment on lines +100 to +101
/// The current storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ntn-x2 I wasn't sure about this one, but we need to bump the storage version if we change the pool struct right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, correct.

@rflechtner
Copy link
Contributor Author

@ntn-x2 I fixed tests and formatting, so if you agree that we can implement migrations for peregrine separately this is ready to be reviewed. My idea is that I'd implement migrations with the help of Adel once he's back next week, as we'd need this merged by Wednesday before the audit deadline runs out.

Copy link
Contributor

@ntn-x2 ntn-x2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it looks good 👍

@ntn-x2
Copy link
Contributor

ntn-x2 commented Mar 17, 2025

Perhaps you can remove the storage version here, and introduce it in the PR that also adds the migration.

@rflechtner
Copy link
Contributor Author

Perhaps you can remove the storage version here, and introduce it in the PR that also adds the migration.

I kinda like that the failing test reminds us of the migration we still need to do though, and it doesn't seem to mess with anything else

@rflechtner rflechtner merged commit fb65baa into bonded-coins-audit-fixes Mar 18, 2025
12 of 15 checks passed
@rflechtner rflechtner deleted the audit-issue-5 branch March 18, 2025 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants