onflow / onflow/flow-cli

Handling contract updates on emulator

Open
#986 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Improvement
Dominant language
Go
Stars
209
Forks
87
Avg merge
1d 17h
Merged PRs (30d)
3

Description

A Cadence developer will during the development process frequently change contracts which makes keeping the contract updated on the emulator a challenge. The Flow mainnet/testnet has limitations on updating the contracts which are too strict to support the initial development of contracts. This problem is present on flow dev but also on Playground. Bellow are two ways of how we are or could handle changes. Each with some downsides.

Current state
Current state handling allows contract updates by removing and redeploying the new contract which can lead to a case where a resource was saved in an account but the contract update removes the resource altogether making the stored resource invalid.

Blocks Account Alice Account Bob State Comment
1 Foo(contract ver:1) X  
2 Foo(contract ver:2) Created  
3 Foo(contract ver:2)    
4 Foo(contract ver:2), Zoo(resource) Zoo(resource)  
5 Foo(contract ver:3 - removed Zoo resource type), Zoo(resource) Zoo(resource) Non-existing resource Zoo on account Alice and Bob

State handling with reset
State handling with reset always resets the state after updating the contract thus also clearing the accounts with possible no-longer valid types, however, it presents another problem where any accounts created after will no longer exist.

Blocks Account Alice Account Bob State Comment
1 Foo(contract ver:1) X  
1 Foo(contract ver:2) X  
      Reset state
2 Foo(contract ver:2) Created  
1 Foo(contract ver:3) X  
      Reset state
1 Foo(contract ver:3),Zoo(resource) Created  
2 Foo(contract ver:4),Zoo(resource) Zoo(resource)  
      Reset state
1 Foo(contract ver:4) X  

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Flow CLI's current emulator contract-update handling and the two state-management approaches described in the issue. Compare redeployment with state reset against the resource and account scenarios in the tables. Done requires a decided approach for safely handling contract updates on flow dev and Playground.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
blockchain, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.