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

fix(zetaclient): add block by number result nil check #2882

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

gartnera
Copy link
Member

@gartnera gartnera commented Sep 14, 2024

We're getting this panic on mainnet which results in inbounds not being processed.

{"level":"error","chain":56,"module":"inbound","error":"panic during ticker run: runtime error: invalid memory address or nil pointer dereference at /go/src/github.com/zeta-chain/node/zetaclient/chains/evm/observer/observer.go:340 +0x34","worker.name":"WatchInbound","time":"2024-09-14T01:33:40Z","message":"Background task failed"}

on release/v19 it points to this function. It looks like it can return nil and no error. Add an explicit nil check to ensure the block.Transactions does not nil dereference.

Related to #2881

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling in the block retrieval process, providing clearer feedback when a requested block is not found.

Copy link
Contributor

coderabbitai bot commented Sep 14, 2024

Walkthrough

Walkthrough

The changes introduce an enhanced error handling condition in the BlockByNumber method of the Observer struct within the observer.go file. A check is added to verify if the block variable is nil after attempting to retrieve a block by its number. If the block is not found, the method now returns an error indicating that the block was not found, along with the specific block number.

Changes

File Path Change Summary
zetaclient/chains/evm/observer/observer.go Added error handling in BlockByNumber method to return an error if the block is nil.

Possibly related PRs

Tip

OpenAI O1 model for chat
  • We have deployed OpenAI's latest O1 model for chat.
  • OpenAI claims that this model has superior reasoning capabilities than their GPT-4o model.
  • Please share any feedback with us in the discussions post.

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

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

codecov bot commented Sep 14, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 66.88%. Comparing base (9988584) to head (86344f6).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
zetaclient/chains/evm/observer/observer.go 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2882      +/-   ##
===========================================
- Coverage    66.89%   66.88%   -0.01%     
===========================================
  Files          377      377              
  Lines        21082    21084       +2     
===========================================
  Hits         14103    14103              
- Misses        6315     6316       +1     
- Partials       664      665       +1     
Files with missing lines Coverage Δ
zetaclient/chains/evm/observer/observer.go 73.54% <0.00%> (-0.97%) ⬇️

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9988584 and 86344f6.

Files selected for processing (1)
  • zetaclient/chains/evm/observer/observer.go (1 hunks)
Additional context used
Path-based instructions (1)
zetaclient/chains/evm/observer/observer.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

GitHub Check: codecov/patch
zetaclient/chains/evm/observer/observer.go

[warning] 319-319: zetaclient/chains/evm/observer/observer.go#L319
Added line #L319 was not covered by tests

zetaclient/chains/evm/observer/observer.go Show resolved Hide resolved
@CryptoFewka CryptoFewka added this pull request to the merge queue Sep 14, 2024
Merged via the queue into develop with commit 8ad6192 Sep 14, 2024
32 of 33 checks passed
@CryptoFewka CryptoFewka deleted the block-by-number-nil-check branch September 14, 2024 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Skip changelog CI check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants