Skip to content

Conversation

@echevrier
Copy link
Contributor

To be improved as issue #33 is not clear.
Config with no burn and impossibility to approve a proposal.

echevrier added 3 commits September 14, 2021 11:15
COnfig treasury pallet and collect fees in the treasury
…accountid from pallet id, funding no hardcoded
@echevrier echevrier requested a review from brenzi September 16, 2021 16:25
@brenzi
Copy link
Collaborator

brenzi commented Sep 16, 2021

if #33 is clear now, please update the description of the PR.
Would you now consider #33 done?
Then I'll run this node and test to review. The allocation math is a bit adventurous, but that's kind of out of scope of this task. It's just about having a treasury and fees being collected in it

@brenzi
Copy link
Collaborator

brenzi commented Sep 17, 2021

How did you check the treasury balance change? That the fee is paid to the treasury? I could verify that it isn't burned, which is a good sign. But js/apps doesn't give me all digits to verify the treasury balance.

I played with a python script but couldn't get treasury balance yet

@brenzi
Copy link
Collaborator

brenzi commented Sep 17, 2021

keep it simple: set initial treasury balance to zero and watch it rising when extrinsics are included. this can be done with js/apps manually.

for an automated approach see: JAMdotTech/py-polkadot-sdk#130

@brenzi
Copy link
Collaborator

brenzi commented Sep 17, 2021

ok. treasury balance can't be below ED, which here is 1mTEER. But that's low enough to see that fees are sent to treasury. After one extrinsic, the treasury holds 1.2mTEER, what corresponds well enough with the fees paid: 271_000_000
decimals are: 12

Copy link
Collaborator

@brenzi brenzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will need to change the allocations and will need to burn all fees at the beginning, according to our burning mechanism.
But I approve as this first step behaves as expected

@brenzi
Copy link
Collaborator

brenzi commented Sep 18, 2021

treasury balance test script (will commit this to repo/scripts. maybe useful for CI):

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 16 20:41:13 2021

@author: brenzi
"""

from substrateinterface import SubstrateInterface, Keypair
from substrateinterface.utils.ss58 import ss58_encode

def get_balance(who):
    return substrate.query('System', 'Account', params=[who]).value['data']['free']

substrate = SubstrateInterface(
        url="ws://127.0.0.1:9944",
        type_registry_preset='kusama'
    )
alice = Keypair.create_from_uri('//Alice')
dave = Keypair.create_from_uri('//Dave')
treasury = ss58_encode('0x' + b'modlpy/trsry'.hex() + '0000000000000000000000000000000000000000')

alicebefore = get_balance(alice.ss58_address)
treasurybefore = get_balance(treasury)
totalissuancebefore = substrate.query('Balances', 'TotalIssuance')
print('total issuance', totalissuancebefore)

amount = 10 * 10**9 #milli

call = substrate.compose_call(
    call_module='Balances',
    call_function='transfer',
    call_params={
        'dest': dave.ss58_address,
        'value': amount
    }
)

payment_info = substrate.get_payment_info(call=call, keypair=alice)
print("Payment info: ", payment_info)

extrinsic = substrate.create_signed_extrinsic(
    call=call,
    keypair=alice,
    era={'period': 64}
)
receipt = substrate.submit_extrinsic(extrinsic, wait_for_inclusion=True)
print('extrinsic sent')

totalissuanceafter = substrate.query('Balances', 'TotalIssuance')
print('difference in total issuance: ', totalissuancebefore.value - totalissuanceafter.value)

aliceafter = get_balance(alice.ss58_address)

paidfee = alicebefore - aliceafter - amount
print('fee paid : ', paidfee)

treasuryafter = get_balance(treasury)

print('treasury balance is ', treasuryafter, ' and has increased by', treasuryafter-treasurybefore)

@echevrier
Copy link
Contributor Author

if #33 is clear now, please update the description of the PR.
Would you now consider #33 done?
Then I'll run this node and test to review. The allocation math is a bit adventurous, but that's kind of out of scope of this task. It's just about having a treasury and fees being collected in it

For #33 I assumed:

  • the allocation math is : 5% of Nbr of endowed_account * 1 << 60
  • The treasury is configured so that:
  1. Proposals can be done, but not accepted/refused, ... (MaxApprovals = 0)
  2. SpendPeriod cannot be 0, so same value as in Polkadot: 24 days
  3. ProposalBond, ... undefined, as we don't handle Proposals.
    So we can close it, if you agree with these assumptions.

@echevrier
Copy link
Contributor Author

How did you check the treasury balance change? That the fee is paid to the treasury? I could verify that it isn't burned, which is a good sign. But js/apps doesn't give me all digits to verify the treasury balance.

I played with a python script but couldn't get treasury balance yet

I added in the worker client a command to request the treasury balance. I also add a script for CI. But I haven't push it, as we need to merge first the node, to make the worker compatible with this version

@echevrier
Copy link
Contributor Author

keep it simple: set initial treasury balance to zero and watch it rising when extrinsics are included. this can be done with js/apps manually.

for an automated approach see: polkascan/py-substrate-interface#130

I don't understand it

@echevrier echevrier deleted the 33/add_treasury branch September 21, 2021 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants