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

Add EVM-native cross-vm NFT interfaces & custom cross-vm registration support #173

Merged
merged 65 commits into from
Mar 21, 2025

Conversation

sisyphusSmiling
Copy link
Contributor

@sisyphusSmiling sisyphusSmiling commented Feb 22, 2025

Closes: #167 #144 #145 #146

Description

  • Adds a types contract to define types required for EVM-native cross-VM NFTs and data structures used in the new custom config contract
  • Implements a custom config contract tasked with retaining and serving custom associations
  • Adds an EVM-native cross-VM NFT implementation for testing and demonstration purposes
  • Adds a Cadence-native cross-VM NFT implementation for testing and demonstration purposes
  • Updates the legacy onboarding path to detect a cross-VM NFT, passing through to registerCrossVMNFT if detected. Note that EVM-native cross-VM NFTs which require an NFTFulfillmentMinter Capability will revert on permissionless onboarding. This is viewed as preferential to onboarding via the permissionless path and later requiring an custom association as cross-VM conformance clearly indicates an intention by the project to onboard as a cross-VM NFT.
  • Updates the central bridge contract to allow for registration of custom cross-VM NFT associations. This supports the registration of net new contracts as well as those previously onboarded to the bridge in a permissionless manner.
  • Test cases to cover registration of net-new EVM- and Cadence-native NFTs as well as updating from bridged to custom cross-VM NFTs
  • Notably, pausing by type and EVM address (Wire in un/pause & un/block functionality for custom associations #172) is not included in this PR as it's already large enough. This functionality will follow in a subsequent PR.

For contributor use:

  • Targeted PR against main 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

@sisyphusSmiling sisyphusSmiling changed the base branch from main to gio/remove-erc721addr-from-locker March 7, 2025 19:19
@sisyphusSmiling sisyphusSmiling self-assigned this Mar 7, 2025
Base automatically changed from gio/remove-erc721addr-from-locker to flip-318 March 7, 2025 19:38
@joshuahannan
Copy link
Member

@sisyphusSmiling Can you also make sure that you pull the latest changes from main into your branches? Just want to make sure everything is up to date and that we include the new contracts in the go package

Copy link
Member

@joshuahannan joshuahannan left a comment

Choose a reason for hiding this comment

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

Most of the contract code looks good! I'll do another pass on the contracts and tests once you've finished writing all the tests


access(all)
fun testRegisterAgainFails() {
Test.reset(to: snapshot)
Copy link
Member

Choose a reason for hiding this comment

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

Just another comment to save code. Maybe we could take a snapshot after we register in the previous test also and then just reset to that so we don't have to copy all the same code here

Comment on lines +388 to +391
var addrRequiresOnboarding = evmAddressRequiresOnboarding(erc721AddressHex)
?? panic("Problem getting onboarding requirement by address")
var typeRequiresOnboarding = typeRequiresOnboardingByIdentifier(exampleCadenceNativeNFTIdentifier)
?? panic("Problem getting onboarding requirement by identifier")
Copy link
Member

Choose a reason for hiding this comment

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

Where was the custom erc721 contract deployed? I'm not seeing it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ERC721 bytecode is passed on deployment of the ExampleCadenceNativeNFT contract and deployed within that contract's init.

Copy link
Member

Choose a reason for hiding this comment

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

It seems like you are still working on adding more test cases, so I assume you were planning on adding these, but it would be nice to have a test case for each pre-condition and assertion in the register cross-vm nft function. A few examples are verifying that the type checks work for non-NFTs, trying to update a bridge-defined contract, trying to register contracts that don't actually point to each other from either side, or trying to register a cross-VM nft for a cadence contract that has been deployed but the solidity contract has not been configured properly, but there are probably more

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI the commented test cases are included as a TODO when I pick up #149 and #150

Copy link
Member

Choose a reason for hiding this comment

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

Similar comments as the cadence native tests. Seems like there are a decent amount more edge cases to test, but I'm sure you're planning on getting to it

@sisyphusSmiling sisyphusSmiling force-pushed the gio/add-evm-native-interfaces branch from 3f8b8f6 to 2e3245a Compare March 19, 2025 18:17
Copy link
Member

@joshuahannan joshuahannan left a comment

Choose a reason for hiding this comment

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

Looks pretty good! Looks like CI is failing because of github diff, so that should hopefully be easy to fix

@joshuahannan
Copy link
Member

oh, also can you add the new contracts to the templates package and add tests for them in templates_test.go?

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 53.77644% with 153 lines in your changes missing coverage. Please review.

Please upload report for BASE (flip-318@53610ef). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...e-assets/cross-vm-nfts/ExampleCadenceNativeNFT.cdc 30.10% 65 Missing ⚠️
...ample-assets/cross-vm-nfts/ExampleEVMNativeNFT.cdc 37.11% 61 Missing ⚠️
...cts/bridge/FlowEVMBridgeCustomAssociationTypes.cdc 52.38% 10 Missing ⚠️
cadence/contracts/bridge/FlowEVMBridgeUtils.cdc 86.66% 6 Missing ⚠️
...ntracts/bridge/FlowEVMBridgeCustomAssociations.cdc 70.58% 5 Missing ⚠️
cadence/contracts/bridge/FlowEVMBridge.cdc 95.45% 2 Missing ⚠️
...adence/contracts/bridge/FlowEVMBridgeNFTEscrow.cdc 50.00% 2 Missing ⚠️
.../tests/contracts/MaliciousNFTFulfillmentMinter.cdc 50.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             flip-318     #173   +/-   ##
===========================================
  Coverage            ?   79.13%           
===========================================
  Files               ?       23           
  Lines               ?     1337           
  Branches            ?        0           
===========================================
  Hits                ?     1058           
  Misses              ?      279           
  Partials            ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sisyphusSmiling
Copy link
Contributor Author

sisyphusSmiling commented Mar 21, 2025

@joshuahannan updated go package files in c922464 and ba61ad3 and I got CI passing

@sisyphusSmiling sisyphusSmiling merged commit 0894a3b into flip-318 Mar 21, 2025
2 checks passed
@sisyphusSmiling sisyphusSmiling deleted the gio/add-evm-native-interfaces branch March 21, 2025 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Define CrossVMBridgeFullfillmentMinter resource interface
3 participants