Skip to content

Conversation

@amimart
Copy link
Contributor

@amimart amimart commented Oct 20, 2025

Purpose of Changes and their Description

This PR integrates the x/mint module with the x/scheduler module to enable periodic emission recalculation via scheduled tasks instead of the previous block-by-block approach in BeginBlocker.

  • Decoupled emission recalculation from BeginBlocker: Removed the monthly emission recalculation logic from BeginBlocker and moved it to a scheduler-based task that runs approximately every 30 days
  • New RecalculateEmission keeper method: Extracted the emission recalculation logic into a standalone method that can be invoked by the scheduler

Link(s) to Ticket(s) or Issue(s) resolved by this PR

https://linear.app/alloralabs/issue/ENGN-4969/tokenomics-recalculation-with-xscheduler-integration

Are these changes tested and documented?

  • If tested, please describe how. If not, why tests are not needed.
  • If documented, please describe where. If not, describe why docs are not needed.
  • Added to Unreleased section of CHANGELOG.md?

@github-actions
Copy link

github-actions bot commented Oct 20, 2025

The latest Buf updates on your PR. Results from workflow Buf Linter / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed⏩ skippedJan 8, 2026, 10:43 AM

@amimart amimart force-pushed the arnaud/engn-4255-expose-events-on-xscheduler-module branch 3 times, most recently from c5936b1 to c487365 Compare October 21, 2025 12:32
@guilherme-brandao guilherme-brandao force-pushed the guilherme/tokenomics-scheduler-rebased2 branch from 771e522 to eec79a6 Compare December 26, 2025 14:18
@guilherme-brandao guilherme-brandao changed the base branch from arnaud/engn-4255-expose-events-on-xscheduler-module to dev January 6, 2026 17:03
@guilherme-brandao guilherme-brandao changed the title Guilherme/tokenomics scheduler rebased2 x/scheduler integration - tokenomics recalculation Jan 8, 2026
@guilherme-brandao guilherme-brandao marked this pull request as ready for review January 8, 2026 10:48
@xmariachi xmariachi changed the title x/scheduler integration - tokenomics recalculation ENGN-4969 x/scheduler integration - tokenomics recalculation Jan 9, 2026
Copy link
Contributor Author

@amimart amimart left a comment

Choose a reason for hiding this comment

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

Hey @guilherme-brandao Here's some remarks mainly regarding on the articulation with the x/scheduler.

Btw maybe you should open a new PR, I can't request changes as this one is in my name, and I see some commit from dev in that one so maybe the occasion to clean that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can be removed

Comment on lines +262 to +266
// Initialize recurring tasks after state is loaded
if loadLatest {
app.InitializeRecurringTasks()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
// Initialize recurring tasks after state is loaded
if loadLatest {
app.InitializeRecurringTasks()
}

That shouldn't be managed here, the x/mint tasks must be managed by the x/mint module

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need to create a task type if there's no arguments

// TaskHandlers returns the task handlers for the mint module
func (k *Keeper) TaskHandlers() schedulertypes.TaskHandlers {
return schedulertypes.TaskHandlers{
schedulertypes.NewTaskHandler(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
schedulertypes.NewTaskHandler(
schedulertypes.NewNoArgsTaskHandler(

Let's declare it as a no args task

Copy link
Contributor Author

@amimart amimart Jan 27, 2026

Choose a reason for hiding this comment

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

The scheduler keeper should be added as module input and put in the mint's keeper

return vm, err
}

if appKeepers != nil && appKeepers.SchedulerKeeper != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All this migration should be achieved in the x/mint module migration

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 think the initial registering of the recalculation task when starting a brand new chain should occur in the begin blocker at the first block

return schedulerKeeper.ScheduleTask(
ctx,
types.TaskEmissionRecalculation,
schedulertypes.TaskID("emission_recalculation"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
schedulertypes.TaskID("emission_recalculation"),
types.TaskEmissionRecalculation,

@@ -9,7 +9,7 @@ import (
upgradekeeper "cosmossdk.io/x/upgrade/keeper"
emissionsKeeper "github.com/allora-network/allora-chain/x/emissions/keeper"
Copy link
Contributor

Choose a reason for hiding this comment

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

good alignment - however we can align the emissionsKeeper too for completeness :P

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.

4 participants