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

increment height in peptide proof #277

Merged
merged 1 commit into from
Dec 6, 2024
Merged

Conversation

RnkSngh
Copy link
Collaborator

@RnkSngh RnkSngh commented Dec 6, 2024

Summary by CodeRabbit

  • New Features

    • Updated the CrossL2Prover contract to improve receipt validation logic.
    • Updated bytecode for both CrossL2Prover and OptimisticProofVerifier contracts, ensuring compatibility with the latest implementation.
  • Chores

    • Incremented version number in package.json from 4.0.13 to 4.0.14.

Copy link

coderabbitai bot commented Dec 6, 2024

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/evm/contracts/factories/CrossL2Prover__factory.ts

(node:12600) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///eslint.config.js?mtime=1733505469743 is not specified and it doesn't parse as CommonJS.
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
To eliminate this warning, add "type": "module" to /package.json.
(Use node --trace-warnings ... to show where the warning was created)

Oops! Something went wrong! :(

ESLint: 8.57.1

TypeError: Key "rules": Key "@typescript-eslint/quotes": Could not find "quotes" in plugin "@typescript-eslint". Did you mean "@/quotes"?
at throwRuleNotFoundError (/node_modules/eslint/lib/config/rule-validator.js:66:11)
at RuleValidator.validate (/node_modules/eslint/lib/config/rule-validator.js:128:17)
at [finalizeConfig] (/node_modules/eslint/lib/config/flat-config-array.js:337:23)
at FlatConfigArray.getConfig (/node_modules/@humanwhocodes/config-array/api.js:1036:55)
at /node_modules/eslint/lib/eslint/flat-eslint.js:812:40
at Array.map ()
at FlatESLint.lintFiles (/node_modules/eslint/lib/eslint/flat-eslint.js:810:23)
at async Object.execute (/node_modules/eslint/lib/cli.js:421:23)
at async main (/node_modules/eslint/bin/eslint.js:152:22)

Walkthrough

The pull request introduces several updates across multiple files. The CrossL2Prover.sol contract has been modified to change the Solidity version and adjust the logic in the validateReceipt function. The package.json file reflects a version update from 4.0.13 to 4.0.14. Additionally, the bytecode for the CrossL2Prover and OptimisticProofVerifier contracts has been updated in their respective factory files, while the overall structure and functionality remain unchanged.

Changes

File Path Change Summary
contracts/core/proofAPI/CrossL2Prover.sol Updated Solidity version to 0.8.15. Modified validateReceipt to verify against block H - 1.
package.json Updated version from 4.0.13 to 4.0.14. No other changes made.
src/evm/contracts/factories/CrossL2Prover__factory.ts Updated bytecode for CrossL2Prover. No changes to constructor parameters or method signatures.
src/evm/contracts/factories/OptimisticProofVerifier__factory.ts Updated bytecode for OptimisticProofVerifier. No changes to constructor parameters or method signatures.

Possibly related PRs

  • bump version to v4.0.12 #266: The changes in this PR involve an update to the package.json file, specifically changing the version number, which is related to the version update in the main PR's package.json from 4.0.13 to 4.0.14.

Suggested reviewers

  • nicopernas
  • alfredo-stonk

Poem

🐇 In the code, a change so bright,
The CrossL2Prover takes new flight.
With version bumps and bytes anew,
The contracts dance, a lively crew!
Hopping through the lines of code,
A rabbit's joy in each new node! 🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@RnkSngh RnkSngh force-pushed the raunak/add-plus-one-height branch from e71cfd4 to 4e5adbe Compare December 6, 2024 17:16
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1dcd580 and 4e5adbe.

📒 Files selected for processing (4)
  • contracts/core/proofAPI/CrossL2Prover.sol (2 hunks)
  • package.json (1 hunks)
  • src/evm/contracts/factories/CrossL2Prover__factory.ts (1 hunks)
  • src/evm/contracts/factories/OptimisticProofVerifier__factory.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • package.json
  • src/evm/contracts/factories/OptimisticProofVerifier__factory.ts
🔇 Additional comments (4)
contracts/core/proofAPI/CrossL2Prover.sol (3)

18-18: LGTM: Solidity version update is appropriate.

The update to Solidity 0.8.15 is a good choice as it includes important security fixes and features.


63-65: LGTM: Correct adjustment for proof verification against previous block state.

The change to use peptideAppProof.height - 1 is correct as a proof generated at height H must be verified against the state root from block H-1. The comment clearly explains this requirement.


63-65: Verify receipt verification with updated height logic.

Let's verify that receipt verification still works correctly with the height adjustment.

✅ Verification successful

Height adjustment in validateReceipt is correctly implemented

The height adjustment logic in validateReceipt is properly implemented and consistent with the rest of the contract:

  • The contract maintains peptide app hashes in a mapping indexed by height
  • The validateReceipt function correctly uses peptideAppProof.height - 1 to verify against the previous block's app hash
  • The implementation aligns with the comment explaining that proofs at height H must be verified against state root from block H-1
  • Other height-related functions (_getPeptideAppHash, getState, _updateClient) work independently and are not affected by this verification logic
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for tests that verify receipt validation to ensure they account for the height adjustment

# Search for receipt validation tests
rg -A 5 "validateReceipt.*test" 

# Search for any height-related assertions in tests
rg -A 5 "peptideAppProof.*height.*assert"

Length of output: 1074


Script:

#!/bin/bash
# Let's search for the test implementation details and height-related logic

# Search for validateReceipt test implementations
rg -B 5 -A 15 "function test.*validateReceipt" 

# Search for peptideAppProof usage in tests
rg -B 2 -A 5 "peptideAppProof" test/

# Search for height-related logic in the CrossL2Prover contract
ast-grep --pattern 'function validateReceipt($$$) {
  $$$
}'

Length of output: 148


Script:

#!/bin/bash
# Let's try a different approach to find test files and implementation

# Find test files
fd ".*\.t\.sol$" test/

# Search for validateReceipt implementation in the contract
rg -B 5 -A 15 "function validateReceipt" contracts/

# Look for height-related logic in the contract
rg -B 2 -A 5 "height" contracts/core/proofAPI/CrossL2Prover.sol

Length of output: 6821

src/evm/contracts/factories/CrossL2Prover__factory.ts (1)

405-405: LGTM: Bytecode update matches contract changes.

The bytecode update correctly reflects the changes made to the contract:

  1. Solidity version update to 0.8.15
  2. Logic changes in the validateReceipt function

contracts/core/proofAPI/CrossL2Prover.sol Show resolved Hide resolved
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.

3 participants