Skip to content
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

feat(gasPriceOracle): Allow caller to pass in base fee multiplier #801

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

nicholaspai
Copy link
Member

We should have quoting API apply its GAS_MARKUP to the base fee rather than the estimated gas units

@nicholaspai nicholaspai requested review from pxrl and dohaki December 19, 2024 15:06
nicholaspai added a commit to across-protocol/relayer that referenced this pull request Dec 19, 2024
@nicholaspai nicholaspai marked this pull request as ready for review December 19, 2024 16:26
src/gasPriceOracle/oracle.ts Outdated Show resolved Hide resolved
@nicholaspai nicholaspai requested a review from mrice32 December 19, 2024 19:42
src/gasPriceOracle/oracle.ts Outdated Show resolved Hide resolved
src/gasPriceOracle/oracle.ts Outdated Show resolved Hide resolved
Comment on lines 268 to 271
const gasMultiplier = 1.0; // Don't apply any multiplier to the gas price.
const queries = [
gasUnits ? Promise.resolve(BigNumber.from(gasUnits)) : voidSigner.estimateGas(unsignedTx),
_gasPrice ? Promise.resolve({ maxFeePerGas: _gasPrice }) : getGasPriceEstimate(provider, chainId, transport),
_gasPrice ? Promise.resolve({ maxFeePerGas: _gasPrice }) : getGasPriceEstimate(provider, chainId, gasMultiplier, transport),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicholaspai I updated this to fix a merge conflcit after merging my PR, but I'm curious about why we don't want to apply any buffer here. This is where the API would otherwise want to apply it, if I've understood correctly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh you're right this is a mistake. I only applied it to the fresh query to the oracle but not to the input value if defined

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what you were thinking? 4a0858a

Copy link
Contributor

@pxrl pxrl Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicholaspai I'm not sure tbh. Do we want to apply the multiplier if the caller specifies the gasPrice? There is a risk that we revert to the recursive gas price multiplication that we had a while ago (i.e. the API sources a gas price including multiplier, then supplies it back to the gasPriceOracle and it gets multiplied again).

But I was also looking at line 268, where we have const gasMultiplier = 1.0. I think we want that to be user-supplied, rather than hardcoded in this file, right?

I'm thinking that we might need a more advanced way of specifying inputs, such that the user can supply a gas price or a gasPriceMultiplier, but not both. OK if I propose that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right this is a mistake. We should allow caller to pass in gas price multiplier and NOT apply it if the gas price is passed in.

Comment on lines 17 to 26
logger: Logger = DEFAULT_LOGGER,
gasMarkup = 0
logger: Logger = DEFAULT_LOGGER
// gasMarkup = 0
) {
assert(isDefined(spokePoolAddress));
super(
provider,
symbolMapping,
spokePoolAddress,
simulatedRelayerAddress,
gasMarkup,
// gasMarkup,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw I think we need to retain these, otherwise the API will just inherit the default 1.0 multiplier.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm confused by your comment here, what do you mean? It seems that we are removing the gasMarkup param from the relayFeeCalculator's constructor so why would we need to retain it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I think this might be relevant that we'll merge in this pr alongside an import of this sdk release into the FE

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I understand now. So the gas multiplier would effectively only apply in the API?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's how we currently use the multiplier so yeah

@nicholaspai nicholaspai requested a review from pxrl December 21, 2024 17:08
@@ -256,18 +256,21 @@ export async function estimateTotalGasRequiredByUnsignedTransaction(
options: Partial<{
gasPrice: BigNumberish;
gasUnits: BigNumberish;
baseFeeMultiplier: number;
Copy link
Member Author

@nicholaspai nicholaspai Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pxrl I added in an optional multiplier arg here. I think in most existing use cases of this function we only want the default multiplier but PTAL

nicholaspai added a commit to across-protocol/relayer that referenced this pull request Dec 24, 2024
Builds on across-protocol/sdk#801 and applies relayer's base fee multiplier to new SDK parameter to scale the base fee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants