From fe07833e8a411fe966835f06bab6f2213d1a3920 Mon Sep 17 00:00:00 2001 From: yongmi2662 <112919248+yongmi2662@users.noreply.github.com> Date: Wed, 3 Jan 2024 21:51:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0transferBalance=E4=B8=AD?= =?UTF-8?q?=E5=90=88=E7=BA=A6=E8=B0=83=E7=94=A8=E7=9A=84=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E4=B9=9F=E8=83=BD=E8=BD=AC=E8=B4=A6=EF=BC=8C=E5=8F=91=E9=80=81?= =?UTF-8?q?=E6=96=B9=E6=94=B9=E4=B8=BAsender=EF=BC=8C=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E6=8E=A5=E6=94=B6=E6=96=B9=E5=9C=B0=E5=9D=80=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=A2=84=E7=BC=96=E8=AF=91=E5=90=88=E7=BA=A6=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=20(#4156)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: binliu21 Co-authored-by: jimmyshi <417711026@qq.com> --- .../src/executive/TransactionExecutive.cpp | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/bcos-executor/src/executive/TransactionExecutive.cpp b/bcos-executor/src/executive/TransactionExecutive.cpp index 1a83d073af..beb627da63 100644 --- a/bcos-executor/src/executive/TransactionExecutive.cpp +++ b/bcos-executor/src/executive/TransactionExecutive.cpp @@ -298,15 +298,22 @@ bool TransactionExecutive::transferBalance(std::string_view origin, std::string_ // sender 是合约地址 // receiver 是转账接收方 EXECUTIVE_LOG(TRACE) << LOG_BADGE("Execute") << "now to transferBalance" - << LOG_KV("subAccount", origin) << LOG_KV("addAccount", receiver) - << LOG_KV("receiveAddress", ACCOUNT_ADDRESS) << LOG_KV("value", value) + << LOG_KV("origin", origin) + << LOG_KV("subAccount", sender) + << LOG_KV("addAccount", receiver) + << LOG_KV("receiveAddress", ACCOUNT_ADDRESS) + << LOG_KV("value", value) << LOG_KV("gas", gas); - + if (isPrecompiled(std::string(receiver))) + { + EXECUTIVE_LOG(DEBUG) << LOG_BADGE("Execute") << "transferBalance, receiverAddress is precompiled address"; + return false; + } // first subAccountBalance, then addAccountBalance - // origin = origin - value + // sender = sender - value auto codec = CodecWrapper(m_blockContext.hashHandler(), m_blockContext.isWasm()); auto params = codec.encodeWithSig("subAccountBalance(uint256)", value); - auto formTableName = bcos::getContractTableName(executor::USER_APPS_PREFIX, origin); + auto formTableName = bcos::getContractTableName(executor::USER_APPS_PREFIX, sender); std::vector fromTableNameVector = {formTableName}; auto inputParams = codec.encode(fromTableNameVector, params); auto subParams = codec.encode(std::string(ACCOUNT_ADDRESS), inputParams); @@ -341,7 +348,7 @@ bool TransactionExecutive::transferBalance(std::string_view origin, std::string_ { EXECUTIVE_LOG(DEBUG) << LOG_BADGE("Execute") << LOG_DESC("transferBalance add failed, need to restore") - << LOG_KV("addAccount", receiver) << LOG_KV("tablename", toTableName); + << LOG_KV("tableName", formTableName) << LOG_KV("will add balance", value); // if receiver add failed, sender need to restore // sender = sender + value @@ -364,7 +371,7 @@ bool TransactionExecutive::transferBalance(std::string_view origin, std::string_ return false; } EXECUTIVE_LOG(DEBUG) << LOG_BADGE("Execute") << "transferBalance finished." - << LOG_KV("subAccount", origin) << LOG_KV("addAccount", receiver) + << LOG_KV("subAccount", sender) << LOG_KV("addAccount", receiver) << LOG_KV("receiveAddress", ACCOUNT_ADDRESS) << LOG_KV("value", value) << LOG_KV("gas", gas); return true;