harmony-one / harmony-log-analysis

Harmony Log Analysis and Visualization
5 stars 3 forks source link

R5 test has error #4

Open JB273 opened 4 years ago

JB273 commented 4 years ago

Running test R5 from Jupyter Notebook 6.0.3 gives following error;

Test-R5: Reward given out to block signers sums up to the total block reward enter the number of blocks you want to test: 10 current block 12393 next block 12394

KeyError Traceback (most recent call last)

in ----> 1 R5_test() in R5_test() 33 address = i['validator']['address'] 34 reward_accumulated = i['lifetime']['reward-accumulated'] ---> 35 shard_metrics = i['metrics']['by-shard'] 36 validator_reward = 0 37 for by_shard in shard_metrics: KeyError: 'by-shard'
ivorytowerdds commented 4 years ago

the same issue https://github.com/harmony-one/harmony-log-analysis/issues/1

ivorytowerdds commented 4 years ago

revise by-shard keyword but didn't pass the test:

Test-R5: Reward given out to block signers sums up to the total block reward enter the number of blocks you want to test: 2 current block 2300 next block 2301 Test-R5 pass? False block 2301 validator block reward 5.5807944400095e+19 total reward 8.40000000000000000000e+19 signers 22 Test-R5 pass? False block 2302 validator block reward 5.5807944400095e+19 total reward 8.40000000000000000000e+19 signers 22 done!!!

@gupadhyaya

mindstyle85 commented 4 years ago

checked this one too, so why does it need to account for a shard? afaik block reward is 28 ONE, so i would just take a shard, take the signers in that shard and calculate it shard specific (not sure the / 0.32 idea is correct in the script)

mindstyle85 commented 4 years ago

@ivorytowerdds

ivorytowerdds commented 4 years ago

@mindstyle85 it doesn't account for a shard. the by-shard keyword is confusing, so now it changes to by-bls-key, it's actually different slots.

block rewards = commission fee + validators' rewards + delegators' rewards

This script is also written by ganesha. but from my understanding, since it's not easy to get the commission fee the validator earned, so we just compare the part deducting commission fee. So here what we compare is only all validators' rewards. one calculation is using the difference of ['lifetime']['reward-accumulated'], another is using the definition, one bls-key's reward is the percentage of voting power / shard overall voting power (32%) * block rewards (28 ONE). for one validator, just add up all the bls-keys, and for all validators, add up all the validators.

but I also have a question, @gupadhyaya the 32% equation doesn't apply for delegators? why we only compare validators' rewards here?

mindstyle85 commented 4 years ago

hmm, but wouldnt it be easier to check each shard separate? i understand the by-bls-key, but to compare correctly maybe the better approach is to go by shard first, then check within shard?

not sure about the 32% either, since there are 4 shards, doesnt each have 25%, not 32%? @ivorytowerdds @gupadhyaya

ivorytowerdds commented 4 years ago

need help from @gupadhyaya R5 failed with not small discrepancies:

2020-04-11 01:55:39,606: INFO: Test-R5: Reward given out to block signers sums up to the total block reward
2020-04-11 01:55:39,820: INFO: current and last block numbers: 8899, 8929
2020-04-11 01:55:39,820: INFO: current block 8899, will begin collecting infos...
2020-04-11 01:55:46,678: INFO: new block 8900 reached, will begin testing...
2020-04-11 01:55:47,160: WARNING: Test-R5: Fail
2020-04-11 01:55:47,160: WARNING: block: 8900, validator block reward: 1.11999999999999983616e+20, total reward: 8.40000000000000000000e+19, signers: 129
mindstyle85 commented 4 years ago

im still not sure its correct, you need to go by shard here imo (can easily filter out the by-bls-key for a specific shard anyways), since each block in each shard produces 28 ONEs, then just compare a shard's total block rewards with what the validators (their bls keys) received in that block @ivorytowerdds