Skip to content

Commit

Permalink
feat: tool to validate state witness (#11388)
Browse files Browse the repository at this point in the history
Completes the lifetime of state witness saved to disk:

Save latest state witnesses for given selection:
```
neard --unsafe-fast-startup view-state --readwrite state-witness latest --shard-id 4 --height 118772867 --binary > witness.txt
```

To validate it:
```
RUST_LOG=debug neard --unsafe-fast-startup view-state --readwrite state-witness validate --input-file witness.txt
```

The huge diff is explained by the need to move lots of state witness
validation code and metrics from near-client to near-chain, and it
actually belong there. Probably quick look is enough to check that I
didn't break it.

The only new logic is `ValidateWitnessCmd` which just calls existing
function for shadow validation. I checked manually that with
`RUST_LOG=debug` it shows error on invalid witness and success on the
valid one.
  • Loading branch information
Longarithm authored Jun 4, 2024
1 parent 041c32c commit 43c04fb
Show file tree
Hide file tree
Showing 18 changed files with 998 additions and 845 deletions.
4 changes: 2 additions & 2 deletions chain/chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ mod doomslug;
pub mod flat_storage_creator;
mod garbage_collection;
mod lightclient;
mod metrics;
pub mod metrics;
pub mod migrations;
pub mod missing_chunks;
pub mod orphan;
pub mod resharding;
pub mod runtime;
mod state_request_tracker;
pub mod state_snapshot_actor;
mod stateless_validation;
pub mod stateless_validation;
mod store;
pub mod store_validator;
pub mod test_utils;
Expand Down
33 changes: 0 additions & 33 deletions chain/chain/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,36 +238,3 @@ pub(crate) static RESHARDING_STATUS: Lazy<IntGaugeVec> = Lazy::new(|| {
)
.unwrap()
});

pub static SAVE_LATEST_WITNESS_GENERATE_UPDATE_TIME: Lazy<HistogramVec> = Lazy::new(|| {
try_create_histogram_vec(
"near_save_latest_witness_generate_update_time",
"Time taken to generate an update of latest witnesses",
&["shard_id"],
Some(exponential_buckets(0.001, 1.6, 20).unwrap()),
)
.unwrap()
});
pub static SAVE_LATEST_WITNESS_COMMIT_UPDATE_TIME: Lazy<HistogramVec> = Lazy::new(|| {
try_create_histogram_vec(
"near_save_latest_witness_commit_update_time",
"Time taken to commit the update of latest witnesses",
&["shard_id"],
Some(exponential_buckets(0.001, 1.6, 20).unwrap()),
)
.unwrap()
});
pub static SAVED_LATEST_WITNESSES_COUNT: Lazy<IntGauge> = Lazy::new(|| {
try_create_int_gauge(
"near_saved_latest_witnesses_count",
"Total number of saved latest witnesses",
)
.unwrap()
});
pub static SAVED_LATEST_WITNESSES_SIZE: Lazy<IntGauge> = Lazy::new(|| {
try_create_int_gauge(
"near_saved_latest_witnesses_size",
"Total size of saved latest witnesses (in bytes)",
)
.unwrap()
});
Loading

0 comments on commit 43c04fb

Please sign in to comment.