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 faulty corpus transaction detection #1184

Merged
merged 2 commits into from Feb 2, 2024
Merged

Fix faulty corpus transaction detection #1184

merged 2 commits into from Feb 2, 2024

Conversation

arcz
Copy link
Member

@arcz arcz commented Feb 2, 2024

NoCalls form corpus shouldn't be checked for destination. Long term, fix the Tx type so NoCall doesn't have unnecessary fields.

Summary by CodeRabbit

  • Refactor
    • Improved the transaction filtering process in the campaign functionality to enhance the selection of potentially faulty transactions by excluding specific non-relevant transactions.
  • Refactor
    • Altered the execution flow within the execTxWith function to handle NoCall cases separately, affecting the return value based on the transaction's call type.
  • Refactor
    • Modified the setupTx function in transactions to exclude the loadContract call for transactions with NoCall, impacting the setup logic for transactions.

Copy link

coderabbitai bot commented Feb 2, 2024

Walkthrough

The recent updates across multiple files in the Echidna library refine transaction handling by distinguishing and treating NoCall transactions differently. These changes collectively enhance the logic flow and processing efficiency by ensuring that transactions without meaningful calls are appropriately filtered and managed, streamlining the code's behavior for improved reliability.

Changes

File(s) Summary
lib/Echidna/Campaign.hs, lib/Echidna/Exec.hs Refinement in handling NoCall transactions by filtering them out and adjusting execution based on call presence.
lib/Echidna/Transaction.hs Removed loadContract call in setupTx for NoCall transactions, altering setup logic flow.

🐰✨
In the code's dance, a change so bright,
NoCall filtered in the moon's soft light.
Transactions now with purpose alight,
Echidna's logic, now pure and right.
🌙🐾

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1d0c937 and 8ecf7b9.
Files selected for processing (1)
  • lib/Echidna/Campaign.hs (1 hunks)
Additional comments: 2
lib/Echidna/Campaign.hs (2)
  • 71-73: The modification to filter out NoCall transactions before proceeding with fault detection based on destination addresses is a targeted and effective solution to the issue described in the PR objectives. This change ensures that transactions inherently lacking a relevant destination are not improperly flagged as faulty, aligning with the intended behavior for NoCall transactions.
  • 71-73: While the current filter effectively excludes NoCall transactions from fault detection based on destination addresses, it's important to ensure that this change does not inadvertently exclude transactions that should be subject to other forms of fault detection. Confirm that all other relevant checks and balances within the replayCorpus function and related transaction handling logic remain intact and effective.

Comment on lines +71 to +73
let maybeFaultyTx =
List.find (\tx -> LitAddr tx.dst `notElem` Map.keys vm.env.contracts) $
List.filter (\case Tx { call = NoCall } -> False; _ -> True) txSeq
Copy link

Choose a reason for hiding this comment

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

Given the PR's mention of a future, more comprehensive fix to the Tx type to eliminate unnecessary fields for NoCall transactions, it's crucial to ensure that this temporary solution is revisited and potentially revised to align with those future changes. This will help maintain the integrity and efficiency of the transaction handling process in the long term.

Would you like to create a follow-up task or issue to revisit this logic once the comprehensive Tx type changes are implemented?

Copy link

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8ecf7b9 and 3205428.
Files selected for processing (2)
  • lib/Echidna/Exec.hs (1 hunks)
  • lib/Echidna/Transaction.hs (1 hunks)
Additional comments: 4
lib/Echidna/Transaction.hs (2)
  • 161-166: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [90-90]

The modification to exclude loadContract for NoCall transactions in setupTx aligns with the PR's objective to refine transaction handling by not setting up unnecessary contract loads for NoCall transactions. This change is logically sound and improves performance by avoiding redundant operations.

  • 161-166: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [90-90]

Ensure that the exclusion of loadContract for NoCall transactions does not inadvertently affect the VM's state in a way that could impact the execution of subsequent transactions. This is particularly relevant in scenarios where the state modified by resetState and other operations in setupTx is expected to be further altered by loadContract.

lib/Echidna/Exec.hs (2)
  • 90-97: The addition of a conditional case to handle NoCall transactions by returning a default value in execTxWith is a logical extension of the PR's objective to refine transaction handling. This ensures that NoCall transactions are processed efficiently without unnecessary execution steps, aligning with the goal of optimizing the transaction execution flow.
  • 90-97: While the handling of NoCall transactions with a default return value is appropriate, it's important to confirm that this approach does not bypass any critical gas accounting or event tracing mechanisms that might be expected to run even for NoCall transactions. This is to ensure that the system's integrity and observability are maintained across all transaction types.

@arcz arcz merged commit f641d1a into master Feb 2, 2024
18 checks passed
@arcz arcz deleted the fix-corpus-checking branch February 2, 2024 17:11
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

1 participant