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:update StorageGasOracle in igpDeployer #3101

Closed
wants to merge 17 commits into from

Conversation

aroralanuk
Copy link
Contributor

@aroralanuk aroralanuk commented Dec 23, 2023

Description

  • CLI
    • add oracleConfig and overhead to hooks config
    • asking user for overhead, tokenExchangeRate (optional - use 1e10 as default), gasPrice (optional - use provider.getPrice() as default)
    • parsing IGPConfig (ZOD) to IGPConfig (SDK)
  • IGPDeployer
    • if onchain storage oracle config doesn't match the desired oracleConfig (inside igpConfig)
    • getStorageGasOracleConfigs - fetches nested storage gas oracle from within the coreConfig (e.g. core -> defaultHook -> routingHook -> igp -> oracleConfig)
    • added hardhat test for modifying oracle config
  • refactoring and pulling building configs from infra to SDK to make it independent of environment specific chains and state
    • createIgpConfig
    • buildMultisigIsmConfigs, buildAggregationIsmConfigs, etc
    • buildRoutingOverAggregationIsmConfig routing over aggregation of msgId and merkleTree (current deployment)
  • test configs: infra -> sdk (for configureGasOracle.hardhat-test.ts)
  • remove igp deployments (will go through the core deployment)
  • remove update-storage-igp-oracle (same functionality by running the igp deployer or directly call deployer.configureStorageGasOracle)

Note: because of the commonJS issues with the cli package, I can't import {ethers} from hardhat which means i cannot test getGasPrice() in the CLI.

Drive-by changes

  • passing in all chains as a batch to TokenPriceGetter as sending chain by chain takes too long because of CoinGecko's 5s rest between API calls.

Related issues

Backward compatibility

Yes, refactoring and config changes

Testing

Hardhat/manual

Copy link

changeset-bot bot commented Dec 23, 2023

🦋 Changeset detected

Latest commit: 474bc96

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@hyperlane-xyz/infra Minor
@hyperlane-xyz/cli Minor
@hyperlane-xyz/sdk Minor
@hyperlane-xyz/helloworld Minor
@hyperlane-xyz/utils Minor
@hyperlane-xyz/core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@yorhodes
Copy link
Member

yorhodes commented Jan 2, 2024

will review once build is fixed

@yorhodes yorhodes marked this pull request as draft January 2, 2024 16:36
@aroralanuk aroralanuk marked this pull request as ready for review January 5, 2024 23:47
@aroralanuk aroralanuk changed the title [WIP]feat:update StorageGasOracle in igpDeployer feat:update StorageGasOracle in igpDeployer Jan 5, 2024
Copy link

codecov bot commented Jan 5, 2024

Codecov Report

Merging #3101 (c400ec9) into main (6044fb8) will decrease coverage by 67.52%.
Report is 131 commits behind head on main.
The diff coverage is n/a.

❗ Current head c400ec9 differs from pull request most recent head 474bc96. Consider uploading reports for the commit 474bc96 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #3101       +/-   ##
==========================================
- Coverage   67.51%   0.00%   -67.52%     
==========================================
  Files         101       1      -100     
  Lines        1022      16     -1006     
  Branches      106       0      -106     
==========================================
- Hits          690       0      -690     
+ Misses        292      16      -276     
+ Partials       40       0       -40     
Components Coverage Δ
core ∅ <ø> (∅)
hooks ∅ <ø> (∅)
isms ∅ <ø> (∅)
token ∅ <ø> (∅)
middlewares ∅ <ø> (∅)

solidity/CHANGELOG.md Outdated Show resolved Hide resolved
typescript/cli/package.json Outdated Show resolved Hide resolved
typescript/cli/src/config/hooks.ts Outdated Show resolved Hide resolved
typescript/cli/src/config/hooks.ts Outdated Show resolved Hide resolved
typescript/cli/src/config/hooks.ts Outdated Show resolved Hide resolved
typescript/cli/src/config/hooks.ts Outdated Show resolved Hide resolved
typescript/sdk/src/gas/HyperlaneIgpDeployer.ts Outdated Show resolved Hide resolved
Comment on lines +7 to +21
export function prettyRemoteGasDataConfig(
chain: ChainName,
config: RemoteGasData,
): string {
return `\tRemote: (${chain})\n${prettyRemoteGasData(config)}`;
}

export function prettyRemoteGasData(data: RemoteGasData): string {
return `\tToken exchange rate: ${prettyTokenExchangeRate(
data.tokenExchangeRate,
)}\n\tGas price: ${data.gasPrice.toString()} (${ethers.utils.formatUnits(
data.gasPrice,
'gwei',
)} gwei)`;
}
Copy link
Member

Choose a reason for hiding this comment

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

is gwei always the gas unit?
do we need to account for decimals here?

getTokenExchangeRate(
base: ChainName,
quote: ChainName,
cacheThemAll: ChainName[],
Copy link
Member

Choose a reason for hiding this comment

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

this is technically a breaking change
the variable name is also unclear

Copy link
Contributor

Choose a reason for hiding this comment

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

is it chainsToCache or does it mean something else?

Copy link
Member

Choose a reason for hiding this comment

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

can you make this optional? I would have no idea from the name how to call getTokenPrice after this change

Comment on lines -129 to +143
const toQuery = chains.filter((c) => !this.cache.isFresh(c));
const toQuery = cacheThemAll.filter((c) => !this.cache.isFresh(c));
Copy link
Member

Choose a reason for hiding this comment

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

I dont understand this change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

coingecko api takes it a list of tickers and the TokenPriceCache caches them. But earlier, we used to cache pairwise for origin and destination which is much slower as we're waiting 5s between every coingecko api, this expedites it by making an api call with all the tickers the first time.

Copy link
Member

Choose a reason for hiding this comment

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

this is another breaking change
why not reuse these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what is breaking, you just commented on the whole file?

- `createIgpConfig`
- `buildMultisigIsmConfigs`, `buildAggregationIsmConfigs`, etc
- `buildRoutingOverAggregationIsmConfig` routing over aggregation of msgId and merkleTree (_current deployement_)
- test configs: infra -> sdk (for configureGasOracle.hardhat-test.ts)
Copy link
Contributor

Choose a reason for hiding this comment

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

Infra and/or test related changes don't need to be noted in the changeset

Copy link
Member

Choose a reason for hiding this comment

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

++

.changeset/loud-chairs-watch.md Show resolved Hide resolved
typescript/cli/src/config/hooks.ts Outdated Show resolved Hide resolved
hookConfig: HookConfig,
): Promise<any> {
if (hookConfig.type === HookType.INTERCHAIN_GAS_PAYMASTER) {
return await processIgpConfig(multiProvider, hookConfig as IgpConfig);
Copy link
Contributor

Choose a reason for hiding this comment

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

The only reason to return await instead of just return is if you explicitly want to force errors to throw here instead of above, which isn't the case since you aren't using a try/catch in this function

typescript/cli/src/config/hooks.ts Outdated Show resolved Hide resolved
Comment on lines +11 to +12
export type TestChains = keyof typeof testConfigs;
export const testChainNames = Object.keys(testConfigs) as TestChains[];
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate of existing code in typescript/sdk/src/consts/chains.ts

Comment on lines +8 to +10
test1: '0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65',
test2: '0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc',
test3: '0x976EA74026E726554dB657fA54763abd0C3a0aa9',
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not start splitting up consts across the src/consts/ and src/config directories please. Can you find a home for these in consts?

Copy link
Member

Choose a reason for hiding this comment

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

++

typescript/sdk/src/gas/HyperlaneIgpDeployer.ts Outdated Show resolved Hide resolved
getTokenExchangeRate(
base: ChainName,
quote: ChainName,
cacheThemAll: ChainName[],
Copy link
Contributor

Choose a reason for hiding this comment

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

is it chainsToCache or does it mean something else?

Copy link
Member

Choose a reason for hiding this comment

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

why remove this? another breaking change

oracleKey: Address;
overhead: ChainMap<number>;
overhead: ChainMap<BigNumber>;
Copy link
Member

Choose a reason for hiding this comment

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

why change this? imo we want this to be as serializable as possible

Comment on lines -16 to +13
gasOracleType: ChainMap<GasOracleContractType>;
oracleConfig: StorageGasOraclesConfig;
Copy link
Member

Choose a reason for hiding this comment

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

why change this again? this is another breaking change

.changeset/loud-chairs-watch.md Show resolved Hide resolved
- `createIgpConfig`
- `buildMultisigIsmConfigs`, `buildAggregationIsmConfigs`, etc
- `buildRoutingOverAggregationIsmConfig` routing over aggregation of msgId and merkleTree (_current deployement_)
- test configs: infra -> sdk (for configureGasOracle.hardhat-test.ts)
Copy link
Member

Choose a reason for hiding this comment

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

++

Comment on lines +103 to +108
const configsToSet: Record<
Address,
StorageGasOracle.RemoteGasDataConfigStruct[]
> = {};

for (const remote of remotes) {
Copy link
Member

Choose a reason for hiding this comment

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

can this be a map instead?

for (const remote of remotes) {
const desiredGasData = gasOracleConfig[remote];
if (desiredGasData.type !== GasOracleContractType.StorageGasOracle) {
continue;
Copy link
Member

Choose a reason for hiding this comment

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

should we throw in this case?

.gasOracle;
const gasOracle = StorageGasOracle__factory.connect(
gasOracleAddress,
this.multiProvider.getSigner(chain),
Copy link
Member

Choose a reason for hiding this comment

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

this can be signer instead of provider

getTokenExchangeRate(
base: ChainName,
quote: ChainName,
cacheThemAll: ChainName[],
Copy link
Member

Choose a reason for hiding this comment

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

can you make this optional? I would have no idea from the name how to call getTokenPrice after this change

const [price] = await this.getTokenPrices([chain]);
async getTokenPrice(
chain: ChainName,
cacheThemAll: ChainName[],
Copy link
Member

Choose a reason for hiding this comment

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

ditto, can this be optional?

@aroralanuk aroralanuk closed this Feb 2, 2024
aroralanuk added a commit that referenced this pull request Feb 8, 2024
### Description

HyperlaneIGPDeployer supports configuring storageGasOracle if provided.
HyperlaneIgpDeployer takes in `IgpConfig & Partial<OracleConfig>`

Note: storageGasOracle cannot be configured in CLI yet.
Note: this is a more minimal version of
#3101 where more
breaking changes were made.


### Drive-by changes

None

### Related issues

- fixes hyperlane-xyz/issues#820

### Backward compatibility

Yes

### Testing

Unit
ltyu pushed a commit to ltyu/hyperlane-monorepo that referenced this pull request Mar 13, 2024
### Description

HyperlaneIGPDeployer supports configuring storageGasOracle if provided.
HyperlaneIgpDeployer takes in `IgpConfig & Partial<OracleConfig>`

Note: storageGasOracle cannot be configured in CLI yet.
Note: this is a more minimal version of
hyperlane-xyz#3101 where more
breaking changes were made.


### Drive-by changes

None

### Related issues

- fixes hyperlane-xyz/issues#820

### Backward compatibility

Yes

### Testing

Unit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Functional config generation in Infra
3 participants