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

Feat/challenger #14

Merged
merged 22 commits into from
Sep 11, 2024
Merged

Feat/challenger #14

merged 22 commits into from
Sep 11, 2024

Conversation

sh-cha
Copy link
Collaborator

@sh-cha sh-cha commented Sep 4, 2024

deposit, output, oracle data and timeout check

Summary by CodeRabbit

  • New Features

    • Introduced a Challenger component for managing blockchain interactions, including deposit handling and challenge management.
    • Added support for a new bot type, BotTypeChallenger, enhancing bot functionality.
    • Implemented robust error handling and validation for bot types during creation.
    • Created a new README.md for the Challenger, detailing its responsibilities.
    • Enhanced batch processing capabilities with new data structures and serialization methods.
  • Bug Fixes

    • Improved error handling in the bot creation process to prevent invalid bot types.
    • Added retry mechanism for transient errors in block processing.
  • Documentation

    • Added comprehensive documentation for the Challenger and its functionalities.
  • Chores

    • Updated import paths to reflect the new module structure.
    • Updated dependency versions in the project.

@sh-cha sh-cha self-assigned this Sep 4, 2024
@sh-cha sh-cha requested a review from a team as a code owner September 4, 2024 05:52
Copy link

coderabbitai bot commented Sep 4, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes involve a comprehensive restructuring of the codebase, including updates to import paths and modifications to the Makefile for versioning. Enhancements have been made to functionalities related to bot types, including the introduction of validation methods. New components, such as the Challenger struct and its associated methods, facilitate the management of deposits, events, and challenges within a blockchain architecture.

Changes

File(s) Change Summary
Makefile Updated ldflags variable to change namespace from github.com/initia-labs/opinit-bots-go/version to github.com/initia-labs/opinit-bots/version.
bot/bot.go Renamed name to botType in NewBot, added validation for botType, and updated logic for shared db and server instances.
bot/types/const.go Added BotTypeChallenger constant and Validate() method for BotType, updated BotTypeFromString to handle new type.
challenger/README.md Introduced a README file outlining the responsibilities of the Challenger.
challenger/challenger.go Defined Challenger struct with methods for initialization, starting, and managing interactions between L1 and L2 blockchains.
challenger/child/child.go Introduced Child struct with interfaces for managing challenges, including methods for initialization and event handling.
challenger/child/deposit.go Implemented methods for finalizing deposits based on blockchain events.
challenger/child/handler.go Added methods for handling block and transaction events.
challenger/child/oracle.go Defined oracleTxHandler function for processing oracle transactions.
challenger/child/status.go Created Status struct and GetStatus() method to encapsulate child node status attributes.
executor/batch/batch.go Renamed NewBatchSubmitter to NewBatchSubmitterV0, removed version parameter, and updated import paths.
executor/batch/db.go Introduced functionality for managing local batch information, including methods for loading, saving, and converting batch data.
executor/batch/handler.go Modified rawBlockHandler to improve message processing and changed method signatures for batch handling.
executor/batch/status.go Updated Status struct to track batch processing with new fields for start and end block numbers.
executor/types/batch.go Introduced LocalBatchInfo, BatchDataHeader, and BatchDataChunk structures, enhancing batch data handling.
executor/types/batch_test.go Added unit tests for batch data handling, focusing on serialization and deserialization.
executor/types/config.go Updated Validate method to restrict configuration version to only version 1.
go.mod Changed module name from github.com/initia-labs/opinit-bots-go to github.com/initia-labs/opinit and updated several dependencies.
node/process.go Enhanced block processing and event management with new error handling and block time parameters.
node/types/handler.go Added BlockTime field to EventHandlerArgs and TxHandlerArgs structures for improved event context.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Bot
    participant Challenger
    participant Child

    User->>Bot: Create NewBot
    Bot->>Challenger: Initialize
    Challenger->>Child: Create Child Instance
    Child->>Challenger: Register Event Handlers
    Challenger->>User: Start Processing
Loading

🐇 "In the code where the changes play,
New bots and challengers come out to play.
With flags that now point the right way,
In the blockchain world, we hop and sway!
Let's celebrate this fine array,
Of features brightening up our day!" 🐇


Note

Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

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.
    • @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.

* change batch spec adding header bytes to batch data

* bump opinit version

* delete oracle option

* bug fix marshal unmarshal batch data
Copy link
Collaborator

@beer-1 beer-1 left a comment

Choose a reason for hiding this comment

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

Firstly merge and I will do review later

@sh-cha sh-cha merged commit 5e6554f into main Sep 11, 2024
4 checks passed
Copy link
Collaborator

@beer-1 beer-1 left a comment

Choose a reason for hiding this comment

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

Firstly have checked challenger related updates

challenger/challenger.go Show resolved Hide resolved
return nil
}

func (c *Challenger) Start(ctx context.Context) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

At start, how about checking l1 and l2 provider height is bigger than the start height? It will prevent overwriting wrong state like last finalized deposit height and sequence.

challenger/child/withdraw.go Show resolved Hide resolved
challenger/eventhandler/challenge.go Show resolved Hide resolved
challenger/eventhandler/challenge.go Show resolved Hide resolved
challenger/handler.go Show resolved Hide resolved
db/db.go Show resolved Hide resolved
@sh-cha sh-cha deleted the feat/challenger branch September 29, 2024 22:35
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