Skip to content

I172 service transactions garbage collector + more#328

Merged
SurfingNerd merged 10 commits intoDMDcoin:4.0from
SurfingNerd:i172-service-transactions-garbage-collector
Dec 10, 2025
Merged

I172 service transactions garbage collector + more#328
SurfingNerd merged 10 commits intoDMDcoin:4.0from
SurfingNerd:i172-service-transactions-garbage-collector

Conversation

@SurfingNerd
Copy link
Collaborator

@SurfingNerd SurfingNerd requested a review from Copilot December 10, 2025 14:36
@SurfingNerd SurfingNerd merged commit 10c2ecb into DMDcoin:4.0 Dec 10, 2025
7 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements three main features: service transaction garbage collection, removal of empty blocks during key generation phases, and gas price retrieval from contracts.

  • Adds a garbage collection mechanism to remove invalid service transactions (zero gas price) from the transaction pool
  • Removes the empty block generation behavior during key generation phases by eliminating start_hbbft_epoch_if_next_phase functionality
  • Changes gas price retrieval to use BlockId::Latest instead of the epoch start block

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
crates/transaction-pool/src/pool.rs Implements core garbage collection logic for service transactions
crates/concensus/miner/src/pool/queue.rs Adds wrapper method for garbage collection in transaction queue
crates/ethcore/src/miner/miner.rs Adds public interface for garbage collection in the Miner
crates/ethcore/src/client/client.rs Implements scheduling and execution of garbage collection, adds tracking state
crates/ethcore/service/src/service.rs Handles NewChainHead message to trigger garbage collection
crates/ethcore/src/engines/hbbft/hbbft_engine.rs Removes empty block generation during key generation phases
crates/ethcore/src/engines/hbbft/test/mod.rs Removes test code related to phase transition timing
crates/ethcore/src/engines/hbbft/hbbft_state.rs Changes gas price retrieval to use latest block
crates/ethcore/src/engines/hbbft/contracts/staking.rs Removes unused phase transition function
crates/ethcore/src/engines/hbbft/hbbft_early_epoch_end_manager.rs Changes logging level from info to trace
crates/transaction-pool/Cargo.toml Removes documentation comment
CHANGELOG.md Documents changes for version 4.0.2

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

for sender in self.transactions.iter() {
for tx in sender.1.iter_transactions() {
if tx.transaction.has_zero_gas_price() {
if service_transaction_check(&tx.transaction) {
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic here is inverted. The function service_transaction_check returns true when a transaction is valid (see line 1590 in client.rs where Ok(_) => true), but here we're adding valid transactions to the removal list. This should be:

if !service_transaction_check(&tx.transaction) {
    txs_to_remove.push(tx.hash().clone());
}

This will correctly remove invalid transactions (when the check returns false).

Suggested change
if service_transaction_check(&tx.transaction) {
if !service_transaction_check(&tx.transaction) {

Copilot uses AI. Check for mistakes.
}
}

/// Garbage collect invalid servive transactions from the transaction queue based on the given block header.
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in documentation comment: "servive" should be "service".

Suggested change
/// Garbage collect invalid servive transactions from the transaction queue based on the given block header.
/// Garbage collect invalid service transactions from the transaction queue based on the given block header.

Copilot uses AI. Check for mistakes.
}

// here hides an accepted race condition.
// latest block could change during loing ongoing GCs.
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: "loing" should be "long".

Suggested change
// latest block could change during loing ongoing GCs.
// latest block could change during long ongoing GCs.

Copilot uses AI. Check for mistakes.
// here hides an accepted race condition.
// latest block could change during loing ongoing GCs.
// this could be avoided developing a more complex GC logic.
// but the GC blocks the tx queue, so it has to be placing fast.
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: "placing" should be "running" or "happening".

Suggested change
// but the GC blocks the tx queue, so it has to be placing fast.
// but the GC blocks the tx queue, so it has to be running fast.

Copilot uses AI. Check for mistakes.

shutdown: Arc<ShutdownManager>,

/// block number and block has of latest gc.
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: "has" should be "hash".

Suggested change
/// block number and block has of latest gc.
/// block number and block hash of latest gc.

Copilot uses AI. Check for mistakes.
match machine.verify_transaction(tx.signed(), block_header, self) {
Ok(_) => true,
Err(e) => {
info!(target: "client", "collected garbage transaction from {:?}: {:?} reason: {:?}", tx.signed().sender(), tx.signed().hash, e);
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace at the end of this line should be removed.

Suggested change
info!(target: "client", "collected garbage transaction from {:?}: {:?} reason: {:?}", tx.signed().sender(), tx.signed().hash, e);
info!(target: "client", "collected garbage transaction from {:?}: {:?} reason: {:?}", tx.signed().sender(), tx.signed().hash, e);

Copilot uses AI. Check for mistakes.
### New behavior for validator nodes
- [Autoshutdown if a Node becomes a regular Node](https://github.com/DMDcoin/diamond-node/issues/322)
- [Remove empty blocks during key gen phases behaviour](https://github.com/DMDcoin/diamond-node/issues/327)
- [Service Transaction cleanup (garbage collect)](https://github.com/DMDcoin/diamond-node/issues/172)
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace at the end of this line should be removed.

Suggested change
- [Service Transaction cleanup (garbage collect)](https://github.com/DMDcoin/diamond-node/issues/172)
- [Service Transaction cleanup (garbage collect)](https://github.com/DMDcoin/diamond-node/issues/172)

Copilot uses AI. Check for mistakes.
}

/// Performs garbage collection of the pool for free service transactions.
/// Removes transaction that are not valid anymore.
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar error: "transaction" should be "transactions" (plural).

Suggested change
/// Removes transaction that are not valid anymore.
/// Removes transactions that are not valid anymore.

Copilot uses AI. Check for mistakes.
}

/// Performs garbage collection of the pool of this transactionqueue for free service transactions.
/// Removes transaction that are not valid anymore.
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar error: "transaction" should be "transactions" (plural).

Suggested change
/// Removes transaction that are not valid anymore.
/// Removes transactions that are not valid anymore.

Copilot uses AI. Check for mistakes.
.collect()
}

/// Performs garbage collection of the pool of this transactionqueue for free service transactions.
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "transactionqueue" should be "transaction queue" (with space).

Suggested change
/// Performs garbage collection of the pool of this transactionqueue for free service transactions.
/// Performs garbage collection of the pool of this transaction queue for free service transactions.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants