diff --git a/src/contract/contractmanager.cpp b/src/contract/contractmanager.cpp index 776023ae..79f0c0a7 100644 --- a/src/contract/contractmanager.cpp +++ b/src/contract/contractmanager.cpp @@ -189,6 +189,7 @@ bool ContractManager::validateCallContractWithTx(const ethCallInfo& callInfo) { this->callLogger_->setContractVars(this, from, from, value); this->ethCall(callInfo); this->callLogger_.reset(); + this->eventManager_.revertEvents(); return true; } @@ -196,12 +197,14 @@ bool ContractManager::validateCallContractWithTx(const ethCallInfo& callInfo) { this->callLogger_->setContractVars(&rdpos_, from, from, value); rdpos_.ethCall(callInfo); this->callLogger_.reset(); + this->eventManager_.revertEvents(); return true; } std::shared_lock lock(this->contractsMutex_); if (!this->contracts_.contains(to)) { this->callLogger_.reset(); + this->eventManager_.revertEvents(); return false; } const auto &contract = contracts_.at(to); @@ -209,9 +212,11 @@ bool ContractManager::validateCallContractWithTx(const ethCallInfo& callInfo) { contract->ethCall(callInfo); } catch (std::exception &e) { this->callLogger_.reset(); + this->eventManager_.revertEvents(); throw DynamicException(e.what()); } this->callLogger_.reset(); + this->eventManager_.revertEvents(); return true; } diff --git a/src/contract/contractmanager.h b/src/contract/contractmanager.h index 268726ff..ee84aed9 100644 --- a/src/contract/contractmanager.h +++ b/src/contract/contractmanager.h @@ -460,7 +460,6 @@ class ContractManagerInterface { // inside contracts and are not emitted if a transaction reverts. // C++ itself already takes care of events not being emitted on pure/view // functions due to its built-in const-correctness logic. - // TODO: check later if events are really not emitted on transaction revert if (!this->manager_.callLogger_) throw DynamicException( "Contracts going haywire! Trying to emit an event without an active contract call" ); diff --git a/tests/sdktestsuite.hpp b/tests/sdktestsuite.hpp index c2ec65c0..f58b20ad 100644 --- a/tests/sdktestsuite.hpp +++ b/tests/sdktestsuite.hpp @@ -469,7 +469,7 @@ class SDKTestSuite { ); ret = tx.hash(); // Check if the execution is not going to be reverted/throw - this->state_.estimateGas(tx.txToCallInfo()); // TODO: this is emitting duplicate events, needs to be fixed + this->state_.estimateGas(tx.txToCallInfo()); this->advanceChain(timestamp, {tx}); return ret; }