-
Notifications
You must be signed in to change notification settings - Fork 58
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
Simplify class TxHelpers #478
Conversation
…the nonce is fetched
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some small stuff; does not necessarily need to be changed but I'd like to discuss
more generally -- it is hard to review the changes; it looks like functionality changed somewhat and things moved around a lot so the diffs are not particularly useful; with good test coverage this is not a problem -- but given how poor our test coverage seems to be: are you sure this does not introduce bugs?
Open questions regarding the
|
no idea, but 1/ - probably not would be my guess... |
|
… in a missing configuration for Base in GitHub's test-suite
…butes only after sending the `eth_estimateGas` and `eth_createAccessList` requests
Closing and reposting as #529 |
Some of the changes in the
TxHelpers
class:Removed the
DEFAULT_GAS_PRICE_OFFSET
("increase by 9%") factor applied on the max priority fee:Removed the parsing of the "baseFee" error-message returned from the node. This error happens when the block's
baseFee
becomes higher than the transaction'smaxGasFee
, which theoretically yields a negative tip to the miner, hence the transaction is immediately reverted. Recall that the miner gets paidmaxGasFee - baseFee
, regardless of the specifiedmaxPriorityFee
, which indicates the maximum tip and not the actual tip. But even before this happens, the block'sbaseFee
may become sufficiently high to bring the effective tip paid to the miner extremely small, thus leading the transaction to linger for a very long time, and most likely become invalid (arbitrage already fulfilled) by the time it gets executed. So the only difference between these two scenarios is a reverted transaction vs a stuck transaction. Both can sporadically happen, just like front-running can sporadically invalidate arbs submitted by this bot, for example. This error can be handled in a "natural manner", at the next iteration of the bot's infinite loop, hence there is no need to tailor-make a special "handle error and retry" method for this specific error.Fetching the
maxPriorityFee
via web3 instead of by sending an HTTP request to the node. It shouldn't yield a notable impact, but, why invent the wheel?Fetching the
gasPrice
instead of thebaseFee
, since the latter requires fetching the entire block, which most likely takes longer to complete. In the case of chains which already support EIP1559 (e.g., Ethereum, starting from the London fork), this value indicates the sum of the current block'sbaseFee
and the averagemaxPriorityFee
, hence it can be used as is when setting the transaction'smaxGasFee
. And of course, in the case of chains which do not yet support EIP1559, it can be used as is in order to set the transaction'sgasPrice
.After the transaction is built, it already includes the estimated gas, so no need to then send another
estimateGas
request to the node.Fetching the access-list via web3 instead of by sending an HTTP request to the node, because - again - why invent the wheel?
After the access-list is added to the transaction, it already includes the new estimated gas, so no need to then send another
estimateGas
request to the node.Removed the
EXPECTED_GAS_MODIFIER
("decrease to 85%") factor used for assessing the actual gas cost of the transaction.Replaced fetching the latest block (used in order to specify max block number when sending a private transaction to Alchemy), with fetching only the block number itself, which is probably (or at least hopefully) more efficient.
Removed support for legacy-transactions; all chains are assumed to be supporting EIP-1559.
Sending
eth_sendPrivateTransaction
HTTP requests via web3 instead of via the node. This change includes the removal of theretries=3
parameter, which needs to be verified.Instead of the
DEFAULT_GAS_PRICE_OFFSET
("increase by 9%") factor applied on the max priority fee, introduced aGAS_STRATEGY
hook function with which the user can configure their desired gas-fee strategy.Ensured that access-list is applied on Ethereum transactions; it is not applied in the current version due to a bug in the code, and even after this PR, it will not be tested within Tenderly (when the target chain is Ethereum) because of that same bug; see issue NETWORK_TENDERLY overrides the original NETWORK #519.
Constructing the
tx
dictionary manually and then setting itsgas
attribute by callingestimate_gas
, instead of viabuild_transaction
to do both of these actions; Following that, setting theaccessList
attribute of this dictionary, and possibly updating itsgas
attribute, by callingcreate_access_list
; The gas-fee attributes (maxFeePerGas
andmaxPriorityFeePerGas
) are set only at the end, in order to avoid getting the "max fee per gas less than block base fee" error.