Skip to content

op-challenger: remove dependency on op-bindings#10221

Closed
tynes wants to merge 1 commit intodevelopfrom
feat/challenger-bindings
Closed

op-challenger: remove dependency on op-bindings#10221
tynes wants to merge 1 commit intodevelopfrom
feat/challenger-bindings

Conversation

@tynes
Copy link
Contributor

@tynes tynes commented Apr 19, 2024

Description

Removes the op-challenger from requiring the global bindings.
This allows the service to be explicit about contract versions
that it supports. The op-bindings were not versioned and
added a lot of pain when it came to smart contract development
as they needed to always be updated.

Follows:

Removes the `op-challenger` from requiring the global bindings.
This allows the service to be explicit about contract versions
that it supports. The `op-bindings` were not versioned and
added a lot of pain when it came to smart contract development
as they needed to always be updated.

Follows:
- #10213
- #10218
@tynes tynes requested a review from a team as a code owner April 19, 2024 01:38
@tynes tynes requested a review from sebastianst April 19, 2024 01:38
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 19, 2024

Walkthrough

Walkthrough

The primary change across the updates involves modifying the import paths from op-bindings/bindings to op-challenger/bindings across several files. Additionally, a new file mips.go has been introduced in the op-challenger/bindings directory, which provides bindings for the MIPS Ethereum contract, enhancing interaction capabilities through various defined functions and structs.

Changes

File Path Change Summary
.../bindings/mips.go Introduced new bindings for MIPS protocol with functions for deploying and interacting with the contract, and sessions for different types of contract operations.
.../game/fault/contracts/*.go, .../*.go Updated import paths from op-bindings/bindings to op-challenger/bindings.
.../game/fault/contracts/*_test.go, .../*.go Updated import paths in test files from op-bindings/bindings to op-challenger/bindings.

Recent Review Details

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between 4a3d3fb and 076dd37.
Files selected for processing (14)
  • op-challenger/bindings/delayedweth.go (1 hunks)
  • op-challenger/bindings/disputegamefactory.go (1 hunks)
  • op-challenger/bindings/mips.go (1 hunks)
  • op-challenger/bindings/preimageoracle.go (1 hunks)
  • op-challenger/game/fault/contracts/delayed_weth.go (1 hunks)
  • op-challenger/game/fault/contracts/delayed_weth_test.go (1 hunks)
  • op-challenger/game/fault/contracts/faultdisputegame.go (1 hunks)
  • op-challenger/game/fault/contracts/faultdisputegame_test.go (1 hunks)
  • op-challenger/game/fault/contracts/gamefactory.go (1 hunks)
  • op-challenger/game/fault/contracts/gamefactory_test.go (1 hunks)
  • op-challenger/game/fault/contracts/oracle.go (1 hunks)
  • op-challenger/game/fault/contracts/oracle_test.go (1 hunks)
  • op-challenger/game/fault/contracts/vm.go (1 hunks)
  • op-challenger/game/fault/contracts/vm_test.go (1 hunks)
Files not summarized due to errors (3)
  • op-challenger/bindings/delayedweth.go: Error: Message exceeds token limit
  • op-challenger/bindings/disputegamefactory.go: Error: Message exceeds token limit
  • op-challenger/bindings/preimageoracle.go: Error: Message exceeds token limit
Additional comments not posted (33)
op-challenger/game/fault/contracts/vm.go (1)

7-7: Updated import path to use local bindings instead of op-bindings. Ensure that all references to the bindings in this file have been correctly updated to reflect this change.

op-challenger/game/fault/contracts/vm_test.go (1)

7-7: Updated import path in test file to use local bindings. Verify that all test cases are correctly using the new bindings and that they pass successfully.

op-challenger/game/fault/contracts/delayed_weth.go (1)

8-8: Updated import path to use local bindings for WETH-related functionalities. Confirm that all contract interaction methods are correctly utilizing the new bindings.

op-challenger/game/fault/contracts/delayed_weth_test.go (1)

8-8: Updated import path in test file for WETH functionalities. Ensure that all test cases are adapted to the new bindings and verify their successful execution.

op-challenger/game/fault/contracts/gamefactory.go (1)

8-8: Updated import path to use local bindings for game factory functionalities. Confirm that all methods related to game management are correctly utilizing the new bindings.

op-challenger/game/fault/contracts/gamefactory_test.go (1)

10-10: Updated import path in test file for game factory functionalities. Ensure that all test cases are adapted to the new bindings and verify their successful execution.

op-challenger/game/fault/contracts/oracle.go (1)

12-12: Updated import path to use local bindings for oracle functionalities. Confirm that all methods related to oracle interactions are correctly utilizing the new bindings.

op-challenger/game/fault/contracts/faultdisputegame_test.go (1)

11-11: Updated import path aligns with PR objectives to decouple from op-bindings.

op-challenger/game/fault/contracts/oracle_test.go (1)

11-11: Updated import path to use local bindings instead of op-bindings.

This change is consistent with the PR's objective to manage dependencies internally within the op-challenger module, enhancing control over contract interactions.

op-challenger/bindings/mips.go (5)

19-29: Unused imports should be avoided for cleaner code.

Consider removing the reference imports if they are not used elsewhere in the code. This can help reduce the clutter and improve readability.


31-35: Ensure ABI and binary data are correctly formatted and secure.

Please verify that the ABI and binary data provided in MIPSMetaData are correctly formatted and do not expose any security vulnerabilities, especially since they directly interact with the blockchain.


38-43: Deprecated items should be removed if no longer needed.

The variables MIPSABI and MIPSBin are marked as deprecated. If these are no longer used in the project, consider removing them to clean up the codebase.


205-219: Ensure error handling and data conversion are correctly implemented.

Verify that the data conversion in the BRKSTART function is safe and does not lead to data corruption or unexpected behavior, especially since it involves type casting which can be error-prone.


297-316: Check for potential reentrancy issues in transaction functions.

Review the Step function to ensure that it handles reentrancy attacks properly, given that it is a transaction function that could potentially be exposed to such risks.

op-challenger/bindings/disputegamefactory.go (8)

1-2: Ensure generated code is not manually edited.

The file header clearly states that this is generated code and should not be manually edited. This is important to prevent accidental modifications which could be overwritten by subsequent code generations.


6-17: Review import statements for necessary libraries.

The import statements include essential Ethereum libraries and Go standard libraries. This setup is typical for Go Ethereum bindings and supports the functionality used throughout the file.


31-38: Check struct definition for Ethereum binding compatibility.

The IDisputeGameFactoryGameSearchResult struct is defined to match the expected output of Ethereum contract calls. This struct will be used to parse and hold data from the contract, ensuring type safety and ease of access to contract results in Go.


41-44: Validate contract metadata for ABI and binary data.

The DisputeGameFactoryMetaData variable holds the ABI and binary data of the contract. It's crucial that this data is correct and matches the deployed Ethereum contract to ensure that the Go bindings work correctly.


54-68: Examine the deployment function for error handling and resource management.

The DeployDisputeGameFactory function handles deploying the contract to an Ethereum network. It includes error handling which is crucial for diagnosing deployment issues. The function returns the contract address, transaction details, and a bound contract instance or an error if the deployment fails.


71-91: Ensure struct definitions align with contract structure.

The structs DisputeGameFactory, DisputeGameFactoryCaller, DisputeGameFactoryTransactor, and DisputeGameFactoryFilterer are defined to facilitate different types of interactions with the Ethereum contract (read-only, write-only, and event filtering). This modular approach enhances code maintainability and clarity.


213-228: Review method binding and error handling for contract method calls.

The method FindLatestGames in DisputeGameFactoryCaller is bound to a contract method. It includes comprehensive error handling, which is essential for robust interaction with the contract. The method returns structured data that conforms to the defined Go struct, facilitating easier data manipulation in Go.


651-718: Evaluate event iterator for correct event handling and resource management.

The DisputeGameFactoryDisputeGameCreatedIterator struct and associated methods (Next, Error, Close) manage the iteration over events emitted by the contract. Proper error handling and resource management in these methods are crucial for avoiding memory leaks and ensuring the application remains responsive and stable.

op-challenger/bindings/preimageoracle.go (3)

57-72: The updates to the DeployPreimageOracle function correctly utilize the new PreimageOracleMetaData for contract deployment. Good error handling and structure.


133-140: The NewPreimageOracle function correctly binds a new instance of PreimageOracle to a deployed contract. Proper error handling and clear structure.


803-817: The Version function is correctly implemented to retrieve the contract version using a read-only call. Good use of error handling and contract interaction patterns.

op-challenger/bindings/delayedweth.go (8)

1-2: Generated code warning is clear and appropriate.


31-35: Ensure the ABI string is correctly formatted and matches the expected contract interface.


45-60: Check error handling in DeployDelayedWETH. Ensure that all possible errors are appropriately handled and logged.


122-128: Ensure that the NewDelayedWETH function correctly handles all errors and edge cases.


205-219: Validate that the Allowance function correctly interprets the contract's ABI and handles the data types accurately.

Verification successful

The script provided for verification of the Allowance function in the DelayedWETHCaller class does not perform any actual code or ABI analysis; it only outputs a statement indicating the need for manual verification. Therefore, based on the code snippet provided in the review context, I will manually analyze the function to determine if it correctly interprets the contract's ABI and handles the data types accurately.

The Allowance function is designed to interact with a smart contract's allowance method, which typically checks the amount of tokens that an owner allowed to another address. The function uses the Call method from the Go Ethereum bindings to make a read-only call to the blockchain. The results are expected to be returned in a slice of interfaces (out), which are then converted to the expected type (*big.Int).

Key points for verification:

  1. ABI Interpretation: The function signature in Solidity (function allowance(address, address) view returns(uint256)) matches the parameters and return type used in the Go function (arg0 common.Address, arg1 common.Address and *big.Int).
  2. Data Handling: The function retrieves the first element from the output slice and converts it to **big.Int. This is a pointer to a pointer of big.Int, which is then dereferenced to match the expected return type of *big.Int.

Given this analysis, the function appears to correctly interpret the ABI and handle the data types as per the Solidity contract's specification. However, without access to the actual ABI and contract implementation, this verification is based on typical patterns observed in Go Ethereum bindings.

Conclusion: The Allowance function seems to be implemented correctly with respect to ABI interpretation and data handling, based on the provided code snippet and typical interaction patterns with Ethereum smart contracts.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Validate the Allowance function for correct ABI interpretation and data handling.
echo "Manual verification needed for Allowance function in DelayedWETH."

Length of output: 140


560-578: Review the Approve function to ensure it conforms to the expected contract behavior, especially in terms of state changes and event emissions.


581-599: Check the Deposit function for compliance with the payable modifier in the Solidity contract and ensure correct transaction handling.


1081-1150: Check the FilterDeposit and related functions for correct event filtering logic and parameter handling.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

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

What generated those bindings? How do we update them when the contracts change? How do we ensure they stay in sync as the contracts change (which is a key requirement for fault proofs currently)?

Sorry I'm a little behind on these changes but I want to make sure we don't change things in a way that's going to cause delay shipping fault proofs so am keen to understand more about what's going on here.

Copy link
Contributor

@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: 5

tynes added a commit that referenced this pull request Apr 19, 2024
Removes the dependency on the `op-bindings/bindings` package.
This is to improve devex in the monorepo and reduce CI time
as maintaining the bindings autogenerated in each PR just
doesn't scale. Now each service is responsible for their own
bindings. In the future, we can work towards releases of
the bindings when contracts are released.

Follows:
- #10213
- #10218
- #10221
@tynes tynes mentioned this pull request Apr 19, 2024
@tynes tynes closed this Apr 19, 2024
@tynes tynes deleted the feat/challenger-bindings branch April 19, 2024 18:40
tynes added a commit that referenced this pull request Apr 23, 2024
Removes the dependency on the `op-bindings/bindings` package.
This is to improve devex in the monorepo and reduce CI time
as maintaining the bindings autogenerated in each PR just
doesn't scale. Now each service is responsible for their own
bindings. In the future, we can work towards releases of
the bindings when contracts are released.

Follows:
- #10213
- #10218
- #10221
github-merge-queue bot pushed a commit that referenced this pull request Apr 23, 2024
* indexer: remove bindings

Removes the dependency on the `op-bindings/bindings` package.
This is to improve devex in the monorepo and reduce CI time
as maintaining the bindings autogenerated in each PR just
doesn't scale. Now each service is responsible for their own
bindings. In the future, we can work towards releases of
the bindings when contracts are released.

Follows:
- #10213
- #10218
- #10221

* indexer: add missing binding
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