Skip to content

Conversation

@m-Peter
Copy link
Collaborator

@m-Peter m-Peter commented Mar 12, 2025

Depends on: onflow/flow-emulator#803

Description

Updates the flow-go to include the newly-added EVM.dryCall & COA.dryCall functions, and adds an E2E test to verify they work as expected. That is, without creating any unnecessary EVM transactions and without committing any state changes.


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the standards mentioned here.
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

Summary by CodeRabbit

  • Chores
    • Upgraded key dependencies to ensure enhanced reliability and performance.
  • Tests
    • Added new comprehensive tests to verify EVM.dryCall and COA.dryCall functionalities, expanding coverage for contract interactions.
    • Introduced a new test case to validate the absence of transactions from EVM.dryCall and COA.dryCall functions.
    • Added a new test case for EVM.dryCall & COA.dryCall to ensure correct contract interactions.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2025

Walkthrough

This pull request updates several dependency versions in the Go module files and adds new test cases. The dependency updates affect packages from the onflow ecosystem, ensuring that the latest versions are used. Additionally, new tests have been introduced in both Go and JavaScript that focus on the dry call functionality of EVM and COA, verifying that state changes do not occur during these calls.

Changes

File(s) Change summary
go.mod, tests/go.mod Updated dependency versions for github.com/onflow/cadence, github.com/onflow/flow-go, github.com/onflow/flow-go-sdk, github.com/onflow/flow-core-contracts/lib/go/contracts, github.com/onflow/flow-core-contracts/lib/go/templates, github.com/onflow/flow/protobuf/go/flow, and github.com/onflow/flow-emulator.
tests/e2e_web3js_test.go Added a new test case (TestWeb3_E2E) testing the EVM.dryCall and COA.dryCall functionalities, including contract deployment and batch transaction verification.
tests/web3js/evm_dry_call_test.js Introduced a new test file that validates the absence of extra transactions from EVM.dryCall and COA.dryCall, checking block transactions and log structures.

Possibly related PRs

  • Update flow-go #612: The changes in the main PR are related to the updates of the github.com/onflow/flow-go dependency, which is also modified in the retrieved PR.
  • Update to Cadence v1.0.0-preview.50 #478: The changes in the main PR and the retrieved PR are related as both involve updates to the same dependencies in the go.mod file, specifically for github.com/onflow/cadence, github.com/onflow/flow-go, and github.com/onflow/flow-go-sdk.
  • Update to Cadence v1.0.0-preview.51 #502: The changes in the main PR and the retrieved PR are related as both involve updates to the same dependencies in the go.mod file, specifically github.com/onflow/cadence, github.com/onflow/flow-go, and github.com/onflow/flow-go-sdk, albeit at different version levels.

Suggested reviewers

  • peterargue
  • devbugging
  • zhangchiqing

Poem

I'm a bunny with a coding cheer,
Hopping through dependencies far and near.
Dry calls and tests make my heart skip a beat,
Each change is a carrot, so crunchy and sweet!
With every update, I dance in the glow,
In the world of code, together we grow!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3af4f6a and 053f977.

⛔ Files ignored due to path filters (2)
  • go.sum is excluded by !**/*.sum
  • tests/go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • go.mod (2 hunks)
  • tests/e2e_web3js_test.go (1 hunks)
  • tests/go.mod (2 hunks)
  • tests/web3js/evm_dry_call_test.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/web3js/evm_dry_call_test.js
  • tests/go.mod
  • go.mod
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Test
🔇 Additional comments (1)
tests/e2e_web3js_test.go (1)

238-345: Well-structured test for EVM.dryCall & COA.dryCall functionality!

This test effectively verifies that dry calls don't modify contract state by:

  1. Setting up the contract with an initial value (42)
  2. Attempting to change the value using dry calls (to 1453 and 1515)
  3. Verifying the original value remains unchanged after each call

The test covers both direct EVM dry calls and Cadence-owned account dry calls, ensuring comprehensive coverage of the functionality. The proper cleanup of the created COA account is also handled appropriately.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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

🧹 Nitpick comments (2)
tests/web3js/evm_dry_call_test.js (1)

1-57: Well-structured test for verifying dry calls don't generate transactions.

The test effectively verifies that EVM.dryCall and COA.dryCall operations don't generate transactions or change state by checking the block content and transaction count.

Consider making the test more maintainable by reducing hardcoded values:

- assert.equal(receipt.contractAddress, '0x99A64c993965f8d69F985b5171bC20065Cc32fAB')
+ const expectedContractAddress = '0x99A64c993965f8d69F985b5171bC20065Cc32fAB'
+ assert.equal(receipt.contractAddress, expectedContractAddress)

This approach would make it easier to update if contract addresses change, especially when used multiple times in the test.

tests/e2e_web3js_test.go (1)

238-345: Comprehensive test case for verifying dry call functionality.

This test effectively verifies that both EVM.dryCall and COA.dryCall don't modify state by checking the returned value remains unchanged after attempting to update it.

Consider refactoring the duplicate code patterns for testing EVM.dryCall and COA.dryCall. Both sections have similar verification logic that could be extracted:

+ func verifyDryCallDoesNotChangeState(t *testing.T, emu emulator.Emulator, script string, expectedValue int) {
+     res, err := flowSendTransaction(emu, script)
+     require.NoError(t, err)
+     require.NoError(t, res.Error)
+ }

// Then call this helper function with appropriate scripts for EVM.dryCall and COA.dryCall

This would reduce duplication and make the test more maintainable.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2106e51 and 522a8da.

⛔ Files ignored due to path filters (2)
  • go.sum is excluded by !**/*.sum
  • tests/go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • go.mod (2 hunks)
  • tests/e2e_web3js_test.go (1 hunks)
  • tests/go.mod (3 hunks)
  • tests/web3js/evm_dry_call_test.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Lint
🔇 Additional comments (4)
tests/go.mod (1)

7-7: Dependency updates look good.

The updated versions of key dependencies are necessary to support the new EVM.dryCall and COA.dryCall functionality being tested in this PR. The updated packages include Cadence, Flow-Go, Flow-Go-SDK, and various Flow core contracts.

Also applies to: 11-12, 154-155, 160-160, 254-254

go.mod (1)

10-12: Dependency updates align with the testing requirements.

The updates to Cadence, Flow-Go, Flow-Go-SDK and other dependencies are consistent with the changes in tests/go.mod and support the new functionality being tested.

Also applies to: 144-145, 150-150

tests/e2e_web3js_test.go (2)

294-314: Good assertion of state persistence after EVM.dryCall.

The test clearly verifies that EVM.dryCall to modify the contract state with storeWithLog(1453) doesn't actually change the state, as the retrieved value remains 42.


316-336: Good verification of COA.dryCall behavior.

The test effectively demonstrates that COA.dryCall with storeWithLog(1515) doesn't change the contract state, maintaining the value at 42. Also correctly handles the resource cleanup with destroy.

@m-Peter m-Peter force-pushed the mpeter/test-evm-dry-call branch from 522a8da to 3af4f6a Compare March 17, 2025 14:53
@m-Peter m-Peter force-pushed the mpeter/test-evm-dry-call branch from 3af4f6a to 053f977 Compare April 7, 2025 08:03
@m-Peter m-Peter merged commit 948ce6e into main Apr 7, 2025
2 checks passed
@m-Peter m-Peter deleted the mpeter/test-evm-dry-call branch April 7, 2025 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants