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

Workaround for StartSmeshing and NodeID #823

Closed
brusherru opened this issue Nov 4, 2021 · 6 comments · Fixed by #824
Closed

Workaround for StartSmeshing and NodeID #823

brusherru opened this issue Nov 4, 2021 · 6 comments · Fixed by #824
Assignees

Comments

@brusherru
Copy link
Member

Right now calling SmesherService.StartSmeshing starts creating PoST data using key.bin created on the Node start. On the second App session, Node will try to find key.bin file in the PoST data directory and use it. It causes a bug, when the User specifies a custom directory (non default ~/post/data) — it does not contain key.bin and Node will create a new one there and created PoST data files mismatches the newly created ID. The Node exits with panic: ID mismatch.

Details: spacemeshos/go-spacemesh#2858

In the issue mentioned above, we decided to make a workaround in Smapp until we have implemented big changes in go-spacemesh. See spacemeshos/go-spacemesh#2858 (comment)

So we need to implement a temporary workaround in the Smapp:

  • On start smeshing (but before calling GRPC SmesherService.StartSmeshing) Smapp should check for the existence of the key.bin file in the selected directory:
    • If it is not there — just copy it from the default path (~/post/data/key.bin)
    • If it is there — check that this is the same file as in the default path (~/post/data/key.bin) using shasum.
      • If it differs — update the config and restart the node.
      • If it is the same — just call StartSmeshing.
    • If ~/post/data/key.bin is not found — update the config and restart the node as well
  • After all, show the success screen as usual
@avive
Copy link
Contributor

avive commented Nov 6, 2021

@noamnelke also note that we have another client - smrepl and users must use it in upcoming devnets until we can ship smapp 0.2. We need to fix post in the node so smeshing will work after restart in smrepl where user updated the node config file. Smrepl is a 100% stateless client so it doesn't keep any post related state or any other user data.

@noamnelke
Copy link
Member

@avive I don't think this issue applies to smrepl. I assume that smrepl users create a config that includes the correct PostDatadir before starting the node for the first time, rather than the SMApp flow of starting the node with a temporary folder and then changing it at runtime. Is there any reason to think this is not the case?

@avive
Copy link
Contributor

avive commented Nov 7, 2021

That's unfortunately not how currently smrepl works. User sets up smeshing via a repl command and is given the code snippet to update the config file and instructions to edit the config file. On next session node takes post data from the config file it is given in startup.

@noamnelke
Copy link
Member

@avive

That's unfortunately not how currently smrepl works.

See my comment here: spacemeshos/smrepl#56 (comment)

@noamnelke
Copy link
Member

@brusherru one point I just noticed: when you mention the default location, that could work for the common case, but not always. Ideally, the location you copy key.bin from and compare an existing file with should be the previous location, which is the default location in the common case (but not always).

If it considerably complicates the kludge, we can consider just doing what you wrote, but it will break badly if the user changes from one non-default location to another. Not very common, but nasty behaviour.

@brusherru
Copy link
Member Author

brusherru commented Nov 9, 2021

@noamnelke thanks for the attention to detail. I got the same idea when implementing it, so I've already done it using this approach. I'm getting the "previous" key.bin path by getting property smeshing.smeshing-opts.smeshing-opts-datadir from the config and, in case if it is empty, fall back to the default ~/post/data/.
Also, if the data-dir path does not change, it starts smeshing as usual without any additional logic.

You can check out PR, I have written quite detailed comments there: https://github.com/spacemeshos/smapp/pull/824/files#diff-0e9c78b6209a81be37df60ca8f7b90f25717ad80685e4de9c5f5337a64758205R98

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 a pull request may close this issue.

3 participants