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

update readme & configs #59

Merged
merged 2 commits into from
Dec 11, 2024
Merged

update readme & configs #59

merged 2 commits into from
Dec 11, 2024

Conversation

sh-cha
Copy link
Collaborator

@sh-cha sh-cha commented Dec 11, 2024

Summary by CodeRabbit

Release Notes

  • Documentation

    • Updated version requirements for OPinit bots in the README files.
    • Enhanced configuration details and querying instructions for the Challenger and Executor components.
    • Introduced new response structures for querying challenges and withdrawals, improving clarity and functionality.
    • Clarified command usage and pagination for querying challenges and withdrawals.
  • Bug Fixes

    • Corrected minor formatting issues in documentation for better readability.
  • Chores

    • Simplified CORS configuration in the server setup.

@sh-cha sh-cha self-assigned this Dec 11, 2024
@sh-cha sh-cha requested a review from a team as a code owner December 11, 2024 04:27
Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

Walkthrough

The pull request introduces updates to the documentation and configuration settings across multiple components related to the OPinit bots. Key changes include incrementing version requirements for various components, adjusting starting heights for L1 and L2 nodes, and refining the query structures for challenges and withdrawals. Additionally, minor formatting corrections and logging adjustments are made to improve clarity and maintain consistency across the codebase.

Changes

File Change Summary
README.md Updated version requirements for L1 Node, MiniMove, MiniWasm, and MiniEVM. Minor formatting correction in node height reset command.
challenger/README.md Modified l1_start_height and l2_start_height from 0 to 1. Simplified query command for challenges. Added new default options for querying challenges. Introduced QueryChallengesResponse structure.
challenger/challenger.go Renamed method from getProcessedHeights to getNodeStartHeights. Updated parameters and return values to reflect start heights. Adjusted initialization logic accordingly.
challenger/types/config.go Updated L1StartHeight and L2StartHeight defaults from 0 to 1. Modified validation logic to require heights to be greater than 0.
executor/README.md Changed l1_start_height, l2_start_height, and batch_start_height from 0 to 1. Restructured QueryWithdrawalResponse with new fields and removed old fields.
node/process.go Removed log statement for "already synced" in blockProcessLooper method.
server/server.go Removed AllowCredentials from CORS configuration in NewServer function.

Possibly related PRs

  • add l1 start height in config to avoid to use TxSearch #32: The changes in this PR involve adding a new configuration parameter l1_start_height in the challenger/README.md and challenger/types/config.go, which is directly related to the version requirements updated in the main PR.
  • Feat/withdrawal api by address #41: This PR introduces a new API endpoint for querying withdrawals by address, which includes modifications to the executor/README.md that also mention the l1_start_height parameter, linking it to the main PR's focus on version requirements.
  • bug fix starting from 1 when initializing tree #52: The changes in this PR involve adjustments to the initialization logic in the prepareTree method, which may relate to the overall structure and requirements of the system, including the handling of heights that are relevant to the updates in the main PR.

Suggested reviewers

  • beer-1

Poem

🐰 In the land of code where changes bloom,
Version numbers rise, dispelling the gloom.
Heights now start from one, not zero,
Clarity reigns, our documentation's hero!
With queries refined, we hop with delight,
Through code and config, our future is bright! 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7680b3d and 3229cc1.

📒 Files selected for processing (3)
  • challenger/README.md (2 hunks)
  • challenger/challenger.go (5 hunks)
  • challenger/query.go (2 hunks)
🔇 Additional comments (7)
challenger/query.go (1)

11-11: LGTM! Parameter rename improves consistency.

The change from from to offset aligns with the withdrawal query implementation, making the API more consistent.

Also applies to: 32-33

challenger/README.md (3)

44-45: LGTM! Start heights now align with typical blockchain conventions.

The change from 0 to 1 for both L1 and L2 start heights is more appropriate as blockchain heights typically start at 1.

Also applies to: 49-49


187-203: LGTM! Query documentation improvements enhance clarity.

The documentation now clearly specifies:

  • Simplified endpoint without {page} parameter
  • Default options for limit, offset, and order
  • Clear pagination instructions using the next field

196-199: LGTM! Well-structured response type documentation.

The QueryChallengesResponse structure is clearly documented with all necessary fields.

challenger/challenger.go (3)

100-100: LGTM! Consistent height initialization.

The initialization logic correctly subtracts 1 from start heights to ensure proper synchronization between nodes.

Also applies to: 106-106, 114-114


189-189: LGTM! Query parameter rename improves consistency.

The change from next to offset aligns with the changes in query.go and maintains consistent terminology.

Also applies to: 206-206


Line range hint 230-287: Verify the edge cases in start height calculations.

The logic for calculating start heights has been significantly updated. Please ensure:

  1. The condition l2StartHeight > 1 at line 261 handles the case when there are no previous outputs correctly
  2. The height calculations at lines 278-282 maintain proper synchronization between L1 and L2 nodes
✅ Verification successful

Let me analyze the code further with additional scripts to verify the edge cases.


Start height calculations are properly handled with appropriate edge cases

After analyzing the code and its usage patterns, the start height calculations are correctly implemented:

  1. The l2StartHeight > 1 condition at line 261 is properly handled:

    • When there are no previous outputs, outputL2Height remains 0, making l2StartHeight = 1
    • When there is a previous output, l2StartHeight is correctly set to outputL2Height + 1
  2. The height synchronization logic is robust:

    • Handles missing deposit transactions by falling back to previous sequence (l1Sequence-1)
    • Ensures L1 height is never less than the output height through outputL1Height + 1 check
    • Properly coordinates with bridge creation height when auto-set is enabled
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of start heights in the codebase
# Test: Search for references to start heights to ensure consistent usage

echo "Checking L1/L2 start height references:"
rg -A 3 "l[12]_start_height|L[12]StartHeight"

echo "Checking height initialization patterns:"
ast-grep --pattern 'Initialize($_, $height, $_)'

Length of output: 7643


Script:

#!/bin/bash
# Check the logic around l2StartHeight and related conditions

# Check how l2StartHeight is used in conditions
echo "Checking l2StartHeight conditions:"
rg -A 5 "if.*l2StartHeight|if.*l2_start_height"

# Check output handling logic
echo "Checking output handling patterns:"
rg -A 10 "QueryLastFinalizedOutput"

# Check deposit height calculations
echo "Checking deposit height logic:"
rg -A 5 "QueryDepositTxHeight"

Length of output: 3877


🪧 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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @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.

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: 0

🧹 Outside diff range and nitpick comments (2)
challenger/challenger.go (1)

Line range hint 230-287: Consider improving error handling and documentation.

The method has complex conditional logic for determining start heights. Consider:

  1. Adding documentation to explain the logic flow
  2. Adding error checks for negative height values
  3. Adding logging statements for better debugging
 func (c *Challenger) getNodeStartHeights(ctx types.Context, bridgeId uint64) (l1StartHeight int64, l2StartHeight int64, startOutputIndex uint64, err error) {
+    // Skip if nodes are already synced
     if c.host.Node().GetSyncedHeight() != 0 && c.child.Node().GetSyncedHeight() != 0 {
         return 0, 0, 0, nil
     }
 
     var outputL1Height, outputL2Height int64
     var outputIndex uint64
 
+    // Query last finalized output if L2 start height is specified
     if c.cfg.L2StartHeight > 1 {
         output, err := c.host.QueryLastFinalizedOutput(ctx, bridgeId)
         if err != nil {
             return 0, 0, 0, err
         } else if output != nil {
             outputL1Height = types.MustUint64ToInt64(output.OutputProposal.L1BlockNumber)
             outputL2Height = types.MustUint64ToInt64(output.OutputProposal.L2BlockNumber)
             outputIndex = output.OutputIndex
+            ctx.Logger().Debug("Found last finalized output",
+                zap.Int64("l1_height", outputL1Height),
+                zap.Int64("l2_height", outputL2Height),
+                zap.Uint64("output_index", outputIndex))
         }
     }
executor/README.md (1)

232-247: Consider improving struct field documentation.

The QueryWithdrawalResponse struct fields are now better organized with logical grouping, but could benefit from field-level documentation.

 type QueryWithdrawalResponse struct {
     // fields required to withdraw funds
     Sequence         uint64     `json:"sequence"`
-    To               string     `json:"to"`
+    To               string     `json:"to"`        // destination address for withdrawal
-    From             string     `json:"from"`
+    From             string     `json:"from"`      // source address of withdrawal
     Amount           types.Coin `json:"amount"`
     OutputIndex      uint64     `json:"output_index"`
     BridgeId         uint64     `json:"bridge_id"`
     WithdrawalProofs [][]byte   `json:"withdrawal_proofs"`
     Version          []byte     `json:"version"`
     StorageRoot      []byte     `json:"storage_root"`
     LastBlockHash    []byte     `json:"last_block_hash"`
 
     // extra info
     TxTime   int64  `json:"tx_time"`
     TxHeight int64  `json:"tx_height"`
     TxHash   string `json:"tx_hash"`
 }
🧰 Tools
🪛 Markdownlint (0.35.0)

233-233: Column: 1
Hard tabs

(MD010, no-hard-tabs)


234-234: Column: 1
Hard tabs

(MD010, no-hard-tabs)


235-235: Column: 1
Hard tabs

(MD010, no-hard-tabs)


236-236: Column: 1
Hard tabs

(MD010, no-hard-tabs)


237-237: Column: 1
Hard tabs

(MD010, no-hard-tabs)


238-238: Column: 1
Hard tabs

(MD010, no-hard-tabs)


239-239: Column: 1
Hard tabs

(MD010, no-hard-tabs)


240-240: Column: 1
Hard tabs

(MD010, no-hard-tabs)


241-241: Column: 1
Hard tabs

(MD010, no-hard-tabs)


242-242: Column: 1
Hard tabs

(MD010, no-hard-tabs)


244-244: Column: 1
Hard tabs

(MD010, no-hard-tabs)


245-245: Column: 1
Hard tabs

(MD010, no-hard-tabs)


246-246: Column: 1
Hard tabs

(MD010, no-hard-tabs)


247-247: Column: 1
Hard tabs

(MD010, no-hard-tabs)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b5d3fd3 and 7680b3d.

📒 Files selected for processing (7)
  • README.md (2 hunks)
  • challenger/README.md (2 hunks)
  • challenger/challenger.go (3 hunks)
  • challenger/types/config.go (2 hunks)
  • executor/README.md (5 hunks)
  • node/process.go (0 hunks)
  • server/server.go (1 hunks)
💤 Files with no reviewable changes (1)
  • node/process.go
✅ Files skipped from review due to trivial changes (1)
  • server/server.go
🧰 Additional context used
🪛 Markdownlint (0.35.0)
executor/README.md

233-233: Column: 1
Hard tabs

(MD010, no-hard-tabs)


234-234: Column: 1
Hard tabs

(MD010, no-hard-tabs)


235-235: Column: 1
Hard tabs

(MD010, no-hard-tabs)


236-236: Column: 1
Hard tabs

(MD010, no-hard-tabs)


237-237: Column: 1
Hard tabs

(MD010, no-hard-tabs)


238-238: Column: 1
Hard tabs

(MD010, no-hard-tabs)


239-239: Column: 1
Hard tabs

(MD010, no-hard-tabs)


240-240: Column: 1
Hard tabs

(MD010, no-hard-tabs)


241-241: Column: 1
Hard tabs

(MD010, no-hard-tabs)


242-242: Column: 1
Hard tabs

(MD010, no-hard-tabs)


244-244: Column: 1
Hard tabs

(MD010, no-hard-tabs)


245-245: Column: 1
Hard tabs

(MD010, no-hard-tabs)


246-246: Column: 1
Hard tabs

(MD010, no-hard-tabs)


247-247: Column: 1
Hard tabs

(MD010, no-hard-tabs)

🔇 Additional comments (9)
README.md (2)

88-88: LGTM: Formatting improvement

The removal of extra space before the comma improves readability.


22-22: Verify compatibility with updated version requirements

The version requirements for all components have been increased:

  • L1 Node: v0.6.1+ → v0.6.4+
  • MiniMove: v0.6.4+ → v0.6.5+
  • MiniWasm: v0.6.4+ → v0.6.5+
  • MiniEVM: v0.6.6+ → v0.6.7+
✅ Verification successful

Based on the search results, I can now generate the final response:

Version requirements are consistent with dependencies

The version requirements in the table match the actual dependencies in go.mod:

  • OPinit v0.6.1 is listed as a direct dependency
  • OPinit/api v0.6.0 is listed as an indirect dependency

These versions are compatible with the updated version requirements table, and there's no evidence of incompatibility issues.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if these versions exist in the repositories
for repo in l1-node mini-move mini-wasm mini-evm; do
  echo "Checking $repo tags..."
  gh api repos/initia-labs/$repo/tags --jq '.[].name'
done

Length of output: 1266


Script:

#!/bin/bash
# Let's check the git history of README.md to understand the version changes
git log -p README.md | grep -A 5 -B 5 "v0.6"

# Also check if there are any other files mentioning version requirements
rg "v0\.6\.[0-9]+" -A 2 -B 2

Length of output: 20551

challenger/types/config.go (2)

104-109: Validation logic strengthened for start heights

The validation now ensures start heights are strictly greater than 0 (changed from >= 0 to > 0). This aligns with the new default values.


78-79: ⚠️ Potential issue

Breaking change: Default start heights updated

The default start heights for both L1 and L2 have been changed from 0 to 1. This is a breaking change that could affect existing configurations.

challenger/README.md (2)

44-49: Config example updated to reflect new defaults

The example configuration has been updated to use start height of 1, which aligns with the new defaults in the code.


187-203: Documentation improved with pagination details

The challenges query endpoint has been simplified and enhanced with:

  • Removal of the {page} parameter
  • Clear documentation of default options
  • New QueryChallengesResponse structure for pagination
challenger/challenger.go (1)

100-114: Verify the off-by-one adjustments in node initialization.

The initialization of both host and child nodes subtracts 1 from their respective start heights. While this appears intentional, we should verify this behavior is correct across the codebase.

✅ Verification successful

The previous pattern was too specific. Let's try a broader search to understand the initialization patterns in the codebase.


Based on the search results, I can now generate a final response as we have sufficient evidence to verify the off-by-one adjustments in node initialization.

The off-by-one adjustments in node initialization are consistent and correct across the codebase.

The pattern of subtracting 1 from start heights is consistently applied across different components:

  • In challenger/challenger.go: Both host and child nodes use height-1
  • In executor/executor.go: All three components (host, child, and batch submitter) use height-1
  • This adjustment ensures initialization starts from the last fully processed height, allowing the system to resume from the next unprocessed height, which is a common pattern in blockchain systems to maintain consistency and avoid gaps in processing.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other node initialization patterns to verify consistency
ast-grep --pattern 'Initialize(ctx, $height, $_, $_, $_)' 

Length of output: 59


Script:

#!/bin/bash
# Search for Initialize method definitions and usages with a broader pattern
ast-grep --pattern 'Initialize($$$)'

# Also search using ripgrep for Initialize calls and definitions
rg "Initialize.*\(" -A 5

Length of output: 17296

executor/README.md (2)

81-89: Documentation update for start height configurations looks good.

The changes from 0 to 1 for start heights are well documented and consistent with the implementation changes.


418-418: Documentation for pagination is clear and helpful.

The addition of pagination information and the note about using next as an offset is well documented.

Also applies to: 456-458

challenger/README.md Outdated Show resolved Hide resolved
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.

LGTM

@sh-cha sh-cha merged commit ece493c into main Dec 11, 2024
6 checks passed
@sh-cha sh-cha deleted the fix/unnecessary-log branch December 11, 2024 04:51
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