Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions node/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,21 @@ impl<N: Network, C: ConsensusStorage<N>> Client<N, C> {
let _node = node.clone();
// For each deployment, spawn a task to verify it.
tokio::task::spawn_blocking(move || {
// First collect the state root.
let Some(state_root) = transaction.fee_transition().map(|t| t.global_state_root()) else {
debug!("Failed to access global state root for deployment from peer_ip {peer_ip}");
_node.num_verifying_deploys.fetch_sub(1, Relaxed);
return;
};
// Check if the state root is in the ledger.
if !_node.ledger().contains_state_root(&state_root).unwrap_or(false) {
debug!("Failed to find global state root for deployment from peer_ip {peer_ip}, propagating anyway");
// Propagate the `UnconfirmedTransaction`.
_node.propagate(Message::UnconfirmedTransaction(serialized), &[peer_ip]);
_node.num_verifying_deploys.fetch_sub(1, Relaxed);
return;
// Also skip the `check_transaction_basic` call if it is already propagated.
}
// Check the deployment.
match _node.ledger.check_transaction_basic(&transaction, None, &mut rand::thread_rng()) {
Ok(_) => {
Expand Down Expand Up @@ -522,6 +537,24 @@ impl<N: Network, C: ConsensusStorage<N>> Client<N, C> {
let _node = node.clone();
// For each execution, spawn a task to verify it.
tokio::task::spawn_blocking(move || {
// First collect the state roots.
let state_roots = [
transaction.execution().map(|t| t.global_state_root()),
transaction.fee_transition().map(|t| t.global_state_root()),
]
.into_iter()
.flatten();

for state_root in state_roots {
if !_node.ledger().contains_state_root(&state_root).unwrap_or(false) {
debug!("Failed to find global state root for execution from peer_ip {peer_ip}, propagating anyway");
// Propagate the `UnconfirmedTransaction`.
_node.propagate(Message::UnconfirmedTransaction(serialized), &[peer_ip]);
_node.num_verifying_executions.fetch_sub(1, Relaxed);
return;
// Also skip the `check_transaction_basic` call if it is already propagated.
}
}
// Check the execution.
match _node.ledger.check_transaction_basic(&transaction, None, &mut rand::thread_rng()) {
Ok(_) => {
Expand Down