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

refactor: remove errors directive comparison #10502

Conversation

kien6034
Copy link
Contributor

Description
This PR uses errors.Is() function instead of directive errors comparision

Tests

Please describe any tests you've added. If you've added no tests, or left important behavior untested, please explain why not.

Additional context

Add any other context about the problem you're solving.

Metadata

  • Fixes #[Link to Issue]

Copy link
Contributor

coderabbitai bot commented May 11, 2024

Walkthrough

Walkthrough

The recent updates across various files primarily focus on enhancing error handling by replacing direct error comparisons with the errors.Is function. This change improves the reliability and accuracy of error checks, particularly for io.EOF and custom error types across multiple packages. The modifications are widespread, affecting error handling in functions related to memory operations, batch processing, data retrieval, and server responses.

Changes

File Path Change Summary
Various files across op-node, op-batcher Replaced direct error comparisons with errors.Is for io.EOF and other errors.
.../op-node/p2p/store/... Added errors import; updated error comparisons to use errors.Is.
.../op-e2e/actions/... Enhanced error handling by using errors.Is in various action functions.
.../op-service/sources/..., proxyd/... Applied errors.Is for improved error checking in service and proxy handling.
.../op-preimage/..., op-program/host/... Imported errors package and updated error handling conditions.

Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 1a20fd9 and d5c5531.
Files selected for processing (34)
  • cannon/mipsevm/memory.go (2 hunks)
  • cannon/mipsevm/page.go (2 hunks)
  • op-batcher/batcher/channel_builder.go (3 hunks)
  • op-batcher/batcher/channel_manager_test.go (2 hunks)
  • op-batcher/batcher/driver.go (2 hunks)
  • op-chain-ops/cmd/receipt-reference-builder/pull.go (1 hunks)
  • op-e2e/actions/l2_batcher.go (4 hunks)
  • op-e2e/actions/l2_verifier.go (1 hunks)
  • op-node/cmd/batch_decoder/reassemble/reassemble.go (2 hunks)
  • op-node/p2p/store/ip_ban_book.go (2 hunks)
  • op-node/p2p/store/mdbook.go (2 hunks)
  • op-node/p2p/store/peer_ban_book.go (2 hunks)
  • op-node/p2p/store/records_book.go (1 hunks)
  • op-node/p2p/store/scorebook.go (2 hunks)
  • op-node/rollup/derive/batch_queue.go (2 hunks)
  • op-node/rollup/derive/channel_bank.go (3 hunks)
  • op-node/rollup/derive/channel_in_reader.go (3 hunks)
  • op-node/rollup/derive/engine_queue.go (2 hunks)
  • op-node/rollup/derive/l1_retrieval.go (3 hunks)
  • op-node/rollup/derive/pipeline.go (2 hunks)
  • op-node/rollup/derive/plasma_data_source_test.go (2 hunks)
  • op-node/rollup/driver/sequencer_test.go (1 hunks)
  • op-node/rollup/driver/state.go (1 hunks)
  • op-preimage/hints.go (2 hunks)
  • op-preimage/hints_test.go (1 hunks)
  • op-preimage/oracle.go (2 hunks)
  • op-program/host/host.go (2 hunks)
  • op-service/solabi/util.go (1 hunks)
  • op-service/sources/batching/batching_test.go (2 hunks)
  • op-service/sources/batching/multicall.go (2 hunks)
  • op-service/sources/receipts_basic.go (2 hunks)
  • proxyd/cache.go (2 hunks)
  • proxyd/consensus_tracker.go (4 hunks)
  • proxyd/server.go (1 hunks)
Additional Context Used
Learnings (1)
op-node/rollup/derive/l1_retrieval.go (1)
User: protolambda
PR: ethereum-optimism/optimism#8981
File: op-node/rollup/derive/l1_traversal.go:78-78
Timestamp: 2024-01-17T07:14:58.134Z
Learning: The user has confirmed that the error message in `UpdateSystemConfigWithL1Receipts` should reference `nextL1Origin` instead of `origin` to accurately reflect the block that caused the issue.
Additional comments not posted (53)
op-service/sources/batching/multicall.go (2)

5-5: Import of errors package is appropriate for the new error handling approach.


62-62: Proper use of errors.Is for error handling, enhancing robustness against wrapped errors.

op-preimage/hints.go (2)

