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 special case FungibleToken handler #46

Merged
merged 19 commits into from
Apr 26, 2024

Conversation

sisyphusSmiling
Copy link
Contributor

@sisyphusSmiling sisyphusSmiling commented Apr 23, 2024

Closes: #26
Stacked on: #39

⚠️ This is a breaking change and will require an updated deployment due to added fields


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

@sisyphusSmiling sisyphusSmiling force-pushed the add-special-case-handler branch from 031e03b to d2c8366 Compare April 23, 2024 17:02
@codecov-commenter
Copy link

codecov-commenter commented Apr 23, 2024

Codecov Report

Attention: Patch coverage is 92.06349% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 85.34%. Comparing base (428634e) to head (669a80f).
Report is 11 commits behind head on main.

Files Patch % Lines
cadence/contracts/bridge/FlowEVMBridgeConfig.cdc 83.78% 6 Missing ⚠️
...ontracts/bridge/FlowEVMBridgeHandlerInterfaces.cdc 87.50% 2 Missing ⚠️
cadence/contracts/bridge/FlowEVMBridgeHandlers.cdc 95.65% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #46      +/-   ##
==========================================
+ Coverage   82.88%   85.34%   +2.45%     
==========================================
  Files          18       18              
  Lines         818      812       -6     
==========================================
+ Hits          678      693      +15     
+ Misses        140      119      -21     

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

@sisyphusSmiling sisyphusSmiling marked this pull request as ready for review April 23, 2024 22:54
@sisyphusSmiling sisyphusSmiling requested a review from a team as a code owner April 23, 2024 22:54
Base automatically changed from evm-updates to main April 24, 2024 16:31
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.

just a few comments to start out

///
/// This contract defines the interfaces for the FlowEVM Bridge Handlers. These Handlers are intended to encapsulate
/// the logic for bridging edge case assets between Cadence and EVM and require configuration by the bridge account to
/// enable. Contracts implementing these resources should be deployed to the bridge account so that privileged methods,
Copy link
Member

Choose a reason for hiding this comment

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

It sounds to me like you're saying here that a contract like FiatToken would have to be deployed to the bridge account to be compatible. Is that true? I don't think that will be possible since these are already deployed to other accounts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. No, the existence of handler assumes the contract is not deployed to the bridge. Rather, what I mean by Contracts implementing these resources should be deployed to the bridge account is that contracts implementing the *Handler* interfaces should be deployed to the bridge. Concretely, FlowEVMBridgeHandlers is one such contract.

/// The Minter enabling minting of Cadence tokens on fulfillment from EVM
access(self) let minter: @{FlowEVMBridgeHandlerInterfaces.TokenMinter}

init(targetType: Type, targetEVMAddress: EVM.EVMAddress?, minter: @{FlowEVMBridgeHandlerInterfaces.TokenMinter}) {
Copy link
Member

Choose a reason for hiding this comment

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

I think that it would be better if the minter resource could just be sent via a public function in a public capability, like addMinterCapability() and it would check to see that the type and such are correct so that people can't sent junk minters to it. That way, the minter can be sent trustlessly, which I think will be important for some of these projects

Copy link
Contributor Author

@sisyphusSmiling sisyphusSmiling Apr 24, 2024

Choose a reason for hiding this comment

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

That's a good idea. So do something like add an expectedMinterType on init instead of the minter itself and confirm that the minter added in addMinterCapability is the expected type?

Alternatively, we could entitle the addMinterCapability and publish a private Capability to the minter provider so they can privately insert the minter. It closes the loop a bit more but does require a bit more coordination.

I like that either option gives us the ability to reserve a handler for a given type without first needing a minter resource.

Copy link
Member

Choose a reason for hiding this comment

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

I like the option that requires the least coordination, so I think just it being a public function that checks the minter type is sufficient

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to address in 3f5d19e


/// Minter interface for configurations requiring the minting of Cadence fungible tokens
///
access(all) resource interface TokenMinter {
Copy link
Member

Choose a reason for hiding this comment

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

So in a contract that wants to be supported here, all they would have to do is have their minter resource implement this interface?

If we expect this implementation to happen as part of the cadence 1.0 upgrade, we need to deploy this interface on all the networks before then so the migrations work properly

Copy link
Contributor Author

@sisyphusSmiling sisyphusSmiling Apr 24, 2024

Choose a reason for hiding this comment

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

Yeah, I didn't see a way around it if we want to store minters with specific interface guarantees. My thought was that we would deploy this contract after the migration and any implementers would then update their contracts, but that feels cumbersome...

Maybe we could deploy this contract with just the TokenMinter interface before the migration so that the contract could be migrated and included in dependent contract updates. And ofc stage this contract which shouldn't be a problem since all of its dependencies will also be migrated. Think that would work?

Edit: I realized that's basically what you suggested. Ha alright in that case I'll just make an 0.42 version as well

Copy link
Member

Choose a reason for hiding this comment

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

yep, that sounds good to me

@sisyphusSmiling sisyphusSmiling merged commit fe05fb5 into main Apr 26, 2024
2 checks passed
@sisyphusSmiling sisyphusSmiling deleted the add-special-case-handler branch April 26, 2024 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Add special case fungible token handling
3 participants