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

Add a tool to write CryptoHash to DB #10766

Merged
merged 4 commits into from
Apr 5, 2024
Merged

Add a tool to write CryptoHash to DB #10766

merged 4 commits into from
Apr 5, 2024

Conversation

posvyatokum
Copy link
Member

@marcelo-gonzalez We should also add this to 1.38.0. It will not break anything, but improve mitigation experience if we are to fail snapshot creation again.
The tool in 1.37.0-fix was called like this

$NEARD_TOOL --unsafe-fast-startup --home $NEAR_HOME database write-crypto-hash --hash $BLOCK_HASH

Now it should be called like this

$NEARD_TOOL --unsafe-fast-startup --home $NEAR_HOME database write-crypto-hash --hash $BLOCK_HASH block-misc state-snapshot

Copy link

codecov bot commented Mar 12, 2024

Codecov Report

Attention: Patch coverage is 0% with 31 lines in your changes are missing coverage. Please review.

Project coverage is 71.47%. Comparing base (a1ae126) to head (07c0618).
Report is 2 commits behind head on master.

Files Patch % Lines
tools/database/src/write_to_db.rs 0.00% 26 Missing and 3 partials ⚠️
tools/database/src/commands.rs 0.00% 1 Missing ⚠️
tools/state-viewer/src/scan_db.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10766      +/-   ##
==========================================
- Coverage   71.49%   71.47%   -0.02%     
==========================================
  Files         758      759       +1     
  Lines      152284   152314      +30     
  Branches   152284   152314      +30     
==========================================
+ Hits       108868   108871       +3     
- Misses      38909    38933      +24     
- Partials     4507     4510       +3     
Flag Coverage Δ
backward-compatibility 0.24% <0.00%> (-0.01%) ⬇️
db-migration 0.24% <0.00%> (-0.01%) ⬇️
genesis-check 1.42% <0.00%> (-0.01%) ⬇️
integration-tests 37.10% <0.00%> (+0.01%) ⬆️
linux 69.94% <0.00%> (+<0.01%) ⬆️
linux-nightly 70.96% <0.00%> (+<0.01%) ⬆️
macos 52.75% <0.00%> (-1.73%) ⬇️
pytests 1.65% <0.00%> (-0.01%) ⬇️
sanity-checks 1.43% <0.00%> (-0.01%) ⬇️
unittests 67.09% <0.00%> (-0.02%) ⬇️
upgradability 0.29% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

pub(crate) struct WriteCryptoHashCommand {
#[clap(long)]
hash: near_primitives::hash::CryptoHash,
#[clap(subcommand)]
Copy link
Contributor

Choose a reason for hiding this comment

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

the fact that this is a subcommand is a bit weird to me, but I guess it's okay. Why not just another long arg, like --column, and then --key could also be another long arg that accepts arbitrary bytes. And if you want to write to the STATE_SNAPSHOT_KEY you could either spell it out in the argument to --key or there could be yet another long arg, --state-snapshot-key, that's a shorthand for that, that you could give in place of --key. just a thought though

column: ColumnSelector,
}

impl WriteCryptoHashCommand {
Copy link
Contributor

Choose a reason for hiding this comment

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

so this command is quite dangerous. Let's say that I run it and then it's in my bash history. And then I'm scrolling through my bash history to find some unrelated thing and I accidentally re-run the previous invocation of this command. This would be quite sad, and quite a bit sadder than accidentally running neard run. Is it worth adding a prompt that the user needs to explicitly agree to (without a -f flag or something)?

@posvyatokum posvyatokum enabled auto-merge April 5, 2024 16:41
@posvyatokum posvyatokum added this pull request to the merge queue Apr 5, 2024
Merged via the queue into master with commit 0045c6f Apr 5, 2024
29 checks passed
@posvyatokum posvyatokum deleted the snapshot-key-tool branch April 5, 2024 17:19
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 this pull request may close these issues.

2 participants