Skip to content
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

SYS-4220 Disable lowering #438

Merged
merged 8 commits into from
Sep 23, 2024
Merged

SYS-4220 Disable lowering #438

merged 8 commits into from
Sep 23, 2024

Conversation

nahuseyoum
Copy link
Contributor

@nahuseyoum nahuseyoum commented Sep 22, 2024

Proposed changes

This PR introduces a flag to toggle lowering capabilities of the chain.

Type of change/Merge

🚨What type of change is this PR?

Put an x in the boxes that apply

  • Release
    • Increase versions
    • Baseline tests passed
    • Release type:
      • Major release
      • Minor release
      • Patch release

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR.

  • You describe the purpose of the PR, e.g.:
    • What does it do?
    • Highlight what important points reviewers should know about;
    • Indicates if there is something left for follow-up PRs.
  • Documentation updated
  • Business logic tested successfully
  • Verify First, Write Last: In Substrate development, it is important that you always ensure preconditions are met and return errors at the beginning. After these checks have completed, then you may begin the function's computation.

Further comments

@nahuseyoum nahuseyoum requested review from ivan-cholakov and micaelffrancoAV and removed request for fluorostani and thadouk September 22, 2024 16:48
@nahuseyoum nahuseyoum changed the title SYS-4220 disable lowering SYS-4220 Disable lowering Sep 22, 2024

#[pallet::call_index(10)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::toggle_lowering())]
pub fn toggle_lowering(origin: OriginFor<T>, enabled: bool) -> DispatchResult {
Copy link
Contributor

@thadouk thadouk Sep 23, 2024

Choose a reason for hiding this comment

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

I prefer having a set_config function where different values can be configured
we already have set_lower_schedule_period so it would be better if we have one set admin function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I personally prefer having smaller extrinsics that do specific tasks. They are easier to test, benchmark and reason with. Happy to hear other thoughts

Copy link
Contributor

Choose a reason for hiding this comment

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

For me, with the little experience I have, I feel like smaller extrinsics are easier to understand but happy either way!

Copy link
Contributor

@thadouk thadouk Sep 23, 2024

Choose a reason for hiding this comment

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

I'm afraid I have to disagree, multiple entry points for sudo configuration is a security concern.
The codebase increases significantly if you have to replicate all origin and benchmark tests for each one of the entry points, making it difficult to navigate through files.
This is a common practice in many pallets with complex config.
Alternatively, we can make this a const, defined by the runtime. Its clean and minimal and the way many pallets are configured in substrate.

Comment on lines +241 to +242
LoweringEnabled,
LoweringDisabled,
Copy link
Contributor

Choose a reason for hiding this comment

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

One event for settings is better to avoid bloating the pallet codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I personally prefer having specific events that describe exactly what is happening instead of a generic one with different argument. Again happy to hear what others think.

Base automatically changed from nahu-sys-4189-updateTokenManager to main September 23, 2024 10:52
Copy link
Contributor

@thadouk thadouk left a comment

Choose a reason for hiding this comment

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

The functionality of the code introduced on this PR is correct, the approach to changing the configuration should improve as mentioned.
Although this has an overhead, this can be done on a separate refactor since the functionality needs to be expedited.
Approved on that basis.

@nahuseyoum nahuseyoum merged commit 02ceb0c into main Sep 23, 2024
5 checks passed
@nahuseyoum nahuseyoum deleted the nahu-sys-4220-disableLowering branch September 23, 2024 16:08
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.

5 participants