hypersign-protocol / hid-node

A permissionless blockchain network to manage digital identity and access rights
https://hypersign.id
Apache License 2.0
223 stars 23 forks source link

feat: Incur fixed cost for each `x/ssi` message #365

Closed arnabghose997 closed 9 months ago

arnabghose997 commented 1 year ago

Description

This PR aims to make x/ssi message incur fixed fees. Fees for each message is distinct and parameterised under x/ssi module. The rationale behind this has been described in HIP-9.

Implementation

Rules

Ante Handlers

The x/ssi ante handlers SSITxDecorator, MempoolFeeDecorator and DeductFeeDecorator come together to perform the necessary verification to filter fixed-fee SSI messages and nominal non-SSI messages, and meter fixed charge for SSI messages. Order of calling ante handlers is crucial, and hence the position of these handlers should not be changed, unless a logic change is needed.

Governance Proposal

Any change of fee parameters of SSI transactions can be done by submitting a Param Change Governance Proposal. This type of Governance Proposal requires a JSON file (if done through CLI), describing the new values for consensus parameter(s), to be provided. Following is the format for changing the fixed-fee value of MsgCreateDID to 4578uhid

{
  "title": "Change CreateDID Fee to 4578uhid",
  "description": "Change CreateDID Fee to 4578uhid",
  "changes": [
    {
      "subspace": "ssi",
      "key": "CreateDidFee",
      "value": {"denom": "uhid","amount": "4578"}
    }
  ],
  "deposit": "10000000uhid"
}

Querying current fixed fee

Querying the current fixed-fee for SSI transactions can be done through following methods:

  1. CLI
$ hid-noded q ssi list-fees
create_did_fee:
  amount: "4000"
  denom: uhid
create_schema_fee:
  amount: "2000"
  denom: uhid
deactivate_did_fee:
  amount: "1000"
  denom: uhid
register_credential_status_fee:
  amount: "2000"
  denom: uhid
update_did_fee:
  amount: "1000"
  denom: uhid
  1. API
GET: <API_HOST>/hypersign-protocol/hidnode/ssi/fixedfee
{
  "create_did_fee": {
    "denom": "uhid",
    "amount": "4000"
  },
  "update_did_fee": {
    "denom": "uhid",
    "amount": "1000"
  },
  "deactivate_did_fee": {
    "denom": "uhid",
    "amount": "1000"
  },
  "create_schema_fee": {
    "denom": "uhid",
    "amount": "2000"
  },
  "register_credential_status_fee": {
    "denom": "uhid",
    "amount": "2000"
  }
}