klaytn / rosetta-klaytn

Apache License 2.0
4 stars 6 forks source link

fix decimal problem in CN/KIR/KGF reward #135

Closed JayChoi1736 closed 2 years ago

JayChoi1736 commented 2 years ago

Fixes # .

Motivation

Error in Baobab check:data: Reconciliation failed for 0xB2bd3178AFFCcD9F9F5189457f1Cad7D17A01c9D at 102775656 computed: 85417893214482613665126234KLAY live: 85417893214482613665126235KLAY

badger 2022/10/06 18:50:54 INFO: Storing value log head: {Fid:0 Len:30 Offset:373660}
Removing temporary directory /tmp/803135562
Missing ops for 0xB2bd3178AFFCcD9F9F5189457f1Cad7D17A01c9D in block 102775656:0xccf1988dfd388f27a4d43ace0ccac91b47cac71fe30409f19b03fafcd8bd980c

Error: failed to call "reconciliation fail" action: inactive reconciliation error for account address 0xB2bd3178AFFCcD9F9F5189457f1Cad7D17A01c9D at block index 102775880 (computed: 85418066482579957915126234KLAY, live: 85418066482579957915126235KLAY): reconciliation failure

The previous problem occurred because rosetta-klaytn calculates feeReward in units of transactions. if there is two transactions which have 20 peb fee reward for each, klaytn calculates the reward as CNreward : 40 0.34 = 13.6 -> 13 KIRreward : 40 0.54 = 21.6 -> 21 KGFReward : 40-13-21 = 6

but formal rosetta-klaytn calculates the reward as CNreward : (20 0.34 = 6.8 -> 6) 2 -> 12 KIRReward : (20 0.54 = 10.8 ->10) 2 -> 20 KGFReward : (20-6-10 -> 4) *2 -> 8

This problem occurs after Magma hardfork (Since the basefee can no longer be in ston units... )

Solution

Changed the rosetta-klaytn fee operation method to the same method as Klaytn reward distributor

Open questions

github-actions[bot] commented 2 years ago

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