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

Update bootstrapping to include nft and metadata views #4536

Merged
merged 8 commits into from
Jul 18, 2023

Conversation

joshuahannan
Copy link
Member

In onflow/flow-core-contracts#370, we're adding metadata views to the FlowToken smart contract. For this, the contract needs to implement all the metadata views contracts. This PR updates the bootstrapping logic to deploy NonFungibleToken, MetadataViews, ViewResolver, and FungibleTokenMetadataViews and provide those import addresses to the FlowToken smart contract deployment.

@joshuahannan
Copy link
Member Author

@ramtinms @janezpodhostnik Would one of you be able to get on a quick call with me so I can explain these changes to you? I'm getting a bunch of errors when running the tests and I'm not sure what is going wrong, so I could use some guidance about how everything fits together.

fvm/bootstrap.go Outdated
@@ -411,14 +413,55 @@ func (b *bootstrapExecutor) deployFungibleToken() flow.Address {
return fungibleToken
}

func (b *bootstrapExecutor) deployFlowToken(service, fungibleToken flow.Address) flow.Address {
func (b *bootstrapExecutor) deployNonFungibleToken() flow.Address {
nonFungibleToken := b.createAccount(b.accountKeys.FungibleTokenAccountPublicKeys)
Copy link
Contributor

Choose a reason for hiding this comment

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

this can break stuff with on emulator, changes flowtoken address.

Copy link
Member Author

Choose a reason for hiding this comment

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

does it break it because the addresses are assigned in order? Is there any way around this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we could create the FlowToken account first, then deploy the other contracts to other accounts, then deploy FlowToken after that to the first account created

Copy link
Contributor

Choose a reason for hiding this comment

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

creating accounts in advance should make it backwards compatible I guess.

flow-go/fvm/bootstrap.go

Lines 318 to 326 in 7dda552

service := b.createServiceAccount()
fungibleToken := b.deployFungibleToken()
nonFungibleToken := b.deployNonFungibleToken()
b.deployMetadataViews(fungibleToken, nonFungibleToken)
flowToken := b.deployFlowToken(service, fungibleToken, nonFungibleToken)
storageFees := b.deployStorageFees(service, fungibleToken, flowToken)
feeContract := b.deployFlowFees(service, fungibleToken, flowToken, storageFees)

Core contracts have fixed indexes https://github.com/onflow/flow-go/blob/91da6d0b24d1d5a5e156c3616f1179b4951d19a6/fvm/environment/account_creator.go#L15C1-L20C1
better not to disturb them.

Copy link
Contributor

@bluesign bluesign Jul 3, 2023

Choose a reason for hiding this comment

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

you can create all accounts (like serviceAccount ), then reference them in the functions. (by passing as parameter )

Copy link
Contributor

Choose a reason for hiding this comment

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

something like this:

 service := b.createServiceAccount() 
 fungibleToken := b.deployFungibleToken() 

//create those to not change index 
 flowTokenAccount := b.createAccount(....)
 flowFeesAccount := b.createAccount(....)

 nonFungibleToken := b.deployNonFungibleToken() 
 b.deployMetadataViews(fungibleToken, nonFungibleToken) 
 flowToken := b.deployFlowToken(service, flowTokenAccount, fungibleToken, nonFungibleToken) 
 storageFees := b.deployStorageFees(service, fungibleToken, flowToken) 
 feeContract := b.deployFlowFees(service, flowFeesAccount, fungibleToken, flowToken, storageFees) 
  

Copy link
Contributor

Choose a reason for hiding this comment

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

we can also deploy metadata views and non fungible tokens on the first/service account

Copy link
Contributor

Choose a reason for hiding this comment

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

@janezpodhostnik actually this is much better, then we would be totally compatible with emulator.

@codecov-commenter
Copy link

codecov-commenter commented Jul 4, 2023

Codecov Report

Merging #4536 (aa528ad) into master (2528190) will decrease coverage by 1.79%.
The diff coverage is 53.49%.

@@            Coverage Diff             @@
##           master    #4536      +/-   ##
==========================================
- Coverage   56.25%   54.47%   -1.79%     
==========================================
  Files         653      914     +261     
  Lines       64699    85238   +20539     
==========================================
+ Hits        36396    46430   +10034     
- Misses      25362    35218    +9856     
- Partials     2941     3590     +649     
Flag Coverage Δ
unittests 54.47% <53.49%> (-1.79%) ⬇️

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

Impacted Files Coverage Δ
cmd/scaffold.go 14.83% <0.00%> (+0.06%) ⬆️
engine/access/rpc/backend/backend_transactions.go 49.01% <0.00%> (+2.86%) ⬆️
model/flow/identifierList.go 22.36% <0.00%> (+0.84%) ⬆️
model/verification/chunkDataPackRequest.go 43.75% <0.00%> (-6.25%) ⬇️
module/metrics/herocache.go 0.00% <0.00%> (ø)
module/metrics/network.go 0.00% <0.00%> (ø)
module/metrics/noop.go 0.00% <0.00%> (ø)
network/p2p/inspector/internal/cache/cache.go 64.70% <ø> (ø)
network/p2p/middleware/middleware.go 1.71% <0.00%> (ø)
network/p2p/p2pbuilder/libp2pNodeBuilder.go 0.00% <0.00%> (ø)
... and 29 more

... and 244 files with indirect coverage changes

@janezpodhostnik
Copy link
Contributor

Looks like the emulator needs to be upgraded with this version of flow-go then the integration tests need to be updated with that emulator version.

@joshuahannan
Copy link
Member Author

I merged the PR in the core contracts repo. What do we need to do to get this PR merged?

@janezpodhostnik
Copy link
Contributor

I merged the PR in the core contracts repo. What do we need to do to get this PR merged?

We need another review.

@janezpodhostnik
Copy link
Contributor

bors merge
I'm not sure whats up with benchstat, I will investigate if it keeps failing

bors bot added a commit that referenced this pull request Jul 14, 2023
4536: Update bootstrapping to include nft and metadata views r=janezpodhostnik a=joshuahannan

In onflow/flow-core-contracts#370, we're adding metadata views to the `FlowToken` smart contract. For this, the contract needs to implement all the metadata views contracts. This PR updates the bootstrapping logic to deploy `NonFungibleToken`, `MetadataViews`, `ViewResolver`, and `FungibleTokenMetadataViews` and provide those import addresses to the `FlowToken` smart contract deployment.

Co-authored-by: Josh Hannan <hannanjoshua19@gmail.com>
Co-authored-by: Janez Podhostnik <janez.podhostnik@gmail.com>
Co-authored-by: Janez Podhostnik <67895329+janezpodhostnik@users.noreply.github.com>
@bors
Copy link
Contributor

bors bot commented Jul 14, 2023

@janezpodhostnik
Copy link
Contributor

bors merge

bors bot added a commit that referenced this pull request Jul 14, 2023
4536: Update bootstrapping to include nft and metadata views r=janezpodhostnik a=joshuahannan

In onflow/flow-core-contracts#370, we're adding metadata views to the `FlowToken` smart contract. For this, the contract needs to implement all the metadata views contracts. This PR updates the bootstrapping logic to deploy `NonFungibleToken`, `MetadataViews`, `ViewResolver`, and `FungibleTokenMetadataViews` and provide those import addresses to the `FlowToken` smart contract deployment.

Co-authored-by: Josh Hannan <hannanjoshua19@gmail.com>
Co-authored-by: Janez Podhostnik <janez.podhostnik@gmail.com>
Co-authored-by: Janez Podhostnik <67895329+janezpodhostnik@users.noreply.github.com>
@bors
Copy link
Contributor

bors bot commented Jul 14, 2023

@janezpodhostnik
Copy link
Contributor

bors merge

bors bot added a commit that referenced this pull request Jul 17, 2023
4536: Update bootstrapping to include nft and metadata views r=janezpodhostnik a=joshuahannan

In onflow/flow-core-contracts#370, we're adding metadata views to the `FlowToken` smart contract. For this, the contract needs to implement all the metadata views contracts. This PR updates the bootstrapping logic to deploy `NonFungibleToken`, `MetadataViews`, `ViewResolver`, and `FungibleTokenMetadataViews` and provide those import addresses to the `FlowToken` smart contract deployment.

Co-authored-by: Josh Hannan <hannanjoshua19@gmail.com>
Co-authored-by: Janez Podhostnik <janez.podhostnik@gmail.com>
Co-authored-by: Janez Podhostnik <67895329+janezpodhostnik@users.noreply.github.com>
@bors
Copy link
Contributor

bors bot commented Jul 17, 2023

Build failed:

@janezpodhostnik
Copy link
Contributor

bors merge

bors bot added a commit that referenced this pull request Jul 17, 2023
4536: Update bootstrapping to include nft and metadata views r=janezpodhostnik a=joshuahannan

In onflow/flow-core-contracts#370, we're adding metadata views to the `FlowToken` smart contract. For this, the contract needs to implement all the metadata views contracts. This PR updates the bootstrapping logic to deploy `NonFungibleToken`, `MetadataViews`, `ViewResolver`, and `FungibleTokenMetadataViews` and provide those import addresses to the `FlowToken` smart contract deployment.

Co-authored-by: Josh Hannan <hannanjoshua19@gmail.com>
Co-authored-by: Janez Podhostnik <janez.podhostnik@gmail.com>
Co-authored-by: Janez Podhostnik <67895329+janezpodhostnik@users.noreply.github.com>
@bors
Copy link
Contributor

bors bot commented Jul 17, 2023

Timed out.

@janezpodhostnik
Copy link
Contributor

bors merge

bors bot added a commit that referenced this pull request Jul 17, 2023
4536: Update bootstrapping to include nft and metadata views r=janezpodhostnik a=joshuahannan

In onflow/flow-core-contracts#370, we're adding metadata views to the `FlowToken` smart contract. For this, the contract needs to implement all the metadata views contracts. This PR updates the bootstrapping logic to deploy `NonFungibleToken`, `MetadataViews`, `ViewResolver`, and `FungibleTokenMetadataViews` and provide those import addresses to the `FlowToken` smart contract deployment.

Co-authored-by: Josh Hannan <hannanjoshua19@gmail.com>
Co-authored-by: Janez Podhostnik <janez.podhostnik@gmail.com>
Co-authored-by: Janez Podhostnik <67895329+janezpodhostnik@users.noreply.github.com>
@bors
Copy link
Contributor

bors bot commented Jul 17, 2023

@janezpodhostnik
Copy link
Contributor

bors merge

bors bot added a commit that referenced this pull request Jul 17, 2023
4536: Update bootstrapping to include nft and metadata views r=janezpodhostnik a=joshuahannan

In onflow/flow-core-contracts#370, we're adding metadata views to the `FlowToken` smart contract. For this, the contract needs to implement all the metadata views contracts. This PR updates the bootstrapping logic to deploy `NonFungibleToken`, `MetadataViews`, `ViewResolver`, and `FungibleTokenMetadataViews` and provide those import addresses to the `FlowToken` smart contract deployment.

Co-authored-by: Josh Hannan <hannanjoshua19@gmail.com>
Co-authored-by: Janez Podhostnik <janez.podhostnik@gmail.com>
Co-authored-by: Janez Podhostnik <67895329+janezpodhostnik@users.noreply.github.com>
@bors
Copy link
Contributor

bors bot commented Jul 17, 2023

Build failed:

@janezpodhostnik janezpodhostnik merged commit e3411ef into master Jul 18, 2023
@janezpodhostnik janezpodhostnik deleted the bootstrapping-views branch July 18, 2023 16:40
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.

5 participants