Skip to content

Commit

Permalink
Merge branch 'feature-rpbft2' of https://github.com/FISCO-BCOS/FISCO-…
Browse files Browse the repository at this point in the history
…BCOS into release-3.11.0
  • Loading branch information
bxq2011hust committed Aug 16, 2024
2 parents cb711ed + 602bfb4 commit 55aa0a6
Show file tree
Hide file tree
Showing 90 changed files with 1,619 additions and 1,540 deletions.
1 change: 1 addition & 0 deletions bcos-boostssl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ target_include_directories(bcos-boostssl PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include/bcos-boostssl>)
target_link_libraries(bcos-boostssl PUBLIC bcos-framework bcos-utilities OpenSSL::SSL)
set_target_properties(bcos-boostssl PROPERTIES UNITY_BUILD "ON")

if(TESTS)
enable_testing()
Expand Down
1 change: 1 addition & 0 deletions bcos-codec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ target_include_directories(${CODEC_TARGET} PUBLIC
$<INSTALL_INTERFACE:include/bcos-codec>
)
target_link_libraries(${CODEC_TARGET} PUBLIC bcos-crypto Microsoft.GSL::GSL)
set_target_properties(${CODEC_TARGET} PROPERTIES UNITY_BUILD "ON")

if (TESTS)
enable_testing()
Expand Down
1 change: 1 addition & 0 deletions bcos-crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ find_package(HSM-CRYPTO REQUIRED)

add_library(bcos-crypto STATIC ${ALL_SRCS})
target_link_libraries(bcos-crypto PUBLIC ${LIB_LIST})
set_target_properties(bcos-crypto PROPERTIES UNITY_BUILD "ON")

if(NOT WIN32)
target_compile_options(bcos-crypto PUBLIC "-Wno-ignored-attributes")
Expand Down
6 changes: 6 additions & 0 deletions bcos-executor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ else()
Boost::context evmone evmc::loader evmc::instructions GroupSig Paillier blst)
endif()

set_source_files_properties(
"src/vm/kzgPrecompiled.cpp"
"src/vm/VMFactory.cpp"
PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
set_target_properties(${EXECUTOR_TARGET} PROPERTIES UNITY_BUILD "ON")

if (TOOLS)
add_subdirectory(tools)
endif()
Expand Down
1 change: 1 addition & 0 deletions bcos-executor/src/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "Common.h"
#include "bcos-executor/src/precompiled/common/Common.h"
#include "bcos-framework/protocol/Exceptions.h"
#include <bcos-utilities/Common.h>

using namespace bcos::protocol;
Expand Down
4 changes: 2 additions & 2 deletions bcos-executor/src/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#pragma once

#include "bcos-crypto/interfaces/crypto/Hash.h"
#include "bcos-framework/protocol/LogEntry.h"
#include "bcos-protocol/TransactionStatus.h"
#include <bcos-framework/protocol/LogEntry.h>
#include <bcos-utilities/Exceptions.h>
#include "bcos-utilities/Exceptions.h"
#include <evmc/instructions.h>
#include <boost/algorithm/string/case_conv.hpp>
#include <algorithm>
Expand Down
4 changes: 3 additions & 1 deletion bcos-executor/src/precompiled/TableManagerPrecompiled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "TableManagerPrecompiled.h"

#include "bcos-executor/src/precompiled/common/Common.h"
#include "bcos-executor/src/precompiled/common/PrecompiledAbi.h"
#include "bcos-executor/src/precompiled/common/PrecompiledResult.h"
#include "bcos-executor/src/precompiled/common/Utilities.h"
#include <bcos-framework/protocol/Exceptions.h>
Expand Down Expand Up @@ -93,7 +94,8 @@ std::shared_ptr<PrecompiledExecResult> TableManagerPrecompiled::call(
if (selector != selector2Func.end())
{
if (blockContext.isWasm() && func == name2Selector[TABLE_METHOD_OPEN])
{}
{
}
auto& [minVersion, execFunc] = selector->second;
if (versionCompareTo(blockContext.blockVersion(), minVersion) >= 0)
{
Expand Down
14 changes: 2 additions & 12 deletions bcos-executor/src/precompiled/common/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,10 @@

#pragma once

#include "PrecompiledAbi.h"
#include "bcos-executor/src/Common.h"
#include "bcos-framework/Common.h"
#include "bcos-framework/protocol/CommonError.h"
#include "bcos-framework/protocol/Exceptions.h"
#include "bcos-framework/storage/Common.h"
#include "bcos-framework/storage/Entry.h"
#include <memory>
#include <string>

namespace bcos
{
namespace precompiled
namespace bcos::precompiled
{
#define PRECOMPILED_LOG(LEVEL) BCOS_LOG(LEVEL) << "[EXECUTOR][PRECOMPILED]"

Expand Down Expand Up @@ -193,5 +184,4 @@ static constexpr inline ContractStatus StatusFromString(std::string_view _status
}
return ContractStatus::Available;
}
} // namespace precompiled
} // namespace bcos
} // namespace bcos::precompiled
16 changes: 8 additions & 8 deletions bcos-executor/src/precompiled/extension/AccountPrecompiled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ using namespace bcos::executor;
using namespace bcos::storage;
using namespace bcos::protocol;

const char* const AM_METHOD_SET_ACCOUNT_STATUS = "setAccountStatus(uint8)";
const char* const AM_METHOD_GET_ACCOUNT_STATUS = "getAccountStatus()";
const char* const ACCOUNT_METHOD_SET_ACCOUNT_STATUS = "setAccountStatus(uint8)";
const char* const ACCOUNT_METHOD_GET_ACCOUNT_STATUS = "getAccountStatus()";
const char* const AM_METHOD_GET_ACCOUNT_BALANCE = "getAccountBalance()";
const char* const AM_METHOD_ADD_ACCOUNT_BALANCE = "addAccountBalance(uint256)";
const char* const AM_METHOD_SUB_ACCOUNT_BALANCE = "subAccountBalance(uint256)";
Expand All @@ -38,10 +38,10 @@ const uint32_t AM_METHOD_RECEIVE_FALLBACK_SELECTOR = 1;

AccountPrecompiled::AccountPrecompiled(crypto::Hash::Ptr hashImpl) : Precompiled(hashImpl)
{
name2Selector[AM_METHOD_SET_ACCOUNT_STATUS] =
getFuncSelector(AM_METHOD_SET_ACCOUNT_STATUS, hashImpl);
name2Selector[AM_METHOD_GET_ACCOUNT_STATUS] =
getFuncSelector(AM_METHOD_GET_ACCOUNT_STATUS, hashImpl);
name2Selector[ACCOUNT_METHOD_SET_ACCOUNT_STATUS] =
getFuncSelector(ACCOUNT_METHOD_SET_ACCOUNT_STATUS, hashImpl);
name2Selector[ACCOUNT_METHOD_GET_ACCOUNT_STATUS] =
getFuncSelector(ACCOUNT_METHOD_GET_ACCOUNT_STATUS, hashImpl);
name2Selector[AM_METHOD_GET_ACCOUNT_BALANCE] =
getFuncSelector(AM_METHOD_GET_ACCOUNT_BALANCE, hashImpl);
name2Selector[AM_METHOD_ADD_ACCOUNT_BALANCE] =
Expand Down Expand Up @@ -78,11 +78,11 @@ std::shared_ptr<PrecompiledExecResult> AccountPrecompiled::call(
bytesConstRef data = getParamData(originParam);
auto table = _executive->storage().openTable(accountTableName);

if (func == name2Selector[AM_METHOD_SET_ACCOUNT_STATUS])
if (func == name2Selector[ACCOUNT_METHOD_SET_ACCOUNT_STATUS])
{
setAccountStatus(accountTableName, _executive, data, _callParameters);
}
else if (func == name2Selector[AM_METHOD_GET_ACCOUNT_STATUS])
else if (func == name2Selector[ACCOUNT_METHOD_GET_ACCOUNT_STATUS])
{
getAccountStatus(accountTableName, _executive, _callParameters);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,95 +30,95 @@ using namespace bcos::protocol;

/// contract ACL
/// wasm
constexpr const char* const AUTH_METHOD_GET_ADMIN = "getAdmin(string)";
constexpr const char* const AUTH_METHOD_SET_ADMIN = "resetAdmin(string,string)";
constexpr const char* const AUTH_METHOD_SET_AUTH_TYPE = "setMethodAuthType(string,bytes4,uint8)";
constexpr const char* const AUTH_METHOD_OPEN_AUTH = "openMethodAuth(string,bytes4,string)";
constexpr const char* const AUTH_METHOD_CLOSE_AUTH = "closeMethodAuth(string,bytes4,string)";
constexpr const char* const AUTH_METHOD_CHECK_AUTH = "checkMethodAuth(string,bytes4,string)";
constexpr const char* const AUTH_METHOD_GET_AUTH = "getMethodAuth(string,bytes4)";
constexpr const char* const CONTRACT_AUTH_METHOD_GET_ADMIN = "getAdmin(string)";
constexpr const char* const CONTRACT_AUTH_METHOD_SET_ADMIN = "resetAdmin(string,string)";
constexpr const char* const CONTRACT_AUTH_METHOD_SET_AUTH_TYPE = "setMethodAuthType(string,bytes4,uint8)";
constexpr const char* const CONTRACT_AUTH_METHOD_OPEN_AUTH = "openMethodAuth(string,bytes4,string)";
constexpr const char* const CONTRACT_AUTH_METHOD_CLOSE_AUTH = "closeMethodAuth(string,bytes4,string)";
constexpr const char* const CONTRACT_AUTH_METHOD_CHECK_AUTH = "checkMethodAuth(string,bytes4,string)";
constexpr const char* const CONTRACT_AUTH_METHOD_GET_AUTH = "getMethodAuth(string,bytes4)";
/// evm
constexpr const char* const AUTH_METHOD_GET_ADMIN_ADD = "getAdmin(address)";
constexpr const char* const AUTH_METHOD_SET_ADMIN_ADD = "resetAdmin(address,address)";
constexpr const char* const AUTH_METHOD_SET_AUTH_TYPE_ADD =
constexpr const char* const CONTRACT_AUTH_METHOD_GET_ADMIN_ADD = "getAdmin(address)";
constexpr const char* const CONTRACT_AUTH_METHOD_SET_ADMIN_ADD = "resetAdmin(address,address)";
constexpr const char* const CONTRACT_AUTH_METHOD_SET_AUTH_TYPE_ADD =
"setMethodAuthType(address,bytes4,uint8)";
constexpr const char* const AUTH_METHOD_OPEN_AUTH_ADD = "openMethodAuth(address,bytes4,address)";
constexpr const char* const AUTH_METHOD_CLOSE_AUTH_ADD = "closeMethodAuth(address,bytes4,address)";
constexpr const char* const AUTH_METHOD_CHECK_AUTH_ADD = "checkMethodAuth(address,bytes4,address)";
constexpr const char* const AUTH_METHOD_GET_AUTH_ADD = "getMethodAuth(address,bytes4)";
constexpr const char* const CONTRACT_AUTH_METHOD_OPEN_AUTH_ADD = "openMethodAuth(address,bytes4,address)";
constexpr const char* const CONTRACT_AUTH_METHOD_CLOSE_AUTH_ADD = "closeMethodAuth(address,bytes4,address)";
constexpr const char* const CONTRACT_AUTH_METHOD_CHECK_AUTH_ADD = "checkMethodAuth(address,bytes4,address)";
constexpr const char* const CONTRACT_AUTH_METHOD_GET_AUTH_ADD = "getMethodAuth(address,bytes4)";

/// contract status
constexpr const char* const AUTH_METHOD_SET_CONTRACT = "setContractStatus(address,bool)";
constexpr const char* const AUTH_METHOD_SET_CONTRACT_32 = "setContractStatus(address,uint8)";
constexpr const char* const AUTH_METHOD_GET_CONTRACT = "contractAvailable(address)";
constexpr const char* const CONTRACT_AUTH_METHOD_SET_CONTRACT = "setContractStatus(address,bool)";
constexpr const char* const CONTRACT_AUTH_METHOD_SET_CONTRACT_32 = "setContractStatus(address,uint8)";
constexpr const char* const CONTRACT_AUTH_METHOD_GET_CONTRACT = "contractAvailable(address)";

ContractAuthMgrPrecompiled::ContractAuthMgrPrecompiled(crypto::Hash::Ptr _hashImpl, bool _isWasm)
: bcos::precompiled::Precompiled(std::move(_hashImpl))
{
const auto* getAdminStr = _isWasm ? AUTH_METHOD_GET_ADMIN : AUTH_METHOD_GET_ADMIN_ADD;
const auto* getAdminStr = _isWasm ? CONTRACT_AUTH_METHOD_GET_ADMIN : CONTRACT_AUTH_METHOD_GET_ADMIN_ADD;
registerFunc(
getFuncSelector(getAdminStr, _hashImpl), [this](auto&& _executive, auto&& _callParameters) {
getAdmin(std::forward<decltype(_executive)>(_executive),
std::forward<decltype(_callParameters)>(_callParameters));
});

const auto* resetAdminStr = _isWasm ? AUTH_METHOD_SET_ADMIN : AUTH_METHOD_SET_ADMIN_ADD;
const auto* resetAdminStr = _isWasm ? CONTRACT_AUTH_METHOD_SET_ADMIN : CONTRACT_AUTH_METHOD_SET_ADMIN_ADD;
registerFunc(getFuncSelector(resetAdminStr, _hashImpl),
[this](auto&& _executive, auto&& _callParameters) {
resetAdmin(std::forward<decltype(_executive)>(_executive),
std::forward<decltype(_callParameters)>(_callParameters));
});

const auto* setMethodAuthTypeStr =
_isWasm ? AUTH_METHOD_SET_AUTH_TYPE : AUTH_METHOD_SET_AUTH_TYPE_ADD;
_isWasm ? CONTRACT_AUTH_METHOD_SET_AUTH_TYPE : CONTRACT_AUTH_METHOD_SET_AUTH_TYPE_ADD;
registerFunc(getFuncSelector(setMethodAuthTypeStr, _hashImpl),
[this](auto&& _executive, auto&& _callParameters) {
setMethodAuthType(std::forward<decltype(_executive)>(_executive),
std::forward<decltype(_callParameters)>(_callParameters));
});

const auto* openMethodAuthStr = _isWasm ? AUTH_METHOD_OPEN_AUTH : AUTH_METHOD_OPEN_AUTH_ADD;
const auto* openMethodAuthStr = _isWasm ? CONTRACT_AUTH_METHOD_OPEN_AUTH : CONTRACT_AUTH_METHOD_OPEN_AUTH_ADD;
registerFunc(getFuncSelector(openMethodAuthStr, _hashImpl),
[this](auto&& _executive, auto&& _callParameters) {
openMethodAuth(std::forward<decltype(_executive)>(_executive),
std::forward<decltype(_callParameters)>(_callParameters));
});

const auto* closeMethodAuthStr = _isWasm ? AUTH_METHOD_CLOSE_AUTH : AUTH_METHOD_CLOSE_AUTH_ADD;
const auto* closeMethodAuthStr = _isWasm ? CONTRACT_AUTH_METHOD_CLOSE_AUTH : CONTRACT_AUTH_METHOD_CLOSE_AUTH_ADD;
registerFunc(getFuncSelector(closeMethodAuthStr, _hashImpl),
[this](auto&& _executive, auto&& _callParameters) {
closeMethodAuth(std::forward<decltype(_executive)>(_executive),
std::forward<decltype(_callParameters)>(_callParameters));
});

const auto* checkMethodAuthStr = _isWasm ? AUTH_METHOD_CHECK_AUTH : AUTH_METHOD_CHECK_AUTH_ADD;
const auto* checkMethodAuthStr = _isWasm ? CONTRACT_AUTH_METHOD_CHECK_AUTH : CONTRACT_AUTH_METHOD_CHECK_AUTH_ADD;
registerFunc(getFuncSelector(checkMethodAuthStr, _hashImpl),
[this](auto&& _executive, auto&& _callParameters) {
checkMethodAuth(std::forward<decltype(_executive)>(_executive),
std::forward<decltype(_callParameters)>(_callParameters));
});

const auto* getMethodAuthStr = _isWasm ? AUTH_METHOD_GET_AUTH : AUTH_METHOD_GET_AUTH_ADD;
const auto* getMethodAuthStr = _isWasm ? CONTRACT_AUTH_METHOD_GET_AUTH : CONTRACT_AUTH_METHOD_GET_AUTH_ADD;
registerFunc(getFuncSelector(getMethodAuthStr, _hashImpl),
[this](auto&& _executive, auto&& _callParameters) {
getMethodAuth(std::forward<decltype(_executive)>(_executive),
std::forward<decltype(_callParameters)>(_callParameters));
});

registerFunc(
getFuncSelector(AUTH_METHOD_SET_CONTRACT_32, _hashImpl),
getFuncSelector(CONTRACT_AUTH_METHOD_SET_CONTRACT_32, _hashImpl),
[this](auto&& _executive, auto&& _callParameters) {
setContractStatus32(std::forward<decltype(_executive)>(_executive),
std::forward<decltype(_callParameters)>(_callParameters));
},
protocol::BlockVersion::V3_2_VERSION);

registerFunc(getFuncSelector(AUTH_METHOD_SET_CONTRACT, _hashImpl),
registerFunc(getFuncSelector(CONTRACT_AUTH_METHOD_SET_CONTRACT, _hashImpl),
[this](auto&& _executive, auto&& _callParameters) {
setContractStatus(std::forward<decltype(_executive)>(_executive),
std::forward<decltype(_callParameters)>(_callParameters));
});
registerFunc(getFuncSelector(AUTH_METHOD_GET_CONTRACT, _hashImpl),
registerFunc(getFuncSelector(CONTRACT_AUTH_METHOD_GET_CONTRACT, _hashImpl),
[this](auto&& _executive, auto&& _callParameters) {
contractAvailable(std::forward<decltype(_executive)>(_executive),
std::forward<decltype(_callParameters)>(_callParameters));
Expand Down
Loading

0 comments on commit 55aa0a6

Please sign in to comment.