-
Notifications
You must be signed in to change notification settings - Fork 188
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
Adds bridge to fvm bootstrapping #7053
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7053 +/- ##
==========================================
+ Coverage 41.37% 41.39% +0.02%
==========================================
Files 2174 2175 +1
Lines 190130 190557 +427
==========================================
+ Hits 78657 78875 +218
- Misses 104895 105091 +196
- Partials 6578 6591 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
12adf5e
to
7ae57c9
Compare
ba6bf93
to
0d96420
Compare
I finished writing all my tests so it is ready for review! @janezpodhostnik There are still some tests failing that I'm confused about. In the evm tests, the bootstrapping is failing with this error:
Do you know why the ABI decoding would fail in that test but not in any of the fvm tests? |
0d96420
to
2ae0bed
Compare
Thank you very much for preparing this! I will take a look at the error in a couple of days. |
2ae0bed
to
976d09d
Compare
Thanks, just to provide a bit more context, that is coming from the bridge setup part of bootstrapping that I wrote. It is from the step where we provide the address of the registrar contract to set the token factory contract that deploys the bridge deployed solidity token smart contracts. It happens when we are decoding the ABI data from the registrar contract. This step succeeds in all of the fvm tests, but doesn't in the evm tests, so it sounds to me like maybe there is something in the config for the EVM tests that differs from the FVM tests that makes this not work in this context. |
What I found is that there is an underlying error: "abi: attempting to unmarshal an empty string while arguments are expected" at this location: https://github.com/onflow/flow-evm-bridge/blob/b32c787631c9c84c548b2e414d87b49fa32b12d8/cadence/transactions/bridge/admin/evm/set_registrar.cdc#L44 which means the |
Interesting. @sisyphusSmiling Are you able to take a look? Do you know why |
Looks like They will need to be changed to be more like the |
@janezpodhostnik Just to clarify, how would starting with a different storage affect the bridge bootstrapping? And are you saying that you'll be able to help update them, or I should do that? |
I am trying to update the tests, but I'm unfamiliar with these tests and its proving difficult. I will let you know how it goes. |
@joshuahannan I tried fixing the tests, but it would take me more time than I currently have. I suggest adding a disable option for bootstrapping the bridge, and disable the bridge in these specific tests (evm_test.go). |
okay, I'll do that. Thanks for taking a look! |
976d09d
to
30cb755
Compare
@janezpodhostnik I just pushed the changes and everything is passing now. Can you review? Also, since I added the bootstrap option to setup the bridge and it doesn't happen by default any more, where do we add that to use that for the bootstrapping that is used for the emulator? |
e8c1ceb
to
f0624b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a commit to cleanup some stuff.
I had some minor comments but overall it looks ok.
for the emulator, the option can be enabled here: https://github.com/onflow/flow-emulator/blob/8528f3e70bae633ff6774a1f32f3cd65a255192d/emulator/blockchain.go#L606
Can you also add a bit more description to the PR (or link it to an issue if you have one):
- the option added
- what does the option enable
- the removal of USDC
@@ -375,9 +386,6 @@ func (b *bootstrapExecutor) Execute() error { | |||
b.deployMetadataViews(fungibleToken, nonFungibleToken, &env) | |||
b.deployFungibleTokenSwitchboard(fungibleToken, &env) | |||
|
|||
// deploys the USDCFlow smart contract | |||
b.deployUSDCFlow(fungibleToken, &env) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will the removal of the USDCFlow smart contract cause any issues with developers using the emulator?
Please not the removal in the PR description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some stuff to the description of the PR. USDC was only in here very briefly (only in the latest release from a few weeks ago), and we never announced it, so it is extremely unlikely that anyone was using it. We should have never added it in the first place. That was my bad
fvm/bootstrap.go
Outdated
).(cadence.String) | ||
|
||
if contractAddr.String() == "" { | ||
log.Fatal("Contract address not found in event") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you return an error instead and handle the error one level higher.
Should this function also return an error if there was no "TransactionExecuted" event found?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, I added both of those. 👍
fvm/bootstrap.go
Outdated
if contractAddr.String() == "" { | ||
log.Fatal("Contract address not found in event") | ||
} | ||
address := strings.ToLower(strings.Split(contractAddr.String(), "x")[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this removing a hex prefix? If so, try:
address := strings.ToLower(strings.Split(contractAddr.String(), "x")[1]) | |
address := strings.ToLower(strings.TrimPrefix(contractAddr.String(), "0x")) |
fvm/bootstrap.go
Outdated
log.Fatal("Contract address not found in event") | ||
} | ||
address := strings.ToLower(strings.Split(contractAddr.String(), "x")[1]) | ||
return address[:len(address)-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why this is needed. Can you add a comment describing what is being parsed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, there are extra double quotes here in the address so the first and last character needs to be removed for it to only be the address. I added a comment saying that.
fvm/bootstrap.go
Outdated
) | ||
panicOnMetaInvokeErrf("failed to create COA in Service Account: %s", txError, err) | ||
|
||
gasLimit := 15000000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a comment describing how this constant was picked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
nameWithCDC := slashSplit[len(slashSplit)-1] | ||
name := nameWithCDC[:len(nameWithCDC)-4] | ||
|
||
if name == "FlowEVMBridgeUtils" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this one is special deploy it outside of the loop. that way you do not need the logic to extract the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is that it needs to be deployed in the middle of all the contracts it is looping through, so if I deployed it outside, i'd have to start a new loop which feels like it kind of negates the code saved from removing the name logic.
f0624b6
to
ca0867b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good.
Do you anticipate more contracts being needed in the short term? I would like to take some time to clean up bootstrapping before we add more.
We're making an upgrade to the bridge soon that will add two more contracts to the bridge bootstrapping, but besides that, I don't think we'll need to add any more soon. |
@zhangchiqing Would you be able to review this also? |
Work towards onflow/flow-emulator#782
Adds the bridge standup script as an option to fvm bootstrapping so that the bridge can be available in the emulator and other testing environments by default.
The option makes it so all the bridge contracts are deployed during bootstrapping. The VM bridge is effectively part of the core protocol now, so it should be deployed by default for the emulator. More and more developers need an easy way to test bridging, so this enables that with the emulator.
USDC deployment was also removed because the flow partnerships/defi team has given up on the old USDC contract in favor of a new EVM based USDC contract. It should never have been included here in the first place. Developers were not using USDC in the emulator, so this should not affect anyone