Skip to content

Emit event on PSE community finalization#113

Merged
TxCorpi0x merged 6 commits into
masterfrom
mehdi/pse-finalization-event
Apr 1, 2026
Merged

Emit event on PSE community finalization#113
TxCorpi0x merged 6 commits into
masterfrom
mehdi/pse-finalization-event

Conversation

@TxCorpi0x

@TxCorpi0x TxCorpi0x commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Description

This pull request introduces a new event to signal the finalization of community token distributions and improves the traceability of distribution events by adding unique identifiers. The changes enhance observability and clarity in the distribution process, ensuring that all relevant information is emitted and documented when distributions are completed.

Event and Distribution Tracking Improvements:

  • Added a new event, EventCommunityDistributionFinalized, which is emitted when all AccountScoreSnapshot entries have been paid out and the leftover is sent to the community pool. This event includes fields for the scheduled time, distribution ID, total distributed, and leftover sent to the pool. [1] [2] [3]
  • Updated the distribution logic to emit the new finalization event after all delegators have been processed and the leftover is sent to the community pool. [1] [2]

Event Structure and API Documentation Updates:

  • Added a distribution_id field to EventAllocationDistributed and ensured it is included in event emission, serialization, and unmarshalling logic for better event traceability. [1] [2] [3] [4] [5] [6] [7]
  • Updated API documentation to include the new event and the new distribution_id field, providing clear descriptions for API consumers. [1] [2] [3]

Internal Refactoring:

  • Refactored distribution processing functions to pass the full ScheduledDistribution object where needed, enabling access to all relevant fields for event emission. [1] [2]

These changes collectively improve the transparency and auditability of the token distribution process.

Reviewers checklist:

  • Try to write more meaningful comments with clear actions to be taken.
  • Nit-picking should be unblocking. Focus on core issues.

Authors checklist

  • Provide a concise and meaningful description
  • Review the code yourself first, before making the PR.
  • Annotate your PR in places that require explanation.
  • Think and try to split the PR to smaller PR if it is big.

This change is Reviewable

@TxCorpi0x TxCorpi0x requested review from a team, akhlopiachyi, masihyeganeh, metalarm10, miladz68, tx-development and ysv and removed request for a team March 31, 2026 16:16
@TxCorpi0x TxCorpi0x requested a review from a team as a code owner March 31, 2026 16:17
@TxCorpi0x TxCorpi0x changed the title Mehdi/pse finalization event Emit event on PSE community finalization Apr 1, 2026

@metalarm10 metalarm10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@metalarm10 reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: 1 of 5 files reviewed, 1 unresolved discussion (waiting on akhlopiachyi, masihyeganeh, miladz68, tx-development, TxCorpi0x, and ysv).


x/pse/keeper/distribute.go line 276 at r1 (raw file):

		CommunityPoolAmount: leftover,
	}); err != nil {
		return err

Event emission failure here is blocking and will prevent cleanupOngoingDistribution from running, leaving the distribution stuck in a retry loop every block.
Recommendation: Let's align with the existing event err handling pattern and log-and-continue instead of returning the error.

@TxCorpi0x TxCorpi0x left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@TxCorpi0x made 1 comment.
Reviewable status: 1 of 5 files reviewed, 1 unresolved discussion (waiting on akhlopiachyi, masihyeganeh, metalarm10, miladz68, tx-development, and ysv).


x/pse/keeper/distribute.go line 276 at r1 (raw file):

Previously, metalarm10 wrote…

Event emission failure here is blocking and will prevent cleanupOngoingDistribution from running, leaving the distribution stuck in a retry loop every block.
Recommendation: Let's align with the existing event err handling pattern and log-and-continue instead of returning the error.

Good Point.
Done

@metalarm10 metalarm10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@metalarm10 reviewed 4 files and all commit messages, and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on akhlopiachyi, masihyeganeh, miladz68, tx-development, and ysv).

@ysv ysv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ysv reviewed 5 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on akhlopiachyi, masihyeganeh, miladz68, and tx-development).

@TxCorpi0x TxCorpi0x merged commit 45e2ee9 into master Apr 1, 2026
14 checks passed
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