-
Notifications
You must be signed in to change notification settings - Fork 106
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
server/asset/eth: max fee rate needs to be a max gas cap #1372
Comments
imo.
I think the difference here is that with other coins and the tip you are dealing with the human element, but with the base fee it's just network usage. A miner cannot screw you on the base fee. If none of this makes sense please call me out, but I think this is what's different and why only the tip cap really matters here. |
I think we need to clarify what is consensus and what is settable as part of the transaction. Each block has a base fee that is decided by consensus. It fluctuates a great deal from block-to-block. Consider the following blocks, where base fee is the right column: Over 10 blocks and 2 minutes, base fee went from 54 to 44 to 64. And it may not get below 50 again for quite some time. For a transaction to be included in one of those blocks, it's Tip / priority fee is much less important as that will only play a role when a block is full (gas used is about 30 million, as with those 3 blocks above) and the miner needs to decide which get in and which don't. The result is that base fee just goes up (see the table) until the block has space for transactions. The gas fee cap on a transaction must be checked because if it is lower than base fee, it doesn't get mined. |
So the only way I can see the priority fee being the fee rate prescribed for matches is if the asset's constant |
If we want to use the If we want to delay the tx until the fee becomes something "reasonable" then what you propose is correct. It's like a blending of a rate check and max possible...
I am proposing just make it the max. |
Yes, it's must be super high, but it also has to be checked by sever during audit. I'm not proposing to delay transaction. Nor should there ever be a need to retry a transaction with a higher fee - the whole point of dynamic transactions is to solve this. I'm saying that we can only check one value presently, thus we cannot have server prescribe tip because it has to be checking the max fee instead. Why I'm focusing this discussion on the match fee rate communicated from server to client is because it is recorded for the match and enforced during server audit of the swap. Whatever we check needs to also be recorded per match. |
The test must be creating the transaction incorrectly. Legacy transactions still work, on mainnet anyway. |
Oof. The server should check that both 1) |
Yes, if we want to check both, it's an API change (and DB changes on both client and server to save both fee rates, uggggh). However, I'm not convinced tip needs to be enforced if the GasFeeCap is sufficiently high. Also, I don't think that it's required that |
Oh, I had a thought about tip last night. We could have tip be set by convention not dynamically. We have a lot of asset conventions such as the contract addresses, redeem script structures, etc., so it would be very reasonable to have the tip always be at least 2 gwei/gas. That would let us check the Anecdotally, checking MetaMask, it seems to set GasFeeCap to something like 120% of current base fee, and the Tip depends on a Low/Medium/High setting that changes it between 1.41/1.5/2.0. These tips might be variable somehow, but I haven't seen Med or High be anything different. The "Max fee" seems to be the main variable here. The etherscan gas tracker also seems to suggest 2 to 4 being a "high" priority fee, with base fee being more variable and precise. |
Found a comment by karalabe describing geth's oracle implementation: ethereum/pm#328 (comment) Specifically, some justification if we went with
So for server/asset's FeeRate: we could pick a |
It's just that |
Maybe there's something I'm still not getting about eip 1559, but there is essentially no need to affect priority on the fly any more. The GasFeeCap only need to be above current block's base fee. The only time tip actually plays a role is when blocks are full and there is a backlog in txpool, but with eip 1559 setting the target block utilization to 50%, that rarely happens for more than a few blocks (a minute or two) at a time. As long as your txn's GasFeeCap is higher than the current block's base fee, and the block is not full, priority fee does not matter. This is part of what I was intending to describe in my comment with the screenshot here, specifically the "Gas used" percentage: #1372 (comment) The behavior of ETH wallets and other gas oracles always suggesting 2-4 for a "high" priority fee, while varying the max fee with base fee much more, supports this I think. |
I think you're probably right. I just hate to use a constant, when we have e.g. if tipRate >= lowestPriorityFee(tipHeight - 10, tipHeight) { ...
And the client is going to lock up funds at |
I agree it's the logical setting for
On this topic, we should be realistic about the timings. Server computes some fee rates, be they the the max fee and/or priority fee. Then some time passes until a transaction is made. Even for maker this is likely to be after a block or two and thus network conditions have changed. For taker, both the priority fee and base fee are super irrelevant since they have been sitting waiting for maker's swap to hit target confs....
Recording both rates then? This sounds like overkill to me. |
What other rate are we recording for the match? |
There's priority and max fee. I thought you were advocating to send both rates separately in the msgjson.Match. Any rate we enforce we must record too. Or you mean it would be a heuristic based on past recent blocks for priority? I guess I'm not clear on |
Not exactly, but I know what you mean. Let's forget about this approach for the time being.
Right. We can record the |
That sounds workable to me for the issue of swap txn fee rate assignment and enforcement. As long as light clients can obtain a priority fee from their chain node that is concordant with the server's. |
Did not mean to assign this to myself |
I'll work on this. So seems like the final consensus is to send the max fee rate in the match request which will be used as the |
Yup, although I'm personally fine with a constant tip of 2 or 2.25. It seems to be fairly unimportant if your max fee is very high |
TLDR: Server contract audits check and enforce a fee rate, but for dynamic ETH transactions there are two fees (tip and max fee) so we have to check max fee, which means that's the fee a match needs to prescribe and record in the DB per-match.
As we have discussed previously, with ETH's eip-1559 "dynamic" transactions:
GasFeeCap
andGasTipCap
) while legacy fee transactions have one (GasPrice
)MaxFeeRate
asset const needs to be something quite high, and as with other asset params, must be set in the server config, and this must be high enough for any server-prescribed max fee.Since a server's fee "suggestions" and prescribed match fee rate in our comms protocol only supports a single rate:
MaxFeeRate
and the eip1559 gas fee cap semantics are the same as MaxFeeRate.A sensible formula for this is used in
go-ethereum/accounts/bind/(*BoundContract).createDynamicTx
:https://github.com/ethereum/go-ethereum/blob/356bbe343a30789e77bb38f25983c8f2f2bfbb47/accounts/abi/bind/base.go#L250-L255
Presently the server gives a fee rate that is obtained from a "legacy" fee rate function that just sums current base fee rate with suggested tip. This is far too low for a max gas fee for a "dynamic" transaction. I started work on this, addressing prerequesites in #1356
In that PR description I've linked a draft commit that will use the base fee and tip suggestion to compute a max gas fee for clients using a formula like the one I've given above.
64a72b4
However, this does not answer the question of what a client should use for their tip, but their funding should use
MaxFeeRate
from the asset config, and their swap transaction should use the gas fee cap provided by the msgjson.Match fee rate. It's not clear how much the tip matters if the gas fee cap is set very high, but if it is important, we will have to establish an enforced convention for the tip (e.g. always 2), or communicate it somehow in addition to the fee cap.EDIT: Instead, it is conceivable that the priority fee for a swap txn can come from the msgjson.Match rate, and the txn should set the
GasFeeCap
toMaxFeeRate
, but this max fee must be checked.The text was updated successfully, but these errors were encountered: