diff --git a/bcos-executor/src/precompiled/extension/AccountPrecompiled.cpp b/bcos-executor/src/precompiled/extension/AccountPrecompiled.cpp index 4bf4b18256..6fab8652bc 100644 --- a/bcos-executor/src/precompiled/extension/AccountPrecompiled.cpp +++ b/bcos-executor/src/precompiled/extension/AccountPrecompiled.cpp @@ -277,17 +277,7 @@ void AccountPrecompiled::addAccountBalance(const std::string& accountTableName, getErrorCodeOut(_callParameters->mutableExecResult(), CODE_NO_AUTHORIZED, codec); return; } - if (isPrecompiledAddressRange(accountTableName.substr(USER_APPS_PREFIX.length()))) - { - PRECOMPILED_LOG(INFO) << BLOCK_NUMBER(blockContext.number()) - << LOG_BADGE("AccountPrecompiled, addAccountBalance") - << LOG_DESC("account is precompiled address") - << LOG_KV( - "account", accountTableName.substr(USER_APPS_PREFIX.length())); - BOOST_THROW_EXCEPTION( - PrecompiledError("addBalance failed, toAddress is precompiledAddress!")); - return; - } + // check account exist auto table = _executive->storage().openTable(accountTableName); if (!table.has_value()) [[unlikely]] @@ -365,17 +355,6 @@ void AccountPrecompiled::subAccountBalance(const std::string& accountTableName, getErrorCodeOut(_callParameters->mutableExecResult(), CODE_NO_AUTHORIZED, codec); return; } - // check account is precompiled address, if true, return - if (isPrecompiledAddressRange(accountTableName.substr(USER_APPS_PREFIX.length()))) - { - PRECOMPILED_LOG(INFO) << BLOCK_NUMBER(blockContext.number()) - << LOG_BADGE("AccountPrecompiled, addAccountBalance") - << LOG_DESC("account is precompiled address") - << LOG_KV("account", accountTableName.substr(6)); - BOOST_THROW_EXCEPTION( - PrecompiledError("addBalance failed, toAddress is precompiledAddress!")); - return; - } // check account exist auto table = _executive->storage().openTable(accountTableName); diff --git a/bcos-executor/src/vm/Precompiled.cpp b/bcos-executor/src/vm/Precompiled.cpp index e179ca7d70..84301feb6a 100644 --- a/bcos-executor/src/vm/Precompiled.cpp +++ b/bcos-executor/src/vm/Precompiled.cpp @@ -471,6 +471,19 @@ const int RSV_LENGTH = 65; const int PUBLIC_KEY_LENGTH = 64; pair ecRecover(bytesConstRef _in) { // _in is hash(32),v(32),r(32),s(32), return address + + if (_in == bytesConstRef()) + { + BCOS_LOG(TRACE) << LOG_BADGE("Precompiled") << LOG_DESC("ecRecover: nullptr input"); + return {false, {}}; + } + + if (_in.size() != 64 + RSV_LENGTH) + { + BCOS_LOG(TRACE) << LOG_BADGE("Precompiled") << LOG_DESC("ecRecover: invalid input size"); + return {true, {}}; + } + BCOS_LOG(TRACE) << LOG_BADGE("Precompiled") << LOG_DESC("ecRecover: ") << _in.size(); byte rawRSV[RSV_LENGTH]; memcpy(rawRSV, _in.data() + 64, RSV_LENGTH - 1); diff --git a/bcos-framework/test/unittests/interfaces/FeaturesTest.cpp b/bcos-framework/test/unittests/interfaces/FeaturesTest.cpp index 8eef9d485e..d78b152630 100644 --- a/bcos-framework/test/unittests/interfaces/FeaturesTest.cpp +++ b/bcos-framework/test/unittests/interfaces/FeaturesTest.cpp @@ -126,22 +126,27 @@ BOOST_AUTO_TEST_CASE(feature) BOOST_CHECK_EQUAL(features7.get("feature_balance_policy1"), true); auto keys = Features::featureKeys(); - - BOOST_CHECK_EQUAL(keys.size(), 14); - BOOST_CHECK_EQUAL(keys[0], "bugfix_revert"); - 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_call_noaddr_return"); - BOOST_CHECK_EQUAL(keys[5], "bugfix_precompiled_codehash"); - BOOST_CHECK_EQUAL(keys[6], "feature_dmc2serial"); - BOOST_CHECK_EQUAL(keys[7], "feature_sharding"); - BOOST_CHECK_EQUAL(keys[8], "feature_rpbft"); - BOOST_CHECK_EQUAL(keys[9], "feature_paillier"); - BOOST_CHECK_EQUAL(keys[10], "feature_balance"); - BOOST_CHECK_EQUAL(keys[11], "feature_balance_precompiled"); - BOOST_CHECK_EQUAL(keys[12], "feature_balance_policy1"); - BOOST_CHECK_EQUAL(keys[13], "feature_paillier_add_raw"); + // clang-format off + std::vector compareKeys = { + "bugfix_revert", + "bugfix_statestorage_hash", + "bugfix_evm_create2_delegatecall_staticcall_codecopy", + "bugfix_event_log_order", + "bugfix_call_noaddr_return", + "bugfix_precompiled_codehash", + "feature_dmc2serial", + "feature_sharding", + "feature_rpbft", + "feature_balance", + "feature_balance_precompiled", + "feature_balance_policy1", + "feature_paillier_add_raw" + }; + // clang-format on + for (size_t i = 0; i < keys.size(); ++i) + { + BOOST_CHECK_EQUAL(keys[i], compareKeys[i]); + } } BOOST_AUTO_TEST_SUITE_END()