liberland / liberland_substrate

Substrate implementation of the Liberland Network node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LLD is locked/reserved on democracy and election actions

kacperzuk-neti opened this issue · comments

Upstream democracy and election pallets use Currency trait to reserve and/or lock some amounts of currency for certain actions. All our pallets, including democracy and election, are configured to use LLD as currency. So even though we've modified them to additionally check LLM, they also make locks/reserves on LLD.

Example (query.balances.locks refers to locks on LLD):

kacper@kacper-HP-ProBook-445-G7 ~> polkadot-js-api -q --ws ws://localhost:9944 --seed "//Charlie" query.balances.locks 0x90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22 # Charlie's AccountID
{
  "locks": []
}
kacper@kacper-HP-ProBook-445-G7 ~ [1]> polkadot-js-api -q --ws ws://localhost:9944 --seed "//Charlie" tx.elections.vote '["0x90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22"]' 1000

{
  "vote": {
    "events": [],
    "status": "Ready"
  }
}
{
[...]
        "event": {
          "method": "ExtrinsicSuccess",
[...]
}
kacper@kacper-HP-ProBook-445-G7 ~> polkadot-js-api -q --ws ws://localhost:9944 --seed "//Charlie" query.balances.locks 0x90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22 # Charlie's AccountID
{
  "locks": [
    {
      "id": "phrelect",
      "amount": "1,000",
      "reasons": "All"
    }
  ]
}

Proper solution: implement Currency traits for LLM and configure democracy and elections pallets to use LLM instead of LLD (see #58 ).

Quick & dirty solution: remove locking and reserving from democracy and elections completely (will make updates in the future harder)

Note that this is unlikely to cause observable issues due to huge difference in LLD and LLM decimals. For example, a vote with value of 5000 means that we'll check if there's 5000 LLM in politipool and lock 0.000000005 LLD. It's just bad engineering to leave it like this.

@DorianSternVukotic this issue is what we've been talking about on call.

Proper solution: implement Currency traits for LLM and configure democracy and elections pallets to use LLM instead of LLD (see #58 ).

Hmm... I guess that we could do it in a half-baked way - just put empty stubs for the Currency traits implementation and use it for pallets. And then only move checking for LLM/citizenships to one of the stubs related to reserving/locking, to make sure it fails for non-citizens / insufficient locked LLM, without needing any real actions being taken.

If I'm not mistaken, that would be totally enough to drop our customizations to pallet-democracy and pallet-elections-phragmen.