From e92448b1cc16fcc68028574b94876f7187a01a87 Mon Sep 17 00:00:00 2001 From: JimmyShi22 <417711026@qq.com> Date: Mon, 22 Apr 2024 21:23:58 +0800 Subject: [PATCH] add log and test --- bcos-scheduler/src/BlockExecutive.cpp | 17 ++++++++--------- tools/.ci/java_sdk_demo_ci_test.sh | 11 +++++++++++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/bcos-scheduler/src/BlockExecutive.cpp b/bcos-scheduler/src/BlockExecutive.cpp index 6f328d00bb..160f3a8d57 100644 --- a/bcos-scheduler/src/BlockExecutive.cpp +++ b/bcos-scheduler/src/BlockExecutive.cpp @@ -1581,15 +1581,14 @@ void BlockExecutive::onTxFinish(bcos::protocol::ExecutionMessage::UniquePtr outp if (bcos::precompiled::c_systemTxsAddress.contains(output->from())) { - if (m_scheduler->ledgerConfig().features().get( - ledger::Features::Flag::bugfix_dmc_deploy_gas_used)) - { - if (output->create()) - { - txGasUsed = 0; - } - } - else + // Note: We will not consume gas when EOA call sys contract directly. + // When dmc return, sys contract is from(), to() is EOA address. + // But if this tx is a deploy tx, from() is sys contract but to() is new address. + // So we need to fix this bug here: only consider output->newEVMContractAddress().empty() + // here. Leaving only EOA call sys contract here. + auto hasBugfix = m_scheduler->ledgerConfig().features().get( + ledger::Features::Flag::bugfix_dmc_deploy_gas_used); + if (!hasBugfix || (hasBugfix && output->newEVMContractAddress().empty())) { txGasUsed = 0; } diff --git a/tools/.ci/java_sdk_demo_ci_test.sh b/tools/.ci/java_sdk_demo_ci_test.sh index 04625c8780..4dcf70614e 100755 --- a/tools/.ci/java_sdk_demo_ci_test.sh +++ b/tools/.ci/java_sdk_demo_ci_test.sh @@ -163,6 +163,17 @@ check_all_contract() { exit 1; fi + LOG_INFO "check block gasUsed" + local current_block_number=$(bash console.sh getBlockNumber) + LOG_INFO "check block gasUsed, current number is ${current_block_number}" + local gas_used=$(bash console.sh getBlockByNumber ${current_block_number} |grep gasUsed |awk -F "'" '{print $2}') + if [ ${gas_used} -ne 0 ]; then + LOG_INFO "check block gasUsed success, current gas is ${gas_used}" + else + LOG_ERROR "check block gasUsed failed, gas is ${gas_used}" + exit 1; + fi + LOG_INFO "addBalance to contract ${test_contract_address}" bash console.sh addBalance ${test_contract_address} 10000000