Skip to content

Commit

Permalink
[Supplier] feat: add staking_fee param to supplier module (#944)
Browse files Browse the repository at this point in the history
## Summary

Add `staking_fee` param to the tokenomics module.

## Issue

- `TODO_BETA`

## Type of change

Select one or more from the following:

- [x] New feature, functionality or library
- [ ] Consensus breaking; add the `consensus-breaking` label if so. See
#791 for details
- [ ] Bug fix
- [ ] Code health or cleanup
- [ ] Documentation
- [ ] Other (specify)

## Testing

- [ ] **Documentation**: `make docusaurus_start`; only needed if you
make doc changes
- [x] **Unit Tests**: `make go_develop_and_test`
- [ ] **LocalNet E2E Tests**: `make test_e2e`
- [x] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR.

## Sanity Checklist

- [x] I have tested my changes using the available tooling
- [ ] I have commented my code
- [x] I have performed a self-review of my own code; both comments &
source code
- [ ] I create and reference any new tickets, if applicable
- [ ] I have left TODOs throughout the codebase, if applicable

---------

Co-authored-by: red-0ne <[email protected]>
  • Loading branch information
bryanchriswhite and red-0ne authored Dec 2, 2024
1 parent f35e879 commit acd7fc8
Show file tree
Hide file tree
Showing 13 changed files with 369 additions and 63 deletions.
141 changes: 118 additions & 23 deletions api/poktroll/supplier/params.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ genesis:
min_stake:
amount: "1000000" # 1 POKT
denom: upokt
# TODO_BETA(@bryanchriswhite): Determine realistic amount for supplier staking fee.
staking_fee:
amount: "1" # 1 uPOKT
denom: upokt
supplierList:
- owner_address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj
operator_address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj
Expand Down
4 changes: 4 additions & 0 deletions makefiles/params.mk
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ params_update_supplier_all: ## Update the supplier module params
params_update_supplier_min_stake: ## Update the supplier module min_stake param
poktrolld tx authz exec ./tools/scripts/params/supplier_min_stake.json $(PARAM_FLAGS)

.PHONY: params_update_supplier_staking_fee
params_update_supplier_staking_fee: ## Update the supplier module staking_fee param
poktrolld tx authz exec ./tools/scripts/params/supplier_staking_fee.json $(PARAM_FLAGS)

### Session Module Params ###
.PHONY: params_get_session
params_get_session: ## Get the session module params
Expand Down
3 changes: 3 additions & 0 deletions proto/poktroll/supplier/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ message Params {
// min_stake is the minimum amount of uPOKT that a supplier must stake to be
// included in network sessions and remain staked.
cosmos.base.v1beta1.Coin min_stake = 1 [(gogoproto.jsontag) = "min_stake", (gogoproto.moretags) = "yaml:\"min_stake\""];

// staking_fee is the fee charged by the protocol for staking a supplier.
cosmos.base.v1beta1.Coin staking_fee = 2 [(gogoproto.jsontag) = "staking_fee", (gogoproto.moretags) = "yaml:\"staking_fee\""];
}
7 changes: 3 additions & 4 deletions testutil/integration/suites/param_configs.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package suites

import (
"encoding/hex"

cosmostypes "github.com/cosmos/cosmos-sdk/types"

"github.com/pokt-network/poktroll/app/volatile"
Expand Down Expand Up @@ -70,8 +68,8 @@ var (
ValidProofMissingPenaltyCoin = cosmostypes.NewInt64Coin(volatile.DenomuPOKT, 500)
ValidProofSubmissionFeeCoin = cosmostypes.NewInt64Coin(volatile.DenomuPOKT, 5000000)
ValidProofRequirementThresholdCoin = cosmostypes.NewInt64Coin(volatile.DenomuPOKT, 100)
ValidRelayDifficultyTargetHash, _ = hex.DecodeString("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
ValidActorMinStake = cosmostypes.NewInt64Coin(volatile.DenomuPOKT, 100)
ValidStakingFee = cosmostypes.NewInt64Coin(volatile.DenomuPOKT, 1)

SharedModuleParamConfig = ModuleParamConfig{
ParamsMsgs: ModuleParamsMessages{
Expand Down Expand Up @@ -192,7 +190,8 @@ var (
QueryParamsResponse: suppliertypes.QueryParamsResponse{},
},
ValidParams: suppliertypes.Params{
MinStake: &ValidActorMinStake,
MinStake: &ValidActorMinStake,
StakingFee: &ValidStakingFee,
},
ParamTypes: map[ParamType]any{
ParamTypeCoin: suppliertypes.MsgUpdateParam_AsCoin{},
Expand Down
4 changes: 4 additions & 0 deletions tools/scripts/params/supplier_all.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"min_stake": {
"amount": "1000000",
"denom": "upokt"
},
"staking_fee": {
"amount": "1",
"denom": "upokt"
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions tools/scripts/params/supplier_staking_fee.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"body": {
"messages": [
{
"@type": "/poktroll.supplier.MsgUpdateParam",
"authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t",
"name": "staking_fee",
"as_coin": {
"amount": "1",
"denom": "upokt"
}
}
]
}
}
3 changes: 3 additions & 0 deletions x/supplier/keeper/msg_server_update_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ func (k msgServer) UpdateParam(ctx context.Context, msg *suppliertypes.MsgUpdate
case suppliertypes.ParamMinStake:
logger = logger.With("min_stake", msg.GetAsCoin())
params.MinStake = msg.GetAsCoin()
case suppliertypes.ParamStakingFee:
logger = logger.With("staking_fee", msg.GetAsCoin())
params.StakingFee = msg.GetAsCoin()
default:
return nil, status.Error(
codes.InvalidArgument,
Expand Down
7 changes: 6 additions & 1 deletion x/supplier/keeper/msg_update_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package keeper_test
import (
"testing"

cosmostypes "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"

"github.com/pokt-network/poktroll/app/volatile"
suppliertypes "github.com/pokt-network/poktroll/x/supplier/types"
)

Expand All @@ -13,6 +15,8 @@ func TestMsgUpdateParams(t *testing.T) {
params := suppliertypes.DefaultParams()
require.NoError(t, k.SetParams(ctx, params))

zerouPokt := cosmostypes.NewInt64Coin(volatile.DenomuPOKT, 0)

// default params
tests := []struct {
desc string
Expand Down Expand Up @@ -42,7 +46,8 @@ func TestMsgUpdateParams(t *testing.T) {
params: &suppliertypes.MsgUpdateParams{
Authority: k.GetAuthority(),
Params: suppliertypes.Params{
MinStake: &suppliertypes.DefaultMinStake,
MinStake: &suppliertypes.DefaultMinStake,
StakingFee: &zerouPokt,
},
},
shouldError: false,
Expand Down
Loading

0 comments on commit acd7fc8

Please sign in to comment.