-
Notifications
You must be signed in to change notification settings - Fork 658
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always record storage when stateless validation is enabled (#10859)
For stateless validation we need to record all trie reads performed when applying a chunk in order to prepare a `PartialState` that will be included in `ChunkStateWitness` Initially it was only necessary to record trie reads when producing a chunk. Validators could read all the values from the provided `PartialState` without recording anything. A recent change (#10703) introduced a soft limit on the size of `PartialState`. When applying a chunk we watch how much state was recorded, and once the amount of state exceeds the soft limit we stop applying the receipts in this chunk. This needs to be done on both the chunk producer and chunk validator - if the chunk validator doesn't record reads and enforce the limit, it will produce a different result of chunk application, which would lead to validation failure. This means that state should be recorded in all cases when a statelessly validated chunk is applied. Let's remove the configuration option that controls whether trie reads should be recorded (`record_storage`) and just record the reads on every chunk application (when `statelessnet_protocol` feature is enabled). Refs: [zulip conversation](https://near.zulipchat.com/#narrow/stream/407237-core.2Fstateless-validation/topic/State.20witness.20size.20limit/near/428313518)
- Loading branch information
1 parent
155acad
commit c2f9695
Showing
10 changed files
with
81 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ use near_epoch_manager::{EpochManagerAdapter, EpochManagerHandle}; | |
use near_parameters::{ActionCosts, ExtCosts, RuntimeConfigStore}; | ||
use near_pool::types::TransactionGroupIterator; | ||
use near_primitives::account::{AccessKey, Account}; | ||
use near_primitives::checked_feature; | ||
use near_primitives::errors::{InvalidTxError, RuntimeError, StorageError}; | ||
use near_primitives::hash::{hash, CryptoHash}; | ||
use near_primitives::receipt::{DelayedReceiptIndices, Receipt}; | ||
|
@@ -30,7 +31,7 @@ use near_primitives::types::{ | |
AccountId, Balance, BlockHeight, EpochHeight, EpochId, EpochInfoProvider, Gas, MerkleHash, | ||
ShardId, StateChangeCause, StateChangesForResharding, StateRoot, StateRootNode, | ||
}; | ||
use near_primitives::version::ProtocolVersion; | ||
use near_primitives::version::{ProtocolVersion, PROTOCOL_VERSION}; | ||
use near_primitives::views::{ | ||
AccessKeyInfoView, CallResult, ContractCodeView, QueryRequest, QueryResponse, | ||
QueryResponseKind, ViewApplyState, ViewStateResult, | ||
|
@@ -704,7 +705,9 @@ impl RuntimeAdapter for NightshadeRuntime { | |
storage_config.use_flat_storage, | ||
), | ||
}; | ||
if storage_config.record_storage { | ||
if checked_feature!("stable", StatelessValidationV0, PROTOCOL_VERSION) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
wacban
Contributor
|
||
|| cfg!(feature = "shadow_chunk_validation") | ||
{ | ||
trie = trie.recording_reads(); | ||
} | ||
let mut state_update = TrieUpdate::new(trie); | ||
|
@@ -865,7 +868,9 @@ impl RuntimeAdapter for NightshadeRuntime { | |
storage_config.use_flat_storage, | ||
), | ||
}; | ||
if storage_config.record_storage { | ||
if checked_feature!("stable", StatelessValidationV0, PROTOCOL_VERSION) | ||
|| cfg!(feature = "shadow_chunk_validation") | ||
{ | ||
trie = trie.recording_reads(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
This is incorrect. The checked_feature should always be used against the protocol version of the current block. During the release PROTOCOL_VERSION will be different than the protocol version of the network.
btw I don't think this is the root cause of the issue we're seeing now.
cc @jancionear Can you address this issue?