Skip to content

Commit

Permalink
feat: add tx_root check for state witness new_transactions (near#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pugachAG authored Nov 12, 2024
1 parent 837b9f9 commit ce278d7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion chain/chain/src/stateless_validation/chunk_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,16 @@ pub fn pre_validate_chunk_state_witness(
RelaxedChunkValidation,
current_protocol_version
) {
// Verify that all proposed transactions are valid.
let new_transactions = &state_witness.new_transactions;
let (new_tx_root_from_state_witness, _) = merklize(&new_transactions);
let chunk_tx_root = state_witness.chunk_header.tx_root();
if new_tx_root_from_state_witness != chunk_tx_root {
return Err(Error::InvalidChunkStateWitness(format!(
"Witness new transactions root {:?} does not match chunk {:?}",
new_tx_root_from_state_witness, chunk_tx_root
)));
}
// Verify that all proposed transactions are valid.
if !new_transactions.is_empty() {
let transactions_validation_storage_config = RuntimeStorageConfig {
state_root: state_witness.chunk_header.prev_state_root(),
Expand Down

0 comments on commit ce278d7

Please sign in to comment.