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

[Flow EVM] smart contract deployment for COAs #5269

Merged
merged 53 commits into from
Feb 5, 2024

Conversation

ramtinms
Copy link
Contributor

@ramtinms ramtinms commented Jan 22, 2024

This PR updates the handler to deploy smart contracts for COA accounts,
I reused the same direct call sub-transaction type except the to address is set in advance.
I have to implement deployment to EVM at the specific address given Geth EVM doesn't allow this operation by default. Given that we use this implementation only for COA deployment we could heavily optimize it in the future.

@codecov-commenter
Copy link

codecov-commenter commented Jan 22, 2024

Codecov Report

Attention: 68 lines in your changes are missing coverage. Please review.

Comparison is base (f4df54c) 55.97% compared to head (75081ff) 55.70%.

Files Patch % Lines
fvm/evm/emulator/emulator.go 71.00% 23 Missing and 6 partials ⚠️
fvm/evm/types/call.go 0.00% 20 Missing ⚠️
fvm/evm/handler/handler.go 83.95% 12 Missing and 1 partial ⚠️
fvm/evm/types/address.go 0.00% 4 Missing ⚠️
fvm/evm/stdlib/contract.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5269      +/-   ##
==========================================
- Coverage   55.97%   55.70%   -0.28%     
==========================================
  Files        1018     1006      -12     
  Lines       98189    97011    -1178     
==========================================
- Hits        54963    54039     -924     
+ Misses      39108    38911     -197     
+ Partials     4118     4061      -57     
Flag Coverage Δ
unittests 55.70% <69.23%> (-0.28%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

// The Second way is through a new form of account called bridged accounts,
// The Second way is through a new form of account called cadence-owned-accounts (COAs),
Copy link
Contributor Author

@ramtinms ramtinms Jan 23, 2024

Choose a reason for hiding this comment

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

I renamed to COA on files in the packages touched by this PR but left the stdlib and fvm/evm packages for another PR since it was changing so many lines.

@ramtinms ramtinms marked this pull request as ready for review January 24, 2024 06:21
@ramtinms ramtinms changed the title [Flow EVM] COA accounts deploys smart contract [Flow EVM] COA account's smart contract Jan 24, 2024
@ramtinms ramtinms changed the title [Flow EVM] COA account's smart contract [Flow EVM] COAs' smart contracts Jan 24, 2024
@ramtinms ramtinms changed the title [Flow EVM] COAs' smart contracts [Flow EVM] smart contract deployment for COAs Jan 24, 2024
Copy link
Contributor

@sideninja sideninja left a comment

Choose a reason for hiding this comment

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

Left some comments but otherwise looks good.

Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Nice! Mostly reviewed from a Cadence-perspective, can't say much regarding EVM perspective

fvm/evm/handler/coa.go Outdated Show resolved Hide resolved
fvm/evm/handler/coa.sol Outdated Show resolved Hide resolved
fvm/evm/stdlib/contract.cdc Outdated Show resolved Hide resolved
fvm/evm/stdlib/contract.cdc Show resolved Hide resolved
Copy link
Contributor

@tarakby tarakby left a comment

Choose a reason for hiding this comment

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

I only looked at the COA address derivation part. I made some suggestions (mainly adding comments) to clarify the reasoning behind the choices, so that they are documented somewhere:

  • security reasoning behind choosing an address prefix of 12 bytes
  • reasoning behind the index to postfix mapping

#5344

I am not sure whether you would need to add the reverse mapping (MOA address to index). If yes, let me know and I can add another PR.

Update: I would also add sanity tests about the size of the address prefix and the parity of the multiplier to avoid future changes break the assumptions, but that requires the constants to be made public (to be used in tests). Would you be fine with making them public? If yes I can also commit the tests.

fvm/evm/handler/addressAllocator.go Show resolved Hide resolved
fvm/evm/handler/addressAllocator.go Outdated Show resolved Hide resolved
@ramtinms ramtinms requested a review from turbolent February 2, 2024 23:27
@ramtinms ramtinms added this pull request to the merge queue Feb 5, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 5, 2024
@ramtinms ramtinms added this pull request to the merge queue Feb 5, 2024
Merged via the queue into master with commit 73e97e7 Feb 5, 2024
51 checks passed
@ramtinms ramtinms deleted the ramtin/5226-coa-smart-contracts branch February 5, 2024 20:50
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.

7 participants