worm: speed up `evm info` by improving concurrency
This commit is contained in:
parent
a7976136b7
commit
e6d3bb8731
|
@ -37,20 +37,43 @@ export async function query_contract_evm(
|
||||||
const core = Implementation__factory.connect(contract_address, provider)
|
const core = Implementation__factory.connect(contract_address, provider)
|
||||||
result.address = contract_address
|
result.address = contract_address
|
||||||
result.currentGuardianSetIndex = await core.getCurrentGuardianSetIndex()
|
result.currentGuardianSetIndex = await core.getCurrentGuardianSetIndex()
|
||||||
result.guardianSet = {}
|
let guardianSetsPromise = Promise.all([...Array(result.currentGuardianSetIndex + 1).keys()].map((i) => core.getGuardianSet(i)))
|
||||||
for (let i of Array(result.currentGuardianSetIndex + 1).keys()) {
|
let [
|
||||||
let guardian_set = await core.getGuardianSet(i)
|
guardianSetExpiry,
|
||||||
result.guardianSet[i] = { keys: guardian_set[0], expiry: guardian_set[1] }
|
chainId,
|
||||||
}
|
evmChainId,
|
||||||
result.guardianSetExpiry = await core.getGuardianSetExpiry()
|
isFork,
|
||||||
result.chainId = await core.chainId()
|
governanceChainId,
|
||||||
result.evmChainId = (await maybeUnsupported(core.evmChainId())).toString()
|
governanceContract,
|
||||||
result.isFork = await maybeUnsupported(core.isFork())
|
messageFee,
|
||||||
result.governanceChainId = await core.governanceChainId()
|
implementationSlot,
|
||||||
result.governanceContract = await core.governanceContract()
|
guardianSets
|
||||||
result.messageFee = await core.messageFee()
|
] = await Promise.all([
|
||||||
result.implementation = (await getStorageAt(rpc, contract_address, _IMPLEMENTATION_SLOT, ["address"]))[0]
|
core.getGuardianSetExpiry(),
|
||||||
|
core.chainId(),
|
||||||
|
maybeUnsupported(core.evmChainId()),
|
||||||
|
maybeUnsupported(core.isFork()),
|
||||||
|
core.governanceChainId(),
|
||||||
|
core.governanceContract(),
|
||||||
|
core.messageFee(),
|
||||||
|
getStorageAt(rpc, contract_address, _IMPLEMENTATION_SLOT, ["address"]),
|
||||||
|
guardianSetsPromise
|
||||||
|
])
|
||||||
|
result.guardianSetExpiry = guardianSetExpiry
|
||||||
|
result.chainId = chainId
|
||||||
|
result.evmChainId = evmChainId.toString()
|
||||||
|
result.isFork = isFork
|
||||||
|
result.governanceChainId = governanceChainId
|
||||||
|
result.governanceContract = governanceContract
|
||||||
|
result.messageFee = messageFee
|
||||||
|
result.implementation = implementationSlot[0]
|
||||||
result.isInitialized = await core.isInitialized(result.implementation)
|
result.isInitialized = await core.isInitialized(result.implementation)
|
||||||
|
result.guardianSet = {}
|
||||||
|
|
||||||
|
for (let [i, guardianSet] of guardianSets.entries()) {
|
||||||
|
result.guardianSet[i] = { keys: guardianSet[0], expiry: guardianSet[1] }
|
||||||
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
case "TokenBridge":
|
case "TokenBridge":
|
||||||
contract_address = contract_address ? contract_address : contracts.token_bridge;
|
contract_address = contract_address ? contract_address : contracts.token_bridge;
|
||||||
|
@ -59,23 +82,51 @@ export async function query_contract_evm(
|
||||||
}
|
}
|
||||||
const tb = BridgeImplementation__factory.connect(contract_address, provider)
|
const tb = BridgeImplementation__factory.connect(contract_address, provider)
|
||||||
result.address = contract_address
|
result.address = contract_address
|
||||||
result.wormhole = await tb.wormhole()
|
const registrationsPromise = Promise.all(
|
||||||
result.implementation = (await getStorageAt(rpc, contract_address, _IMPLEMENTATION_SLOT, ["address"]))[0]
|
Object.entries(CHAINS)
|
||||||
|
.filter(([c_name, _]) => c_name !== chain && c_name !== "unset")
|
||||||
|
.map(async ([c_name, c_id]) => [c_name, await tb.bridgeContracts(c_id)])
|
||||||
|
)
|
||||||
|
let [
|
||||||
|
wormhole,
|
||||||
|
implementationSlotTb,
|
||||||
|
tokenImplementation,
|
||||||
|
chainIdTb,
|
||||||
|
finality,
|
||||||
|
evmChainIdTb,
|
||||||
|
isForkTb,
|
||||||
|
governanceChainIdTb,
|
||||||
|
governanceContractTb,
|
||||||
|
WETH,
|
||||||
|
registrations
|
||||||
|
] = await Promise.all([
|
||||||
|
tb.wormhole(),
|
||||||
|
getStorageAt(rpc, contract_address, _IMPLEMENTATION_SLOT, ["address"]),
|
||||||
|
tb.tokenImplementation(),
|
||||||
|
tb.chainId(),
|
||||||
|
tb.finality(),
|
||||||
|
maybeUnsupported(tb.evmChainId()),
|
||||||
|
maybeUnsupported(tb.isFork()),
|
||||||
|
tb.governanceChainId(),
|
||||||
|
tb.governanceContract(),
|
||||||
|
tb.WETH(),
|
||||||
|
registrationsPromise
|
||||||
|
])
|
||||||
|
result.wormhole = wormhole
|
||||||
|
result.implementation = implementationSlotTb[0]
|
||||||
result.isInitialized = await tb.isInitialized(result.implementation)
|
result.isInitialized = await tb.isInitialized(result.implementation)
|
||||||
result.tokenImplementation = await tb.tokenImplementation()
|
result.tokenImplementation = tokenImplementation
|
||||||
result.chainId = await tb.chainId()
|
result.chainId = chainIdTb
|
||||||
result.finality = await tb.finality()
|
result.finality = finality
|
||||||
result.evmChainId = (await maybeUnsupported(tb.evmChainId())).toString()
|
result.evmChainId = evmChainIdTb.toString()
|
||||||
result.isFork = await maybeUnsupported(tb.isFork())
|
result.isFork = isForkTb
|
||||||
result.governanceChainId = await tb.governanceChainId()
|
result.governanceChainId = governanceChainIdTb
|
||||||
result.governanceContract = await tb.governanceContract()
|
result.governanceContract = governanceContractTb
|
||||||
result.WETH = await tb.WETH()
|
result.WETH = WETH
|
||||||
result.registrations = {}
|
result.registrations = {}
|
||||||
for (let [c_name, c_id] of Object.entries(CHAINS)) {
|
|
||||||
if (c_name === chain || c_name === "unset") {
|
for (let [c_name, c] of registrations) {
|
||||||
continue
|
result.registrations[c_name] = c
|
||||||
}
|
|
||||||
result.registrations[c_name] = await tb.bridgeContracts(c_id)
|
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case "NFTBridge":
|
case "NFTBridge":
|
||||||
|
@ -85,22 +136,48 @@ export async function query_contract_evm(
|
||||||
}
|
}
|
||||||
const nb = NFTBridgeImplementation__factory.connect(contract_address, provider)
|
const nb = NFTBridgeImplementation__factory.connect(contract_address, provider)
|
||||||
result.address = contract_address
|
result.address = contract_address
|
||||||
result.wormhole = await nb.wormhole()
|
const registrationsPromiseNb = Promise.all(
|
||||||
result.implementation = (await getStorageAt(rpc, contract_address, _IMPLEMENTATION_SLOT, ["address"]))[0]
|
Object.entries(CHAINS)
|
||||||
|
.filter(([c_name, _]) => c_name !== chain && c_name !== "unset")
|
||||||
|
.map(async ([c_name, c_id]) => [c_name, await nb.bridgeContracts(c_id)])
|
||||||
|
)
|
||||||
|
let [
|
||||||
|
wormholeNb,
|
||||||
|
implementationSlotNb,
|
||||||
|
tokenImplementationNb,
|
||||||
|
chainIdNb,
|
||||||
|
finalityNb,
|
||||||
|
evmChainIdNb,
|
||||||
|
isForkNb,
|
||||||
|
governanceChainIdNb,
|
||||||
|
governanceContractNb,
|
||||||
|
registrationsNb
|
||||||
|
] = await Promise.all([
|
||||||
|
nb.wormhole(),
|
||||||
|
getStorageAt(rpc, contract_address, _IMPLEMENTATION_SLOT, ["address"]),
|
||||||
|
nb.tokenImplementation(),
|
||||||
|
nb.chainId(),
|
||||||
|
nb.finality(),
|
||||||
|
maybeUnsupported(nb.evmChainId()),
|
||||||
|
maybeUnsupported(nb.isFork()),
|
||||||
|
nb.governanceChainId(),
|
||||||
|
nb.governanceContract(),
|
||||||
|
registrationsPromiseNb
|
||||||
|
])
|
||||||
|
result.wormhole = wormholeNb
|
||||||
|
result.implementation = implementationSlotNb[0]
|
||||||
result.isInitialized = await nb.isInitialized(result.implementation)
|
result.isInitialized = await nb.isInitialized(result.implementation)
|
||||||
result.tokenImplementation = await nb.tokenImplementation()
|
result.tokenImplementation = tokenImplementationNb
|
||||||
result.chainId = await nb.chainId()
|
result.chainId = chainIdNb
|
||||||
result.finality = await nb.finality()
|
result.finality = finalityNb
|
||||||
result.evmChainId = (await maybeUnsupported(nb.evmChainId())).toString()
|
result.evmChainId = evmChainIdNb.toString()
|
||||||
result.isFork = await maybeUnsupported(nb.isFork())
|
result.isFork = isForkNb
|
||||||
result.governanceChainId = await nb.governanceChainId()
|
result.governanceChainId = governanceChainIdNb
|
||||||
result.governanceContract = await nb.governanceContract()
|
result.governanceContract = governanceContractNb
|
||||||
result.registrations = {}
|
result.registrations = {}
|
||||||
for (let [c_name, c_id] of Object.entries(CHAINS)) {
|
|
||||||
if (c_name === chain || c_name === "unset") {
|
for (let [c_name, c] of registrationsNb) {
|
||||||
continue
|
result.registrations[c_name] = c
|
||||||
}
|
|
||||||
result.registrations[c_name] = await nb.bridgeContracts(c_id)
|
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue