-
Notifications
You must be signed in to change notification settings - Fork 619
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
feat(state-viewer): list accounts with contracts #8371
Conversation
let (_runtime, state_roots, _header) = load_trie(store.clone(), home_dir, &near_config); | ||
|
||
for (shard_id, &state_root) in state_roots.iter().enumerate() { | ||
eprintln!("Starting shard {shard_id}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find a single instance of eprintln!
used in this file, so maybe let's keep it consistent and use println!
here as well? Then it would be easier to redirect script output to file, since you only have to handle stdout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see the consistency argument but I believe eprintln
is the right choice here anyway.
The reason this goes to stderr is precisely because I don't want it in redirected output. This is just a general progress update to reassure whoever sits in front of the terminal that things are moving along. But scripts working with the output will not want that line.
Case in point, in this comment I have outlined a number of in-terminal data transformations. The script below that adds up all sizes would actually break if there was a line like the above, where the second field is not a number.
awk '{total+=$2} END{printf "%d\n", total}' < contract_accounts.log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh but if you still think it's better for consistency to not write to eprintln!
, then I can also just remove this line, I don't care about it that much. As long as it doesn't go to stdout. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point and it definitely makes sense to print progress messages to stderr.
Let's keep eprintln!
here, I think the right solution would be to fix all other instances of printing progress messages to stdout (but definitely not a part of this PR).
let key = TrieKey::ContractCode { account_id: "xx".parse()? }.to_vec(); | ||
let (prefix, suffix) = key.split_at(key.len() - 2); | ||
assert_eq!(suffix, "xx".as_bytes()); | ||
|
||
// `visit_nodes_interval` wants nibbles stored in `Vec<u8>` as input | ||
let nibbles_before: Vec<u8> = NibbleSlice::new(prefix).iter().collect(); | ||
let nibbles_after = { | ||
let mut tmp = nibbles_before.clone(); | ||
*tmp.last_mut().unwrap() += 1; | ||
tmp | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just fyi: I'm working on exposing API around trie key ranges as part of #8332, I will try to keep this use case in mind when designing it, so we can replace this with something nicer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good to know, thanks
- update command alias - better pattern matching
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks for the review. @Longarithm I will also need a code owner approval on this one, pretty please :) |
A state viewer command to list all accounts with contracts deployed. So far it only shows the account names and the wasm size. The intention is to extend it for more sophisticated filtering. So far, the command finishes all four shards in 2 minutes on a mainnet archival RocksDB.
A state viewer command to list all accounts with contracts deployed. So far it only shows the account names and the wasm size. The intention is to extend it for more sophisticated filtering. So far, the command finishes all four shards in 2 minutes on a mainnet archival RocksDB.
A state viewer command to list all accounts with contracts deployed. So far it only shows the account names and the wasm size. The intention is to extend it for more sophisticated filtering. So far, the command finishes all four shards in 2 minutes on a mainnet archival RocksDB.
A state viewer command to list all accounts with contracts deployed. So far it only shows the account names and the wasm size. The intention is to extend it for more sophisticated filtering. So far, the command finishes all four shards in 2 minutes on a mainnet archival RocksDB.
A state viewer command to list all accounts with contracts deployed. So far it only shows the account names and the wasm size. The intention is to extend it for more sophisticated filtering. So far, the command finishes all four shards in 2 minutes on a mainnet archival RocksDB.
A state viewer command to list all accounts with contracts deployed. So far it only shows the account names and the wasm size. The intention is to extend it for more sophisticated filtering. So far, the command finishes all four shards in 2 minutes on a mainnet archival RocksDB.
A state viewer command to list all accounts with contracts deployed.
So far it only shows the account names and the wasm size.
The intention is to extend it for more sophisticated filtering.
So far, the command finishes all four shards in 2 minutes on a
mainnet archival RocksDB.