QuarkChain / pyquarkchain

Python implementation of QuarkChain
https://quarkchain.io
MIT License
225 stars 114 forks source link

Add total balance counting script #899

Closed ninjaahhh closed 4 years ago

ninjaahhh commented 4 years ago

running on code at #898, gives following output (total process takes about ~20 seconds)

python count_total_balance.py --rheight 665755

2020-07-15 01:51:43: root block at height 665755 has minor block headers for 8 shards
2020-07-15 01:51:43: querying total balance for shard 0x00000001
2020-07-15 01:51:44: shard 0x00000001: iteration 10, total balance is 606820443.34
2020-07-15 01:51:45: shard 0x00000001: iteration 20, total balance is 1989722405.86
2020-07-15 01:51:45: shard 0x00000001: iteration 30, total balance is 2128933647.77
2020-07-15 01:51:46: shard 0x00000001: iteration 40, total balance is 2153685825.39
2020-07-15 01:51:46: shard 0x00000001: iteration 50, total balance is 2155391015.13
2020-07-15 01:51:47: shard 0x00000001: iteration 60, total balance is 2156638555.18
2020-07-15 01:51:47: shard 0x00000001: iteration 70, total balance is 2282764252.85
2020-07-15 01:51:48: shard 0x00000001: iteration 80, total balance is 2362320942.55
2020-07-15 01:51:48: shard 0x00000001: finished, total balance is 2363399871.51
2020-07-15 01:51:48: ======
2020-07-15 01:51:48: querying total balance for shard 0x00010001
2020-07-15 01:51:49: shard 0x00010001: iteration 10, total balance is 597970743.40
2020-07-15 01:51:49: shard 0x00010001: iteration 20, total balance is 600210916.55
2020-07-15 01:51:50: shard 0x00010001: iteration 30, total balance is 610366193.14
2020-07-15 01:51:50: shard 0x00010001: finished, total balance is 610371897.29
2020-07-15 01:51:50: ======
2020-07-15 01:51:50: querying total balance for shard 0x00020001
2020-07-15 01:51:50: shard 0x00020001: iteration 10, total balance is 68212388.09
2020-07-15 01:51:51: shard 0x00020001: iteration 20, total balance is 73730684.52
2020-07-15 01:51:51: shard 0x00020001: finished, total balance is 91880450.67
2020-07-15 01:51:51: ======
2020-07-15 01:51:51: querying total balance for shard 0x00030001
2020-07-15 01:51:52: shard 0x00030001: iteration 10, total balance is 606792976.07
2020-07-15 01:51:53: shard 0x00030001: iteration 20, total balance is 620672975.84
2020-07-15 01:51:53: shard 0x00030001: finished, total balance is 648900150.89
2020-07-15 01:51:53: ======
2020-07-15 01:51:53: querying total balance for shard 0x00040001
2020-07-15 01:51:53: shard 0x00040001: iteration 10, total balance is 602714883.79
2020-07-15 01:51:54: shard 0x00040001: iteration 20, total balance is 652289120.60
2020-07-15 01:51:54: shard 0x00040001: finished, total balance is 652303064.57
2020-07-15 01:51:54: ======
2020-07-15 01:51:54: querying total balance for shard 0x00050001
2020-07-15 01:51:55: shard 0x00050001: iteration 10, total balance is 601790215.02
2020-07-15 01:51:55: shard 0x00050001: iteration 20, total balance is 602684653.25
2020-07-15 01:51:55: shard 0x00050001: finished, total balance is 691841820.50
2020-07-15 01:51:55: ======
2020-07-15 01:51:55: querying total balance for shard 0x00060001
2020-07-15 01:51:56: shard 0x00060001: iteration 10, total balance is 588922672.35
2020-07-15 01:51:57: shard 0x00060001: iteration 20, total balance is 598751019.81
2020-07-15 01:51:57: shard 0x00060001: iteration 30, total balance is 611407766.83
2020-07-15 01:51:57: shard 0x00060001: finished, total balance is 611409369.33
2020-07-15 01:51:57: ======
2020-07-15 01:51:57: querying total balance for shard 0x00070001
2020-07-15 01:51:58: shard 0x00070001: iteration 10, total balance is 600601628.10
2020-07-15 01:51:58: shard 0x00070001: iteration 20, total balance is 601675536.13
2020-07-15 01:51:59: shard 0x00070001: iteration 30, total balance is 628109018.94
2020-07-15 01:51:59: shard 0x00070001: finished, total balance is 628109018.94
2020-07-15 01:51:59: ======
2020-07-15 01:51:59: counting finished, total balance is 6298215643.70
ninjaahhh commented 4 years ago

one todo is to handle cases if the queried root block doesn't contain all the shards.