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

Implement import and export functions in modules #1848

Merged
merged 2 commits into from
May 28, 2020

Conversation

NicolasMahe
Copy link
Member

@NicolasMahe NicolasMahe commented May 27, 2020

Closes #1847

This PR implements the import and export functions in modules.

To export, use the command:

mesg-daemon export

Make sure the first line returned by the command doesn't contain "WARNING: State is not initialized. Returning genesis file.". If it's the case, try to start the node and stop it mesg-daemon start. I think I have this issue because I'm running the node in docker and the cli on mac. So when I start the node on the Mac, it may resolve the issue.

To import, copy the output of previous command in the genesis.json file of a new node that doesn't have any database, start the node, and see the data are present.

@NicolasMahe NicolasMahe added the release:add Pull requests that add something label May 27, 2020
@NicolasMahe NicolasMahe added this to the next milestone May 27, 2020
@NicolasMahe NicolasMahe requested a review from antho1404 May 27, 2020 08:15
@NicolasMahe NicolasMahe self-assigned this May 27, 2020
@NicolasMahe NicolasMahe changed the title implemented import and export functions in modules Implement import and export functions in modules May 27, 2020
@antho1404
Copy link
Member

I think the export/import should stay as close as possible to the database we use. Here we are losing the key on all export. We usually use the hash but we might change to the address or anything. We shouldn't loose this information. I would recommend to switch to a map instead of array or an array of key/value

@NicolasMahe
Copy link
Member Author

NicolasMahe commented May 27, 2020

I think the export/import should stay as close as possible to the database we use. Here we are losing the key on all export. We usually use the hash but we might change to the address or anything. We shouldn't loose this information. I would recommend to switch to a map instead of array or an array of key/value

As you say, the keys are the hash. If the data didn't contain keys, then a map can be implemented, but it's not the case.
Each module can have its own export and import function, so there is no need to implement exactly the same logic everywhere.

Copy link
Member

@antho1404 antho1404 left a comment

Choose a reason for hiding this comment

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

I'm ok with the fact to store just the data and not the indexes, for now it's sufficient and it might be much more complicated to store both with maybe an iterator on the keeper.

Just a small feedback, not blocking but might just be nicer.

x/execution/internal/types/genesis.go Outdated Show resolved Hide resolved
@NicolasMahe
Copy link
Member Author

Now the genesis contains empty array instead of null.
Before:

{"instances":null}

After:

{"instances":[]}

@NicolasMahe NicolasMahe merged commit f9c37d5 into dev May 28, 2020
@NicolasMahe NicolasMahe deleted the feature/export-import branch May 28, 2020 04:30
@NicolasMahe NicolasMahe modified the milestones: next, v0.25.1 May 28, 2020
@NicolasMahe NicolasMahe added release:fix Pull requests that fix something and removed release:add Pull requests that add something labels May 28, 2020
@NicolasMahe NicolasMahe mentioned this pull request May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix Pull requests that fix something
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add export and import data to genesis for mesg modules
2 participants