-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
frontrunning issue with gas: 'auto' vs gas: number ( neither works like in prev hardhat version ) #4471
Comments
Hey @moneyDev1111, I'm not sure I understand your problem. If you are trying to simulate a frontrunning attack, then I guess you are disabling automining, sending a tx 1, and then sending a tx 2 with a higher gas price. Then, if you send a |
gas: 'auto' or gas: number changes the behavior of hardhat!!! the transactions order |
@fvictorio I will record a video a bit later for a better explanation, non of the settings allow frontrunning |
@fvictorio I've found the working settings for the newer version, If mining interval set to 0 seconds, everything works. If to 10 seconds - doesn't work. Could you please explain why such behavior? Thank you 50 seconds also works... I see I needed to read the docs more carefully, the right answer is to use 0 seconds interval.... |
Version of Hardhat
2.17.3
What happened?
I'm simulating a frontrunning attack using one of the latest hardhat version ( yes, I've found the closed issue here, when it only allows a single tx to be in a block, without gas 'auto' in the config ( BUT it presents some new issue )).
In short, if I use gas: 'auto', frontrunning logic doesn't work... I have only 3 txs: contract deployment, victim tx and the attacker tx, and the evm_mine call at the end of the code.. ( I will provide it if you need it, but it seems like the problem should be clear for you hopefully even without it ).
So, when using gas auto, I don't even see my transaction, tho I'm using the victims tx data and sending it with the bigger gasPrice or maxPriorityFeePerGas ( I tried both ) amount. It seems like tho the block is not mined yet, hardhat is already decided that the victim's tx should be first, cause it's higher in the code or sth, and then the attacker tx is just being reverted cause the victim's tx already got ETH from the contract.
But when gas: number is used everything seems to work. BUT ONLY IF there's little amount of tx and they are not too complex. I can't get it work either way when I have lots of tx that I need to sort through to find the victim's tx.... Could you please explain why so and what's the proper way to 'fix' it if there's sth to fix in the first place. Thank you
Minimal reproduction steps
comparing behavior using gas: auto vs gas: number in the config
Search terms
No response
The text was updated successfully, but these errors were encountered: