Skip to content

chore: store block numbers#1101

Merged
ctrlc03 merged 1 commit into
mainfrom
chore/store-block-numbers-crisp
Dec 11, 2025
Merged

chore: store block numbers#1101
ctrlc03 merged 1 commit into
mainfrom
chore/store-block-numbers-crisp

Conversation

@ctrlc03

@ctrlc03 ctrlc03 commented Dec 10, 2025

Copy link
Copy Markdown
Collaborator

Store block numbers for crisp contracts

Summary by CodeRabbit

  • Chores
    • Deployment metadata now records the current block number during contract deployments, improving traceability of deployed artifacts and on-chain context.

✏️ Tip: You can customize this high-level summary in your review settings.

@ctrlc03 ctrlc03 requested a review from hmzakhalid December 10, 2025 21:37
@vercel

vercel Bot commented Dec 10, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
crisp Skipped Skipped Dec 11, 2025 5:12pm
enclave-docs Skipped Skipped Dec 11, 2025 5:12pm

@coderabbitai

coderabbitai Bot commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

A straightforward enhancement that captures and stores the current blockchain block number during contract deployments for HonkVerifier, CRISPProgram, RiscZeroGroth16Verifier, and MockRISC0Verifier in the deployment metadata.

Changes

Cohort / File(s) Change Summary
Deployment metadata enrichment
examples/CRISP/packages/crisp-contracts/deploy/crisp.ts
Added blockNumber: await ethers.provider.getBlockNumber() to deployment argument stores across multiple contract deployments in deployCRISPContracts and deployVerifier functions.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single file with homogeneous, repetitive changes applied consistently
  • No control flow modifications or new logic introduced
  • Simple metadata field addition to existing deployment calls

Poem

🐰 I hopped through code at break of dawn,
I fetched the block where contracts yawn,
HonkVerifier, CRISP, each told the time,
A tiny stamp, precise and prime,
Deployments sing — the chain's small rhyme.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: store block numbers' directly and clearly describes the main change: adding block number storage to deployment metadata in the CRISP contracts deployment script.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/store-block-numbers-crisp

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd85da1 and 59dbbbb.

📒 Files selected for processing (1)
  • examples/CRISP/packages/crisp-contracts/deploy/crisp.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/CRISP/packages/crisp-contracts/deploy/crisp.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: test_net
  • GitHub Check: build_enclave_cli
  • GitHub Check: rust_unit
  • GitHub Check: crisp_unit
  • GitHub Check: build_sdk
  • GitHub Check: build_e3_support_dev
  • GitHub Check: rust_integration
  • GitHub Check: test_contracts
  • GitHub Check: integration_prebuild

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
examples/CRISP/packages/crisp-contracts/deploy/crisp.ts (1)

58-65: Consider using deployment receipts (and/or helpers) for more precise block numbers

The new blockNumber: await ethers.provider.getBlockNumber() fields are functionally fine and will store the latest mined block at the time each storeDeploymentArgs call runs. However, two small improvements are worth considering:

  1. Precision of “deployment block”
    getBlockNumber() returns the current head of the chain on the connected provider, not necessarily the block that mined the specific deployment transaction.(eeth.dev)
    If the goal is to record the actual deployment block for each contract (HonkVerifier, CRISPProgram, RiscZeroGroth16Verifier, MockRISC0Verifier), consider instead:

    • Grabbing the deployment transaction via contract.deploymentTransaction() and waiting on its receipt, then
    • Storing receipt.blockNumber as the deployment block in your metadata.

    This avoids any drift if additional blocks are mined between deployment and the metadata write.

  2. Minor RPC efficiency / consistency
    Each storeDeploymentArgs call independently awaits ethers.provider.getBlockNumber(). That’s cheap, but if you end up doing more of this, it may be cleaner to:

    • Capture the relevant block number right after each deployment (or from the receipt as above), and
    • Pass the captured value into storeDeploymentArgs, rather than calling the provider again inside the object literal.

These are refinements rather than correctness issues, so fine to defer, but they’ll make the recorded blockNumber more robust and self-explanatory in the long run.

Also applies to: 78-91, 127-134, 147-154

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 71a1e0b and 5381ce1.

📒 Files selected for processing (2)
  • README.md (1 hunks)
  • examples/CRISP/packages/crisp-contracts/deploy/crisp.ts (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-11T13:09:03.800Z
Learnt from: ctrlc03
Repo: gnosisguild/enclave PR: 677
File: packages/enclave-contracts/scripts/deployAndSave/naiveRegistryFilter.ts:30-31
Timestamp: 2025-09-11T13:09:03.800Z
Learning: In Hardhat v3 deployment scripts, use `(await signer.provider?.getNetwork())?.name ?? "localhost"` instead of `hre.globalOptions.network` to reliably get the network name, as `hre.globalOptions.network` can be undefined in some contexts.

Applied to files:

  • examples/CRISP/packages/crisp-contracts/deploy/crisp.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: build_e3_support_risc0
  • GitHub Check: crisp_unit
  • GitHub Check: integration_prebuild
  • GitHub Check: build_sdk
  • GitHub Check: build_enclave_cli
  • GitHub Check: rust_integration
  • GitHub Check: test_contracts
  • GitHub Check: rust_unit
  • GitHub Check: test_net
🔇 Additional comments (1)
README.md (1)

388-389: Non-semantic line reflow looks good

This is purely formatting (line wrap) around the main branch + feature flags sentence; content and meaning are unchanged. ✅

@ctrlc03 ctrlc03 force-pushed the chore/store-block-numbers-crisp branch from 5381ce1 to cd85da1 Compare December 11, 2025 08:32
@vercel vercel Bot temporarily deployed to Preview – enclave-docs December 11, 2025 08:32 Inactive
@vercel vercel Bot temporarily deployed to Preview – crisp December 11, 2025 08:32 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
examples/CRISP/packages/crisp-contracts/deploy/crisp.ts (2)

55-65: Retrieve block number from deployment transaction receipt for accuracy.

The current implementation retrieves the block number from the current chain state after deployment, which may result in a block number that's later than the actual deployment block—especially on fast networks or during high traffic. Additionally, there's no waitForDeployment() call to ensure the transaction is mined.

Apply this diff to retrieve the accurate deployment block number:

 const honkVerifierFactory = await ethers.getContractFactory('HonkVerifier', {
   libraries: {
     'project/contracts/CRISPVerifier.sol:ZKTranscriptLib': zkTranscriptLibAddress,
   },
 })
 const honkVerifier = await honkVerifierFactory.deploy()
+await honkVerifier.waitForDeployment()
 const honkVerifierAddress = await honkVerifier.getAddress()
+const deploymentTx = honkVerifier.deploymentTransaction()
+const receipt = await deploymentTx?.wait()

 storeDeploymentArgs(
   {
     address: honkVerifierAddress,
-    blockNumber: await ethers.provider.getBlockNumber(),
+    blockNumber: receipt?.blockNumber,
   },
   'HonkVerifier',
   chain,
 )

75-91: Retrieve block number from deployment transaction receipt for accuracy.

Similar to the HonkVerifier deployment, the block number is retrieved from the current chain state without waiting for deployment confirmation. This could result in storing an inaccurate block number.

Apply this diff to retrieve the accurate deployment block number:

 const crisp = await crispFactory.deploy(enclaveAddress, verifier, honkVerifierAddress, IMAGE_ID)
-
+await crisp.waitForDeployment()
 const crispAddress = await crisp.getAddress()
+const deploymentTx = crisp.deploymentTransaction()
+const receipt = await deploymentTx?.wait()
+
 storeDeploymentArgs(
   {
     address: crispAddress,
-    blockNumber: await ethers.provider.getBlockNumber(),
+    blockNumber: receipt?.blockNumber,
     constructorArgs: {
       enclave: enclaveAddress,
       verifierAddress: verifier,
       honkVerifierAddress,
       imageId: IMAGE_ID,
     },
   },
   'CRISPProgram',
   chain,
 )
🧹 Nitpick comments (2)
examples/CRISP/packages/crisp-contracts/deploy/crisp.ts (2)

122-135: Consider retrieving block number from deployment transaction receipt.

While this implementation correctly waits for deployment, it still retrieves the block number from the current chain state rather than from the deployment transaction receipt. For maximum accuracy, consider using the transaction receipt.

Apply this diff to retrieve the block number from the transaction receipt:

 const verifierFactory = await ethers.getContractFactory('RiscZeroGroth16Verifier')
 const verifier = await verifierFactory.deploy()
 await verifier.waitForDeployment()
 const address = await verifier.getAddress()
+const deploymentTx = verifier.deploymentTransaction()
+const receipt = await deploymentTx?.wait()

 storeDeploymentArgs(
   {
     address,
-    blockNumber: await ethers.provider.getBlockNumber(),
+    blockNumber: receipt?.blockNumber,
   },
   'RiscZeroGroth16Verifier',
   chain,
 )

143-154: Consider retrieving block number from deployment transaction receipt.

Similar to the RiscZeroGroth16Verifier deployment, this correctly waits for deployment but retrieves the block number from current chain state. Using the transaction receipt would provide more accurate block numbers.

Apply this diff to retrieve the block number from the transaction receipt:

 const mockVerifierFactory = await ethers.getContractFactory('MockRISC0Verifier')
 const mockVerifier = await mockVerifierFactory.deploy()
 await mockVerifier.waitForDeployment()
 const mockVerifierAddress = await mockVerifier.getAddress()
+const deploymentTx = mockVerifier.deploymentTransaction()
+const receipt = await deploymentTx?.wait()
+
 storeDeploymentArgs(
   {
     address: mockVerifierAddress,
-    blockNumber: await ethers.provider.getBlockNumber(),
+    blockNumber: receipt?.blockNumber,
   },
   'MockRISC0Verifier',
   hre.globalOptions.network,
 )
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5381ce1 and cd85da1.

📒 Files selected for processing (1)
  • examples/CRISP/packages/crisp-contracts/deploy/crisp.ts (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-11T13:09:03.800Z
Learnt from: ctrlc03
Repo: gnosisguild/enclave PR: 677
File: packages/enclave-contracts/scripts/deployAndSave/naiveRegistryFilter.ts:30-31
Timestamp: 2025-09-11T13:09:03.800Z
Learning: In Hardhat v3 deployment scripts, use `(await signer.provider?.getNetwork())?.name ?? "localhost"` instead of `hre.globalOptions.network` to reliably get the network name, as `hre.globalOptions.network` can be undefined in some contexts.

Applied to files:

  • examples/CRISP/packages/crisp-contracts/deploy/crisp.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: crisp_unit
  • GitHub Check: build_sdk
  • GitHub Check: test_net
  • GitHub Check: build_enclave_cli
  • GitHub Check: test_contracts
  • GitHub Check: rust_unit
  • GitHub Check: integration_prebuild
  • GitHub Check: rust_integration

@ctrlc03 ctrlc03 requested a review from 0xjei December 11, 2025 10:52

@0xjei 0xjei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

utACK

@ctrlc03 ctrlc03 force-pushed the chore/store-block-numbers-crisp branch from cd85da1 to 59dbbbb Compare December 11, 2025 17:11
@ctrlc03 ctrlc03 enabled auto-merge (squash) December 11, 2025 17:11
@vercel vercel Bot temporarily deployed to Preview – enclave-docs December 11, 2025 17:12 Inactive
@vercel vercel Bot temporarily deployed to Preview – crisp December 11, 2025 17:12 Inactive
@ctrlc03 ctrlc03 merged commit 0e9e92e into main Dec 11, 2025
25 checks passed
@ctrlc03 ctrlc03 deleted the chore/store-block-numbers-crisp branch December 11, 2025 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants