-
Notifications
You must be signed in to change notification settings - Fork 673
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
feature(chain): Exposed accounts touched within the block #2253
Conversation
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 am not absolutely happy with the naming, so I am open to suggestions.
chain/chain/src/store.rs
Outdated
/// Retrieve the kinds of state changes occurred in a given block. | ||
/// | ||
/// We store different types of data, so we prefer to only expose minimal information about the | ||
/// changes (i.e. a kind of the change and an account id). | ||
fn get_key_value_changes_in_block( | ||
&self, | ||
block_hash: &CryptoHash, | ||
) -> Result<StateChangesKinds, Error> { |
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.
FYI, This is the core part of the PR.
It's already not the case. Nevermind :) |
…e stage to be compatible with the upcoming hashed account_id design
@evgenykuzyakov @nearmax I need your help. This latest commit failed on a test, and this raised a question I had before. Do we want to expose the following types of changes via changes API? pub const POSTPONED_RECEIPT_ID: &[u8] = &[4];
pub const PENDING_DATA_COUNT: &[u8] = &[5];
pub const POSTPONED_RECEIPT: &[u8] = &[6];
pub const DELAYED_RECEIPT_INDICES: &[u8] = &[7];
pub const DELAYED_RECEIPT: &[u8] = &[8]; At least |
It's a singleton per shard. It keeps the indices of the delayed receipts queue:
|
@evgenykuzyakov Thank you for the information! I will put your comments into the code. It seems that that info is only relevant for internal operation, and given that we don't expose it via API yet, I can skip saving those changes. Though, reading all the above I realized that we are missing shard information in our APIs. It seems that we need to pass |
…se them via RPC anyway
…e/2128-RPC-expose-changes-kinds-per-block
I'm not sure you need to do this, because |
Yeah we should not expose |
… KeyForStateChanges
…e/2128-RPC-expose-changes-kinds-per-block
I believe this PR is ready to be merged. |
The follow-up documentation request is near/docs#267 |
Introducing `TrieKey` trait to work with keys within `TrieUpdate` instead of using raw `Vec<u8>`. This allows to have additional logic for keys. E.g. if we want to hash AccountID for keys (see #2215) and later return all touched accounts for a block (see #2253) we need a way to map `sha256(account_id)` from a raw key back to the `account_id`. Then `TrieKey` may implement `fn get_account_id_with_hash() -> Option<(AccountId, CryptoHash)>` logic that provides Account ID and hash of this Account ID. With this info we can remember pairs of touched Accounts in memory of `TrieUpdate` and now we can map back hashes here: https://github.com/nearprotocol/nearcore/blob/62f00b211915790d06e822da866fb01ceb6cdc89/core/store/src/trie/mod.rs#L578 Removes iterators from VMLogic (cause they somewhat block changes from this PR). Fixes #2276 ##Test Plan: - unit tests and CI
Resolves #2128
API:
NOTE: The endpoint naming needs some bikeshedding.
The response: