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

Loading values from a migrated emulator state fails #3143

Closed
SupunS opened this issue Feb 28, 2024 · 10 comments · Fixed by onflow/flow-emulator#591
Closed

Loading values from a migrated emulator state fails #3143

SupunS opened this issue Feb 28, 2024 · 10 comments · Fixed by onflow/flow-emulator#591
Assignees
Labels
Bug Something isn't working

Comments

@SupunS
Copy link
Member

SupunS commented Feb 28, 2024

Issue to be solved

Loading already stored values from a migrated emulator state fails for certain values. e.g: Dictionary values.

This could be either:

  • A problem in the way the updated payloads are written back to the emulator state, or
  • A problem with the migration

Needs to investigate further.

Suggested Solution

No response

@SupunS SupunS added the Bug Something isn't working label Feb 28, 2024
@SupunS SupunS self-assigned this Feb 28, 2024
@turbolent
Copy link
Member

Is there any kind of error that is reported?

@SupunS
Copy link
Member Author

SupunS commented Feb 28, 2024

The two errors that I ran into so far was:

  • Loading a dictionary (say {String:Int}) loads some random dictionary value.

    error: failed to force-cast value: expected type `{String: Int}`, got `{UInt64: Never?}`
      --> d15604fc4f6a3ebafa9de405add09237341bcb45505cd167798de1d65f3fbaa4:16:16
       |
    16 |     var dict1 = acct.storage.load<{String: Int}>(from: /storage/dictionary_with_string_keys)
       |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    

    The value is indeed something else (e.g: {2: nil})

  • Imports cannot be found after migrating the contract

@SupunS
Copy link
Member Author

SupunS commented Feb 28, 2024

It seems the registers are somehow messed up

@turbolent
Copy link
Member

It's weird that this happens, given that the we have a test case in flow-go that works

@turbolent
Copy link
Member

turbolent commented Feb 28, 2024

Maybe this is caused by the gap that #3141 fills?

@SupunS
Copy link
Member Author

SupunS commented Feb 28, 2024

Maybe this is caused by the gap that #3141 fills?

It shouldn't be: the said dictionary value doesn't change it's static type (its a {String: Int} value), so #3141 wouldn't really impact this one.

@SupunS
Copy link
Member Author

SupunS commented Feb 28, 2024

Values in the storage seems to be correct: onflow/flow-emulator#584 (PR is failing CI due to unrelated changes, but the updated test TestCadence1Migration assertions pass)

@SupunS
Copy link
Member Author

SupunS commented Feb 28, 2024

Maybe the way the register keys are created/encoded got changed in the emulator latest version, or something like that? 🤔

@SupunS
Copy link
Member Author

SupunS commented Mar 5, 2024

So it turns out to be the snapshot was taken before shutting down the emulator, which may have left the store with some unwritten data.

@SupunS SupunS closed this as completed Mar 5, 2024
@turbolent
Copy link
Member

What are the steps for creating a valid snapshot? We'll have to document this and provide it to developers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants