accounts/abi/bind: Do not overwrite TransactOpts in transact #23663
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.
Motivation
At the moment, the
BoundContract.transact()
will populate the GasTipCap (i.e. maxPriorityFee) and GasFeeCap (i.e. maxFeePerGas) of a transaction if theTransactOpts
passed to the method do not specify a GasTipCap/GasFeeCap by setting the GasTipCap field and GasFeeCap field on theTransactOpts
. Since theTransactOpts
parameter is a pointer, if the same pointer is passed to another call toBoundContract.transact()
, the GasTipCap and GasFeeCap fields will already be populated which means fixed values will be used for these fields instead of values based on the latest suggested GasTipCap and the latest base fee.The above behavior can be a problem when a contract binding session is used. The first transaction sent using the session will set the GasTipCap and GasFeeCap fields of the
TransactOpts
stored in the session. Then, subsequent transactions would end up using the same fixed GasTipCap and GasFeeCap.If EIP-1559 is not enabled and the GasPrice field in
TransactOpts
is used then the above applies for the GasPrice field as well.Solution
This PR updates
BoundContract.transact()
to not set the GasTipCap/GasFeeCap/GasPrice fields on theTransactOpts
parameter. The method will only read fields fromTransactOpts
and will not write fields.Additional Info
This was not a problem prior to the EIP-1559 related changes to
BoundContract
at commit 38ea7f2 because thetransact()
method did not set the GasPrice field on the TransactOpts.