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

Update to Cadence v1.2.1 #623

Merged
merged 7 commits into from
Oct 23, 2024
Merged

Update to Cadence v1.2.1 #623

merged 7 commits into from
Oct 23, 2024

Conversation

turbolent
Copy link
Member

@turbolent turbolent commented Oct 22, 2024

Description

Automatically update to:

Summary by CodeRabbit

  • New Features
    • Added a new dependency for NFT storefront contracts.
  • Improvements
    • Updated multiple dependencies to their latest versions for enhanced performance and compatibility.
    • Enhanced test flexibility by using dynamic block height calculations in various test cases.
    • Improved configuration consistency by updating string formatting and initial block height settings.
  • Bug Fixes
    • Adjusted import paths to ensure proper functionality of event subscription mechanisms.
    • Improved error handling and assertions in filter endpoint tests for better reliability.

Copy link
Contributor

coderabbitai bot commented Oct 22, 2024

Walkthrough

The pull request includes updates to the go.mod files across multiple modules, focusing on dependency version upgrades. Key dependencies such as github.com/onflow/cadence, github.com/onflow/flow-go, and github.com/onflow/flow-go-sdk have been updated to newer versions. Additionally, the services/ingestion/subscriber.go file has modified the import path for the common package, affecting how it is referenced in the code. The overall structure and functionality of the affected files remain unchanged.

Changes

File(s) Change Summary
go.mod (root module) Updated dependencies: github.com/onflow/atree, github.com/onflow/cadence, github.com/onflow/flow-go, github.com/onflow/flow-go-sdk, github.com/onflow/flow-core-contracts, github.com/onflow/flow-ft, github.com/onflow/flow-nft with various version changes.
services/ingestion/subscriber.go Changed import path from github.com/onflow/cadence/runtime/common to github.com/onflow/cadence/common.
tests/go.mod Updated dependencies: github.com/onflow/cadence, github.com/onflow/flow-emulator, github.com/onflow/flow-go, github.com/onflow/flow-go-sdk, github.com/onflow/atree, github.com/onflow/flow-core-contracts, github.com/onflow/flow-ft, github.com/onflow/flow-nft, and added github.com/onflow/nft-storefront.
tests/integration_test.go Added constant startingBlockHeight set to 3 and updated assertions in Test_EthClientTest.
tests/web3js/build_evm_state_test.js Updated expected block heights to be dynamic based on transaction counts instead of hardcoded values.
tests/web3js/config.js Changed string formatting to single quotes and updated startBlockHeight from 2n to 3n.
tests/web3js/eth_filter_endpoints_test.js Added new assertions for eth_getFilterChanges and eth_getFilterLogs methods, improving error handling.
tests/web3js/eth_non_interactive_test.js Updated assertions and parameters for block number consistency and response structure in tests.
tests/web3js/eth_revert_reason_test.js Updated string literals to single quotes and adjusted block number assertions to use dynamic references.

Possibly related PRs

Suggested labels

Improvement, EVM

Suggested reviewers

  • zhangchiqing
  • peterargue
  • janezpodhostnik

Poem

🐇 In the code, we hop and play,
Dependencies updated, hip-hip-hooray!
With cadence and flow, we dance in delight,
New versions are here, everything feels right!
So let’s code and create, with joy in our hearts,
For every small change, a new journey starts! 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f4763b1 and 347b5a1.