5-5: Import of errors package is appropriate for the new error handling approach.


52-52: Proper use of errors.Is for error handling, enhancing robustness against wrapped errors.

op-preimage/oracle.go (2)

6-6: Import of errors package is appropriate for the new error handling approach.


55-55: Proper use of errors.Is for error handling, enhancing robustness against wrapped errors.

op-node/p2p/store/ip_ban_book.go (2)

6-6: Import of errors package is appropriate for the new error handling approach.


75-75: Proper use of errors.Is for error handling, enhancing robustness against wrapped errors.

op-node/p2p/store/peer_ban_book.go (2)

6-6: Import of errors package is appropriate for the new error handling approach.


71-71: Proper use of errors.Is for error handling, enhancing robustness against wrapped errors.

op-service/sources/receipts_basic.go (2)

5-5: Import of errors package is appropriate for the new error handling approach.


43-43: Proper use of errors.Is for error handling, enhancing robustness against wrapped errors.

op-node/p2p/store/scorebook.go (2)

5-5: Import of errors package is appropriate for the new error handling approach.


75-75: Proper use of errors.Is for error handling, enhancing robustness against wrapped errors.

op-node/rollup/derive/l1_retrieval.go (2)

5-5: Import of errors package is appropriate for the new error handling approach.


53-53: Proper use of errors.Is for error handling, enhancing robustness against wrapped errors.

op-node/p2p/store/mdbook.go (2)

6-6: Import of errors package added to support the new error handling mechanism.


73-73: Refactored error handling using errors.Is for better error type checking.

cannon/mipsevm/page.go (2)

9-9: Import of errors package added to support the new error handling mechanism.


51-51: Refactored error handling using errors.Is for better error type checking.

op-preimage/hints_test.go (1)

46-46: Refactored error handling using errors.Is for better error type checking in test scenarios.

op-service/solabi/util.go (1)

88-88: Refactored error handling using errors.Is for better error type checking.

op-node/rollup/derive/channel_in_reader.go (3)

6-6: Import of errors package added to support the new error handling mechanism.


69-69: Refactored error handling using errors.Is for better error type checking.


83-83: Refactored error handling using errors.Is for better error type checking.

proxyd/cache.go (2)

6-6: Import of errors package added to support the new error handling mechanism.


70-70: Refactored error handling using errors.Is for better error type checking.

op-node/p2p/store/records_book.go (1)

131-131: Refactored error handling using errors.Is for better error type checking.

op-node/cmd/batch_decoder/reassemble/reassemble.go (2)

5-5: Import of errors package added to support the new error handling mechanism.


117-117: Refactored error handling using errors.Is for better error type checking.

op-node/rollup/derive/pipeline.go (1)

Line range hint 165-177: Use of errors.Is() enhances error handling by correctly identifying wrapped errors. Good implementation.

op-node/rollup/derive/channel_bank.go (1)

Line range hint 184-193: Correct use of errors.Is() for robust error handling in NextData. Well done.

op-service/sources/batching/batching_test.go (1)

Line range hint 136-150: Proper use of errors.Is() in test assertions enhances the accuracy and reliability of tests.

op-program/host/host.go (2)

Line range hint 221-241: Effective use of errors.Is() for error handling in routeHints. Enhances error identification.


241-241: Proper implementation of errors.Is() in launchOracleServer for robust error handling.

cannon/mipsevm/memory.go (1)

282-282: Correct implementation of errors.Is() in SetMemoryRange for handling wrapped errors.

op-e2e/actions/l2_verifier.go (1)

229-229: Use of errors.Is for error comparison enhances error handling by correctly identifying wrapped errors.

proxyd/consensus_tracker.go (3)

196-196: Proper use of errors.Is for error handling in Redis operations.


230-230: Effective error handling with errors.Is to check for non-nil errors that are not redis.Nil.


239-239: Correct application of errors.Is for robust error checking in remote state retrieval.

op-chain-ops/cmd/receipt-reference-builder/pull.go (1)

338-338: Appropriate use of errors.Is to handle io.EOF in batch processing, improving error detection.

op-batcher/batcher/channel_manager_test.go (1)

413-413: Use of errors.Is() for error comparison is a best practice in Go, especially for handling wrapped errors. Good implementation.

op-e2e/actions/l2_batcher.go (4)

8-8: Import of errors package is appropriate for the use of errors.Is() in error handling.


243-243: Proper use of errors.Is() for error handling with io.EOF. This ensures robust error checking, especially useful in I/O operations.


346-346: Correct implementation of errors.Is() in a loop for error handling. This is crucial for correctly identifying io.EOF during batch processing.


414-414: Usage of errors.Is() for error handling in the method ActL2BatchSubmitGarbage is correctly applied, ensuring that io.EOF is properly checked.

op-batcher/batcher/driver.go (2)

379-379: Effective use of errors.Is() for error handling in publishStateToL1. This ensures that errors other than io.EOF are logged, which is crucial for debugging.


439-439: Correct application of errors.Is() for handling io.EOF in publishTxToL1. This is essential for managing the end of data streams correctly.

op-node/rollup/driver/state.go (1)

375-375: Use errors.Is() for consistent error handling.

This change aligns with the PR's objective to standardize error handling using errors.Is(), enhancing the system's ability to correctly identify and handle wrapped errors.

proxyd/server.go (4)

372-372: Use errors.Is for consistent error handling.

This change aligns with the PR's objective to replace direct error comparisons with errors.Is(), enhancing error handling by correctly identifying wrapped errors.


372-372: Correct use of errors.Is for error handling.

The replacement of direct error comparisons with errors.Is() in this function is correctly implemented and improves the robustness of error handling.


372-372: Ensure consistent error handling with errors.Is.

The use of errors.Is() for error handling in batch processing aligns with the PR's objectives and enhances the robustness of the system.


372-372: Review for consistent error handling.

Ensure that the HandleWS function uses errors.Is() for error handling to maintain consistency across the server code.

Verification successful

The verification process has confirmed that the HandleWS function in proxyd/server.go does indeed use errors.Is() for error handling. Specifically, it is used to check if an error is of type ErrNoBackends in line 603. This aligns with the initial review comment suggesting the need for consistent error handling across server functions using errors.Is().

Here are the details:

  • File: proxyd/server.go
  • Function: HandleWS
  • Usage of errors.Is(): Yes, in line 603 to check for ErrNoBackends.

This confirms that the HandleWS function is consistent with the error handling strategy discussed in the review comment.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `HandleWS` uses `errors.Is` for error handling.

# Test: Search for error handling in `HandleWS`. Expect: Usage of `errors.Is`.
rg --type go $'HandleWS' | rg $'errors.Is'

Length of output: 38



Script:

#!/bin/bash
# Description: More comprehensive search for error handling in `HandleWS` function.
# This script searches for the function `HandleWS` and then checks for any error handling within that function.

# Step 1: Find the file containing the `HandleWS` function.
file_path=$(fd --type f --extension go 'server.go')

# Step 2: Extract the `HandleWS` function from the file.
ast-grep --lang go --pattern $'func (s *Server) HandleWS($_, $_) {
  $$$
}' $file_path

Length of output: 2563


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

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

Out of diff range and nitpick comments (2)
op-batcher/batcher/channel_builder.go (1)

332-332: Clarify error handling in outputFrame.

Consider adding a comment to explain why io.EOF is treated differently here, as it might not be immediately clear to other developers.

op-node/rollup/derive/batch_queue.go (1)

171-171: Clarify error handling in deriveNextBatch.

Consider adding a comment to explain why io.EOF is treated differently here, as it might not be immediately clear to other developers.

