emeraldpay / dshackle

Fault Tolerant Load Balancer for Ethereum and Bitcoin APIs
Apache License 2.0
312 stars 56 forks source link

Slow to get nonce in MetaMask #113

Open MysticRyuujin opened 3 years ago

MysticRyuujin commented 3 years ago

Using the 10.1 release (docker), I've noticed that when I'm using Polygon and I go to submit a transaction, MetaMask pops up and the custom nonce field is empty. It sits there for...2 to 3 seconds maybe, before populating the nonce value.

It's not the end of the world or anything but I can't figure out why there's such a delay in getting the nonce?

I did a LITTLE bit of testing, and subsequent transactions are not as slow, but that could be some kind of cache or MetaMask? I don't see any errors or anything in the logs.

I have 8 nodes lol, does dshackle query all of them before returning the nonce after some amount of time?

Multistream | State of MATIC: height=19349893, status=LAGGING/4,OK/2,SYNCING/2, lag=[4, 4, 0, 92, 4, 1, 4, 32]
splix commented 3 years ago

Dshackle tries to query 3 nodes (when available) to ensure consistency, and it seems it doesn't works well with Matic. Because Dshackle checks only fully synced nodes for nonce (also for Balance requests), and while it's usual state with Ethereum it becomes problematic with Matic where it's common to lag behind. Like in your example only 1 node is fully synced, so sometimes it have to wait for another one.

I guess I can to make it configurable and allow to use lagging nodes, though I'm not sure it's a right solution.

sambacha commented 3 years ago

Do you have the custom noce option enabled in Metamask @MysticRyuujin? Metamask is quite fanatical on how they manage nonce (i.e. not exposed to developers). Check your state logs (use their state log explorer utility)[https://metamask.github.io/state-log-explorer/] it should give you more information.

Is this on Chrome or Firefox by the way?