-
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
client/eth: Respect user's max fee. #1485
Conversation
e60d00b
to
d3313f1
Compare
Check initiation and redeem fee suggestions are not zero or too high. If so attempt to get our own gas rate limit value. If that also fails or is above our max limit, do not send the transaction.
d3313f1
to
da0754d
Compare
Actually the server is pretty strict about this, so I guess we can't use our estimation for initiations if the server's is too high. It has to be the suggestion. |
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.
We realistically never have a fee suggestion from the server, since the wallet implements FeeRater
.
tx, err := eth.node.initiate(eth.ctx, swaps.Contracts, swaps.FeeRate, swaps.AssetVersion) | ||
tx, err := eth.node.initiate(eth.ctx, swaps.Contracts, gasFeeLimit, swaps.AssetVersion) |
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.
Can't do this part. This is validated by the server.
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.
More than that, the "fee limit" was only ever intended to block order funding, nothing else. In fact, this is the setting that I fought to keep out of the wallet since Core's trade methods (prepareTrackedTrade) could have just as easily applied this user set limit in the one place it was intended. #874 (comment)
I suppose the limit can expand in scope somewhat to limit the wallet's own local estimate though.
if lowerRate > 0 { | ||
eth.log.Warnf("Eth gas rate limit too low! Set above %d gwei to complete current transaction!", | ||
lowerRate) | ||
return 0, fmt.Errorf("the needed gas fee rate limit (%d gwei) is higher than set max (%d gwei)", lowerRate, eth.gasFeeLimit) |
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.
No way we can just block inits, redeems, or refunds.
nACK, Unless really I'm misunderstanding something.
But I do approve of the formula for computing a local fee rate ( |
Looks like only server has |
While I agree, the server can currently insert any value here and unless the total gas goes over 1 eth (#1304) the wallet will not reject it. On the other side, the server could send something too low and screw the user, which this pr wouldn't solve. There is currently no resolution for txn with fees that are too low with eth. Low fee tx are a bigger problem with eth. IMO client can not blindly trust the server. Also, I guess I misundersood the meaning of the gas limit. It only applies to initiations, and not to anything else. Can't we just not do the swap if fee is too high/low though? I mean initiation. I agree it could be catastrophic to not redeem/refund. I would agree that after you initiate, you kinda agreed to pay whatever fees you need to to complete the swap. |
It does not need to reject it because this Lines 577 to 579 in 26b0c82
and the Lines 259 to 261 in 26b0c82
and dcrdex/client/asset/dcr/dcr.go Lines 1061 to 1070 in 26b0c82
|
As for too low, sure we can use any fee rate minimum as long as its not over the MaxFeeRate because that would potentially eat into the reserves required for the swap(s) for the order. On the high end limit though, if the wallet did block a swap/init because the fee was higher than it's configured fee limit, that could just be because the fee limit was changed after the order was placed (funded). I wouldn't object to a second very high limit as a sanity check, but it would have to be super high, as in beyond any setting the user might switch their gasFeeLimit setting to. |
In fact, I would 100% support changes to all asset impls to do this. Particularly BTC where as taker you are using a fee rate prescribed at match time that was potentially a long time ago if the maker's swap took a while to confirm. It should be fine to use any rate |
I think I see it now. The |
Right, you have a certain configured fee rate limit at order time. If the server's |
Ok, then we were respecting the max in the manner intended. |
Yes although in this contorted way because the user's fee limit is configurable and this need to be recorded with the order metadata. I like the idea of bumping the rate if it looks too low though |
But the redeem is not checked at all, and we are using the suggestion. |
Oh, I see, if it were a FeeRater, it would be using the local fee? |
I think @martonp said on matrix he would add that. |
Ah, yeah, @buck54321 's point there is that the eth client should be a FeeRater, not needing the suggestion at all. @martonp said he was going to make that change in his PR. Would be good to coordinate with him on this so we're on the same page. |
I guess I will close this pr and the linked issue. Will make a new issue for suggested fees that are too low. |
closes #1336