Skip to content

add pse structures to the pse module.#95

Merged
metalarm10 merged 5 commits into
masterfrom
milad/pse-temp-structures
Mar 3, 2026
Merged

add pse structures to the pse module.#95
metalarm10 merged 5 commits into
masterfrom
milad/pse-temp-structures

Conversation

@miladz68

@miladz68 miladz68 commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Description

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

@miladz68 miladz68 requested a review from a team as a code owner February 25, 2026 11:59
@miladz68 miladz68 requested review from TxCorpi0x, masihyeganeh, metalarm10 and ysv and removed request for a team February 25, 2026 11:59
@miladz68 miladz68 changed the title Milad/pse temp structures add distribution id to pse data structures Feb 25, 2026

@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 18 files and all commit messages, and made 6 comments.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on masihyeganeh, metalarm10, miladz68, and TxCorpi0x).


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

		kv.Value.LastChangedUnixSec = currentBlockTime
		// TODO review all the logic for score reset
		key := collections.Join3(distributionID+1, kv.Key.K2(), kv.Key.K3())

distribution ids are validated to be sequential integers, right ?

Code quote:

distributionID+1

x/pse/keeper/genesis.go line 32 at r1 (raw file):

	// TODO revise this logic for distribution id and genesis state
	var currentDistributionID uint64

I didn't get this part


x/pse/keeper/hooks.go line 39 at r1 (raw file):

		return err
	}
	distributionID := distribution.ID // TODO update to use distribution ID

nit: this todo is not very clear for me.
I guess we can't just use distribution.ID instead but not sure why ?

Code quote:

// TODO update to use distribution ID

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

	AccountScoreSnapshot collections.Map[collections.Pair[uint64, sdk.AccAddress], sdkmath.Int]
	AllocationSchedule   collections.Map[uint64, types.ScheduledDistribution] // Map: id -> ScheduledDistribution
	// OngoingDistribution   collections.Item[uint64]

question: could you remind me what we decided here. Do we store OngoingDistribution inside store or query it from Schedule each time ?

(could be discussed on call)


x/pse/keeper/params.go line 125 at r1 (raw file):

// Removing DelegationTimeEntries ensures they start completely fresh when re-included.
// Entries will be recreated naturally when hooks fire after re-inclusion.
func (k Keeper) removeExcludedAccountData(ctx context.Context, addrStr string, distributionID uint64) error {

nit: distributionId should be 2nd arg I guess
To be consistent with other methods


x/pse/types/params.go line 133 at r1 (raw file):

	for i, period := range schedule {
		// TODO: this was uncommented to allow tests to pass.

lets discuss

@miladz68 miladz68 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.

@miladz68 made 5 comments and resolved 1 discussion.
Reviewable status: 14 of 18 files reviewed, 5 unresolved discussions (waiting on masihyeganeh, metalarm10, TxCorpi0x, and ysv).


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

Previously, ysv (Yaroslav Savchuk) wrote…

distribution ids are validated to be sequential integers, right ?

correct.


x/pse/keeper/genesis.go line 32 at r1 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

I didn't get this part

this was a place holder to be fixed later once ID and genesis changes are finalized. But we can make those changes now.


x/pse/keeper/hooks.go line 39 at r1 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

nit: this todo is not very clear for me.
I guess we can't just use distribution.ID instead but not sure why ?

added more context on what should be done.


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

Previously, ysv (Yaroslav Savchuk) wrote…

question: could you remind me what we decided here. Do we store OngoingDistribution inside store or query it from Schedule each time ?

(could be discussed on call)

we decided to leave it for later. John will decide at implementation, I will remove the commented code from this PR.


x/pse/keeper/params.go line 125 at r1 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

nit: distributionId should be 2nd arg I guess
To be consistent with other methods

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 made 3 comments.
Reviewable status: 12 of 21 files reviewed, 6 unresolved discussions (waiting on masihyeganeh, miladz68, TxCorpi0x, and ysv).


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

Previously, miladz68 (milad) wrote…

we decided to leave it for later. John will decide at implementation, I will remove the commented code from this PR.

for context: I've added "OngoingDistribution" store in my branch as collections.Item[types.ScheduledDistribution] , because during multi-block processing, hooks need to know whether a distribution is actively being processed.


x/pse/types/params.go line 133 at r1 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

lets discuss

I think no need to comment out this validation since it was added and tested in pse task-1. tests should use ID: 1 instead of ID: 0.
also starting from 1 is intentional, proto3 defaults to 0 for unset fields, so 1-based IDs let us distinguish "not set" from "first entry.


x/pse/keeper/genesis.go line 34 at r2 (raw file):

	var currentDistributionID uint64
	if len(genState.ScheduledDistributions) > 0 {
		currentDistributionID = genState.ScheduledDistributions[0].Timestamp

this should be genState.ScheduledDistributions[0].IDi think.

@miladz68 miladz68 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.

@miladz68 made 3 comments.
Reviewable status: 12 of 21 files reviewed, 6 unresolved discussions (waiting on masihyeganeh, metalarm10, TxCorpi0x, and ysv).


x/pse/keeper/genesis.go line 34 at r2 (raw file):

Previously, metalarm10 wrote…

this should be genState.ScheduledDistributions[0].IDi think.

this no longer applies. removed the code.


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

Previously, metalarm10 wrote…

for context: I've added "OngoingDistribution" store in my branch as collections.Item[types.ScheduledDistribution] , because during multi-block processing, hooks need to know whether a distribution is actively being processed.

great, in that case I will comment it out to be fixed by your PR.


x/pse/types/params.go line 133 at r1 (raw file):

Previously, metalarm10 wrote…

I think no need to comment out this validation since it was added and tested in pse task-1. tests should use ID: 1 instead of ID: 0.
also starting from 1 is intentional, proto3 defaults to 0 for unset fields, so 1-based IDs let us distinguish "not set" from "first entry.

starting from 0 will break the tests, we need to decide what to do with the scenario where delegations are present but no scheduled distribution exists, and then we add the distribution.

@ysv ysv requested a review from metalarm10 February 26, 2026 13:14

@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 resolved 5 discussions.
Reviewable status: 12 of 21 files reviewed, 1 unresolved discussion (waiting on masihyeganeh, metalarm10, and TxCorpi0x).

@miladz68 miladz68 changed the title add distribution id to pse data structures add pse structures to the pse module. Feb 27, 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 resolved 1 discussion.
Reviewable status: 11 of 21 files reviewed, all discussions resolved (waiting on masihyeganeh, TxCorpi0x, 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 10 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on masihyeganeh and TxCorpi0x).

@metalarm10 metalarm10 merged commit e1babcc into master Mar 3, 2026
18 of 20 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