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] COA ownership proof - part 3 #5343

Merged
merged 19 commits into from
Feb 13, 2024
Merged

Conversation

ramtinms
Copy link
Contributor

@ramtinms ramtinms commented Feb 1, 2024

This updates the evm contract with verify function for COA ownership proofs, it also updates the handler to use the invoke to make a call.

closes #5197

@ramtinms ramtinms marked this pull request as ready for review February 2, 2024 05:27
fvm/evm/stdlib/contract.go Show resolved Hide resolved
fvm/evm/testutils/backend.go Show resolved Hide resolved
fvm/evm/stdlib/contract.cdc Show resolved Hide resolved
fvm/evm/stdlib/contract.cdc Outdated Show resolved Hide resolved
signedData: [UInt8],
keyIndices: [UInt64],
signatures: [[UInt8]],
evmAddress: [UInt8; 20]
Copy link
Contributor

Choose a reason for hiding this comment

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

random thought, but I'm seeing this array definition multiple times and I think we should maybe create an evmAddress type for it

@@ -3646,3 +3648,155 @@ func TestEVMAccountBalanceForABIOnlyContract(t *testing.T) {
"error: value of type `EVM` has no member `createBridgedAccount`",
)
}

func TestEVMValidateCOAOwnershipProof(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we also add a test where the proof fails

require.NoError(tb, err)
return &TestContract{
Code: `
pragma solidity >=0.7.0 <0.9.0;
// SPDX-License-Identifier: GPL-3.0
Copy link
Contributor

@sideninja sideninja Feb 8, 2024

Choose a reason for hiding this comment

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

should we maybe start extracting solidity code and bytecode into separate files, like Storage.sol which are then embeded into the Go code using the embed. I prefer it because you have syntax highlighting possible, you can use the file directly to compile to bytecode, I even think we should in the future generate the bytecode file using a make action, same for ABI, have ABI.json and that could also get generated in the future.

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 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.

👍

fvm/evm/stdlib/contract.cdc Show resolved Hide resolved
@@ -61,6 +66,23 @@ func NewAddressFromBytes(inp []byte) Address {
return Address(gethCommon.BytesToAddress(inp))
}

func COAAddressFromFlowEvent(evmContractAddress flow.Address, event flow.Event) (Address, error) {
// check the type first
if string(event.Type) != fmt.Sprintf(COAAddressTemplate, evmContractAddress.Hex()) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe optimize this check by avoiding the string formatting/allocation, and just decode the event's type ID and comparing address and qualified identifier

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not a code that is touched by the onchain execution but I'll update the next PR to do as you suggested. How do I decode the event type ID? is there a utility function on the cadence side to decode from string?

Base automatically changed from ramtin/5197-part2-precompile to master February 12, 2024 23:06
@ramtinms ramtinms enabled auto-merge February 12, 2024 23:07
@codecov-commenter
Copy link

codecov-commenter commented Feb 12, 2024

Codecov Report

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

Comparison is base (cafb1a6) 56.02% compared to head (aefd300) 55.91%.
Report is 3261 commits behind head on master.

Files Patch % Lines
...util/ledger/migrations/cadence_value_validation.go 43.62% 172 Missing and 27 partials ⚠️
...edger/migrations/change_contract_code_migration.go 27.90% 184 Missing and 2 partials ⚠️
...md/util/ledger/util/migration_runtime_interface.go 0.00% 150 Missing ⚠️
...util/ledger/migrations/atree_register_migration.go 52.10% 104 Missing and 21 partials ⚠️
cmd/execution_builder.go 0.00% 116 Missing ⚠️
...d/util/ledger/migrations/storage_used_migration.go 2.40% 81 Missing ⚠️
cmd/util/ledger/util/util.go 0.00% 79 Missing ⚠️
.../util/ledger/migrations/account_based_migration.go 70.53% 50 Missing and 11 partials ⚠️
cmd/scaffold.go 0.00% 38 Missing ⚠️
consensus/hotstuff/committees/static.go 0.00% 37 Missing ⚠️
... and 32 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5343      +/-   ##
==========================================
- Coverage   56.02%   55.91%   -0.12%     
==========================================
  Files         965     1024      +59     
  Lines       89671    98842    +9171     
==========================================
+ Hits        50241    55268    +5027     
- Misses      35678    39403    +3725     
- Partials     3752     4171     +419     
Flag Coverage Δ
unittests 55.91% <43.43%> (-0.12%) ⬇️

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.

@ramtinms ramtinms added this pull request to the merge queue Feb 13, 2024
Merged via the queue into master with commit 26ac4b4 Feb 13, 2024
51 checks passed
@ramtinms ramtinms deleted the ramtin/5197-part3-stdlib branch February 13, 2024 04:58
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.

[Flow EVM] add COA ownership proofs
5 participants