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

[Supplier] feat: add staking_fee param to supplier module #944

Merged
merged 15 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
bryanchriswhite marked this conversation as resolved.
Show resolved Hide resolved
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