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

Problem: priv_validator_state.json may get corrupted #202

Open
tomtau opened this issue Nov 17, 2021 · 1 comment
Open

Problem: priv_validator_state.json may get corrupted #202

tomtau opened this issue Nov 17, 2021 · 1 comment
Assignees

Comments

@tomtau
Copy link

tomtau commented Nov 17, 2021

@borischeuk-crypto came across an issue where priv_validator_state.json was empty and the nitro helper would crash with:

failed to get a state syncing helper: Error(Context { kind: SyncError, source: Some(Message("error parsing .../.tmkms/state/priv_validator_state.json: EOF while parsing a value at line 1 column 0")), backtrace: Some(   0: tmkms_nitro_helper::command::start

There are probably a few ways how this can be improved:

  1. check the state syncing helper code whether atomic writing via tempfile can be improved (also not sure if the helper @borischeuk-crypto used had https://github.com/crypto-com/tmkms-light/pull/115/files )
  2. improve the error message to e.g. give some troubleshooting suggestion (re-initialize the file with the latest block height?)
  3. add a different option for storing/retrieving priv_validator_state.json... e.g. with DynamoDB instead of a local file
@tomtau
Copy link
Author

tomtau commented Mar 31, 2022

For reference, a code snippet for that potential DynamoDB fallback option

...
client.update_item().table_name(table_name).key("validator-id", AttributeValue::S(validator_id))
    .condition_expression("Height < :he OR (Height = :he AND Round < :ro) OR (Height = :he AND Round = :ro AND Step < :st)")
    .update_expression("SET BlockId = :bl, Height = :he, Round = :ro, Step = :st")
    .expression_attribute_values(":bl", AttributeValue::S(state.block_id.unwrap_or_default().to_string()))
    .expression_attribute_values(":he", AttributeValue::N(state.height.to_string()))
    .expression_attribute_values(":ro", AttributeValue::N(state.round.to_string()))
    .expression_attribute_values(":st", AttributeValue::N(state.step.to_string()))
    .send().await;

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

No branches or pull requests

6 participants