Skip to content

Commit

Permalink
fix dmc not the same with eth in staticcall at no addr return
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyShi22 committed Dec 19, 2023
1 parent eae66ae commit b26640a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
4 changes: 2 additions & 2 deletions bcos-executor/src/executive/CoroutineTransactionExecutive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ CallParameters::UniquePtr CoroutineTransactionExecutive::externalCall(
if (output->delegateCall && output->type != CallParameters::FINISHED)
{
output->data = bytes();
if (m_blockContext.features().get(
ledger::Features::Flag::bugfix_delegatecall_noaddr_return))
if (m_blockContext.features().get(ledger::Features::Flag::bugfix_call_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->type = CallParameters::FINISHED;
output->status = (int32_t)bcos::protocol::TransactionStatus::None;
output->evmStatus = EVMC_SUCCESS;
}
Expand Down
23 changes: 20 additions & 3 deletions bcos-executor/src/executive/TransactionExecutive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ CallParameters::UniquePtr TransactionExecutive::externalCall(CallParameters::Uni
<< LOG_KV("codeAddress", input->codeAddress);

output->data = bytes();
if (m_blockContext.features().get(
ledger::Features::Flag::bugfix_delegatecall_noaddr_return))
if (m_blockContext.features().get(ledger::Features::Flag::bugfix_call_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
Expand Down Expand Up @@ -265,7 +264,7 @@ CallParameters::UniquePtr TransactionExecutive::execute(CallParameters::UniquePt
}
}

else if (callParameters->create)
if (callParameters->create)
{
std::tie(hostContext, callResults) = create(std::move(callParameters));
}
Expand Down Expand Up @@ -949,6 +948,24 @@ CallParameters::UniquePtr TransactionExecutive::go(
{
revert();
auto callResult = hostContext.takeCallParameters();

if (m_blockContext.features().get(
ledger::Features::Flag::bugfix_call_noaddr_return) &&
callResult->staticCall)
{
// Note: to be the same as eth
// Just fix DMC:
// if bugfix_call_noaddr_return is not set, callResult->evmStatus is still
// default to EVMC_SUCCESS and serial mode is execute same as eth, but DMC is
// using callResult->status, so we need to compat with DMC here

callResult->type = CallParameters::FINISHED;
callResult->evmStatus = EVMC_SUCCESS;
callResult->status = (int32_t)TransactionStatus::None;
callResult->message = "Error contract address.";
return callResult;
}

callResult->type = CallParameters::REVERT;
callResult->status = (int32_t)TransactionStatus::CallAddressError;
callResult->message = "Error contract address.";
Expand Down
4 changes: 2 additions & 2 deletions bcos-framework/bcos-framework/ledger/Features.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Features
bugfix_statestorage_hash,
bugfix_evm_create2_delegatecall_staticcall_codecopy,
bugfix_event_log_order,
bugfix_delegatecall_noaddr_return,
bugfix_call_noaddr_return,
bugfix_precompiled_codehash,
feature_dmc2serial,
feature_sharding,
Expand Down Expand Up @@ -129,7 +129,7 @@ class Features
if (version >= protocol::BlockVersion::V3_2_6_VERSION)
{
set(Flag::bugfix_event_log_order);
set(Flag::bugfix_delegatecall_noaddr_return);
set(Flag::bugfix_call_noaddr_return);
set(Flag::bugfix_precompiled_codehash);
}

Expand Down

0 comments on commit b26640a

Please sign in to comment.