bsc icon indicating copy to clipboard operation
bsc copied to clipboard

How does transactions processing work?

Open kwkr opened this issue 5 years ago • 12 comments

Yesterday there was the FC Porto token IFO on Pancake Swap. The network seemed to be highly congested and I wasn't able to finish a single transaction (whether a simple transfer or a contract call). But I could still see a lot of transactions being processed. So my question is, what are the factors that could prevent my transactions from processing? I tried setting the gasPrice to much higher levels (30+) but it didn't help at all. I think I just don't understand the rules governing the transactions processing, therefore could you maybe point me to some reference that would explain it to me? Thanks!

kwkr avatar Nov 17 '21 08:11 kwkr

@kwkr how do you know your transaction was not processed? I mean it's impossible to answer your question based on the little info you provided.

psdlt avatar Nov 17 '21 11:11 psdlt

Sorry, I'm quite a newbie so I just provided the information that I was considering. The transaction failed after staying in pending state for like 30-45 minutes. I can provide you more info if needed, but I would say the question is more about the general situation rather than a specific transaction.

kwkr avatar Nov 17 '21 11:11 kwkr

@kwkr by default, validators should sort pending transaction pool from highest gas price to lowest, take as many txs as they can fit into a single block and publish that block. Now this is not guaranteed as validators can choose to implement any other kind of sorting they like. In your specific situation it's quite possible that your transaction wasn't even submitted to network because of some unknown issues and the software that you use (MetaMask, Web3JS, etc.) to interact with network simply didn't report that issue properly.

psdlt avatar Nov 17 '21 11:11 psdlt

Is it possible to make sure that the transaction got submitted to the network? Is there any way that will maximize my chances of successfully sending the transaction to the network? From what I understand using MetaMask/Trustwallet isn't the most optimal solution when speed counts, right?

kwkr avatar Nov 17 '21 11:11 kwkr

Is it possible to make sure that the transaction got submitted to the network? Is there any way that will maximize my chances of successfully sending the transaction to the network? From what I understand using MetaMask/Trustwallet isn't the most optimal solution when speed counts, right?

Which RPC endpoint do you use to submit the transaction?

NullQubits avatar Nov 17 '21 11:11 NullQubits

If you're not a programmer/developer and you're not looking to running your own nodes and writing code - I'm afraid your options are pretty limited. As NullQubit suggested, you might try using a different RPC endpoint, but given a high network congestion it probably won't improve your situation by much.

psdlt avatar Nov 17 '21 11:11 psdlt

I'm actually a programmer and I'm currently experimenting with different types of settings. But as I said, I am new to this stuff, so still trying to figure it out. Currently I'm experimenting with web3 for JS and tried different WS endpoints (public one, QuickNode and some other services, even tried running my own node, but couldn't sync it). So in this case could you actually give me some tips what my options are?

kwkr avatar Nov 17 '21 11:11 kwkr

@kwkr well, in that case :) Run your own node (it is possible to sync up, just don't fall for the "snapshot" scam), set max_peers settings to a high enough number (anywhere between several hundred to several thousand). And then submit your txs through your own node. That's your best shot.

psdlt avatar Nov 17 '21 11:11 psdlt

Okay, will try it once again then. If you have one yourself, could you give me a hint on the machine specification that I should use? Previously I used i3.xlarge with 4 CPU, ~30GB RAM and 0.95 TB NVME (https://aws.amazon.com/ec2/instance-types/i3/) and I wanted to try it again with i3.2xlarge which has double the specs above. Is the default config enough (except from the max-peers setting you suggested)?

So in this case it seems that the most important factor for the transaction to go through, would be the speed at which it is delivered to the network which is the best in case of running own node? Because playing with different gas prices I didn't see any difference to be honest. Also if you say, that the validators choose their processing strategy, it might be as well the case, that their buddies have some priority in the process, is it correct?

Btw, I'm curious what do you mean with the "snapshot scam"?

kwkr avatar Nov 17 '21 11:11 kwkr

@kwkr 0.95TB is not enough. i3en.2xlarge is sufficient for now, but probably would be better to start from i3en.3xlarge (i3en is supposedly better than i3 as it's a newer offering from AWS). Default config is fine.

As for "snapshot scam": downloading snapshot and syncing from that is the recommended way, but IMO it's stupid and that never worked for me. Takes several hours to download snapshot, several more hours to extract it, and then it still doesn't work because node just can't sync up to latest block. Tried multiple times, never worked. Syncing from genesis worked every time and is about the same time-wise.

psdlt avatar Nov 17 '21 13:11 psdlt

Well, thanks a lot for all the information you provided me! Can't wait to try it again in this case. One last question: Given all the information above, do you actually ever adjust the gasPrice when writing bots or anything that needs to quickly send transactions? Or the speed of sending the transactions is the most crucial thing?

kwkr avatar Nov 17 '21 13:11 kwkr

@kwkr yes, accounting for gas price is crucial in writing bots :)

psdlt avatar Nov 17 '21 13:11 psdlt