From f739be50dd58b3a6e8d2f0dc010d40c531e2dcb1 Mon Sep 17 00:00:00 2001 From: daveroga Date: Mon, 2 Jun 2025 11:04:24 +0200 Subject: [PATCH 1/2] add maintenance script to check block timestamp --- hardhat.config.ts | 18 ++++++++++ helpers/helperUtils.ts | 14 ++++++++ .../multi-chain/checkBlockTimestamp.ts | 35 +++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 scripts/maintenance/multi-chain/checkBlockTimestamp.ts diff --git a/hardhat.config.ts b/hardhat.config.ts index 578f7823e..ae934e16e 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -29,6 +29,24 @@ task("accounts", "Prints the list of accounts", async (taskArgs, hre) => { } }); +task("blockTimestamp", "Prints the block timestamp", async (taskArgs, hre) => { + const currentBlock = await hre.ethers.provider.getBlockNumber(); + if (!currentBlock) { + console.error("Failed to get the current block number."); + return; + } + let block = await hre.ethers.provider.getBlock(currentBlock); + while (!block) { + await new Promise((resolve) => setTimeout(resolve, 200)); + block = await hre.ethers.provider.getBlock(currentBlock); + } + + const blockTimestamp = block.timestamp; + console.log(blockTimestamp); + const date = new Date(blockTimestamp * 1000); // Date requires ms, whereas block.timestamp is in s + console.log(date); +}); + // You need to export an object to set up your config // Go to https://hardhat.org/config/ to learn more diff --git a/helpers/helperUtils.ts b/helpers/helperUtils.ts index a53396a05..9e5dd7d30 100644 --- a/helpers/helperUtils.ts +++ b/helpers/helperUtils.ts @@ -218,6 +218,20 @@ export async function getStateContractAddress(chainId?: number): Promise return stateContractAddress; } +export async function getBlockTimestamp(provider: JsonRpcProvider): Promise { + const currentBlock = await provider.getBlockNumber(); + if (!currentBlock) { + throw new Error("Failed to get the current block number."); + } + let block = await provider.getBlock(currentBlock); + while (!block) { + await new Promise((resolve) => setTimeout(resolve, 200)); + block = await provider.getBlock(currentBlock); + } + const date = new Date(block.timestamp * 1000); // Date requires ms, whereas block.timestamp is in s + return date; +} + export class Logger { static error(message: string) { console.log(`\x1b[31m[𐄂] \x1b[0m${message}`); diff --git a/scripts/maintenance/multi-chain/checkBlockTimestamp.ts b/scripts/maintenance/multi-chain/checkBlockTimestamp.ts new file mode 100644 index 000000000..80c4ef329 --- /dev/null +++ b/scripts/maintenance/multi-chain/checkBlockTimestamp.ts @@ -0,0 +1,35 @@ +import { + getBlockTimestamp, + getChainId, + getProviders, + getStateContractAddress, + isContract, + Logger, +} from "../../../helpers/helperUtils"; +import { contractsInfo, DEFAULT_MNEMONIC, networks } from "../../../helpers/constants"; +import { ethers } from "hardhat"; + +const mnemonicWallet = ethers.Wallet.fromPhrase(DEFAULT_MNEMONIC); + +async function main() { + const providers = getProviders(); + + for (const provider of providers) { + const jsonRpcProvider = new ethers.JsonRpcProvider(provider.rpcUrl); + + try { + const blockTimestamp = await getBlockTimestamp(jsonRpcProvider); + Logger.success(`${provider.network}: blockTimeStamp ${blockTimestamp.toISOString()}`); + } catch (error) { + Logger.error(`${provider.network}: Failed to get block timestamp - ${error.message}`); + continue; + } + } +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); From 1351c865cf3c76c04de82817c812a7724e3d6e36 Mon Sep 17 00:00:00 2001 From: daveroga Date: Tue, 9 Sep 2025 16:40:24 +0200 Subject: [PATCH 2/2] update references from modules properly --- helpers/DeployHelper.ts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/helpers/DeployHelper.ts b/helpers/DeployHelper.ts index 8931eb818..84486be05 100644 --- a/helpers/DeployHelper.ts +++ b/helpers/DeployHelper.ts @@ -5,16 +5,16 @@ import { deployPoseidons } from "./PoseidonDeployHelper"; import { GenesisUtilsWrapper, PrimitiveTypeUtilsWrapper } from "../typechain-types"; import { SmtLibModule, - VCPaymentModule, + VCPaymentProxyModule, StateProxyModule, IdentityTreeStoreProxyModule, UniversalVerifierProxyModule, - LinkedMultiQueryValidatorModule, - EthIdentityValidatorModule, - AuthV2ValidatorModule, - CredentialAtomicQueryV3ValidatorModule, - CredentialAtomicQueryMTPV2ValidatorModule, - CredentialAtomicQuerySigV2ValidatorModule, + LinkedMultiQueryValidatorProxyModule, + EthIdentityValidatorProxyModule, + AuthV2ValidatorProxyModule, + CredentialAtomicQueryV3ValidatorProxyModule, + CredentialAtomicQueryMTPV2ValidatorProxyModule, + CredentialAtomicQuerySigV2ValidatorProxyModule, } from "../ignition"; import { chainIdInfoMap, contractsInfo } from "./constants"; import { @@ -694,22 +694,22 @@ export class DeployHelper { if (deployStrategy === "create2") { switch (validatorType) { case "mtpV2": - validatorModule = CredentialAtomicQueryMTPV2ValidatorModule; + validatorModule = CredentialAtomicQueryMTPV2ValidatorProxyModule; break; case "sigV2": - validatorModule = CredentialAtomicQuerySigV2ValidatorModule; + validatorModule = CredentialAtomicQuerySigV2ValidatorProxyModule; break; case "v3": - validatorModule = CredentialAtomicQueryV3ValidatorModule; + validatorModule = CredentialAtomicQueryV3ValidatorProxyModule; break; case "authV2": - validatorModule = AuthV2ValidatorModule; + validatorModule = AuthV2ValidatorProxyModule; break; case "lmq": - validatorModule = LinkedMultiQueryValidatorModule; + validatorModule = LinkedMultiQueryValidatorProxyModule; break; case "ethIdentity": - validatorModule = EthIdentityValidatorModule; + validatorModule = EthIdentityValidatorProxyModule; break; } @@ -1157,7 +1157,7 @@ export class DeployHelper { // Deploying VCPayment contract to predictable address but with dummy implementation vcPayment = ( - await ignition.deploy(VCPaymentModule, { + await ignition.deploy(VCPaymentProxyModule, { strategy: deployStrategy, }) ).vcPayment;