ethersphere / bee

Bee is a Swarm client implemented in Go. It’s the basic building block for the Swarm network: a private; decentralized; and self-sustaining network for permissionless publishing and access to your (application) data.
https://www.ethswarm.org
BSD 3-Clause "New" or "Revised" License
1.44k stars 338 forks source link

Implement bee node "Trx Debug mode" #4664

Open n00b21337 opened 2 months ago

n00b21337 commented 2 months ago

To iterate on this issue here https://github.com/ethersphere/bee/issues/4662 I have a better solution.

Context When we are checking for the proper gas amount to use we are not only doing that but we are also checking if the transaction will go through or would it fail.

Problem The problem we are actually having is that we are always simulating transactions through EstimateGas and SuggestGasPrice (probably, maybe something else also?) https://github.com/ethersphere/bee/blob/ac52e18f168654d52402cd3c6f0073b93d3e2a5c/pkg/transaction/wrapped/wrapped.go#L161 that produces the situation where transactions on blockchain never happen and we get obscure info from Bee on what happened when there is an ERROR.

Suggestion So I would suggest that there is an implementation of "trx-debug mode" flag when running a bee node. If this global flag is on, then there will be no simulations, trx should be made on blockchain whether they fail or succeed. This will give us transparency and ready-made debug info for what is happening, we can then just check the tools like etherscan or tenderly and see what happened and have full info on problems.

Implementation I can see here that there is a prepare transaction part where gas is checked, so just skipping gas checking when this flag is ON would be enough https://github.com/ethersphere/bee/blob/ac52e18f168654d52402cd3c6f0073b93d3e2a5c/pkg/transaction/transaction.go#L278 possible other solution would be on the first link to add some default gas if the flag is on on all estimate methods.

Also, check if there is some other way trx are simulated I am not aware of bee nodes code details. This should be also applied when using beekeeper.

istae commented 2 months ago

Question:

regarding this, how would we know how much gas to put up for the transaction. if the trx-debug mode was ON, what should be the gas?

Answer:

good question but also easy to solve. we just put default that is big enough, can be safe and 2x/3x of usual max. how gas works anyway since eip 1559 is that all extra gas is returned so nothing is lost