diff --git a/bcos-executor/src/executive/TransactionExecutive.cpp b/bcos-executor/src/executive/TransactionExecutive.cpp index 88d55a6421..f8397ff8ec 100644 --- a/bcos-executor/src/executive/TransactionExecutive.cpp +++ b/bcos-executor/src/executive/TransactionExecutive.cpp @@ -124,43 +124,58 @@ CallParameters::UniquePtr TransactionExecutive::externalCall(CallParameters::Uni // get codeHash in contract table auto codeHashEntry = storage().getRow(tableName, ACCOUNT_CODE_HASH); - if (!codeHashEntry || codeHashEntry->get().empty()) + do { - auto& output = input; - EXECUTIVE_LOG(DEBUG) << "Could not getCodeHash during externalCall" - << LOG_KV("codeAddress", input->codeAddress); - - output->data = bytes(); - if (m_blockContext.features().get(ledger::Features::Flag::bugfix_call_noaddr_return)) + if (!codeHashEntry || codeHashEntry->get().empty()) { - // 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; + auto& output = input; + EXECUTIVE_LOG(DEBUG) << "Could not getCodeHash during externalCall" + << LOG_KV("codeAddress", input->codeAddress); + + if (m_blockContext.features().get( + ledger::Features::Flag::bugfix_call_noaddr_return)) + { + auto entry = storage().getRow(tableName, ACCOUNT_CODE); + if (entry && !entry->get().empty()) + { + input->delegateCallCode = toBytes(entry->get()); + break; + } + } + + output->data = bytes(); + 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->status = (int32_t)TransactionStatus::None; + output->evmStatus = EVMC_SUCCESS; + } + else + { + output->status = (int32_t)TransactionStatus::RevertInstruction; + output->evmStatus = EVMC_REVERT; + } + return std::move(output); } - else + + auto codeHash = codeHashEntry->getField(0); + + // get code in code binary table + auto entry = storage().getRow(bcos::ledger::SYS_CODE_BINARY, codeHash); + if (!entry || entry->get().empty()) { + auto& output = input; + EXECUTIVE_LOG(DEBUG) << "Could not getCode during externalCall" + << LOG_KV("codeAddress", input->codeAddress); + output->data = bytes(); output->status = (int32_t)TransactionStatus::RevertInstruction; output->evmStatus = EVMC_REVERT; + return std::move(output); } - return std::move(output); - } - - auto codeHash = codeHashEntry->getField(0); - - // get code in code binary table - auto entry = storage().getRow(bcos::ledger::SYS_CODE_BINARY, codeHash); - if (!entry || entry->get().empty()) - { - auto& output = input; - EXECUTIVE_LOG(DEBUG) << "Could not getCode during externalCall" - << LOG_KV("codeAddress", input->codeAddress); - output->data = bytes(); - output->status = (int32_t)TransactionStatus::RevertInstruction; - output->evmStatus = EVMC_REVERT; - return std::move(output); - } - input->delegateCallCode = toBytes(entry->get()); + input->delegateCallCode = toBytes(entry->get()); + } while (0); } if (input->data == bcos::protocol::GET_CODE_INPUT_BYTES) @@ -175,6 +190,16 @@ CallParameters::UniquePtr TransactionExecutive::externalCall(CallParameters::Uni auto codeHashEntry = storage().getRow(tableName, ACCOUNT_CODE_HASH); if (!codeHashEntry || codeHashEntry->get().empty()) { + if (m_blockContext.features().get(ledger::Features::Flag::bugfix_call_noaddr_return)) + { + auto entry = storage().getRow(tableName, ACCOUNT_CODE); + if (entry && !entry->get().empty()) + { + output->data = toBytes(entry->get()); + return std::move(output); + } + } + EXECUTIVE_LOG(DEBUG) << "Could not get external code hash from local storage" << LOG_KV("codeAddress", input->codeAddress); output->data = bytes(); @@ -959,7 +984,9 @@ CallParameters::UniquePtr TransactionExecutive::go( if (m_blockContext.features().get( ledger::Features::Flag::bugfix_call_noaddr_return) && - callResult->staticCall) + callResult->staticCall && + callResult->seq > 0 // must staticCall from contract(not from rpc call) + ) { // Note: to be the same as eth // Just fix DMC: diff --git a/bcos-executor/src/vm/HostContext.cpp b/bcos-executor/src/vm/HostContext.cpp index 3b544357f0..fb36b861f0 100644 --- a/bcos-executor/src/vm/HostContext.cpp +++ b/bcos-executor/src/vm/HostContext.cpp @@ -133,7 +133,7 @@ evmc_result HostContext::externalRequest(const evmc_message* _msg) evmAddress2String(_msg->sender) == std::string(bcos::precompiled::EVM_BALANCE_SENDER_ADDRESS)) { - // for AccountPrecompiled to sub and add + // comes from selfdestruct() getAccountBalance use EVM_BALANCE_SENDER_ADDRESS as msg->sender request->senderAddress = std::string(bcos::precompiled::EVM_BALANCE_SENDER_ADDRESS); } else diff --git a/bcos-utilities/bcos-utilities/BoostLogInitializer.cpp b/bcos-utilities/bcos-utilities/BoostLogInitializer.cpp index 5c277d2ee0..f9a2e7554c 100644 --- a/bcos-utilities/bcos-utilities/BoostLogInitializer.cpp +++ b/bcos-utilities/bcos-utilities/BoostLogInitializer.cpp @@ -58,7 +58,8 @@ struct BoostLogLevelResetHandler << LOG_KV("logLevelStr", logLevelStr) << LOG_KV("logLevel", logLevel); } catch (...) - {} + { + } } static std::string configFile; @@ -213,7 +214,7 @@ boost::shared_ptr BoostLogInitializer::initHo std::string fileName = _logPath + "/" + _logPrefix + "_%Y%m%d%H.%M.log"; boost::shared_ptr sink(new sink_t()); - sink->locked_backend()->set_open_mode(std::ios::app); + sink->locked_backend()->set_open_mode(std::ios::ate); sink->locked_backend()->set_time_based_rotation( boost::bind(&BoostLogInitializer::canRotate, this, (m_currentHourVec.size() - 1)));