optimism icon indicating copy to clipboard operation
optimism copied to clipboard

cannon: Finish emulating rest of 64-bit instructions

Open Inphi opened this issue 1 year ago • 2 comments

This completes 64-bit instruction execution (except lld/scd which is handled separately).

Testing

  • Differential tests for non-trivial 32-bit instructions asserting backwards compatibility.
  • Added new tests for 64-bit instructions (except lld/scd).
  • Fuzz tests for dmult

These tests are only run on by the 64-bit VM. So they do not run on CI, except for the dmult fuzz test which is executed by the fuzz-golang job.

Meta

Fixes #12243 and #12248.

Inphi avatar Oct 16 '24 14:10 Inphi

Semgrep found 6 sol-style-input-arg-fmt findings:

Inputs to functions must be prepended with an underscore (_)

Ignore this finding from sol-style-input-arg-fmt.

Semgrep found 1 golang_fmt_errorf_no_params finding:

  • op-supervisor/supervisor/backend/db/db_test.go

No fmt.Errorf invocations without fmt arguments allowed

Ignore this finding from golang_fmt_errorf_no_params.

Semgrep found 1 math-random-used finding:

  • op-supervisor/supervisor/backend/source/head_monitor_test.go

Do not use math/rand. Use crypto/rand instead.

Ignore this finding from math-random-used.

Semgrep found 1 marshal-json-pointer-receiver finding:

  • op-supervisor/supervisor/backend/db/heads/types.go

MarshalJSON with a pointer receiver has surprising results: https://github.com/golang/go/issues/22967

Ignore this finding from marshal-json-pointer-receiver.

Semgrep found 1 err-nil-check finding:

superfluous nil err check before return

Ignore this finding from err-nil-check.

semgrep-app[bot] avatar Oct 16 '24 14:10 semgrep-app[bot]

Codecov Report

Attention: Patch coverage is 19.81132% with 85 lines in your changes missing coverage. Please review.

Project coverage is 63.79%. Comparing base (f6ca236) to head (8fb303e). Report is 30 commits behind head on develop.

Files with missing lines Patch % Lines
cannon/mipsevm/exec/mips_instructions.go 19.81% 79 Missing and 6 partials :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #12483      +/-   ##
===========================================
- Coverage    64.86%   63.79%   -1.08%     
===========================================
  Files           54       54              
  Lines         4460     4538      +78     
===========================================
+ Hits          2893     2895       +2     
- Misses        1391     1461      +70     
- Partials       176      182       +6     
Flag Coverage Δ
cannon-go-tests 63.79% <19.81%> (-1.08%) :arrow_down:

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

Files with missing lines Coverage Δ
cannon/mipsevm/exec/mips_instructions.go 64.89% <19.81%> (-9.30%) :arrow_down:

codecov[bot] avatar Oct 16 '24 14:10 codecov[bot]

Semgrep found 1 sol-style-require-reason finding:

  • packages/contracts-bedrock/src/L2/SuperchainWETH.sol

require() must include a reason string

Ignore this finding from sol-style-require-reason.

Semgrep found 1 sol-style-notice-over-dev-natspec finding:

  • packages/contracts-bedrock/src/cannon/interfaces/IPreimageOracle.sol

Prefer @notice over @dev in natspec comments

Ignore this finding from sol-style-notice-over-dev-natspec.

Semgrep found 5 sol-style-input-arg-fmt findings:

Inputs to functions must be prepended with an underscore (_)

Ignore this finding from sol-style-input-arg-fmt.

Semgrep found 8 golang_fmt_errorf_no_params findings:

No fmt.Errorf invocations without fmt arguments allowed

Ignore this finding from golang_fmt_errorf_no_params.

semgrep-app[bot] avatar Oct 22 '24 07:10 semgrep-app[bot]

@mbaxter I fixed a bug in dmult. And I've removed the dmult fuzz tests in favor of more static tests. I couldn't figure out a way to reimplement dmult correctly using the Go std library. At least not without copying the implementation used by mipsevm, which defeats the purpose of the fuzz test.

I have verified the expected dmult behavior using user-mode qemu like I mentioned earlier. All static test cases were written based off the results of qemu-mips. Please let me know if there are any more interesting cases you'd like me to add.

Inphi avatar Oct 22 '24 07:10 Inphi

Semgrep found 1 no-direct-write-to-responsewriter finding:

  • op-challenger/game/fault/trace/prestates/multi_test.go

Detected directly writing or similar in 'http.ResponseWriter.write()'. This bypasses HTML escaping that prevents cross-site scripting vulnerabilities. Instead, use the 'html/template' package and render data using 'template.Execute()'.

Ignore this finding from no-direct-write-to-responsewriter.

Semgrep found 1 no-direct-write-to-responsewriter-taint finding:

  • op-challenger/game/fault/trace/prestates/multi_test.go

Untrusted input could be used to tamper with a web page rendering, which can lead to a Cross-site scripting (XSS) vulnerability. XSS vulnerabilities occur when untrusted input executes malicious JavaScript code, leading to issues such as account compromise and sensitive information leakage. To prevent this vulnerability, validate the user input, perform contextual output encoding or sanitize the input. For more information, see: Go XSS prevention.

View Dataflow Graph
flowchart LR
    classDef invis fill:white, stroke: none
    classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none

    subgraph File0["<b>op-challenger/game/fault/trace/prestates/multi_test.go</b>"]
        direction LR
        %% Source

        subgraph Source
            direction LR

            v0["<a href=https://github.com/ethereum-optimism/optimism/blob/498a36def44ac54d68189319fff89cc45994414b/op-challenger/game/fault/trace/prestates/multi_test.go#L194 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 194] r.URL</a>"]
        end
        %% Intermediate

        %% Sink

        subgraph Sink
            direction LR

            v1["<a href=https://github.com/ethereum-optimism/optimism/blob/498a36def44ac54d68189319fff89cc45994414b/op-challenger/game/fault/trace/prestates/multi_test.go#L194 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 194] w.Write([]byte(r.URL.Path))</a>"]
        end
    end
    %% Class Assignment
    Source:::invis
    Sink:::invis

    File0:::invis

    %% Connections

    Source --> Sink

Ignore this finding from no-direct-write-to-responsewriter-taint.

semgrep-app[bot] avatar Oct 23 '24 19:10 semgrep-app[bot]


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>, 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 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.

coderabbitai[bot] avatar Oct 23 '24 22:10 coderabbitai[bot]

Semgrep found 1 ban_non_wraparound_modifiers finding:

  • packages/contracts-bedrock/src/L2/SuperchainERC20.sol

Modifiers that don't do something before and after execution are banned.

Ignore this finding from ban_non_wraparound_modifiers.

semgrep-app[bot] avatar Oct 23 '24 22:10 semgrep-app[bot]