Skip to content

Commit

Permalink
Only store transactions on validator nodes (#8965)
Browse files Browse the repository at this point in the history
At the moment transactions are indefinitely stored on RPC nodes that are not validators (#8878, #6713).

After this commit, nodes without validator keys will not store transactions in the transaction pool at all.
  • Loading branch information
akashin committed Apr 24, 2023
1 parent e7575ae commit 2da01b0
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions chain/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2006,20 +2006,18 @@ impl Client {
} else if check_only {
Ok(ProcessTxResponse::ValidTx)
} else {
let active_validator = self.active_validator(shard_id)?;

// TODO #6713: Transactions don't need to be recorded if the node is not a validator
// for the shard.
// If I'm not an active validator I should forward tx to next validators.
self.sharded_tx_pool.insert_transaction(shard_id, tx.clone());
trace!(target: "client", shard_id, "Recorded a transaction.");
// Transactions only need to be recorded if the node is a validator.
if me.is_some() {
self.sharded_tx_pool.insert_transaction(shard_id, tx.clone());
trace!(target: "client", shard_id, "Recorded a transaction.");
}

// Active validator:
// possibly forward to next epoch validators
// Not active validator:
// forward to current epoch validators,
// possibly forward to next epoch validators
if active_validator {
if self.active_validator(shard_id)? {
trace!(target: "client", account = ?me, shard_id, is_forwarded, "Recording a transaction.");
metrics::TRANSACTION_RECEIVED_VALIDATOR.inc();

Expand Down

0 comments on commit 2da01b0

Please sign in to comment.