Skip to content

Instantly share code, notes, and snippets.

@brenzi
Last active May 7, 2024 11:30
Show Gist options
  • Save brenzi/ca9e0c326198c73ff2dd0a2e74468053 to your computer and use it in GitHub Desktop.
Save brenzi/ca9e0c326198c73ff2dd0a2e74468053 to your computer and use it in GitHub Desktop.
instructions to trace fees on encointer
git clone https://github.com/encointer/encointer-parachain.git
git checkout ab/collator-selection
cargo build --release
zombienet-linux-x64 spawn --provider native zombienet/rococo-local-with-encointer.toml
#next terminal
git clone https://github.com/encointer/encointer-node.git
cd client
cargo build --release
# demo community with Alice, Bob, Charlie. this will take a moment
./bootstrap_demo_community.py
# you should see "Community sqm1v79dF6b successfully bootstrapped"
../target/release/encointer-client-notee balance --all //Alice
# sqm1v79dF6b: 0.9999992087363977373
# 1152921259788621410
# check collator balances:
../target/release/encointer-client-notee balance --all EXHoFmksfPoyTyuFgcJ2c11uLj9KPgCZ2wWxshxuDrvpZuq
# 141890013284
brenzi@caribe:~/encointer/encointer-node/client$ ../target/release/encointer-client-notee balance --all E8Np37TgMvVNST2Qj7YpEMvNon2kBSPNSkMM9D2TuKjwKQZ
# 3160953679661
# send a transaction paying fees in CC
../target/release/encointer-client-notee transfer //Alice //Ferdie 0.1 --cid sqm1v79dF6b --tx-payment-cid sqm1v79dF6b
# now, one collator should get 50% of the CC fees:
../target/release/encointer-client-notee balance --all EXHoFmksfPoyTyuFgcJ2c11uLj9KPgCZ2wWxshxuDrvpZuq
# sqm1v79dF6b: 0.0009464797817201854
# 141890032889
# Alices balance went down by 0.99999736245709394927-0.8981042268912815589-0.1 => fees paid: 1.8931e-03
# so, ok, 50% of CC has been paid to the collator
# the other 50% went to the dummy 0x00000 pubkey:
../target/release/encointer-client-notee balance --all 5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM
# sqm1v79dF6b: 0.0009464787831669817
# 0
# verify the handling of KSM fees:
polkadot-js-api query.balances.totalIssuance
# "totalIssuance": "3,458,764,513,820,540,928"
# transfer KSM and pay fees in KSM
../target/release/encointer-client-notee transfer //Alice //Ferdie 1000000000
polkadot-js-api query.balances.totalIssuance
# "totalIssuance": "3,458,764,513,820,540,928"
# therefore, the total issuance stayed constant ...and
../target/release/encointer-client-notee balance --all 5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM
sqm1v79dF6b: 0.0009464732911431924
0
# the dummy account didn't get any share of these rewards, which proves that the fee handling for KSM is unaffected by our HandleCredit impelementation
# the KSM fees go entirely to the StakePot at 5EYCAe5cKPAoFh2HnQQvpKqRYZGqBpaA87u4Zzw89qPE58is
../target/release/encointer-client-notee balance --all //Alice
sqm1v79dF6b: 0.8980769862015140838
1152921257447576468
../target/release/encointer-client-notee balance --all 5EYCAe5cKPAoFh2HnQQvpKqRYZGqBpaA87u4Zzw89qPE58is
118444860
../target/release/encointer-client-notee transfer //Alice //Ferdie 1000000000
../target/release/encointer-client-notee balance --all 5EYCAe5cKPAoFh2HnQQvpKqRYZGqBpaA87u4Zzw89qPE58is
246107700
../target/release/encointer-client-notee balance --all //Alice
sqm1v79dF6b: 0.89807682828688077784
1152921256277357865
So, the math seems correct: Alice's balance went down by 1000000000 + 170218624(fees)
The StakingPot went up by 127662840, which is 75% of the fees paid by Alice. The other 25% went to the collator directly (?tricky to test. maybe the queries happened accross different blocks)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment