feat: support priorityFee fetching from RPC and some better logging (#3972)

### Description

`main` equivalent for
https://github.com/hyperlane-xyz/hyperlane-monorepo/pull/3971 to get it
in for the latest warp UI deployment
pull/3980/head
Nam Chu Hoai 5 months ago committed by GitHub
parent 6620fe6367
commit 921e449b41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      .changeset/sixty-ducks-brush.md
  2. 2
      typescript/cli/src/deploy/warp.ts
  3. 1
      typescript/sdk/src/providers/SmartProvider/HyperlaneEtherscanProvider.ts
  4. 7
      typescript/sdk/src/providers/SmartProvider/HyperlaneJsonRpcProvider.ts
  5. 1
      typescript/sdk/src/providers/SmartProvider/ProviderMethods.ts
  6. 36
      typescript/sdk/src/providers/SmartProvider/SmartProvider.ts
  7. 15
      typescript/sdk/src/token/deploy.ts

@ -0,0 +1,6 @@
---
"@hyperlane-xyz/cli": patch
"@hyperlane-xyz/sdk": patch
---
Support priorityFee fetching from RPC and some better logging

@ -125,7 +125,7 @@ async function executeDeploy(params: DeployParams) {
const deployedContracts = await deployer.deploy(config);
logGreen('✅ Hyp token deployments complete');
logGreen('✅ Warp contract deployments complete');
const warpCoreConfig = await getWarpCoreConfig(params, deployedContracts);
if (!isDryRun) {

@ -24,6 +24,7 @@ export class HyperlaneEtherscanProvider
ProviderMethod.Call,
ProviderMethod.EstimateGas,
ProviderMethod.SendTransaction,
ProviderMethod.MaxPriorityFeePerGas,
]);
constructor(

@ -32,6 +32,13 @@ export class HyperlaneJsonRpcProvider
super(rpcConfig.connection ?? rpcConfig.http, network);
}
prepareRequest(method: string, params: any): [string, any[]] {
if (method === ProviderMethod.MaxPriorityFeePerGas) {
return ['eth_maxPriorityFeePerGas', []];
}
return super.prepareRequest(method, params);
}
async perform(method: string, params: any, reqId?: number): Promise<any> {
if (this.options?.debug)
this.logger.debug(

@ -16,6 +16,7 @@ export enum ProviderMethod {
GetTransactionReceipt = 'getTransactionReceipt',
GetLogs = 'getLogs',
SendTransaction = 'sendTransaction',
MaxPriorityFeePerGas = 'maxPriorityFeePerGas',
}
export const AllProviderMethods = Object.values(ProviderMethod);

@ -1,4 +1,4 @@
import { providers } from 'ethers';
import { BigNumber, providers, utils } from 'ethers';
import { Logger } from 'pino';
import {
@ -97,6 +97,40 @@ export class HyperlaneSmartProvider
this.supportedMethods = [...supportedMethods.values()];
}
async getPriorityFee() {
try {
return BigNumber.from(await this.perform('maxPriorityFeePerGas', {}));
} catch (error) {
return BigNumber.from('1500000000');
}
}
async getFeeData(): Promise<providers.FeeData> {
// override hardcoded getFeedata
// Copied from https://github.com/ethers-io/ethers.js/blob/v5/packages/abstract-provider/src.ts/index.ts#L235 which SmartProvider inherits this logic from
const { block, gasPrice } = await utils.resolveProperties({
block: this.getBlock('latest'),
gasPrice: this.getGasPrice().catch(() => {
return null;
}),
});
let lastBaseFeePerGas: BigNumber | null = null,
maxFeePerGas: BigNumber | null = null,
maxPriorityFeePerGas: BigNumber | null = null;
if (block?.baseFeePerGas) {
// We may want to compute this more accurately in the future,
// using the formula "check if the base fee is correct".
// See: https://eips.ethereum.org/EIPS/eip-1559
lastBaseFeePerGas = block.baseFeePerGas;
maxPriorityFeePerGas = await this.getPriorityFee();
maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas);
}
return { lastBaseFeePerGas, maxFeePerGas, maxPriorityFeePerGas, gasPrice };
}
static fromChainMetadata(
chainMetadata: ChainMetadataWithRpcConnectionInfo,
options?: SmartProviderOptions,

@ -135,10 +135,17 @@ abstract class TokenDeployer<
}
async deploy(configMap: WarpRouteDeployConfig) {
const tokenMetadata = await TokenDeployer.deriveTokenMetadata(
this.multiProvider,
configMap,
);
let tokenMetadata: TokenMetadata | undefined;
try {
tokenMetadata = await TokenDeployer.deriveTokenMetadata(
this.multiProvider,
configMap,
);
} catch (err) {
this.logger.error('Failed to derive token metadata', err, configMap);
throw err;
}
const resolvedConfigMap = objMap(configMap, (_, config) => ({
...tokenMetadata,
gas: gasOverhead(config.type),

Loading…
Cancel
Save