poanetwork / poa-ballot-stats

Read POA voting records and rank voters by how many ballots they missed.
GNU Lesser General Public License v3.0
7 stars 6 forks source link

Empty query results. #4

Closed afck closed 6 years ago

afck commented 6 years ago

Unlike https://sokol.poa.network or local nodes, https://core.poa.network sometimes returns empty or incomplete queries (without any error, it seems), so the stats table is empty or outdated.

One difference is that core is load-balanced, while sokol and local nodes aren't.

igorbarinov commented 6 years ago

@phahulin please take a look. Could it be because of nesting load balancers?

phahulin commented 6 years ago

I think this might be related to the use of eth filters, probably here

As it was pointed out by @rstormsf json rpc methods like eth_newFilter register filters on the server and then poll events from there by filter id. In case of multiple nodes behind a load-balancer it could mean that filter is registered on one node but updates are polled from another node.

One possible solution I can think of is to use eth_getLogs instead. Also, maybe @yrashk could you help with this? since bridge is working fine, it must be using some other method to poll events from contract.

igorbarinov commented 6 years ago

You are right, it seems like session affinity. Cloudflare supports affinity only with cookies which is not an option here https://support.cloudflare.com/hc/en-us/articles/115001771451-Load-Balancing-Session-Affinity

they plan to have sticky sessions by IP in the future

Additionally while affinity is currently only available by cookie, in the future Cloudflare will also add support for Session Affinity by IP, as well as custom cookies and header. 

To resolve the issue we created an endpoint with one node for core core-solo.poa.network. It's like it is for Sokol. @afck let's include endpoints into the documentation Results are much better https://asciinema.org/a/v56GSe96Xe7xR2aErCKBbFJ5y

        Missed  Voting key   Mining key   Name
   9/22, 41.0%  0x81de…91d6  0x8e6c…6b61  Jefferson Flowers
   9/22, 41.0%  0x978b…d42e  0xf1f5…1a75  Stephen Arsenault
   9/22, 41.0%  0xe3eb…77c2  0x18be…a44e  Lillian Chan
   6/22, 27.3%  0x9c53…1be9  0x8fe3…dced  Sherina Yang
   6/22, 27.3%  0xdf11…17a5  0x7a6a…d32e  John H.  LeGassic
   3/22, 13.7%  0x1206…7efb  0x3091…39a0  John D. Storey
   3/22, 13.7%  0xf404…6152  0x6e4f…6494  Michael Milirud
   1/22,  4.6%  0x57b8…21f6  0x28e7…2cc3  Melanie Marsollier
    0/3,  0.0%  0x4af0…1e3d  0x7130…a480  Adam Kagy
    0/6,  0.0%  0xac5d…7317  0xbc70…913b  Ilmira Nugumanova
   0/10,  0.0%  0x774e…ce0a  0x6e34…697e  Marat Pekker
   0/12,  0.0%  0x2d68…2404
   0/13,  0.0%  0xcec2…f084  0xdad4…1a41  Alex Emelyanov
   0/22,  0.0%  0x2341…33e5  0x49bb…9b67  Jim O'Regan
   0/22,  0.0%  0x302b…9416  0x0f1e…cdfc  Rocco Mancini
   0/22,  0.0%  0x6d22…b255  0xdc47…6252  Sviataslau Vishneuski

@afck btw one validator has an empty name. Should I create a separate issue?

afck commented 6 years ago

Thank you, that makes sense! (Although it's still weird that the other nodes then respond with empty results instead of an error. But that may as well be a problem in rust-web3.)

I'll extend the documentation. Then I'll try to use eth_getLogs and I'll have a look at the poa-bridge code.

I added #11: I'm pretty sure that's why there's an empty name; I'll try it out next week.