Skip to content

Commit

Permalink
Fix event log order & delegatecall noaddr return true
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyShi22 committed Nov 17, 2023
1 parent 43858f8 commit 40a8ddc
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
21 changes: 17 additions & 4 deletions bcos-executor/src/executive/CoroutineTransactionExecutive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,24 @@ CallParameters::UniquePtr CoroutineTransactionExecutive::externalCall(

if (output->delegateCall && output->type != CallParameters::FINISHED)
{
EXECUTIVE_LOG(DEBUG) << "Could not getCode during DMC externalCall"
<< LOG_KV("codeAddress", output->codeAddress);
output->data = bytes();
output->status = (int32_t)bcos::protocol::TransactionStatus::RevertInstruction;
output->evmStatus = EVMC_REVERT;
if (m_blockContext.lock()->features().get(
ledger::Features::Flag::bugfix_delegatecall_noaddr_return))
{
// This is eth's bug, but we still need to compat with it :)
// https://docs.soliditylang.org/en/v0.8.17/control-structures.html#error-handling-assert-require-revert-and-exceptions
output->status = (int32_t)bcos::protocol::TransactionStatus::None;
output->evmStatus = EVMC_SUCCESS;
}
else
{
output->status = (int32_t)bcos::protocol::TransactionStatus::RevertInstruction;
output->evmStatus = EVMC_REVERT;
}
EXECUTIVE_LOG(DEBUG) << "Could not getCode during DMC externalCall"
<< LOG_KV("codeAddress", output->codeAddress)
<< LOG_KV("status", output->status)
<< LOG_KV("evmStatus", output->evmStatus);
}

if (versionCompareTo(
Expand Down
16 changes: 14 additions & 2 deletions bcos-executor/src/executive/TransactionExecutive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,21 @@ CallParameters::UniquePtr TransactionExecutive::externalCall(CallParameters::Uni
auto& output = input;
EXECUTIVE_LOG(DEBUG) << "Could not getCodeHash during externalCall"
<< LOG_KV("codeAddress", input->codeAddress);

output->data = bytes();
output->status = (int32_t)TransactionStatus::RevertInstruction;
output->evmStatus = EVMC_REVERT;
if (m_blockContext.lock()->features().get(
ledger::Features::Flag::bugfix_delegatecall_noaddr_return))
{
// This is eth's bug, but we still need to compat with it :)
// https://docs.soliditylang.org/en/v0.8.17/control-structures.html#error-handling-assert-require-revert-and-exceptions
output->status = (int32_t)TransactionStatus::None;
output->evmStatus = EVMC_SUCCESS;
}
else
{
output->status = (int32_t)TransactionStatus::RevertInstruction;
output->evmStatus = EVMC_REVERT;
}
return std::move(output);
}

Expand Down
5 changes: 5 additions & 0 deletions bcos-executor/src/vm/HostContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ evmc_result HostContext::externalRequest(const evmc_message* _msg)
.create_address = toEvmC(boost::algorithm::unhex(response->newEVMContractAddress)),
.padding = {}};

if (features().get(ledger::Features::Flag::bugfix_event_log_order))
{
// put event log by stack(dfs) order
m_callParameters->logEntries = std::move(response->logEntries);
}
// Put response to store in order to avoid data lost
m_responseStore.emplace_back(std::move(response));

Expand Down
10 changes: 9 additions & 1 deletion bcos-framework/bcos-framework/ledger/Features.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class Features
bugfix_revert, // https://github.com/FISCO-BCOS/FISCO-BCOS/issues/3629
bugfix_statestorage_hash,
bugfix_evm_create2_delegatecall_staticcall_codecopy,
bugfix_event_log_order,
bugfix_delegatecall_noaddr_return,
feature_dmc2serial,
feature_sharding,
feature_rpbft,
Expand Down Expand Up @@ -63,7 +65,7 @@ class Features
{
BOOST_THROW_EXCEPTION(NoSuchFeatureError{});
}

validate(*value);
}

Expand Down Expand Up @@ -122,6 +124,12 @@ class Features
set(Flag::bugfix_statestorage_hash);
set(Flag::bugfix_evm_create2_delegatecall_staticcall_codecopy);
}
if (version >= protocol::BlockVersion::V3_6_0_VERSION)
{
set(Flag::bugfix_event_log_order);
set(Flag::bugfix_delegatecall_noaddr_return);
}

setToShardingDefault(version);
}

Expand Down

0 comments on commit 40a8ddc

Please sign in to comment.