Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Stop tracking sent transactions once they've been imported into the blockchain #5706

Merged
merged 3 commits into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- Fixed: [#5664](https://github.com/ethereum/aleth/pull/5664) Behavior in corner case tests about touching empty Precompiles now agrees with geth's results.
- Fixed: [#5662](https://github.com/ethereum/aleth/pull/5662) Correct depth value when aleth-interpreter invokes `evmc_host_interface::call` callback.
- Fixed: [#5666](https://github.com/ethereum/aleth/pull/5666) aleth-interpreter returns `EVMC_INVALID_INSTRUCTION` when `INVALID` opcode is encountered and `EVMC_UNKNOWN_INSTRUCTION` for undefined opcodes.
- Fixed: [#5706](https://github.com/ethereum/aleth/pull/5706) Stop tracking sent transactions after they've been imported into the blockchain.

## [1.6.0] - 2019-04-16

Expand Down
6 changes: 6 additions & 0 deletions libethereum/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,17 @@ void Client::onChainChanged(ImportRoute const& _ir)
// ctrace << "onChainChanged()";
h256Hash changeds;
onDeadBlocks(_ir.deadBlocks, changeds);
vector<h256> goodTransactions;
goodTransactions.reserve(_ir.goodTranactions.size());
for (auto const& t: _ir.goodTranactions)
{
LOG(m_loggerDetail) << "Safely dropping transaction " << t.sha3();
m_tq.dropGood(t);
goodTransactions.push_back(t.sha3());
}
auto h = m_host.lock();
if (h)
h->removeSentTransactions(goodTransactions);
onNewBlocks(_ir.liveBlocks, changeds);
if (!isMajorSyncing())
resyncStateFromChain();
Expand Down
13 changes: 13 additions & 0 deletions libethereum/EthereumCapability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,19 @@ void EthereumCapability::disablePeer(NodeID const& _peerID, std::string const& _
m_host->disableCapability(_peerID, name(), _problem);
}

void EthereumCapability::removeSentTransactions(std::vector<h256> const& _txHashes)
{
if (!_txHashes.empty())
{
// Function can be called from the client thread so we need to ensure that
// m_transactionsSent modifications occur on the network thread
m_host->postWork([_txHashes, this]() {
for (auto const& txHash : _txHashes)
m_transactionsSent.erase(txHash);
});
}
}

EthereumPeer const& EthereumCapability::peer(NodeID const& _peerID) const
{
return const_cast<EthereumCapability*>(this)->peer(_peerID);
Expand Down
6 changes: 6 additions & 0 deletions libethereum/EthereumCapability.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ class EthereumCapability : public p2p::CapabilityFace
EthereumPeer& peer(NodeID const& _peerID);
void disablePeer(NodeID const& _peerID, std::string const& _problem);

/// Remove the supplied transaction hashes from the sent transactions list. Done when
/// the transactions have been confirmed to be a part of the blockchain so we no longer
/// need to explicitly track them to prevent sending them out to peers. Can be called safely
/// from any thread.
void removeSentTransactions(std::vector<h256> const& _txHashes);

private:
static char const* const c_stateNames[static_cast<int>(SyncState::Size)];
static constexpr std::chrono::milliseconds c_backgroundWorkInterval{1000};
Expand Down