⛔ Files ignored due to path filters (1)
  • tests/go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • tests/integration_test.go (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
tests/integration_test.go (2)

193-194: LGTM: Proper context usage for BlockNumber call.

The context is correctly created and used for the BlockNumber call.


197-197: LGTM: Improved test robustness with dynamic block number.

The test now correctly uses the actual block number instead of a hardcoded value, making it more maintainable and reliable.

Also applies to: 199-199


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.

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

🧹 Outside diff range and nitpick comments (3)
tests/web3js/eth_revert_reason_test.js (1)

7-7: Avoid unrelated style changes in dependency update PRs.

The change from double quotes to single quotes is purely cosmetic and unrelated to the Cadence upgrade. Consider reverting this change to maintain focus on the dependency updates.

tests/integration_test.go (1)

197-201: Document the block height offset.

While using startingBlockHeight improves maintainability, the +2 offset in the assertions is not documented. Consider adding a comment explaining why we expect the block number to be startingBlockHeight + 2 to help future maintainers understand the test's assumptions.

Example comment:

+ // We expect blockNumber to be startingBlockHeight + 2 because:
+ // 1. One block is created during emulator startup
+ // 2. Another block is created during COA resource deployment
 assert.Equal(t, uint64(startingBlockHeight+2), blockNumber)
tests/web3js/eth_non_interactive_test.js (1)

Line range hint 211-215: Document the Flow-to-EVM transaction signature mapping scheme.

The structured pattern in signature values across transactions suggests a deterministic mapping scheme from Flow to EVM transactions. Consider adding documentation explaining this scheme.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c9f3d95 and f4763b1.

📒 Files selected for processing (6)
  • tests/integration_test.go (2 hunks)
  • tests/web3js/build_evm_state_test.js (4 hunks)
  • tests/web3js/config.js (1 hunks)
  • tests/web3js/eth_filter_endpoints_test.js (2 hunks)
  • tests/web3js/eth_non_interactive_test.js (4 hunks)
  • tests/web3js/eth_revert_reason_test.js (3 hunks)
🧰 Additional context used
🔇 Additional comments (14)
tests/web3js/config.js (2)

2-2: LGTM: String formatting changes are consistent with modern JS practices.

The switch to single quotes for strings is a common JavaScript convention and improves consistency.

Also applies to: 6-6


8-9: Please verify the block height increment's compatibility.

The startBlockHeight has been increased from 2n to 3n. While this change is reflected across test files, we should verify if this increment is specifically required by the Cadence v1.2.1 upgrade.

Let's check for any related changes or requirements:

tests/web3js/eth_revert_reason_test.js (2)

80-80: LGTM! Block height calculation is correct.

The change to conf.startBlockHeight + 3n correctly accounts for:

  1. The initial block
  2. The contract deployment transaction
  3. The assert error transaction
  4. The custom error transaction

46-46: LGTM! Verify block height calculation.

The change to use dynamic block height references makes the test more robust. However, please verify that the offset of +2n accounts for:

  1. The initial block
  2. The contract deployment transaction
  3. The assert error transaction
✅ Verification successful

Let me gather more context about the test file to understand the transaction flow better.


After analyzing the test file content, I can now generate the final response since I have enough context to verify the block height calculation.

Block height calculation is correct and verified

The offset of +2n in conf.startBlockHeight + 2n is accurate because the test performs exactly two transactions before this assertion:

  1. Contract deployment transaction (helpers.deployContract('storage'))
  2. Assert error transaction (eth_sendRawTransaction with assertErrorTx)

This is further validated by the subsequent test section that uses +3n after executing one more transaction (the custom error test).

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the block height calculation logic in other test files
rg -A 2 "startBlockHeight.*[+].*2n" tests/

Length of output: 298


Script:

#!/bin/bash
# Check the full test file content to understand the transaction sequence
cat tests/web3js/eth_revert_reason_test.js

# Also search for any other block number assertions in tests
rg "block.number" tests/

Length of output: 7019

tests/integration_test.go (1)

28-28: LGTM! Good constant extraction.

The introduction of startingBlockHeight constant improves maintainability by removing magic numbers and centralizing the configuration of the starting block height.

tests/web3js/build_evm_state_test.js (5)

9-10: LGTM: Improved test maintainability with dynamic block height tracking.

Good change to initialize block height from configuration instead of hardcoding. This makes the test more maintainable and flexible across different environments.


41-43: LGTM: Well-documented block height calculation.

Good addition of comments explaining the block height increment logic. The assertion correctly verifies the blockchain state after EOA transactions.

Also applies to: 49-49


92-94: LGTM: Clear documentation of block height progression.

Good explanation of the 60-block increment resulting from 20 EOAs performing 3 transfers each. The assertion correctly validates the blockchain state.

Also applies to: 97-97


143-145: LGTM: Accurate block height tracking after contract operations.

Good documentation of the 60-block increment resulting from contract deployments (20), store operations (20), and sum operations (20). The assertion correctly validates the final blockchain state.

Also applies to: 148-148


Line range hint 153-158: Verify historical block number references.

The test uses hardcoded block numbers (82n) for historical state verification. Consider updating these to use dynamic block height calculations for consistency with the rest of the changes.

Consider refactoring the historical block number references to use calculated values:

-    }, 82n)
+    }, expectedBlockHeight - 60n) // Calculate based on the known number of transactions

Also applies to: 171-174, 182-185

tests/web3js/eth_non_interactive_test.js (3)

317-317: Verify block height changes across the codebase.

The block height has been updated from 2 to 3. This change should be consistent with other test files and configurations.

#!/bin/bash
# Search for other occurrences of block heights in test files
rg -A 1 "startBlockHeight.*[23]" --type js tests/
rg "0x[23].*block" --type js tests/

Also applies to: 330-330


206-210: Verify the non-standard ECDSA signature values.

The transaction signature components have non-standard values:

  • v = 0xff (typical Ethereum values are 27/28)
  • r and s have very structured values

Please verify if these values are intentionally set this way for Flow-to-EVM transaction mapping.


381-383: Verify fee history changes with Cadence v1.2.1.

The fee history response now includes an additional block entry. Please verify if this change is:

  1. Required by the Cadence v1.2.1 upgrade
  2. Related to the block height changes
  3. Consistent with the Flow emulator v1.1.0 behavior
tests/web3js/eth_filter_endpoints_test.js (1)

393-393: Block number updates align with configuration changes.

The block number updates from '0xc' (12) to '0xd' (13) in the transaction assertions are consistent with the related changes in config.js where startBlockHeight was updated from 2n to 3n. This maintains the test's integrity with the broader configuration updates.

Let's verify the block height configuration changes:

Also applies to: 413-413

Copy link
Collaborator

@m-Peter m-Peter left a comment

Choose a reason for hiding this comment

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

LGTM! 💯

@turbolent turbolent merged commit aff0b0e into main Oct 23, 2024
2 checks passed
@turbolent turbolent deleted the auto-update-onflow-cadence-v1.2.1 branch October 23, 2024 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

4 participants