@@ -304,7 +304,7 @@ func (eq *EngineQueue) Step(ctx context.Context) error {
// Trying unsafe payload should be done before safe attributes
// It allows the unsafe head can move forward while the long-range consolidation is in progress.
if eq.unsafePayloads.Len() > 0 {
if err := eq.tryNextUnsafePayload(ctx); err != io.EOF {
if err := eq.tryNextUnsafePayload(ctx); !errors.Is(err, io.EOF) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for non-EOF errors in tryNextUnsafePayload.

-		if err := eq.tryNextUnsafePayload(ctx); !errors.Is(err, io.EOF) {
+		if err := eq.tryNextUnsafePayload(ctx); err != nil && !errors.Is(err, io.EOF) {
			return err
		}

The current implementation only handles the case where the error is not io.EOF, potentially missing other critical errors that should also halt the execution. The suggested change ensures that any error, except io.EOF, is properly handled.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if err := eq.tryNextUnsafePayload(ctx); !errors.Is(err, io.EOF) {
if err := eq.tryNextUnsafePayload(ctx); err != nil && !errors.Is(err, io.EOF) {
return err
}

@@ -331,7 +331,7 @@ func (eq *EngineQueue) Step(ctx context.Context) error {
if err := eq.tryFinalizePastL2Blocks(ctx); err != nil {
return err
}
if next, err := eq.prev.NextAttributes(ctx, eq.ec.PendingSafeL2Head()); err == io.EOF {
if next, err := eq.prev.NextAttributes(ctx, eq.ec.PendingSafeL2Head()); errors.Is(err, io.EOF) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Handle potential io.EOF error correctly in Step method.

-	if next, err := eq.prev.NextAttributes(ctx, eq.ec.PendingSafeL2Head()); errors.Is(err, io.EOF) {
+	if next, err := eq.prev.NextAttributes(ctx, eq.ec.PendingSafeL2Head()); err != nil {
+		if errors.Is(err, io.EOF) {
			return io.EOF
+		}
+		return err
	} else if err != nil {
		return err
	} else {

The original code does not handle other errors that might occur when fetching the next attributes. This change ensures that all errors are handled appropriately, not just io.EOF.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if next, err := eq.prev.NextAttributes(ctx, eq.ec.PendingSafeL2Head()); errors.Is(err, io.EOF) {
if next, err := eq.prev.NextAttributes(ctx, eq.ec.PendingSafeL2Head()); err != nil {
if errors.Is(err, io.EOF) {
return io.EOF
}
return err
} else if err != nil {
return err
} else {

@@ -260,7 +261,7 @@ func TestPlasmaDataSource(t *testing.T) {
break
}

for data, err := src.Next(ctx); err != io.EOF; data, err = src.Next(ctx) {
for data, err := src.Next(ctx); !errors.Is(err, io.EOF); data, err = src.Next(ctx) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The verification process has revealed that there are multiple instances across the codebase where error handling does not use the errors.Is() function, contrary to the best practices mentioned in the review comment. These instances are spread across various files and modules, indicating that the update to use errors.Is() for error comparison is not consistently applied throughout the project.

Locations needing attention:

  • proxyd/consensus_tracker.go
  • op-ufm/pkg/provider/roundtrip.go
  • op-ufm/pkg/provider/heartbeat.go
  • op-node/rollup/derive/engine_queue.go
  • op-node/rollup/derive/batch_queue_test.go
  • op-node/rollup/driver/sequencer_test.go
  • op-node/cmd/batch_decoder/reassemble/reassemble.go
  • op-e2e/e2eutils/*
  • op-conductor/conductor/service.go
  • op-challenger/game/scheduler/coordinator.go
  • op-chain-ops/cmd/op-simulate/main.go
  • op-batcher/batcher/*

These files contain direct comparisons of errors without using errors.Is(), which should be refactored to align with the updated error handling strategy.

Analysis chain

Use of errors.Is() for error comparison is a best practice in Go, especially for handling wrapped errors. Good implementation.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all instances of error handling in the project have been updated to use `errors.Is()`.

# Test: Search for direct error comparisons. Expect: No occurrences of direct error comparisons.
rg --type go '!errors.Is' --glob '*.go'

Length of output: 2982

@@ -300,7 +300,7 @@ func (c *ChannelBuilder) outputReadyFrames() error {
// When creating a frame from the ready compression data, the frame overhead
// will be added to the total output size, so we can add it in the condition.
for c.co.ReadyBytes()+derive.FrameV0OverHeadSize >= int(c.cfg.MaxFrameSize) {
if err := c.outputFrame(); err == io.EOF {
if err := c.outputFrame(); errors.Is(err, io.EOF) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling in outputReadyFrames.

- if err := c.outputFrame(); errors.Is(err, io.EOF) {
+ if err := c.outputFrame(); err != nil && !errors.Is(err, io.EOF) {

The original code does not handle errors that are not io.EOF. This change ensures that all errors are properly handled.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if err := c.outputFrame(); errors.Is(err, io.EOF) {
if err := c.outputFrame(); err != nil && !errors.Is(err, io.EOF) {

@@ -315,7 +315,7 @@ func (c *ChannelBuilder) closeAndOutputAllFrames() error {
}

for {
if err := c.outputFrame(); err == io.EOF {
if err := c.outputFrame(); errors.Is(err, io.EOF) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling in closeAndOutputAllFrames.

- if err := c.outputFrame(); errors.Is(err, io.EOF) {
+ if err := c.outputFrame(); err != nil && !errors.Is(err, io.EOF) {

Similar to the previous comment, this ensures that all errors are properly handled, not just io.EOF.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if err := c.outputFrame(); errors.Is(err, io.EOF) {
if err := c.outputFrame(); err != nil && !errors.Is(err, io.EOF) {

@@ -148,7 +148,7 @@ func (bq *BatchQueue) NextBatch(ctx context.Context, parent eth.L2BlockRef) (*Si

// Load more data into the batch queue
outOfData := false
if batch, err := bq.prev.NextBatch(ctx); err == io.EOF {
if batch, err := bq.prev.NextBatch(ctx); errors.Is(err, io.EOF) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling in NextBatch.

- if batch, err := bq.prev.NextBatch(ctx); errors.Is(err, io.EOF) {
+ if batch, err := bq.prev.NextBatch(ctx); err != nil && !errors.Is(err, io.EOF) {

This change ensures that all errors are properly handled, not just io.EOF.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if batch, err := bq.prev.NextBatch(ctx); errors.Is(err, io.EOF) {
if batch, err := bq.prev.NextBatch(ctx); err != nil && !errors.Is(err, io.EOF) {

return nil, false, io.EOF
} else if err == io.EOF {
} else if errors.Is(err, io.EOF) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling in deriveNextBatch.

- } else if errors.Is(err, io.EOF) {
+ } else if err != nil && !errors.Is(err, io.EOF) {

This ensures that all errors are properly handled, not just io.EOF.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
} else if errors.Is(err, io.EOF) {
} else if err != nil && !errors.Is(err, io.EOF) {

@@ -324,7 +324,7 @@ func TestSequencerChaosMonkey(t *testing.T) {
// reset errors
originErr = nil
attrsErr = nil
if engControl.err != mockResetErr { // the mockResetErr requires the sequencer to Reset() to recover.
if !errors.Is(engControl.err, mockResetErr) { // the mockResetErr requires the sequencer to Reset() to recover.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure consistent error handling in TestSequencerChaosMonkey.

- if !errors.Is(engControl.err, mockResetErr) {
+ if engControl.err != nil && !errors.Is(engControl.err, mockResetErr) {

This change ensures that all errors are properly handled, not just mockResetErr.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if !errors.Is(engControl.err, mockResetErr) { // the mockResetErr requires the sequencer to Reset() to recover.
if engControl.err != nil && !errors.Is(engControl.err, mockResetErr) { // the mockResetErr requires the sequencer to Reset() to recover.

Copy link

codecov bot commented May 11, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 42.31%. Comparing base (1a20fd9) to head (d5c5531).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #10502   +/-   ##
========================================
  Coverage    42.31%   42.31%           
========================================
  Files           73       73           
  Lines         4838     4838           
  Branches       766      766           
========================================
  Hits          2047     2047           
  Misses        2682     2682           
  Partials       109      109           
Flag Coverage Δ
cannon-go-tests 81.59% <50.00%> (ø)
chain-mon-tests 27.14% <ø> (ø)
common-ts-tests 26.72% <ø> (ø)
contracts-ts-tests 12.25% <ø> (ø)
core-utils-tests 44.03% <ø> (ø)
sdk-tests 40.27% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
cannon/mipsevm/memory.go 80.86% <100.00%> (ø)
cannon/mipsevm/page.go 66.21% <0.00%> (ø)

Copy link
Contributor

@protolambda protolambda left a comment

Choose a reason for hiding this comment

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

io.EOF is one of the few errors in Go where == is fine in my opinion, as it is a documented part of the API to return an EOF error, even in many standard-lib functions. It's not wrapped, since an internal function might return EOF, which means something different than the outer function returning EOF. While not pretty as-is, I don't think changing literally errors.Is improves the code, due to this difference in meaning. We should be documenting returned errors instead of slamming a errors.Is on everything blindly.

@trianglesphere
Copy link
Contributor

Ditto directly comparing errors to io.EOF is idiomatic.

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.

None yet

3 participants