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 e953176 commit bd134db
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ endif()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

set(VERSION "3.2.4")
set(VERSION "3.2.5")
set(VERSION_SUFFIX "")
include(Options)
configure_project()
Expand Down
21 changes: 17 additions & 4 deletions bcos-executor/src/executive/CoroutineTransactionExecutive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,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);
}

// After coroutine switch, set the recoder
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 @@ -134,9 +134,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
8 changes: 7 additions & 1 deletion bcos-executor/src/vm/HostContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ evmc_result HostContext::externalRequest(const evmc_message* _msg)
{
case EVMC_CREATE2:
request->createSalt = fromEvmC(_msg->create2_salt);
if (features().get(ledger::Features::Flag::bugfix_evm_create2_delegatecall_staticcall_codecopy))
if (features().get(
ledger::Features::Flag::bugfix_evm_create2_delegatecall_staticcall_codecopy))
{
request->data.assign(_msg->input_data, _msg->input_data + _msg->input_size);
request->create = true;
Expand Down Expand Up @@ -239,6 +240,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
7 changes: 7 additions & 0 deletions bcos-framework/bcos-framework/ledger/Features.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,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,
};

Expand Down Expand Up @@ -85,6 +87,11 @@ class Features
set(Flag::bugfix_statestorage_hash);
set(Flag::bugfix_evm_create2_delegatecall_staticcall_codecopy);
}
if (version >= protocol::BlockVersion::V3_2_5_VERSION)
{
set(Flag::bugfix_event_log_order);
set(Flag::bugfix_delegatecall_noaddr_return);
}
}

auto flags() const
Expand Down
3 changes: 2 additions & 1 deletion bcos-framework/bcos-framework/protocol/Protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,15 @@ enum ProtocolVersion : uint32_t

enum class BlockVersion : uint32_t
{
V3_2_5_VERSION = 0x03020500,
V3_2_4_VERSION = 0x03020400,
V3_2_3_VERSION = 0x03020300,
V3_2_VERSION = 0x03020000,
V3_1_VERSION = 0x03010000,
V3_0_VERSION = 0x03000000,
RC4_VERSION = 4,
MIN_VERSION = RC4_VERSION,
MAX_VERSION = V3_2_4_VERSION,
MAX_VERSION = V3_2_5_VERSION,
};
const std::string RC4_VERSION_STR = "3.0.0-rc4";
const std::string V3_0_VERSION_STR = "3.0.0";
Expand Down

0 comments on commit bd134db

Please sign in to comment.