-
Notifications
You must be signed in to change notification settings - Fork 412
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: modify gas oracle TS tooling to be friendly for all protocol types #5198
Open
tkporter
wants to merge
26
commits into
main
Choose a base branch
from
trevor/igp-consolidation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+563
−253
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
820e1af
it aint pretty and it dont work, but it sorta works
tkporter 12b2caf
printing gas oracles mostly works, gonna do a little cleanup
tkporter ee4c7c9
a little cweanup
tkporter e080a97
some cleanup, getting there
tkporter b80f703
Merge branch 'main' of github.com:abacus-network/abacus-monorepo into…
tkporter 9dd4108
it's hideous but seemingly works
tkporter 06d0a02
Merge branch 'main' of github.com:abacus-network/abacus-monorepo into…
tkporter c833035
evm quotes are the same
tkporter 29f8041
IGP configure script, woo
tkporter 458d83a
nits
tkporter cf5df0d
Merge branch 'main' of github.com:abacus-network/abacus-monorepo into…
tkporter d966e64
some measures in e2e
tkporter 876cec1
some kleenup
tkporter 1ba7130
cleaning up
tkporter e854ee6
add hardcoded connections
tkporter 782db53
testnet svm setting
tkporter ad01cab
starting to set mainnets
tkporter 60e8667
Merge branch 'main' of github.com:abacus-network/abacus-monorepo into…
tkporter ca20724
gas oracle config
tkporter d4227ab
rust nit
tkporter 0a97475
e2e passes
tkporter f348e2a
rm old configs
tkporter 5ad7621
rm the rust changes for now
tkporter eb53191
rm gas oracle config for now
tkporter f66ca53
nits
tkporter c94f5a1
Merge branch 'main' into trevor/igp-consolidation
paulbalaji File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,6 +177,13 @@ export function withChainsRequired<T>( | |
return withChains(args, chainOptions).demandOption('chains'); | ||
} | ||
|
||
export function withOutFile<T>(args: Argv<T>) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: rename to |
||
return args | ||
.describe('outFile', 'output file') | ||
.string('outFile') | ||
.alias('o', 'outFile'); | ||
} | ||
|
||
export function withWarpRouteId<T>(args: Argv<T>) { | ||
return args.describe('warpRouteId', 'warp route id').string('warpRouteId'); | ||
} | ||
|
117 changes: 117 additions & 0 deletions
117
typescript/infra/scripts/sealevel-helpers/print-gas-oracles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import { | ||
ChainMap, | ||
ChainName, | ||
ProtocolAgnositicGasOracleConfig, | ||
} from '@hyperlane-xyz/sdk'; | ||
import { | ||
ProtocolType, | ||
objFilter, | ||
objMap, | ||
stringifyObject, | ||
} from '@hyperlane-xyz/utils'; | ||
|
||
import { WarpRouteIds } from '../../config/environments/mainnet3/warp/warpIds.js'; | ||
import { getChain, getWarpAddresses } from '../../config/registry.js'; | ||
import { writeJsonAtPath } from '../../src/utils/utils.js'; | ||
import { getArgs, withOutFile } from '../agent-utils.js'; | ||
import { getEnvironmentConfig } from '../core-utils.js'; | ||
|
||
// This script exists to print the gas oracle configs for a given environment | ||
// so they can easily be copied into the Sealevel tooling. :'( | ||
|
||
interface GasOracleConfigWithOverhead { | ||
oracleConfig: ProtocolAgnositicGasOracleConfig; | ||
overhead?: number; | ||
} | ||
|
||
async function main() { | ||
const { environment, outFile } = await withOutFile(getArgs()).argv; | ||
|
||
const environmentConfig = getEnvironmentConfig(environment); | ||
|
||
const allConnectedChains = getChainConnections(); | ||
|
||
// Construct a nested map of origin -> destination -> { oracleConfig, overhead } | ||
let gasOracles = objMap(environmentConfig.igp, (origin, igpConfig) => { | ||
// Only SVM origins for now | ||
if (getChain(origin).protocol !== ProtocolType.Sealevel) { | ||
return undefined; | ||
} | ||
|
||
// If there's no oracle config, don't do anything for this origin | ||
if (!igpConfig.oracleConfig) { | ||
return undefined; | ||
} | ||
// Get the set of chains that are connected to this origin via warp routes | ||
const connectedChainsSet = allConnectedChains[origin]; | ||
if (!connectedChainsSet) { | ||
return undefined; | ||
} | ||
const connectedChains = [...connectedChainsSet]; | ||
|
||
return connectedChains.reduce((agg, destination) => { | ||
const oracleConfig = igpConfig.oracleConfig[destination]; | ||
if (oracleConfig.tokenDecimals === undefined) { | ||
throw new Error( | ||
`Token decimals not defined for ${origin} -> ${destination}`, | ||
); | ||
} | ||
agg[destination] = { | ||
oracleConfig, | ||
overhead: igpConfig?.overhead?.[destination], | ||
}; | ||
return agg; | ||
}, {} as ChainMap<GasOracleConfigWithOverhead>); | ||
}); | ||
|
||
// Filter out undefined values | ||
gasOracles = objFilter( | ||
gasOracles, | ||
(_, value): value is ChainMap<GasOracleConfigWithOverhead> | undefined => | ||
value !== undefined, | ||
); | ||
|
||
console.log(stringifyObject(gasOracles, 'json', 2)); | ||
|
||
if (outFile) { | ||
console.log(`Writing config to ${outFile}`); | ||
writeJsonAtPath(outFile, gasOracles); | ||
} | ||
} | ||
|
||
// Because there is a limit to how many chains we want to figure in an SVM IGP, | ||
// we limit the chains to only those that are connected via warp routes. | ||
// Returns a record of origin chain -> set of chains that are connected via warp routes. | ||
function getChainConnections(): ChainMap<Set<ChainName>> { | ||
// A list of connected chains | ||
const connectedChains = [ | ||
// Hardcoded connections | ||
['sonicsvmtestnet', 'solanatestnet'], | ||
// All known warp routes | ||
...Object.values(WarpRouteIds).map((warpRouteId) => { | ||
const warpRouteAddresses = getWarpAddresses(warpRouteId); | ||
return Object.keys(warpRouteAddresses); | ||
}), | ||
]; | ||
|
||
return connectedChains.reduce((agg, chains) => { | ||
// Make sure each chain is connected to every other chain | ||
chains.forEach((chainA) => { | ||
chains.forEach((chainB) => { | ||
if (chainA === chainB) { | ||
return; | ||
} | ||
if (agg[chainA] === undefined) { | ||
agg[chainA] = new Set(); | ||
} | ||
agg[chainA].add(chainB as ChainName); | ||
}); | ||
}); | ||
return agg; | ||
}, {} as ChainMap<Set<ChainName>>); | ||
Comment on lines
+86
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't this also connect the warp route mainnets to the sonicsvm/solana testnet? don't think we want that to happen |
||
} | ||
|
||
main().catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,8 +39,6 @@ async function main() { | |
} | ||
} | ||
|
||
console.warn; | ||
|
||
console.log(JSON.stringify(config, null, 2)); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
were these updates applied on chain?