Skip to content

Commit

Permalink
sync fix from 3.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyShi22 committed Dec 20, 2023
1 parent a631b96 commit d5fffcf
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ CallParameters::UniquePtr CoroutineTransactionExecutive::externalCall(
{
output->data = bytes();
if (m_blockContext.lock()->features().get(
ledger::Features::Flag::bugfix_delegatecall_noaddr_return))
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
20 changes: 19 additions & 1 deletion bcos-executor/src/executive/TransactionExecutive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ CallParameters::UniquePtr TransactionExecutive::externalCall(CallParameters::Uni

output->data = bytes();
if (m_blockContext.lock()->features().get(
ledger::Features::Flag::bugfix_delegatecall_noaddr_return))
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 @@ -834,6 +834,24 @@ CallParameters::UniquePtr TransactionExecutive::go(
{
revert();
auto callResult = hostContext.takeCallParameters();

if (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 @@ -30,7 +30,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,
};
Expand Down Expand Up @@ -91,7 +91,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
2 changes: 1 addition & 1 deletion bcos-framework/test/unittests/interfaces/FeaturesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ BOOST_AUTO_TEST_CASE(feature)
BOOST_CHECK_EQUAL(keys[1], "bugfix_statestorage_hash");
BOOST_CHECK_EQUAL(keys[2], "bugfix_evm_create2_delegatecall_staticcall_codecopy");
BOOST_CHECK_EQUAL(keys[3], "bugfix_event_log_order");
BOOST_CHECK_EQUAL(keys[4], "bugfix_delegatecall_noaddr_return");
BOOST_CHECK_EQUAL(keys[4], "bugfix_call_noaddr_return");
BOOST_CHECK_EQUAL(keys[5], "bugfix_precompiled_codehash");
BOOST_CHECK_EQUAL(keys[6], "feature_dmc2serial");
}
Expand Down

0 comments on commit d5fffcf

Please sign in to comment.