I172 service transactions garbage collector + more#328
I172 service transactions garbage collector + more#328SurfingNerd merged 10 commits intoDMDcoin:4.0from
Conversation
SurfingNerd
commented
Dec 10, 2025
- Remove empty blocks during key gen phases behaviour
- Service Transaction cleanup (garbage collect)
- Gas price from contracts
todo: dont gc same block twice
There was a problem hiding this comment.
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_phasefunctionality - Changes gas price retrieval to use
BlockId::Latestinstead 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) { |
There was a problem hiding this comment.
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).
| if service_transaction_check(&tx.transaction) { | |
| if !service_transaction_check(&tx.transaction) { |
| } | ||
| } | ||
|
|
||
| /// Garbage collect invalid servive transactions from the transaction queue based on the given block header. |
There was a problem hiding this comment.
Typo in documentation comment: "servive" should be "service".
| /// 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. |
| } | ||
|
|
||
| // here hides an accepted race condition. | ||
| // latest block could change during loing ongoing GCs. |
There was a problem hiding this comment.
Typo in comment: "loing" should be "long".
| // latest block could change during loing ongoing GCs. | |
| // latest block could change during long ongoing GCs. |
| // 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. |
There was a problem hiding this comment.
Typo in comment: "placing" should be "running" or "happening".
| // 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. |
|
|
||
| shutdown: Arc<ShutdownManager>, | ||
|
|
||
| /// block number and block has of latest gc. |
There was a problem hiding this comment.
Typo in comment: "has" should be "hash".
| /// block number and block has of latest gc. | |
| /// block number and block hash of latest gc. |
| 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); |
There was a problem hiding this comment.
Trailing whitespace at the end of this line should be removed.
| 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); |
| ### 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) |
There was a problem hiding this comment.
Trailing whitespace at the end of this line should be removed.
| - [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) |
| } | ||
|
|
||
| /// Performs garbage collection of the pool for free service transactions. | ||
| /// Removes transaction that are not valid anymore. |
There was a problem hiding this comment.
Grammar error: "transaction" should be "transactions" (plural).
| /// Removes transaction that are not valid anymore. | |
| /// Removes transactions that are not valid anymore. |
| } | ||
|
|
||
| /// Performs garbage collection of the pool of this transactionqueue for free service transactions. | ||
| /// Removes transaction that are not valid anymore. |
There was a problem hiding this comment.
Grammar error: "transaction" should be "transactions" (plural).
| /// Removes transaction that are not valid anymore. | |
| /// Removes transactions that are not valid anymore. |
| .collect() | ||
| } | ||
|
|
||
| /// Performs garbage collection of the pool of this transactionqueue for free service transactions. |
There was a problem hiding this comment.
Typo: "transactionqueue" should be "transaction queue" (with space).
| /// 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. |