[price-pusher] Add nonce for evm + refactor #679
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes the EVM pusher to rely on the account nonce to increase reliability and cost-efficiency of the pusher.
On EVM networks nonce is the transaction index of the user transaction. it increments 1 by 1 and you cannot send two transactions with the same nonce; if there are multiple transactions with the same nonce only one gets chosen on-chain.
Sometimes our transactions do not land on chain because the gas is lower than the necessary amount to be included on-chain. By setting nonce manually we can replace the older transaction with a higher gas to increase likelihood of the price landing on-chain without paying any extra cost. The
override-gas-price-multiplieroption with the default of 1.1 is added to handle this situation. Also we can try updating the prices on a faster frequency or even run multiple pushers with the same sender without adding any extra cost because they will be excluded (without reverting on-chain). Since we get nonce from the RPC, if the tx is landed with the RPC knowledge, then the quick update will get rejected on simulation because the RPC state is up to date. However, in our experiments due to RPCs being behind a load-balancer and not being completely in-sync there were rare occurances of on-chain reverted transaction under extreme conditions (pushing every second). We can reduce the chances of this happening by reducing the pushing frequency.Because of the above change and better handlings of errors, now it is safe to run multiple instances of the pusher using the same account without additional cost overhead.
In this PR there are some refactorings: