0xPolygonHermez / zkevm-node

Go implementation of a node that operates the Polygon zkEVM Network
Other
533 stars 692 forks source link

be able to force a transaction to be published to L1 even though it fails #2692

Closed eduadiez closed 1 year ago

eduadiez commented 1 year ago

Rationale

Sometimes it may happen that when the EthTxManager tries to estimate a transaction it will result in a revert, so it will not be published in L1. Normally this happens due to an issue on with the SmartContract, for instance a permission issue or that it does not fulfill some of the requirements that the SmartContract has.

It would be very helpful to be able to force these transactions to be published in L1 despite knowing that they will revert since this helps debugging from the SmartContract side.

Implementation

With a flag in the config that allows this to happen would be enough, forceRevertedTxs, or something like that.

This by default has to be set to false, and should only be enabled at particular times when we need to debug an specific tx.

As an extra measure of protection could be also to add the hash of the transaction in the config, so that only the indicated one is forced, avoiding that more transactions are published since generally one is enough, and thus avoid spending unnecessary gas.

tclemos commented 1 year ago

@eduadiez we already have in place a mechanism to accept a transaction when the estimation fails and a forced gas amount is set.

here is the config: https://github.com/0xPolygonHermez/zkevm-node/blob/3a4aa63a8baaee4e70b62db19ccb2977d85bcaf2/ethtxmanager/config.go#L16-L17

here is the code using it: https://github.com/0xPolygonHermez/zkevm-node/blob/3a4aa63a8baaee4e70b62db19ccb2977d85bcaf2/ethtxmanager/ethtxmanager.go#L76-L90

Theoretically, setting the ForcedGas config parameter would be enough to make the code to be able to continue in case a problem happens to the transaction gas estimation.

Do you think we still need something else?

I'll be adding a test to make sure this scenario is covered and working as expected.