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

feat: add in distribution to x/protocolpool #23972

Draft
wants to merge 11 commits into
base: exp/distr-options
Choose a base branch
from

Conversation

aljo242
Copy link
Collaborator

@aljo242 aljo242 commented Mar 12, 2025

  • add sendCommunityPoolToProtocolPool function call in beginblocker every 1000 blocks
  • add abci method testing
  • add e2e testing x/distribution when x/protocolpool is enabled

@aljo242 aljo242 requested a review from a team as a code owner March 12, 2025 19:49
@aljo242 aljo242 marked this pull request as draft March 12, 2025 19:50
@github-actions github-actions bot added the C:x/distribution distribution module related label Mar 12, 2025
Copy link
Contributor

@aljo242 your pull request is missing a changelog!

ModuleName: authtypes.ModuleName,
KvStoreKey: "acc",
},
ModuleConfig = []*appv1alpha1.ModuleConfig{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

factored this out so that we can do some modifications to it in the network tests

network *network.Network
}

func NewGRPCQueryTestSuite(protocolPoolEnabled bool) *GRPCQueryTestSuite {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we can now create this test suite with the x/protocolpool enabled or not

@@ -7,6 +7,11 @@ import (
"net/http"
)

type ErrorResponse struct {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

defining a common struct that is returned when your query fails. tests can just decode to this

"github.com/cosmos/cosmos-sdk/x/distribution/types"
)

const truncationBlockInterval = 1000
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is what was defined before (not as a constant). I am not sure why this number was chosen - I'm assuming arbitrary

if err := k.AllocateTokens(ctx, previousTotalPower, ctx.VoteInfos()); err != nil {
return err
}
if err := k.BeginBlocker(ctx); err != nil {

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
// ref https://github.com/cosmos/cosmos-sdk/issues/3095
height := ctx.BlockHeight()
if height > 1 {
if err := k.AllocateTokens(ctx, previousTotalPower, ctx.VoteInfos()); err != nil {

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call

// every 1000 blocks send whole coins from community pool to x/protocolpool if enabled
if height%truncationBlockInterval == 0 && k.protocolPoolEnabled {
if err := k.sendCommunityPoolToProtocolPool(ctx); err != nil {

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call

// record the proposer for when we pay out on the next block
consAddr := sdk.ConsAddress(ctx.BlockHeader().ProposerAddress)
return k.SetPreviousProposerConsAddr(ctx, consAddr)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:x/distribution distribution module related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant