Skip to content

Commit

Permalink
[Proof] Proof submission fee param (#779)
Browse files Browse the repository at this point in the history
## Summary

This PR adds `ProofSubmissionFee` governance param as a `Coin` type.

It is based on PR #778 

## Issue

Proof messages take up a lot of block space. We need to deter submitting
unnecessary ones by making their submission payable by a governance
adjusted parameter.

The current PR is only about adding the governance param. The feature
itself will be submitted as a follow-up PR.

- #758 

## Type of change

Select one or more:

- [x] New feature, functionality or library
- [ ] 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`
- [x] **LocalNet E2E Tests**: `make test_e2e`
- [ ] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR.

## Sanity Checklist

- [x] I have tested my changes using the available tooling
- [x] 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
- [x] I have left TODOs throughout the codebase, if applicable
  • Loading branch information
red-0ne authored Sep 6, 2024
1 parent 7775e1d commit 33efad8
Show file tree
Hide file tree
Showing 17 changed files with 404 additions and 47 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,10 @@ params_update_proof_proof_requirement_threshold: ## Update the proof module proo
params_update_proof_proof_missing_penalty: ## Update the proof module proof_missing_penalty param
poktrolld tx authz exec ./tools/scripts/params/proof_proof_missing_penalty.json $(PARAM_FLAGS)

.PHONY: params_update_proof_proof_submission_fee
params_update_proof_proof_submission_fee: ## Update the proof module proof_submission_fee param
poktrolld tx authz exec ./tools/scripts/params/proof_proof_submission_fee.json $(PARAM_FLAGS)

### Shared Module Params ###
.PHONY: params_update_shared_all
params_update_shared_all: ## Update the session module params
Expand Down
138 changes: 118 additions & 20 deletions api/poktroll/proof/params.pulsar.go

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

3 changes: 3 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ genesis:
proof_missing_penalty:
amount: "320"
denom: upokt
proof_submission_fee:
amount: "1000000"
denom: upokt
shared:
params:
num_blocks_per_session: 10
Expand Down
2 changes: 2 additions & 0 deletions e2e/tests/parse_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ func (s *suite) newProofMsgUpdateParams(params paramsMap) cosmostypes.Msg {
msgUpdateParams.Params.ProofRequirementThreshold = uint64(paramValue.value.(int64))
case prooftypes.ParamProofMissingPenalty:
msgUpdateParams.Params.ProofMissingPenalty = paramValue.value.(*cosmostypes.Coin)
case prooftypes.ParamProofSubmissionFee:
msgUpdateParams.Params.ProofSubmissionFee = paramValue.value.(*cosmostypes.Coin)
default:
s.Fatalf("ERROR: unexpected %q type param name %q", paramValue.typeStr, paramName)
}
Expand Down
2 changes: 2 additions & 0 deletions e2e/tests/update_params.feature
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Feature: Params Namespace
| proof_request_probability | 0.1 | float |
| proof_requirement_threshold | 100 | int64 |
| proof_missing_penalty | 500 | coin |
| proof_submission_fee | 5000000 | coin |
Then all "proof" module params should be updated

# NB: If you are reading this and the proof module has parameters
Expand Down Expand Up @@ -92,6 +93,7 @@ Feature: Params Namespace
| proof | /poktroll.proof.MsgUpdateParam | proof_request_probability | 0.1 | float |
| proof | /poktroll.proof.MsgUpdateParam | proof_requirement_threshold | 100 | int64 |
| proof | /poktroll.proof.MsgUpdateParam | proof_missing_penalty | 500 | coin |
| proof | /poktroll.proof.MsgUpdateParam | proof_submission_fee | 5000000 | coin |
| shared | /poktroll.shared.MsgUpdateParam | num_blocks_per_session | 5 | int64 |
| shared | /poktroll.shared.MsgUpdateParam | grace_period_end_offset_blocks | 2 | int64 |
| shared | /poktroll.shared.MsgUpdateParam | claim_window_open_offset_blocks | 2 | int64 |
Expand Down
5 changes: 5 additions & 0 deletions e2e/tests/update_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,11 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) {
params.ProofMissingPenalty = proofMissingPenalty.value.(*cosmostypes.Coin)
}

proofSubmissionFee, ok := paramsMap[prooftypes.ParamProofSubmissionFee]
if ok {
params.ProofSubmissionFee = proofSubmissionFee.value.(*cosmostypes.Coin)
}

assertUpdatedParams(s,
[]byte(res.Stdout),
&prooftypes.QueryParamsResponse{
Expand Down
6 changes: 6 additions & 0 deletions proto/poktroll/proof/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ message Params {
// but is not provided.
cosmos.base.v1beta1.Coin proof_missing_penalty = 4 [(gogoproto.jsontag) = "proof_missing_penalty"];

// proof_submission_fee is the number of tokens (uPOKT) which should be paid by
// the supplier operator when submitting a proof.
// This is needed to account for the cost of storing proofs on-chain and prevent
// spamming (i.e. sybil bloat attacks) the network with non-required proofs.
cosmos.base.v1beta1.Coin proof_submission_fee = 5 [(gogoproto.jsontag) = "proof_submission_fee"];

// IMPORTANT: Make sure to update all related files if you're modifying or adding a new parameter.
// Try the following grep to find all related places: `grep -r compute_units_to_tokens_multiplier`
// TODO_IMPROVE: Look into an opportunity to use an enum to avoid using strings throughout the codebase.
Expand Down
4 changes: 4 additions & 0 deletions tools/scripts/params/proof_all.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"proof_missing_penalty": {
"amount": "320",
"denom": "upokt"
},
"proof_submission_fee": {
"amount": "1000000",
"denom": "upokt"
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions tools/scripts/params/proof_proof_submission_fee.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"body": {
"messages": [
{
"@type": "/poktroll.proof.MsgUpdateParam",
"authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t",
"name": "proof_submission_fee",
"as_coin": {
"denom": "upokt",
"amount": "1000000"
}
}
]
}
}
12 changes: 12 additions & 0 deletions x/proof/keeper/msg_server_update_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ func (k msgServer) UpdateParam(
}

params.ProofMissingPenalty = proofMissingPenalty
case types.ParamProofSubmissionFee:
value, ok := msg.AsType.(*types.MsgUpdateParam_AsCoin)
if !ok {
return nil, types.ErrProofParamInvalid.Wrapf("unsupported value type for %s param: %T", msg.Name, msg.AsType)
}
proofSubmissionFee := value.AsCoin

if err := types.ValidateProofSubmissionFee(proofSubmissionFee); err != nil {
return nil, err
}

params.ProofSubmissionFee = proofSubmissionFee
default:
return nil, types.ErrProofParamInvalid.Wrapf("unsupported param %q", msg.Name)
}
Expand Down
Loading

0 comments on commit 33efad8

Please sign in to comment.