diff --git a/.github/workflows/workflow-self-hosted-centos-upload.yml b/.github/workflows/workflow-self-hosted-centos-upload.yml index ba38f4f3e2..4faa5aee66 100644 --- a/.github/workflows/workflow-self-hosted-centos-upload.yml +++ b/.github/workflows/workflow-self-hosted-centos-upload.yml @@ -9,9 +9,10 @@ on: branches: - release-3.* - feature-3.* + - bugfix-3.* - master release: - types: [push] + types: [ push ] concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true @@ -73,7 +74,7 @@ jobs: . /opt/rh/rh-perl530/enable export LIBCLANG_PATH=/opt/rh/llvm-toolset-7.0/root/lib64/ . /opt/rh/llvm-toolset-7.0/enable - cd build && cmake -DALLOCATOR=jemalloc -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake -DTESTS=ON -DWITH_LIGHTNODE=OFF -DWITH_CPPSDK=OFF -DWITH_TIKV=OFF -DWITH_TARS_SERVICES=OFF .. || cat *.log + cd build && cmake -DALLOCATOR=defalut -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake -DTESTS=ON -DWITH_LIGHTNODE=OFF -DWITH_CPPSDK=OFF -DWITH_TIKV=OFF -DWITH_TARS_SERVICES=OFF .. || cat *.log make -j8 chmod +x ./fisco-bcos-air/fisco-bcos ./fisco-bcos-air/fisco-bcos -v diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cb17547e7..52e613376e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ endif() list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) -set(VERSION "3.9.0") +set(VERSION "3.10.0") set(VERSION_SUFFIX "") include(Options) configure_project() @@ -36,7 +36,6 @@ include(BuildInfoGenerator) include(IncludeDirectories) include(TargetSettings) -include(PrecompiledHeaders) add_subdirectory(bcos-boostssl) add_subdirectory(bcos-framework) @@ -62,6 +61,7 @@ if(FULLNODE) endif() include(ProjectGroupSig) include(ProjectPaillier) + include(ProjectBLST) add_subdirectory(bcos-sealer) add_subdirectory(bcos-security) diff --git a/README.md b/README.md index 41a4db1298..d3da0d9a25 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,10 @@ FISCO BCOS(读作/ˈfɪskl bi:ˈkɒz/) 是一个稳定、高效、安全的 单链配置下,性能TPS可达10万+。全面支持国密算法、国产操作系统与国产CPU架构。包含区块流水线、可拔插共识机制、全方位并行计算、区块链文件系统、权限治理框架、分布式存储等特性。 ## 版本信息 -- 稳定版本(生产环境使用):v3.2.7,版本内容可参考[《FISCO-BCOS v3.2.7版本说明》](https://github.com/FISCO-BCOS/FISCO-BCOS/releases/tag/v3.2.7) -- 最新版本(用户体验新特性):v3.9.0,版本内容可参考 [《FISCO-BCOS v3.9.0版本说明》](https://github.com/FISCO-BCOS/FISCO-BCOS/releases/tag/v3.9.0) +- +稳定版本(生产环境使用):v3.7.3,版本内容可参考[《FISCO-BCOS v3.7.3版本说明》](https://github.com/FISCO-BCOS/FISCO-BCOS/releases/tag/v3.7.3) +- +最新版本(用户体验新特性):v3.10.0,版本内容可参考 [《FISCO-BCOS v3.10.0版本说明》](https://github.com/FISCO-BCOS/FISCO-BCOS/releases/tag/v3.10.0) ## 系统概述 FISCO BCOS系统架构包括基础层、核心层、服务层、用户层和接入层提供稳定、安全的区块链底层服务。中间件层通过可视化界面,简化了用户管理区块链系统的流程。右侧配套相关开发、运维、安全控制的组件,辅助应用落地过程中不同角色的需要;同时,提供隐私保护和跨链相关的技术组件,满足不同场景的应用诉求。 @@ -68,31 +70,34 @@ FISCO BCOS系统架构包括基础层、核心层、服务层、用户层和接 - 乡村振兴:智慧农业养殖大数据云平台、数字化平台建设等。 - 智慧政务:城市大脑、公积金区块链平台、证书电子化项目等 -FISCO BCOS已在领域创建了诸多标杆应用示范,涵盖19类场景的252个典型应用案例,产业应用具体信息可参考[《2023 FISCO BCOS 产业应用发展报告》](https://mp.weixin.qq.com/s/hyEdSluUSG-iUZDR2PO_Ew)。 - +FISCO +BCOS已在领域创建了诸多标杆应用示范,涵盖19类场景的252个典型应用案例,产业应用具体信息可参考[《2023 FISCO BCOS 产业应用发展报告》](https://mp.weixin.qq.com/s/hyEdSluUSG-iUZDR2PO_Ew)。 ## 加入我们的社区 **FISCO BCOS开源社区** -FISCO BCOS是由深圳市金融区块链发展促进会(以下简称“金链盟”)开源工作组牵头研发的金融级、国产安全可控的区块链底层平台。作为最早开源的国产联盟链底层平台之一,FISCO BCOS于2017年面向全球开源。 +FISCO BCOS是由深圳市金融区块链发展促进会(以下简称“金链盟”)开源工作组牵头研发的金融级、国产安全可控的区块链底层平台。作为最早开源的国产联盟链底层平台之一,FISCO +BCOS于2017年面向全球开源。 开源六周年至今,FISCO BCOS开源社区在技术创新、应用产业以及开源生态均取得了非凡成绩。 -FISCO BCOS持续攻关核心关键技术,单链性能突破10万TPS。首创DMC算法大幅度提升性能、推出三种架构形态灵活适配业务需求;全链路国产化,采用国密算法与软硬件体系,支持国产OS,适配国产芯片和服务器,支持多语言多终端国密接入。拥有覆盖底层+中间件+应用组件的丰富周边组件。 +FISCO +BCOS持续攻关核心关键技术,单链性能突破10万TPS。首创DMC算法大幅度提升性能、推出三种架构形态灵活适配业务需求;全链路国产化,采用国密算法与软硬件体系,支持国产OS,适配国产芯片和服务器,支持多语言多终端国密接入。拥有覆盖底层+中间件+应用组件的丰富周边组件。 底层平台可用性已经广泛应用实践检验,支撑政务、金融、医疗、双碳、跨境数据通等关乎国计民生的重点领域落地超过400个标杆应用,在助力实体经济发展、促进公平与可持续等方面贡献力量。 -社区以开源链接多方,截止2023年12月,围绕FISCO BCOS构建的国产开源联盟链生态圈已汇聚了超过5000家机构、超10万名个人成员,以及50家认证合作伙伴、500余名核心贡献者。社区认证了63位FISCO BCOS MVP, 发展了12个专项兴趣小组SIG,此外与上百所知名院校开展人才共育合作,培育区块链产业人才超8万人次,已发展成为最大最活跃的国产开源联盟链生态圈之一。 - +社区以开源链接多方,截止2023年12月,围绕FISCO +BCOS构建的国产开源联盟链生态圈已汇聚了超过5000家机构、超10万名个人成员,以及50家认证合作伙伴、500余名核心贡献者。社区认证了63位FISCO +BCOS MVP, 发展了12个专项兴趣小组SIG,此外与上百所知名院校开展人才共育合作,培育区块链产业人才超8万人次,已发展成为最大最活跃的国产开源联盟链生态圈之一。 如您对FISCO BCOS开源技术及应用感兴趣,欢迎加入社区获得更多支持与帮助。 + - [2023年度MVP](https://fisco-bcos-doc.readthedocs.io/zh_CN/latest/docs/community/MVP_list_new.html) - [2023年度贡献者](https://fisco-bcos-doc.readthedocs.io/zh_CN/latest/docs/community/contributor_list_new.html) - [FISCO BCOS 认证合作伙伴名单](https://mp.weixin.qq.com/s/A-gH2SJNQPDLgnhSGyuYDg) - [2023 FISCO BCOS产业应用发展报告](https://mp.weixin.qq.com/s/hyEdSluUSG-iUZDR2PO_Ew) - [社区历史文章资源](https://fisco-bcos-doc.readthedocs.io/zh_CN/latest/docs/articles/index.html) - ![](https://raw.githubusercontent.com/FISCO-BCOS/LargeFiles/master/images/QR_image.png) ## 贡献代码 diff --git a/bcos-crypto/bcos-crypto/hasher/Hasher.h b/bcos-crypto/bcos-crypto/hasher/Hasher.h index 54f1f1c3d0..81ad061498 100644 --- a/bcos-crypto/bcos-crypto/hasher/Hasher.h +++ b/bcos-crypto/bcos-crypto/hasher/Hasher.h @@ -8,14 +8,13 @@ namespace bcos::crypto::hasher { template -concept Hasher = - requires(HasherType hasher, std::span out) { - // requires std::move_constructible; - hasher.update(std::span{}); - hasher.final(out); - requires std::same_as::clone), HasherType>>, - std::decay_t>; - }; +concept Hasher = requires(HasherType hasher, std::span out) { + // requires std::move_constructible; + hasher.update(std::span{}); + hasher.final(out); + requires std::same_as< + std::decay_t::clone), HasherType>>, + std::decay_t>; +}; } // namespace bcos::crypto::hasher diff --git a/bcos-crypto/test/unittests/HashTest.cpp b/bcos-crypto/test/unittests/HashTest.cpp index dc8ce580f3..71f3b648d3 100644 --- a/bcos-crypto/test/unittests/HashTest.cpp +++ b/bcos-crypto/test/unittests/HashTest.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -122,6 +123,26 @@ BOOST_AUTO_TEST_CASE(testSha3) BOOST_REQUIRE_EQUAL(cryptoSuite->hash("hello"sv), h256("3338be694f50c5f338814986cdf0686453a888b84f424d792af4b9202398f392")); } + +BOOST_AUTO_TEST_CASE(SHA256_test) +{ + HashType hash; + auto sha256 = std::make_shared(); + bcos::bytes input{}; + hash = sha256->hash(bcos::ref(input)); + BCOS_LOG(DEBUG) << "hash: " << hash.hex(); + BOOST_CHECK_EQUAL( + hash.hex(), "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); + + std::string data = + "123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812" + "3456781234567812345678"; + input += bcos::fromHex(data); + hash = sha256->hash(bcos::ref(input)); + BCOS_LOG(DEBUG) << "hash: " << hash.hex(); + BOOST_REQUIRE_EQUAL( + hash.hex(), "7303caef875be8c39b2c2f1905ea24adcc024bef6830a965fe05370f3170dc52"); +} BOOST_AUTO_TEST_SUITE_END() } // namespace test } // namespace bcos diff --git a/bcos-executor/CMakeLists.txt b/bcos-executor/CMakeLists.txt index 67ab42ad33..17da9a85f9 100644 --- a/bcos-executor/CMakeLists.txt +++ b/bcos-executor/CMakeLists.txt @@ -18,10 +18,10 @@ file(GLOB_RECURSE SRCS src/*.cpp) add_library(${EXECUTOR_TARGET} ${SRCS}) if(WITH_WASM) target_link_libraries(${EXECUTOR_TARGET} PUBLIC jsoncpp_static ${CODEC_TARGET} ${TOOL_TARGET} ${CRYPTO_TARGET} ${TABLE_TARGET} wedprcrypto::fisco-bcos bcos-protocol - Boost::context evmone fbwasm evmc::loader evmc::instructions wabt GroupSig Paillier) + Boost::context evmone fbwasm evmc::loader evmc::instructions wabt GroupSig Paillier blst) else() target_link_libraries(${EXECUTOR_TARGET} PUBLIC jsoncpp_static ${CODEC_TARGET} ${TOOL_TARGET} ${CRYPTO_TARGET} ${TABLE_TARGET} wedprcrypto::fisco-bcos bcos-protocol - Boost::context evmone evmc::loader evmc::instructions GroupSig Paillier) + Boost::context evmone evmc::loader evmc::instructions GroupSig Paillier blst) endif() if (TOOLS) diff --git a/bcos-executor/src/Common.h b/bcos-executor/src/Common.h index 7396583a2c..35a251a96d 100644 --- a/bcos-executor/src/Common.h +++ b/bcos-executor/src/Common.h @@ -165,6 +165,7 @@ struct VMSchedule bool exceptionalFailedCodeDeposit = true; bool enableLondon = true; bool enablePairs = false; + bool enableCanCun = false; unsigned sstoreRefundGas = 15000; unsigned suicideRefundGas = 24000; unsigned createDataGas = 20; @@ -185,6 +186,14 @@ static const VMSchedule FiscoBcosScheduleV320 = [] { return schedule; }(); +static const VMSchedule FiscoBcosScheduleCancun = [] { + VMSchedule schedule = VMSchedule(); + schedule.enableCanCun = true; + schedule.maxEvmCodeSize = 0x100000; // 1MB + schedule.maxWasmCodeSize = 0xF00000; // 15MB + return schedule; +}(); + static const int64_t BALANCE_TRANSFER_GAS = 21000; constexpr evmc_gas_metrics ethMetrics{32000, 20000, 5000, 200, 9000, 2300, 25000}; diff --git a/bcos-executor/src/executive/BlockContext.cpp b/bcos-executor/src/executive/BlockContext.cpp index 40cc75f7bf..96a2a51529 100644 --- a/bcos-executor/src/executive/BlockContext.cpp +++ b/bcos-executor/src/executive/BlockContext.cpp @@ -40,16 +40,16 @@ using namespace std; BlockContext::BlockContext(std::shared_ptr storage, LedgerCache::Ptr ledgerCache, crypto::Hash::Ptr _hashImpl, bcos::protocol::BlockNumber blockNumber, h256 blockHash, uint64_t timestamp, - uint32_t blockVersion, const VMSchedule& _schedule, bool _isWasm, bool _isAuthCheck, + uint32_t blockVersion, bool _isWasm, bool _isAuthCheck, storage::StorageInterface::Ptr backendStorage) : m_blockNumber(blockNumber), m_blockHash(blockHash), m_timeStamp(timestamp), m_blockVersion(blockVersion), - m_schedule(_schedule), m_isWasm(_isWasm), m_isAuthCheck(_isAuthCheck), m_storage(std::move(storage)), + m_transientStorageMap(std::make_shared(10)), m_hashImpl(std::move(_hashImpl)), m_ledgerCache(std::move(ledgerCache)), m_backendStorage(std::move(backendStorage)) @@ -61,15 +61,15 @@ BlockContext::BlockContext(std::shared_ptr stora } task::syncWait(readFromStorage(m_features, *m_storage, m_blockNumber)); + setVMSchedule(); } BlockContext::BlockContext(std::shared_ptr storage, LedgerCache::Ptr ledgerCache, crypto::Hash::Ptr _hashImpl, protocol::BlockHeader const& current, - const VMSchedule& _schedule, bool _isWasm, bool _isAuthCheck, - storage::StorageInterface::Ptr backendStorage, + bool _isWasm, bool _isAuthCheck, storage::StorageInterface::Ptr backendStorage, std::shared_ptr>> _keyPageIgnoreTables) : BlockContext(std::move(storage), std::move(ledgerCache), std::move(_hashImpl), current.number(), - current.hash(), current.timestamp(), current.version(), _schedule, _isWasm, _isAuthCheck, + current.hash(), current.timestamp(), current.version(), _isWasm, _isAuthCheck, std::move(backendStorage)) { if (current.number() > 0 && !current.parentInfo().empty()) @@ -97,6 +97,7 @@ BlockContext::BlockContext(std::shared_ptr stora } } } + setVMSchedule(); } @@ -123,6 +124,21 @@ void BlockContext::setExecutiveFlow( bcos::ReadGuard l(x_executiveFlows); m_executiveFlows.emplace(codeAddress, executiveFlow); } +void BlockContext::setVMSchedule() +{ + if (m_features.get(ledger::Features::Flag::feature_evm_cancun)) + { + m_schedule = FiscoBcosScheduleCancun; + } + else if (m_blockVersion >= (uint32_t)bcos::protocol::BlockVersion::V3_2_VERSION) + { + m_schedule = FiscoBcosScheduleV320; + } + else + { + m_schedule = FiscoBcosSchedule; + } +} void BlockContext::suicide(std::string_view contract2Suicide) { diff --git a/bcos-executor/src/executive/BlockContext.h b/bcos-executor/src/executive/BlockContext.h index a78c38ed04..b922583120 100644 --- a/bcos-executor/src/executive/BlockContext.h +++ b/bcos-executor/src/executive/BlockContext.h @@ -28,6 +28,9 @@ #include "bcos-framework/protocol/ProtocolTypeDef.h" #include "bcos-framework/protocol/Transaction.h" #include "bcos-framework/storage/EntryCache.h" +#include "bcos-framework/storage/Table.h" +#include "bcos-table/src/StateStorage.h" +#include "bcos-utilities/BucketMap.h" #include #include #include @@ -46,13 +49,13 @@ class BlockContext : public std::enable_shared_from_this BlockContext(std::shared_ptr storage, LedgerCache::Ptr ledgerCache, crypto::Hash::Ptr _hashImpl, bcos::protocol::BlockNumber blockNumber, h256 blockHash, uint64_t timestamp, - uint32_t blockVersion, const VMSchedule& _schedule, bool _isWasm, bool _isAuthCheck, + uint32_t blockVersion, bool _isWasm, bool _isAuthCheck, storage::StorageInterface::Ptr backendStorage = nullptr); BlockContext(std::shared_ptr storage, LedgerCache::Ptr ledgerCache, crypto::Hash::Ptr _hashImpl, - protocol::BlockHeader const& current, const VMSchedule& _schedule, bool _isWasm, - bool _isAuthCheck, storage::StorageInterface::Ptr backendStorage = nullptr, + protocol::BlockHeader const& current, bool _isWasm, bool _isAuthCheck, + storage::StorageInterface::Ptr backendStorage = nullptr, std::shared_ptr>> = nullptr); using getTxCriticalsHandler = std::function>( @@ -60,6 +63,11 @@ class BlockContext : public std::enable_shared_from_this virtual ~BlockContext() = default; std::shared_ptr storage() const { return m_storage; } + using transientStorageMap = BucketMap>; + std::shared_ptr getTransientStorageMap() const + { + return m_transientStorageMap; + } uint64_t txGasLimit() const { return m_ledgerCache->fetchTxGasLimit(); } @@ -86,6 +94,7 @@ class BlockContext : public std::enable_shared_from_this void setExecutiveFlow(std::string codeAddress, ExecutiveFlowInterface::Ptr executiveFlow); std::shared_ptr getVMFactory() const { return m_vmFactory; } + void setVMSchedule(); void setVMFactory(std::shared_ptr factory) { m_vmFactory = factory; } void stop() @@ -147,6 +156,7 @@ class BlockContext : public std::enable_shared_from_this bool m_isWasm = false; bool m_isAuthCheck = false; std::shared_ptr m_storage; + transientStorageMap::Ptr m_transientStorageMap; crypto::Hash::Ptr m_hashImpl; std::function f_onNeedSwitchEvent; std::shared_ptr>> m_keyPageIgnoreTables; diff --git a/bcos-executor/src/executive/TransactionExecutive.cpp b/bcos-executor/src/executive/TransactionExecutive.cpp index 3963236936..68acb1f79b 100644 --- a/bcos-executor/src/executive/TransactionExecutive.cpp +++ b/bcos-executor/src/executive/TransactionExecutive.cpp @@ -218,6 +218,8 @@ CallParameters::UniquePtr TransactionExecutive::execute(CallParameters::UniquePt << LOG_KV("blockNumber", m_blockContext.number()); } m_storageWrapper->setRecoder(m_recoder); + auto transientStorage = getTransientStateStorage(m_contextID); + transientStorage->setRecoder(m_transientRecoder); std::unique_ptr hostContext; CallParameters::UniquePtr callResults; if (c_fileLogLevel <= LogLevel::TRACE) @@ -1391,6 +1393,8 @@ void TransactionExecutive::revert() } m_blockContext.storage()->rollback(*m_recoder); + auto transientStateStorage = getTransientStateStorage(m_contextID); + transientStateStorage->rollback(*m_transientRecoder); m_recoder->clear(); } @@ -1936,3 +1940,38 @@ std::string TransactionExecutive::getContractTableName( return std::string(USER_APPS_PREFIX).append(formatAddress); } + +std::shared_ptr TransactionExecutive::getTransientStateStorage( + int64_t contextID) +{ + auto transientStorageMap = blockContext().getTransientStorageMap(); + bcos::storage::StateStorageInterface::Ptr transientStorage; + bool has; + { + tssMap::ReadAccessor::Ptr readAccessor; + has = transientStorageMap->find(readAccessor, contextID); + if (has) + { + transientStorage = readAccessor->value(); + } + } + if (!has) + { + { + tssMap::WriteAccessor::Ptr writeAccessor; + auto hasWrite = + transientStorageMap->find(writeAccessor, contextID); + + if (!hasWrite) + { + transientStorage = std::make_shared(nullptr, true); + transientStorageMap->insert(writeAccessor, {contextID, transientStorage}); + } + else + { + transientStorage = writeAccessor->value(); + } + } + } + return transientStorage; +} diff --git a/bcos-executor/src/executive/TransactionExecutive.h b/bcos-executor/src/executive/TransactionExecutive.h index 4095cda69b..90a9d18c35 100644 --- a/bcos-executor/src/executive/TransactionExecutive.h +++ b/bcos-executor/src/executive/TransactionExecutive.h @@ -32,6 +32,7 @@ #include "bcos-framework/protocol/BlockHeader.h" #include "bcos-framework/protocol/Transaction.h" #include "bcos-protocol/TransactionStatus.h" +#include "bcos-table/src/StateStorage.h" #include #include #include @@ -65,10 +66,11 @@ class TransactionExecutive : public std::enable_shared_from_this()), + m_transientRecoder(std::make_shared()), m_storageWrapperObj(m_blockContext.storage(), m_recoder), m_storageWrapper(&m_storageWrapperObj) { - m_recoder = std::make_shared(); m_hashImpl = m_blockContext.hashHandler(); m_storageWrapperObj.setCodeCache(m_blockContext.getCodeCache()); m_storageWrapperObj.setCodeHashCache(m_blockContext.getCodeHashCache()); @@ -92,6 +94,7 @@ class TransactionExecutive : public std::enable_shared_from_this execPrecompiled( precompiled::PrecompiledExecResult::Ptr const& _precompiledParams); + using tssMap = bcos::BucketMap>; VMSchedule const& vmSchedule() const { return m_blockContext.vmSchedule(); } @@ -166,6 +170,8 @@ class TransactionExecutive : public std::enable_shared_from_this getTransientStateStorage(int64_t contextID); + std::shared_ptr getRecoder() { return m_recoder; } protected: @@ -224,6 +230,7 @@ class TransactionExecutive : public std::enable_shared_from_this m_childExecutives; storage::StorageWrapper m_storageWrapperObj; diff --git a/bcos-executor/src/executor/TransactionExecutor.cpp b/bcos-executor/src/executor/TransactionExecutor.cpp index c0ea6cad99..ff18bafe2c 100644 --- a/bcos-executor/src/executor/TransactionExecutor.cpp +++ b/bcos-executor/src/executor/TransactionExecutor.cpp @@ -60,8 +60,10 @@ #include "../vm/gas_meter/GasInjector.h" #endif +#include "../Common.h" #include "ExecuteOutputs.h" #include "bcos-codec/abi/ContractABIType.h" +#include "bcos-executor/src/executive/BlockContext.h" #include "bcos-executor/src/precompiled/common/Common.h" #include "bcos-executor/src/precompiled/common/PrecompiledResult.h" #include "bcos-executor/src/precompiled/common/Utilities.h" @@ -76,6 +78,7 @@ #include "bcos-table/src/KeyPageStorage.h" #include "bcos-table/src/StateStorage.h" #include "bcos-table/src/StateStorageFactory.h" +#include "bcos-task/Wait.h" #include "bcos-tool/BfsFileFactory.h" #include "tbb/flow_graph.h" #include @@ -404,8 +407,7 @@ BlockContext::Ptr TransactionExecutor::createBlockContext( backend = m_cachedStorage; } BlockContext::Ptr context = make_shared(storage, m_ledgerCache, m_hashImpl, - *currentHeader, getVMSchedule((uint32_t)currentHeader->version()), m_isWasm, m_isAuthCheck, - std::move(backend), m_keyPageIgnoreTables); + *currentHeader, m_isWasm, m_isAuthCheck, std::move(backend), m_keyPageIgnoreTables); context->setVMFactory(m_vmFactory); if (f_onNeedSwitchEvent) { @@ -420,8 +422,7 @@ std::shared_ptr TransactionExecutor::createBlockContextForCall( int32_t blockVersion, storage::StateStorageInterface::Ptr storage) { BlockContext::Ptr context = make_shared(storage, m_ledgerCache, m_hashImpl, - blockNumber, blockHash, timestamp, blockVersion, getVMSchedule((uint32_t)blockVersion), - m_isWasm, m_isAuthCheck); + blockNumber, blockHash, timestamp, blockVersion, m_isWasm, m_isAuthCheck); context->setVMFactory(m_vmFactory); return context; } @@ -2053,9 +2054,12 @@ void TransactionExecutor::getCode( // asyncGetRow key should not be empty auto codeKey = codeHash.empty() ? ACCOUNT_CODE : codeHash; // try to get abi from SYS_CODE_BINARY first + ledger::Features features; + task::syncWait(features.readFromStorage(*stateStorage, m_lastCommittedBlockNumber)); stateStorage->asyncGetRow(bcos::ledger::SYS_CODE_BINARY, codeKey, [this, contractTableName, callback = std::move(callback), - getCodeFromContractTable = std::move(getCodeFromContractTable)]( + getCodeFromContractTable = std::move(getCodeFromContractTable), + features = std::move(features)]( Error::UniquePtr error, std::optional entry) { if (!m_isRunning) { @@ -2082,11 +2086,9 @@ void TransactionExecutor::getCode( } auto code = entry->getField(0); - if ((m_blockContext->features().get( - ledger::Features::Flag::bugfix_eoa_as_contract) && + if ((features.get(ledger::Features::Flag::bugfix_eoa_as_contract) && bcos::precompiled::isDynamicPrecompiledAccountCode(code)) || - (m_blockContext->features().get( - ledger::Features::Flag::bugfix_eoa_match_failed) && + (features.get(ledger::Features::Flag::bugfix_eoa_match_failed) && bcos::precompiled::matchDynamicAccountCode(code))) { EXECUTOR_NAME_LOG(DEBUG) << "Get eoa code success, return empty code to evm"; diff --git a/bcos-executor/src/executor/TransactionExecutor.h b/bcos-executor/src/executor/TransactionExecutor.h index 9b0e044b14..54c2e3752c 100644 --- a/bcos-executor/src/executor/TransactionExecutor.h +++ b/bcos-executor/src/executor/TransactionExecutor.h @@ -335,14 +335,6 @@ class TransactionExecutor : public ParallelTransactionExecutorInterface, void initWasmEnvironment(); void resetEnvironment(); void initTestPrecompiledTable(storage::StorageInterface::Ptr storage); - VMSchedule getVMSchedule(uint32_t currentVersion) const - { - if (currentVersion >= (uint32_t)bcos::protocol::BlockVersion::V3_2_VERSION) - { - return FiscoBcosScheduleV320; - } - return FiscoBcosSchedule; - } std::function f_onNeedSwitchEvent; LedgerCache::Ptr m_ledgerCache; diff --git a/bcos-executor/src/precompiled/common/Utilities.h b/bcos-executor/src/precompiled/common/Utilities.h index 9b06a5f401..a8c90d9c58 100644 --- a/bcos-executor/src/precompiled/common/Utilities.h +++ b/bcos-executor/src/precompiled/common/Utilities.h @@ -89,13 +89,14 @@ inline std::string getDynamicPrecompiledCodeString( inline bool matchDynamicAccountCode(std::string_view code) { - return code.starts_with(getDynamicPrecompiledCodeString(ACCOUNT_ADDRESS, "")); + auto const prefix = getDynamicPrecompiledCodeString(ACCOUNT_ADDRESS, ""); + return code.starts_with(prefix); } // ERROR: this method match account precompiled in wrong logic, use matchDynamicAccountCode instead. inline bool isDynamicPrecompiledAccountCode(const std::string_view& _code) { - return std::string_view(getDynamicPrecompiledCodeString(ACCOUNT_ADDRESS, "")) == _code; + return getDynamicPrecompiledCodeString(ACCOUNT_ADDRESS, "") == _code; } inline std::string trimHexPrefix(const std::string& _hex) diff --git a/bcos-executor/src/vm/EVMHostInterface.cpp b/bcos-executor/src/vm/EVMHostInterface.cpp index 24cd9f2ba3..ab59699eb3 100644 --- a/bcos-executor/src/vm/EVMHostInterface.cpp +++ b/bcos-executor/src/vm/EVMHostInterface.cpp @@ -68,6 +68,18 @@ evmc_bytes32 getStorage( return hostContext.store(key); } +evmc_bytes32 getTransientStorage( + evmc_host_context* context, [[maybe_unused]] const evmc_address* addr, const evmc_bytes32* key) +{ + auto& hostContext = static_cast(*context); + + // programming assert for debug + assert(fromEvmC(*addr) == boost::algorithm::unhex(std::string(hostContext.myAddress()))); + + return hostContext.getTransientStorage(key); +} + + evmc_storage_status setStorage(evmc_host_context* context, [[maybe_unused]] const evmc_address* addr, const evmc_bytes32* key, const evmc_bytes32* value) { @@ -85,6 +97,14 @@ evmc_storage_status setStorage(evmc_host_context* context, return status; } +void setTransientStorage(evmc_host_context* context, [[maybe_unused]] const evmc_address* addr, + const evmc_bytes32* key, const evmc_bytes32* value) +{ + auto& hostContext = static_cast(*context); + hostContext.setTransientStorage(key, value); // Interface uses native endianness +} + + evmc_bytes32 getBalance(evmc_host_context* _context, const evmc_address* _addr) noexcept { auto& hostContext = static_cast(*_context); @@ -281,6 +301,8 @@ evmc_host_interface const fnTable = { log, access_account, access_storage, + getTransientStorage, + setTransientStorage, }; // clang-format on diff --git a/bcos-executor/src/vm/HostContext.cpp b/bcos-executor/src/vm/HostContext.cpp index 1f578dafd2..bb47f18813 100644 --- a/bcos-executor/src/vm/HostContext.cpp +++ b/bcos-executor/src/vm/HostContext.cpp @@ -573,6 +573,36 @@ evmc_bytes32 HostContext::store(const evmc_bytes32* key) } return result; } +evmc_bytes32 HostContext::getTransientStorage(const evmc_bytes32* key) +{ + evmc_bytes32 result; + auto keyView = std::string_view((char*)key->bytes, sizeof(key->bytes)); + + auto transientStorageMap = m_executive->blockContext().getTransientStorageMap(); + using TSMap = bcos::BucketMap>; + TSMap::ReadAccessor::Ptr readAccessor; + auto has = + transientStorageMap->find(readAccessor, m_executive->contextID()); + if (!has) + { + EXECUTOR_LOG(DEBUG) << LOG_DESC("get transient storage failed") + << LOG_KV("transientStorageMapKey", m_executive->contextID()) + << LOG_KV("key", keyView); + std::uninitialized_fill_n(result.bytes, sizeof(result), 0); + return result; + } + auto entry = readAccessor->value()->getRow(m_tableName, keyView); + if (!entry.first && entry.second.has_value()) + { + auto field = entry.second->getField(0); + std::uninitialized_copy_n(field.data(), sizeof(result), result.bytes); + } + else + { + std::uninitialized_fill_n(result.bytes, sizeof(result), 0); + } + return result; +} void HostContext::setStore(const evmc_bytes32* key, const evmc_bytes32* value) { @@ -584,6 +614,26 @@ void HostContext::setStore(const evmc_bytes32* key, const evmc_bytes32* value) m_executive->storage().setRow(m_tableName, keyView, std::move(entry)); } +void HostContext::setTransientStorage(const evmc_bytes32* key, const evmc_bytes32* value) +{ + auto keyView = std::string_view((char*)key->bytes, sizeof(key->bytes)); + bytes valueBytes(value->bytes, value->bytes + sizeof(value->bytes)); + + Entry entry; + entry.importFields({std::move(valueBytes)}); + + bcos::storage::StateStorageInterface::Ptr transientStorage = + m_executive->getTransientStateStorage(m_executive->contextID()); + + transientStorage->asyncSetRow(m_tableName, keyView, std::move(entry), [](auto&& error) { + if (error) + { + EXECUTOR_LOG(ERROR) << LOG_DESC("set transient storage failed") + << LOG_KV("error", error); + } + }); +} + void HostContext::log(h256s&& _topics, bytesConstRef _data) { // if (m_isWasm || myAddress().empty()) diff --git a/bcos-executor/src/vm/HostContext.h b/bcos-executor/src/vm/HostContext.h index a77ac9d3b6..9236dc31a6 100644 --- a/bcos-executor/src/vm/HostContext.h +++ b/bcos-executor/src/vm/HostContext.h @@ -65,10 +65,12 @@ class HostContext : public evmc_host_context /// Read storage location. evmc_bytes32 store(const evmc_bytes32* key); + evmc_bytes32 getTransientStorage(const evmc_bytes32* key); /// Write a value in storage. // void setStore(const u256& _n, const u256& _v); void setStore(const evmc_bytes32* key, const evmc_bytes32* value); + void setTransientStorage(const evmc_bytes32* key, const evmc_bytes32* value); /// Create a new contract. evmc_result externalRequest(const evmc_message* _msg); diff --git a/bcos-executor/src/vm/Precompiled.cpp b/bcos-executor/src/vm/Precompiled.cpp index ad50d97b7a..79b77caac4 100644 --- a/bcos-executor/src/vm/Precompiled.cpp +++ b/bcos-executor/src/vm/Precompiled.cpp @@ -24,12 +24,12 @@ #include "bcos-crypto/hash/Keccak256.h" #include "bcos-crypto/signature/codec/SignatureDataWithV.h" #include "bcos-crypto/signature/secp256k1/Secp256k1Crypto.h" +#include "kzgPrecompiled.h" #include "wedpr-crypto/WedprBn128.h" #include "wedpr-crypto/WedprCrypto.h" #include #include - using namespace std; using namespace bcos; using namespace bcos::crypto; @@ -287,6 +287,53 @@ ETH_REGISTER_PRECOMPILED_PRICER(blake2_compression) return rounds; } +// The precompiled contract for point evaluation, EIP-4844: +// https://eips.ethereum.org/EIPS/eip-4844#point-evaluation-precompile +ETH_REGISTER_PRECOMPILED(point_evaluation)(bytesConstRef _in) +{ + static constexpr size_t versioned_hash_size = 32; + static constexpr size_t z_end_bound = 64; + static constexpr size_t y_end_bound = 96; + static constexpr size_t commitment_end_bound = 144; + static constexpr size_t proof_end_bound = 192; + + if (_in.size() != 192) + return {false, {}}; + + auto const versioned_hash = _in.getCroppedData(0, versioned_hash_size); + auto const z = _in.getCroppedData(versioned_hash_size, z_end_bound - versioned_hash_size); + auto const y = _in.getCroppedData(z_end_bound, y_end_bound - z_end_bound); + auto const commitment = _in.getCroppedData(y_end_bound, commitment_end_bound - y_end_bound); + auto const proof = + _in.getCroppedData(commitment_end_bound, proof_end_bound - commitment_end_bound); + + auto kzg = make_shared(); + + if (kzg->kzg2VersionedHash(commitment) != h256(versioned_hash)) + { + BCOS_LOG(ERROR) << LOG_DESC("versioned_hash not equal"); + return {false, {}}; + } + + if (!kzg->verifyKZGProof(commitment, z, y, proof)) + { + BCOS_LOG(ERROR) << LOG_DESC("verifyKZGProof failed"); + return {false, {}}; + } + + // Return FIELD_ELEMENTS_PER_BLOB and BLS_MODULUS as padded 32 byte big endian values + // return turn and Bytes(U256(FIELD_ELEMENTS_PER_BLOB).to_be_bytes32() + + // U256(BLS_MODULUS).to_be_bytes32()) refer to + // https://github.com/erigontech/silkworm/blob/85ba5171e88855a6702602d38f102aae9b896f9c/silkworm/core/execution/precompile.cpp#L502-L524 + return {true, + *bcos::fromHexString("000000000000000000000000000000000000000000000000000000000000100073eda" + "753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")}; +} + +ETH_REGISTER_PRECOMPILED_PRICER(point_evaluation)(bytesConstRef _in) +{ + return 50000; +} } // namespace @@ -346,6 +393,7 @@ struct blake2b_state uint8_t last_node; }; + // clang-format off constexpr uint64_t blake2b_IV[8] = { diff --git a/bcos-executor/src/vm/VMInstance.cpp b/bcos-executor/src/vm/VMInstance.cpp index 1f9dc3d262..ac96fe3e0d 100644 --- a/bcos-executor/src/vm/VMInstance.cpp +++ b/bcos-executor/src/vm/VMInstance.cpp @@ -20,10 +20,9 @@ */ #include "VMInstance.h" - #include "HostContext.h" -#include "evmone/advanced_analysis.hpp" #include "evmone/advanced_execution.hpp" +#include "evmone/execution_state.hpp" #include using namespace std; @@ -60,8 +59,8 @@ Result VMInstance::execute(HostContext& _hostContext, evmc_message* _msg) return Result(m_instance->execute(m_instance, _hostContext.interface, &_hostContext, m_revision, _msg, m_code.data(), m_code.size())); } - auto state = std::make_unique( - *_msg, m_revision, *_hostContext.interface, &_hostContext, m_code); + auto state = std::unique_ptr(new evmone::ExecutionState( + *_msg, m_revision, *_hostContext.interface, &_hostContext, m_code, {})); { // baseline static auto* evm = evmc_create_evmone(); // baseline use the vm to get options return Result(evmone::baseline::execute( @@ -77,6 +76,10 @@ evmc_revision toRevision(VMSchedule const& _schedule) { return EVMC_PARIS; } + if (_schedule.enableCanCun) + { + return EVMC_CANCUN; + } return EVMC_LONDON; } } // namespace bcos::executor diff --git a/bcos-executor/src/vm/gas_meter/Metric.cpp b/bcos-executor/src/vm/gas_meter/Metric.cpp index 51c586a368..8e466e65c7 100644 --- a/bcos-executor/src/vm/gas_meter/Metric.cpp +++ b/bcos-executor/src/vm/gas_meter/Metric.cpp @@ -25,6 +25,7 @@ namespace bcos { namespace wasm { +using bcos::wasm::Instruction; InstructionTable GetInstructionTable() { auto defaultInstructionTable = InstructionTable{}; diff --git a/bcos-executor/src/vm/kzgPrecompiled.h b/bcos-executor/src/vm/kzgPrecompiled.h new file mode 100644 index 0000000000..894b0091a8 --- /dev/null +++ b/bcos-executor/src/vm/kzgPrecompiled.h @@ -0,0 +1,212 @@ +/* + * Copyright (C) 2021 FISCO BCOS. + * SPDX-License-Identifier: Apache-2.0 + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + * @file KZGPrecompiled.h + * @author: wenlinli + * @date: 2024-04-29 + */ + +#pragma once +#include +#include +#include +#include +#include +#include + + +namespace bcos::executor +{ + +inline constexpr uint8_t kBlobCommitmentVersionKzg{1}; + +namespace crypto +{ + +class kzgPrecompiled +{ +public: + using Ptr = std::shared_ptr; + using ConstPtr = std::shared_ptr; + using G1 = blst_p1; + using G2 = blst_p2; + using Fr = blst_fr; + + kzgPrecompiled() = default; + ~kzgPrecompiled() = default; + + + static bool pairings_verify(const G1* a1, const G2* a2, const G1* b1, const G2* b2) + { + blst_fp12 loop0, loop1, gt_point; + blst_p1_affine aa1, bb1; + blst_p2_affine aa2, bb2; + + G1 a1neg = *a1; + blst_p1_cneg(&a1neg, true); + + blst_p1_to_affine(&aa1, &a1neg); + blst_p1_to_affine(&bb1, b1); + blst_p2_to_affine(&aa2, a2); + blst_p2_to_affine(&bb2, b2); + + blst_miller_loop(&loop0, &aa2, &aa1); + blst_miller_loop(&loop1, &bb2, &bb1); + + blst_fp12_mul(>_point, &loop0, &loop1); + blst_final_exp(>_point, >_point); + + return blst_fp12_is_one(>_point); + } + + static void g1_mul(G1* out, const G1* a, const Fr* b) + { + blst_scalar s; + blst_scalar_from_fr(&s, b); + blst_p1_mult(out, a, s.b, 8 * sizeof(blst_scalar)); + } + + + static void g2_mul(G2* out, const G2* a, const Fr* b) + { + blst_scalar s; + blst_scalar_from_fr(&s, b); + blst_p2_mult(out, a, s.b, 8 * sizeof(blst_scalar)); + } + + + static void g1_sub(G1* out, const G1* a, const G1* b) + { + G1 bneg = *b; + blst_p1_cneg(&bneg, true); + blst_p1_add_or_double(out, a, &bneg); + } + + + static void g2_sub(G2* out, const G2* a, const G2* b) + { + G2 bneg = *b; + blst_p2_cneg(&bneg, true); + blst_p2_add_or_double(out, a, &bneg); + } + + constexpr static const G2 kKzgSetupG2_1{ + {{{0x6120a2099b0379f9, 0xa2df815cb8210e4e, 0xcb57be5577bd3d4f, 0x62da0ea89a0c93f8, + 0x02e0ee16968e150d, 0x171f09aea833acd5}, + {0x11a3670749dfd455, 0x04991d7b3abffadc, 0x85446a8e14437f41, 0x27174e7b4e76e3f2, + 0x7bfa6dd397f60a20, 0x02fcc329ac07080f}}}, + {{{0xaa130838793b2317, 0xe236dd220f891637, 0x6502782925760980, 0xd05c25f60557ec89, + 0x6095767a44064474, 0x185693917080d405}, + {0x549f9e175b03dc0a, 0x32c0c95a77106cfe, 0x64a74eae5705d080, 0x53deeaf56659ed9e, + 0x09a1d368508afb93, 0x12cf3a4525b5e9bd}}}, + {{{0x760900000002fffd, 0xebf4000bc40c0002, 0x5f48985753c758ba, 0x77ce585370525745, + 0x5c071a97a256ec6d, 0x15f65ec3fa80e493}, + {0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000}}}}; + + + static bool validate_kzg_g1(G1* out, bytesConstRef b) + { + blst_p1_affine p1_affine; + + /* Convert the bytes to a p1 point */ + /* The uncompress routine checks that the point is on the curve */ + if (blst_p1_uncompress(&p1_affine, b.data()) != BLST_SUCCESS) + { + return false; + } + blst_p1_from_affine(out, &p1_affine); + + /* The point at infinity is accepted! */ + if (blst_p1_is_inf(out)) + { + return true; + } + + /* The point must be on the right subgroup */ + return blst_p1_in_g1(out); + } + + static bool bytes_to_bls_field(Fr* out, bytesConstRef b) + { + blst_scalar tmp; + blst_scalar_from_bendian(&tmp, b.data()); + if (!blst_scalar_fr_check(&tmp)) + { + return false; + } + blst_fr_from_scalar(out, &tmp); + return true; + } + + + bcos::crypto::HashType kzg2VersionedHash(bytesConstRef input) + { + auto sha256 = std::make_shared(); + auto hash = sha256->hash(input); + BCOS_LOG(DEBUG) << LOG_DESC("hash") << LOG_KV("hash", hash) + << LOG_KV("hash hex", hash.hex()); + hash[0] = kBlobCommitmentVersionKzg; + BCOS_LOG(DEBUG) << LOG_DESC("a") << LOG_KV("a", hash) << LOG_KV("a hex", hash.hex()); + return hash; + } + + bool verifyKZGProof( + bytesConstRef commitment, bytesConstRef z, bytesConstRef y, bytesConstRef proof) + { + Fr z_fr, y_fr; + G1 commitment_g1, proof_g1; + + if (!validate_kzg_g1(&commitment_g1, commitment)) + { + return false; + } + if (!bytes_to_bls_field(&z_fr, z)) + { + return false; + } + if (!bytes_to_bls_field(&y_fr, y)) + { + return false; + } + if (!validate_kzg_g1(&proof_g1, proof)) + { + return false; + } + + return verifyKZGProofImpl(&commitment_g1, &z_fr, &y_fr, &proof_g1); + } + + static bool verifyKZGProofImpl(const G1* commitment, const Fr* z, const Fr* y, const G1* proof) + { + G2 x_g2, X_minus_z; + G1 y_g1, P_minus_y; + + /* Calculate: X_minus_z */ + g2_mul(&x_g2, blst_p2_generator(), z); + g2_sub(&X_minus_z, &kKzgSetupG2_1, &x_g2); + + /* Calculate: P_minus_y */ + g1_mul(&y_g1, blst_p1_generator(), y); + g1_sub(&P_minus_y, commitment, &y_g1); + + /* Verify: P - y = Q * (X - z) */ + return pairings_verify(&P_minus_y, blst_p2_generator(), proof, &X_minus_z); + } +}; + +} // namespace crypto +} // namespace bcos::executor diff --git a/bcos-executor/test/unittest/libexecutor/TestBlockContext.cpp b/bcos-executor/test/unittest/libexecutor/TestBlockContext.cpp index 8c707543b3..3b74d9c8d8 100644 --- a/bcos-executor/test/unittest/libexecutor/TestBlockContext.cpp +++ b/bcos-executor/test/unittest/libexecutor/TestBlockContext.cpp @@ -28,7 +28,7 @@ BOOST_AUTO_TEST_CASE(BlockContextTest) LedgerCache::Ptr ledgerCache = std::make_shared(std::make_shared()); BlockContext::Ptr blockContext = std::make_shared( - nullptr, ledgerCache, nullptr, 0, h256(), 0, 0, FiscoBcosSchedule, false, false); + nullptr, ledgerCache, nullptr, 0, h256(), 0, 0, false, false); h256 blockhash = blockContext->hash(); EXECUTOR_LOG(DEBUG) << blockhash; diff --git a/bcos-executor/test/unittest/libexecutor/TestEVMExecutor.cpp b/bcos-executor/test/unittest/libexecutor/TestEVMExecutor.cpp index 4d41ec2fb4..f8cb1b156c 100644 --- a/bcos-executor/test/unittest/libexecutor/TestEVMExecutor.cpp +++ b/bcos-executor/test/unittest/libexecutor/TestEVMExecutor.cpp @@ -26,9 +26,15 @@ #include "bcos-framework/bcos-framework/testutils/faker/FakeBlockHeader.h" #include "bcos-framework/bcos-framework/testutils/faker/FakeTransaction.h" #include "bcos-framework/executor/ExecutionMessage.h" +#include "bcos-framework/ledger/Features.h" +#include "bcos-framework/ledger/LedgerTypeDef.h" #include "bcos-framework/protocol/ProtocolTypeDef.h" #include "bcos-framework/protocol/Transaction.h" +#include "bcos-framework/storage/Entry.h" +#include "bcos-table/src/StateStorage.h" #include "bcos-table/src/StateStorageFactory.h" +#include "bcos-task/Task.h" +#include "bcos-task/Wait.h" #include "evmc/evmc.h" #include "executor/TransactionExecutorFactory.h" #include @@ -1806,6 +1812,768 @@ contract HelloWorld { executePromise3.get_future().get(); } +BOOST_AUTO_TEST_CASE(transientStorageTest) +{ + // test opcode tstore and tload, contracts: + // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/StorageSlot.sol + std::string transientCodeBin = + "60806040526100337fbad128a9c9f118267291de46fed9cb24d9fbbe19a927cfee43cdc3b8e4eba17161010e60" + "201b60201c565b5f556100647fe51529ae218841954601d43f697e9bb24b282c1a2ddf95745a7e79ee1b4b7b7d" + "61011760201b60201c565b6001556100967f5d4010ae4473cd3ede543746d54ec6f990232434c2d4884f06e3cc" + "4ac77168e561012060201b60201c565b6002556100c87fb734117ebc01eac75f020b05b2620ab71735dfa2175a" + "c8e98f85bd7f529bb96f61012960201b60201c565b6003556100fa7feb7753d6e9a22bf47d9682cdc6f111b5de" + "fde6c206047689bad23120af3743bd61013260201b60201c565b600455348015610108575f80fd5b5061013b56" + "5b5f819050919050565b5f819050919050565b5f819050919050565b5f819050919050565b5f81905091905056" + "5b6105e3806101485f395ff3fe608060405234801561000f575f80fd5b506004361061009c575f3560e01c8063" + "c2b12a7311610064578063c2b12a7314610134578063d2282dc514610150578063e30081a01461016c578063f5" + "b53e1714610188578063f8462a0f146101a65761009c565b80631f903037146100a05780632d1be94d146100be" + "57806338cc4831146100dc57806368895979146100fa578063a53b1c1e14610118575b5f80fd5b6100a86101c2" + "565b6040516100b591906102fa565b60405180910390f35b6100c66101d3565b6040516100d3919061032d565b" + "60405180910390f35b6100e46101e4565b6040516100f19190610385565b60405180910390f35b6101026101f4" + "565b60405161010f91906103b6565b60405180910390f35b610132600480360381019061012d9190610406565b" + "610205565b005b61014e6004803603810190610149919061045b565b61021d565b005b61016a60048036038101" + "9061016591906104b0565b610235565b005b61018660048036038101906101819190610505565b61024d565b00" + "5b610190610264565b60405161019d919061053f565b60405180910390f35b6101c060048036038101906101bb" + "9190610582565b610275565b005b5f6101ce60025461028d565b905090565b5f6101df600154610297565b9050" + "90565b5f6101ef5f546102a1565b905090565b5f6102006003546102ab565b905090565b61021a816004546102" + "b590919063ffffffff16565b50565b610232816002546102bc90919063ffffffff16565b50565b61024a816003" + "546102c390919063ffffffff16565b50565b610261815f546102ca90919063ffffffff16565b50565b5f610270" + "6004546102d1565b905090565b61028a816001546102db90919063ffffffff16565b50565b5f815c9050919050" + "565b5f815c9050919050565b5f815c9050919050565b5f815c9050919050565b80825d5050565b80825d505056" + "5b80825d5050565b80825d5050565b5f815c9050919050565b80825d5050565b5f819050919050565b6102f481" + "6102e2565b82525050565b5f60208201905061030d5f8301846102eb565b92915050565b5f8115159050919050" + "565b61032781610313565b82525050565b5f6020820190506103405f83018461031e565b92915050565b5f73ff" + "ffffffffffffffffffffffffffffffffffffff82169050919050565b5f61036f82610346565b9050919050565b" + "61037f81610365565b82525050565b5f6020820190506103985f830184610376565b92915050565b5f81905091" + "9050565b6103b08161039e565b82525050565b5f6020820190506103c95f8301846103a7565b92915050565b5f" + "80fd5b5f819050919050565b6103e5816103d3565b81146103ef575f80fd5b50565b5f81359050610400816103" + "dc565b92915050565b5f6020828403121561041b5761041a6103cf565b5b5f610428848285016103f2565b9150" + "5092915050565b61043a816102e2565b8114610444575f80fd5b50565b5f8135905061045581610431565b9291" + "5050565b5f602082840312156104705761046f6103cf565b5b5f61047d84828501610447565b91505092915050" + "565b61048f8161039e565b8114610499575f80fd5b50565b5f813590506104aa81610486565b92915050565b5f" + "602082840312156104c5576104c46103cf565b5b5f6104d28482850161049c565b91505092915050565b6104e4" + "81610365565b81146104ee575f80fd5b50565b5f813590506104ff816104db565b92915050565b5f6020828403" + "121561051a576105196103cf565b5b5f610527848285016104f1565b91505092915050565b610539816103d356" + "5b82525050565b5f6020820190506105525f830184610530565b92915050565b61056181610313565b81146105" + "6b575f80fd5b50565b5f8135905061057c81610558565b92915050565b5f602082840312156105975761059661" + "03cf565b5b5f6105a48482850161056e565b9150509291505056fea2646970667358221220c24f2807e50107ea" + "7f1b14927e683f13801dba0387067d73ff19776123092a7d64736f6c63430008190033"; + + bytes input; + boost::algorithm::unhex(transientCodeBin, std::back_inserter(input)); + + auto tx = + fakeTransaction(cryptoSuite, keyPair, "", input, std::to_string(101), 100001, "1", "1"); + auto sender = boost::algorithm::hex_lower(std::string(tx->sender())); + // The contract address + h256 addressCreate("ff6f30856ad3bae00b1169808488502786a13e3c174d85682135ffd51310310e"); + std::string address = addressCreate.hex().substr(0, 40); + + auto hash = tx->hash(); + txpool->hash2Transaction.emplace(hash, tx); + + auto params = std::make_unique(); + params->setContextID(100); + params->setSeq(1000); + params->setDepth(0); + + params->setOrigin(std::string(sender)); + params->setFrom(std::string(sender)); + + params->setTo(std::string(sender)); + params->setStaticCall(false); + params->setGasAvailable(gas); + params->setData(input); + params->setType(NativeExecutionMessage::TXHASH); + params->setTransactionHash(hash); + params->setCreate(true); + + NativeExecutionMessage paramsBak = *params; + auto blockHeader = std::make_shared( + [m_blockHeader = bcostars::BlockHeader()]() mutable { return &m_blockHeader; }); + blockHeader->setNumber(1); + + std::vector parentInfos{ + {{blockHeader->number() - 1, h256(blockHeader->number() - 1)}}}; + blockHeader->setParentInfo(parentInfos); + ledger->setBlockNumber(blockHeader->number() - 1); + blockHeader->calculateHash(*cryptoSuite->hashImpl()); + std::promise nextPromise; + executor->nextBlockHeader(0, blockHeader, [&](bcos::Error::Ptr&& error) { + BOOST_CHECK(!error); + nextPromise.set_value(); + }); + nextPromise.get_future().get(); + + // -------------------------- + // Deploy + // -------------------------- + std::promise executePromise; + executor->dmcExecuteTransaction(std::move(params), + [&](bcos::Error::UniquePtr&& error, bcos::protocol::ExecutionMessage::UniquePtr&& result) { + BOOST_CHECK(!error); + executePromise.set_value(std::move(result)); + }); + auto result = executePromise.get_future().get(); + BOOST_CHECK(result); + + // feature_evm_cancun is off + BOOST_CHECK_EQUAL(result->type(), NativeExecutionMessage::REVERT); + BOOST_CHECK_EQUAL(result->status(), 10); + BOOST_CHECK_EQUAL(result->evmStatus(), 5); +} + +BOOST_AUTO_TEST_CASE(transientStorageTest2) +{ + // turn on feature_evm_cuncan swtich + std::shared_ptr newStorage = + std::make_shared(hashImpl); + Entry entry; + bcos::protocol::BlockNumber blockNumber = 0; + entry.setObject( + ledger::SystemConfigEntry{boost::lexical_cast((int)1), blockNumber}); + newStorage->asyncSetRow(ledger::SYS_CONFIG, "feature_evm_cancun", entry, + [](Error::UniquePtr error) { BOOST_CHECK_EQUAL(error.get(), nullptr); }); + // check feature_evm_cancun whether is on + auto entry1 = newStorage->getRow(ledger::SYS_CONFIG, "feature_evm_cancun"); + // BOOST_CHECK_EQUAL(value, "1"); + // BOOST_CHECK_EQUAL(enableNumber, 0); + + auto executionResultFactory = std::make_shared(); + auto stateStorageFactory = std::make_shared(0); + auto lruStorage = std::make_shared(newStorage, false); + auto newExecutor = bcos::executor::TransactionExecutorFactory::build(ledger, txpool, lruStorage, + newStorage, executionResultFactory, stateStorageFactory, hashImpl, false, false); + + std::string transientCodeBin = + "6080604052348015600e575f80fd5b506108748061001c5f395ff3fe608060405234801561000f575f80fd5b50" + "60043610610029575f3560e01c8063fa3e317e1461002d575b5f80fd5b61004760048036038101906100429190" + "610194565b61005d565b60405161005491906101d9565b60405180910390f35b5f808260405161006c90610150" + "565b6100769190610201565b604051809103905ff08015801561008f573d5f803e3d5ffd5b5090505f8173ffff" + "ffffffffffffffffffffffffffffffffffff16636428f3dc6040518163ffffffff1660e01b8152600401602060" + "4051808303815f875af11580156100dd573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060" + "405250810190610101919061022e565b9050838114610145576040517f08c379a0000000000000000000000000" + "00000000000000000000000000000000815260040161013c906102d9565b60405180910390fd5b600192505050" + "919050565b610547806102f883390190565b5f80fd5b5f819050919050565b61017381610161565b811461017d" + "575f80fd5b50565b5f8135905061018e8161016a565b92915050565b5f602082840312156101a9576101a86101" + "5d565b5b5f6101b684828501610180565b91505092915050565b5f8115159050919050565b6101d3816101bf56" + "5b82525050565b5f6020820190506101ec5f8301846101ca565b92915050565b6101fb81610161565b82525050" + "565b5f6020820190506102145f8301846101f2565b92915050565b5f815190506102288161016a565b92915050" + "565b5f602082840312156102435761024261015d565b5b5f6102508482850161021a565b91505092915050565b" + "5f82825260208201905092915050565b7f73746f72652076616c7565206e6f7420657175616c20746c6f616420" + "726573755f8201527f6c7400000000000000000000000000000000000000000000000000000000000060208201" + "5250565b5f6102c3602283610259565b91506102ce82610269565b604082019050919050565b5f602082019050" + "8181035f8301526102f0816102b7565b905091905056fe6080604052348015600e575f80fd5b50604051610547" + "3803806105478339818101604052810190602e9190607b565b603d5f5482604260201b60201c565b5060a1565b" + "80825d5050565b5f80fd5b5f819050919050565b605d81604d565b81146066575f80fd5b50565b5f8151905060" + "75816056565b92915050565b5f60208284031215608d57608c6049565b5b5f6098848285016069565b91505092" + "915050565b610499806100ae5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560" + "e01c80633bc5de30146100385780636428f3dc14610056575b5f80fd5b610040610074565b60405161004d9190" + "61015c565b60405180910390f35b61005e610084565b60405161006b919061015c565b60405180910390f35b5f" + "61007f5f5461012d565b905090565b5f8060405161009290610137565b604051809103905ff0801580156100ab" + "573d5f803e3d5ffd5b5090508073ffffffffffffffffffffffffffffffffffffffff1663c1df0f483060405182" + "63ffffffff1660e01b81526004016100e791906101b4565b6020604051808303815f875af1158015610103573d" + "5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061012791906101fb565b9150" + "5090565b5f815c9050919050565b61023d8061022783390190565b5f819050919050565b61015681610144565b" + "82525050565b5f60208201905061016f5f83018461014d565b92915050565b5f73ffffffffffffffffffffffff" + "ffffffffffffffff82169050919050565b5f61019e82610175565b9050919050565b6101ae81610194565b8252" + "5050565b5f6020820190506101c75f8301846101a5565b92915050565b5f80fd5b6101da81610144565b811461" + "01e4575f80fd5b50565b5f815190506101f5816101d1565b92915050565b5f602082840312156102105761020f" + "6101cd565b5b5f61021d848285016101e7565b9150509291505056fe6080604052348015600e575f80fd5b5061" + "02218061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063c1df" + "0f481461002d575b5f80fd5b6100476004803603810190610042919061013a565b61005d565b60405161005491" + "9061017d565b60405180910390f35b5f808290505f8173ffffffffffffffffffffffffffffffffffffffff1663" + "3bc5de306040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100ac573d5f803e" + "3d5ffd5b505050506040513d601f19601f820116820180604052508101906100d091906101c0565b9050809250" + "5050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6101" + "09826100e0565b9050919050565b610119816100ff565b8114610123575f80fd5b50565b5f8135905061013481" + "610110565b92915050565b5f6020828403121561014f5761014e6100dc565b5b5f61015c84828501610126565b" + "91505092915050565b5f819050919050565b61017781610165565b82525050565b5f6020820190506101905f83" + "018461016e565b92915050565b61019f81610165565b81146101a9575f80fd5b50565b5f815190506101ba8161" + "0196565b92915050565b5f602082840312156101d5576101d46100dc565b5b5f6101e2848285016101ac565b91" + "50509291505056fea2646970667358221220b74855b53bcf2b3cc2261d3f57e16507da8b24f81ff519699191e3" + "4ce025bc8664736f6c63430008190033a26469706673582212201eb1e02998c84b08c3db1bdb2487184ca8357f" + "1d2739ec65daa47ffe3e89316a64736f6c63430008190033a2646970667358221220bad0e7bec379be9bb4f446" + "b845050f59959e8bd9da49d83f3c9f669a63e5e51e64736f6c63430008190033"; + bytes input; + boost::algorithm::unhex(transientCodeBin, std::back_inserter(input)); + + auto tx = + fakeTransaction(cryptoSuite, keyPair, "", input, std::to_string(100), 100000, "1", "1"); + auto sender = boost::algorithm::hex_lower(std::string(tx->sender())); + // The contract address + h256 addressCreate("ff6f30856ad3bae00b1169808488502786a13e3c174d85682135ffd51310310e"); + std::string address = addressCreate.hex().substr(0, 40); + + auto hash = tx->hash(); + txpool->hash2Transaction.emplace(hash, tx); + + + auto params1 = std::make_unique(); + params1->setContextID(101); + params1->setSeq(1001); + params1->setDepth(0); + params1->setOrigin(std::string(sender)); + params1->setFrom(std::string(sender)); + + // The contract address + params1->setTo(sender); + params1->setStaticCall(false); + params1->setGasAvailable(gas); + params1->setData(input); + params1->setType(NativeExecutionMessage::TXHASH); + params1->setTransactionHash(hash); + params1->setCreate(true); + + NativeExecutionMessage paramsBak1 = *params1; + + auto blockHeader = std::make_shared( + [m_blockHeader = bcostars::BlockHeader()]() mutable { return &m_blockHeader; }); + blockHeader->setNumber(1); + blockHeader->setVersion((uint32_t)bcos::protocol::BlockVersion::MAX_VERSION); + + std::vector parentInfos{ + {{blockHeader->number() - 1, h256(blockHeader->number() - 1)}}}; + blockHeader->setParentInfo(parentInfos); + ledger->setBlockNumber(blockHeader->number() - 1); + blockHeader->calculateHash(*cryptoSuite->hashImpl()); + std::promise nextPromise; + newExecutor->nextBlockHeader(0, blockHeader, [&](bcos::Error::Ptr&& error) { + BOOST_CHECK(!error); + nextPromise.set_value(); + }); + nextPromise.get_future().get(); + + // -------------------------- + // Deploy + // -------------------------- + std::promise executePromise; + newExecutor->executeTransaction(std::move(params1), + [&](bcos::Error::UniquePtr&& error, bcos::protocol::ExecutionMessage::UniquePtr&& result) { + BOOST_CHECK(!error); + executePromise.set_value(std::move(result)); + }); + auto result = executePromise.get_future().get(); + BOOST_CHECK(result); + + BOOST_CHECK_EQUAL(result->type(), NativeExecutionMessage::FINISHED); + BOOST_CHECK_EQUAL(result->status(), 0); + BOOST_CHECK_EQUAL(result->evmStatus(), 0); +} + +BOOST_AUTO_TEST_CASE(mcopy_opcode_test) +{ + // test opcode mcopy + /* solidity code + pragma solidity 0.8.25; + + contract mcopy { + function memoryCopy() external pure returns (bytes32 x) { + assembly { + mstore(0x20, 0x50) // Store 0x50 at word 1 in memory + mcopy(0, 0x20, 0x20) // Copies 0x50 to word 0 in memory + x := mload(0) // Returns 32 bytes "0x50" + } + } + }*/ + std::string mcopyCodeBin = + "6080604052348015600e575f80fd5b5060b980601a5f395ff3fe6080604052348015600e575f80fd5b50600436" + "106026575f3560e01c80632dbaeee914602a575b5f80fd5b60306044565b604051603b9190606c565b60405180" + "910390f35b5f60506020526020805f5e5f51905090565b5f819050919050565b6066816056565b82525050565b" + "5f602082019050607d5f830184605f565b9291505056fea2646970667358221220c16107fa00317d2d630d4d01" + "9754eb2bae42e96482d0050308e60ec21c69d7eb64736f6c63430008190033"; + + bytes input; + boost::algorithm::unhex(mcopyCodeBin, std::back_inserter(input)); + + auto tx = + fakeTransaction(cryptoSuite, keyPair, "", input, std::to_string(101), 100001, "1", "1"); + auto sender = boost::algorithm::hex_lower(std::string(tx->sender())); + // The contract address + h256 addressCreate("ff6f30856ad3bae00b1169808488502786a13e3c174d85682135ffd51310310e"); + std::string address = addressCreate.hex().substr(0, 40); + + auto hash = tx->hash(); + txpool->hash2Transaction.emplace(hash, tx); + + auto params = std::make_unique(); + params->setContextID(100); + params->setSeq(1000); + params->setDepth(0); + + params->setOrigin(std::string(sender)); + params->setFrom(std::string(sender)); + + params->setTo(std::string(sender)); + params->setStaticCall(false); + params->setGasAvailable(gas); + params->setData(input); + params->setType(NativeExecutionMessage::TXHASH); + params->setTransactionHash(hash); + params->setCreate(true); + + NativeExecutionMessage paramsBak = *params; + auto blockHeader = std::make_shared( + [m_blockHeader = bcostars::BlockHeader()]() mutable { return &m_blockHeader; }); + blockHeader->setNumber(1); + std::vector parentInfos{ + {{blockHeader->number() - 1, h256(blockHeader->number() - 1)}}}; + blockHeader->setParentInfo(parentInfos); + ledger->setBlockNumber(blockHeader->number() - 1); + blockHeader->calculateHash(*cryptoSuite->hashImpl()); + std::promise nextPromise; + executor->nextBlockHeader(0, blockHeader, [&](bcos::Error::Ptr&& error) { + BOOST_CHECK(!error); + nextPromise.set_value(); + }); + nextPromise.get_future().get(); + + // -------------------------- + // Deploy on executor which feature_evm_cancun is off + // -------------------------- + std::promise executePromise; + executor->dmcExecuteTransaction(std::move(params), + [&](bcos::Error::UniquePtr&& error, bcos::protocol::ExecutionMessage::UniquePtr&& result) { + BOOST_CHECK(!error); + executePromise.set_value(std::move(result)); + }); + auto result = executePromise.get_future().get(); + BOOST_CHECK(result); + + // feature_evm_cancun is off + BOOST_CHECK_EQUAL(result->type(), NativeExecutionMessage::REVERT); + BOOST_CHECK_EQUAL(result->status(), 10); + BOOST_CHECK_EQUAL(result->evmStatus(), 5); +} + +BOOST_AUTO_TEST_CASE(mcopy_opcode_test_1) +{ + // turn on feature_evm_cuncan swtich + std::shared_ptr newStorage = + std::make_shared(hashImpl); + Entry entry; + bcos::protocol::BlockNumber blockNumber = 0; + entry.setObject( + ledger::SystemConfigEntry{boost::lexical_cast((int)1), blockNumber}); + newStorage->asyncSetRow(ledger::SYS_CONFIG, "feature_evm_cancun", entry, + [](Error::UniquePtr error) { BOOST_CHECK_EQUAL(error.get(), nullptr); }); + // check feature_evm_cancun whether is on + auto entry1 = newStorage->getRow(ledger::SYS_CONFIG, "feature_evm_cancun"); + // BOOST_CHECK_EQUAL(value, "1"); + // BOOST_CHECK_EQUAL(enableNumber, 0); + + auto executionResultFactory = std::make_shared(); + auto stateStorageFactory = std::make_shared(0); + auto lruStorage = std::make_shared(newStorage, false); + auto newExecutor = bcos::executor::TransactionExecutorFactory::build(ledger, txpool, lruStorage, + newStorage, executionResultFactory, stateStorageFactory, hashImpl, false, false); + + std::string mcopyCodeBin = + "6080604052348015600e575f80fd5b5060b980601a5f395ff3fe6080604052348015600e575f80" + "fd5b50600436106026575f3560e01c80632dbaeee914602a575b5f80fd5b60306044565b604051603b9190606c" + "565b60405180" + "910390f35b5f60506020526020805f5e5f51905090565b5f819050919050565b6066816056565b82525050565b" + "5f6020820190" + "50607d5f830184605f565b9291505056fea2646970667358221220c16107fa00317d2d630d4d019754eb2bae42" + "e96482d00503" + "08e60ec21c69d7eb64736f6c63430008190033"; + + bytes input; + boost::algorithm::unhex(mcopyCodeBin, std::back_inserter(input)); + + auto tx = + fakeTransaction(cryptoSuite, keyPair, "", input, std::to_string(101), 100001, "1", "1"); + auto sender = boost::algorithm::hex_lower(std::string(tx->sender())); + // The contract address + h256 addressCreate("ff6f30856ad3bae00b1169808488502786a13e3c174d85682135ffd51310310e"); + std::string address = addressCreate.hex().substr(0, 40); + + auto hash = tx->hash(); + txpool->hash2Transaction.emplace(hash, tx); + + auto params = std::make_unique(); + params->setContextID(100); + params->setSeq(1000); + params->setDepth(0); + + params->setOrigin(std::string(sender)); + params->setFrom(std::string(sender)); + + params->setTo(std::string(sender)); + params->setStaticCall(false); + params->setGasAvailable(gas); + params->setData(input); + params->setType(NativeExecutionMessage::TXHASH); + params->setTransactionHash(hash); + params->setCreate(true); + + NativeExecutionMessage paramsBak = *params; + auto blockHeader = std::make_shared( + [m_blockHeader = bcostars::BlockHeader()]() mutable { return &m_blockHeader; }); + blockHeader->setNumber(1); + std::vector parentInfos{ + {{blockHeader->number() - 1, h256(blockHeader->number() - 1)}}}; + blockHeader->setParentInfo(parentInfos); + ledger->setBlockNumber(blockHeader->number() - 1); + blockHeader->calculateHash(*cryptoSuite->hashImpl()); + std::promise nextPromise; + newExecutor->nextBlockHeader(0, blockHeader, [&](bcos::Error::Ptr&& error) { + BOOST_CHECK(!error); + nextPromise.set_value(); + }); + nextPromise.get_future().get(); + + // -------------------------- + // Deploy on executor which feature_evm_cancun is off + // -------------------------- + std::promise executePromise; + newExecutor->dmcExecuteTransaction(std::move(params), + [&](bcos::Error::UniquePtr&& error, bcos::protocol::ExecutionMessage::UniquePtr&& result) { + BOOST_CHECK(!error); + executePromise.set_value(std::move(result)); + }); + auto result = executePromise.get_future().get(); + BOOST_CHECK(result); + BOOST_CHECK_EQUAL(result->type(), NativeExecutionMessage::FINISHED); + BOOST_CHECK_EQUAL(result->status(), 0); + BOOST_CHECK_EQUAL(result->evmStatus(), 0); +} + +BOOST_AUTO_TEST_CASE(blobBaseFee_test) +{ + /* + pragma solidity 0.8.25; + + contract blobBaseFee { + function getBlobBaseFeeYul() external view returns (uint256 blobBaseFee) { + assembly { + blobBaseFee := blobbasefee() + } + } + + function getBlobBaseFeeSolidity() external view returns (uint256 blobBaseFee) { + blobBaseFee = block.blobbasefee; + } + } + */ + // turn on feature_evm_cuncan swtich + std::shared_ptr newStorage = + std::make_shared(hashImpl); + Entry entry; + bcos::protocol::BlockNumber blockNumber = 0; + entry.setObject( + ledger::SystemConfigEntry{boost::lexical_cast((int)1), blockNumber}); + newStorage->asyncSetRow(ledger::SYS_CONFIG, "feature_evm_cancun", entry, + [](Error::UniquePtr error) { BOOST_CHECK_EQUAL(error.get(), nullptr); }); + // check feature_evm_cancun whether is on + auto entry1 = newStorage->getRow(ledger::SYS_CONFIG, "feature_evm_cancun"); + // BOOST_CHECK_EQUAL(value, "1"); + // BOOST_CHECK_EQUAL(enableNumber, 0); + + auto executionResultFactory = std::make_shared(); + auto stateStorageFactory = std::make_shared(0); + auto lruStorage = std::make_shared(newStorage, false); + auto newExecutor = bcos::executor::TransactionExecutorFactory::build(ledger, txpool, lruStorage, + newStorage, executionResultFactory, stateStorageFactory, hashImpl, false, false); + + std::string blobBaseFeeCodeBin = + "6080604052348015600e575f80fd5b5060d980601a5f395ff3fe6080" + "604052348015600e575f80fd5b50600436106030575f3560e01c806348a35d4e1460345780635b85fe9814" + "604e575b5f80fd5b603a6068565b60405160459190608c565b60405180910390f35b6054606f565b604051" + "605f9190608c565b60405180910390f35b5f4a905090565b5f4a905090565b5f819050919050565b608681" + "6076565b82525050565b5f602082019050609d5f830184607f565b9291505056fea2646970667358221220" + "954cfa4357894c6c07e251b6fe89f193c6348d4425388a3cae9a77548e09789964736f6c63430008190033"; + + bytes input; + boost::algorithm::unhex(blobBaseFeeCodeBin, std::back_inserter(input)); + + auto tx = + fakeTransaction(cryptoSuite, keyPair, "", input, std::to_string(101), 100001, "1", "1"); + auto sender = boost::algorithm::hex_lower(std::string(tx->sender())); + // The contract address + h256 addressCreate("ff6f30856ad3bae00b1169808488502786a13e3c174d85682135ffd51310310e"); + std::string address = addressCreate.hex().substr(0, 40); + + auto hash = tx->hash(); + txpool->hash2Transaction.emplace(hash, tx); + + auto params = std::make_unique(); + params->setContextID(100); + params->setSeq(1000); + params->setDepth(0); + + params->setOrigin(std::string(sender)); + params->setFrom(std::string(sender)); + + params->setTo(std::string(sender)); + params->setStaticCall(false); + params->setGasAvailable(gas); + params->setData(input); + params->setType(NativeExecutionMessage::TXHASH); + params->setTransactionHash(hash); + params->setCreate(true); + + NativeExecutionMessage paramsBak = *params; + auto blockHeader = std::make_shared( + [m_blockHeader = bcostars::BlockHeader()]() mutable { return &m_blockHeader; }); + blockHeader->setNumber(1); + std::vector parentInfos{ + {{blockHeader->number() - 1, h256(blockHeader->number() - 1)}}}; + blockHeader->setParentInfo(parentInfos); + ledger->setBlockNumber(blockHeader->number() - 1); + blockHeader->calculateHash(*cryptoSuite->hashImpl()); + std::promise nextPromise; + newExecutor->nextBlockHeader(0, blockHeader, [&](bcos::Error::Ptr&& error) { + BOOST_CHECK(!error); + nextPromise.set_value(); + }); + nextPromise.get_future().get(); + + // -------------------------- + // Deploy on executor which feature_evm_cancun is off + // -------------------------- + std::promise executePromise; + newExecutor->dmcExecuteTransaction(std::move(params), + [&](bcos::Error::UniquePtr&& error, bcos::protocol::ExecutionMessage::UniquePtr&& result) { + BOOST_CHECK(!error); + executePromise.set_value(std::move(result)); + }); + auto result = executePromise.get_future().get(); + BOOST_CHECK(result); + BOOST_CHECK_EQUAL(result->type(), NativeExecutionMessage::FINISHED); + BOOST_CHECK_EQUAL(result->status(), 0); + BOOST_CHECK_EQUAL(result->evmStatus(), 0); +} + +BOOST_AUTO_TEST_CASE(blobHash_test) +{ + /* + pragma solidity 0.8.25; + contract blobhash { + function storeBlobHash(uint256 index) external { + assembly { + sstore(0, blobhash(index)) + } + } + } + */ + + // turn on feature_evm_cuncan swtich + std::shared_ptr newStorage = + std::make_shared(hashImpl); + Entry entry; + bcos::protocol::BlockNumber blockNumber = 0; + entry.setObject( + ledger::SystemConfigEntry{boost::lexical_cast((int)1), blockNumber}); + newStorage->asyncSetRow(ledger::SYS_CONFIG, "feature_evm_cancun", entry, + [](Error::UniquePtr error) { BOOST_CHECK_EQUAL(error.get(), nullptr); }); + // check feature_evm_cancun whether is on + auto entry1 = newStorage->getRow(ledger::SYS_CONFIG, "feature_evm_cancun"); + // BOOST_CHECK_EQUAL(value, "1"); + // BOOST_CHECK_EQUAL(enableNumber, 0); + + auto executionResultFactory = std::make_shared(); + auto stateStorageFactory = std::make_shared(0); + auto lruStorage = std::make_shared(newStorage, false); + auto newExecutor = bcos::executor::TransactionExecutorFactory::build(ledger, txpool, lruStorage, + newStorage, executionResultFactory, stateStorageFactory, hashImpl, false, false); + + std::string blobHashCodeBin = + "6080604052348015600e575f80fd5b5060d780601a5f395ff3fe6080604052348015600e575f80fd5b50600436" + "106026575f3560e01c8063ae67ac9b14602a575b5f80fd5b60406004803603810190603c9190607b565b604256" + "5b005b80495f5550565b5f80fd5b5f819050919050565b605d81604d565b81146066575f80fd5b50565b5f8135" + "90506075816056565b92915050565b5f60208284031215608d57608c6049565b5b5f6098848285016069565b91" + "50509291505056fea2646970667358221220ad2b619fbd8e82b272adfa7e9278d31e0c2f6e109361b2206b5b03" + "84aee5700f64736f6c63430008190033"; + bytes input; + boost::algorithm::unhex(blobHashCodeBin, std::back_inserter(input)); + + auto tx = + fakeTransaction(cryptoSuite, keyPair, "", input, std::to_string(101), 100001, "1", "1"); + auto sender = boost::algorithm::hex_lower(std::string(tx->sender())); + // The contract address + h256 addressCreate("ff6f30856ad3bae00b1169808488502786a13e3c174d85682135ffd51310310e"); + std::string address = addressCreate.hex().substr(0, 40); + + auto hash = tx->hash(); + txpool->hash2Transaction.emplace(hash, tx); + + auto params = std::make_unique(); + params->setContextID(100); + params->setSeq(1000); + params->setDepth(0); + + params->setOrigin(std::string(sender)); + params->setFrom(std::string(sender)); + + params->setTo(std::string(sender)); + params->setStaticCall(false); + params->setGasAvailable(gas); + params->setData(input); + params->setType(NativeExecutionMessage::TXHASH); + params->setTransactionHash(hash); + params->setCreate(true); + + NativeExecutionMessage paramsBak = *params; + auto blockHeader = std::make_shared( + [m_blockHeader = bcostars::BlockHeader()]() mutable { return &m_blockHeader; }); + blockHeader->setNumber(1); + std::vector parentInfos{ + {{blockHeader->number() - 1, h256(blockHeader->number() - 1)}}}; + blockHeader->setParentInfo(parentInfos); + ledger->setBlockNumber(blockHeader->number() - 1); + blockHeader->calculateHash(*cryptoSuite->hashImpl()); + std::promise nextPromise; + newExecutor->nextBlockHeader(0, blockHeader, [&](bcos::Error::Ptr&& error) { + BOOST_CHECK(!error); + nextPromise.set_value(); + }); + nextPromise.get_future().get(); + + // -------------------------- + // Deploy on executor which feature_evm_cancun is off + // -------------------------- + std::promise executePromise; + newExecutor->dmcExecuteTransaction(std::move(params), + [&](bcos::Error::UniquePtr&& error, bcos::protocol::ExecutionMessage::UniquePtr&& result) { + BOOST_CHECK(!error); + executePromise.set_value(std::move(result)); + }); + auto result = executePromise.get_future().get(); + BOOST_CHECK(result); + BOOST_CHECK_EQUAL(result->type(), NativeExecutionMessage::FINISHED); + BOOST_CHECK_EQUAL(result->status(), 0); + BOOST_CHECK_EQUAL(result->evmStatus(), 0); +} + +BOOST_AUTO_TEST_CASE(getTransientStorageTest) +{ + // turn on feature_evm_cuncan swtich + std::shared_ptr newStorage = + std::make_shared(hashImpl); + Entry entry; + bcos::protocol::BlockNumber blockNumber = 0; + entry.setObject( + ledger::SystemConfigEntry{boost::lexical_cast((int)1), blockNumber}); + newStorage->asyncSetRow(ledger::SYS_CONFIG, "feature_evm_cancun", entry, + [](Error::UniquePtr error) { BOOST_CHECK_EQUAL(error.get(), nullptr); }); + // check feature_evm_cancun whether is on + auto entry1 = newStorage->getRow(ledger::SYS_CONFIG, "feature_evm_cancun"); + // BOOST_CHECK_EQUAL(value, "1"); + // BOOST_CHECK_EQUAL(enableNumber, 0); + + auto executionResultFactory = std::make_shared(); + auto stateStorageFactory = std::make_shared(0); + auto lruStorage = std::make_shared(newStorage, false); + auto newExecutor = bcos::executor::TransactionExecutorFactory::build(ledger, txpool, lruStorage, + newStorage, executionResultFactory, stateStorageFactory, hashImpl, false, false); + + std::string transientCodeBin = + "60806040527fe3598e46f24394be411dcf68a978c22ef80d97a0ef7c630d9b8e35d241c0210060015534801560" + "32575f80fd5b506106a9806100405f395ff3fe608060405234801561000f575f80fd5b5060043610610055575f" + "3560e01c806320965255146100595780632a130724146100775780635524107714610093578063613d81e11461" + "00af57806374f7ca87146100b9575b5f80fd5b6100616100d7565b60405161006e91906103a4565b6040518091" + "0390f35b610091600480360381019061008c919061041b565b6100eb565b005b6100ad60048036038101906100" + "a89190610470565b61012d565b005b6100b761013a565b005b6100c1610369565b6040516100ce91906104aa56" + "5b60405180910390f35b5f8060015490505f815c9050809250505090565b805f806101000a81548173ffffffff" + "ffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217" + "90555050565b5f600154905081815d5050565b5f73ffffffffffffffffffffffffffffffffffffffff165f8054" + "906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffff" + "ffffffffff16036101c7576040517f08c379a00000000000000000000000000000000000000000000000000000" + "000081526004016101be9061051d565b60405180910390fd5b5f805f9054906101000a900473ffffffffffffff" + "ffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16604051602401604051" + "6020818303038152906040527fb7fd278600000000000000000000000000000000000000000000000000000000" + "7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffff" + "ffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161028f919061058d565b" + "5f604051808303815f865af19150503d805f81146102c8576040519150601f19603f3d011682016040523d8252" + "3d5f602084013e6102cd565b606091505b5050905080610311576040517f08c379a00000000000000000000000" + "00000000000000000000000000000000008152600401610308906105ed565b60405180910390fd5b5f61031a61" + "00d7565b90506103246100d7565b8114610365576040517f08c379a00000000000000000000000000000000000" + "0000000000000000000000815260040161035c90610655565b60405180910390fd5b5050565b5f805490610100" + "0a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f819050919050565b61039e8161038c56" + "5b82525050565b5f6020820190506103b75f830184610395565b92915050565b5f80fd5b5f73ffffffffffffff" + "ffffffffffffffffffffffffff82169050919050565b5f6103ea826103c1565b9050919050565b6103fa816103" + "e0565b8114610404575f80fd5b50565b5f81359050610415816103f1565b92915050565b5f6020828403121561" + "04305761042f6103bd565b5b5f61043d84828501610407565b91505092915050565b61044f8161038c565b8114" + "610459575f80fd5b50565b5f8135905061046a81610446565b92915050565b5f60208284031215610485576104" + "846103bd565b5b5f6104928482850161045c565b91505092915050565b6104a4816103e0565b82525050565b5f" + "6020820190506104bd5f83018461049b565b92915050565b5f82825260208201905092915050565b7f4220636f" + "6e74726163742061646472657373206e6f74207365740000000000005f82015250565b5f610507601a836104c3" + "565b9150610512826104d3565b602082019050919050565b5f6020820190508181035f830152610534816104fb" + "565b9050919050565b5f81519050919050565b5f81905092915050565b8281835e5f83830152505050565b5f61" + "05678261053b565b6105718185610545565b935061058181856020860161054f565b8084019150509291505056" + "5b5f610598828461055d565b915081905092915050565b7f43616c6c20746f204220636f6e7472616374206661" + "696c6564000000000000005f82015250565b5f6105d76019836104c3565b91506105e2826105a3565b60208201" + "9050919050565b5f6020820190508181035f830152610604816105cb565b9050919050565b7f53746f72656420" + "76616c756520646f6573206e6f74206d6174636800000000005f82015250565b5f61063f601b836104c3565b91" + "5061064a8261060b565b602082019050919050565b5f6020820190508181035f83015261066c81610633565b90" + "5091905056fea264697066735822122032dafff81aab17ab191d852a4391e85e6339bf0c051c273ddc9ac41348" + "25fb5464736f6c63430008190033"; + bytes input; + boost::algorithm::unhex(transientCodeBin, std::back_inserter(input)); + + auto tx = + fakeTransaction(cryptoSuite, keyPair, "", input, std::to_string(100), 100000, "1", "1"); + auto sender = boost::algorithm::hex_lower(std::string(tx->sender())); + // The contract address + h256 addressCreate("ff6f30856ad3bae00b1169808488502786a13e3c174d85682135ffd51310310e"); + std::string address = addressCreate.hex().substr(0, 40); + + auto hash = tx->hash(); + txpool->hash2Transaction.emplace(hash, tx); + + + auto params1 = std::make_unique(); + params1->setContextID(101); + params1->setSeq(1001); + params1->setDepth(0); + params1->setOrigin(std::string(sender)); + params1->setFrom(std::string(sender)); + + // The contract address + params1->setTo(sender); + params1->setStaticCall(false); + params1->setGasAvailable(gas); + params1->setData(input); + params1->setType(NativeExecutionMessage::TXHASH); + params1->setTransactionHash(hash); + params1->setCreate(true); + + NativeExecutionMessage paramsBak1 = *params1; + + auto blockHeader = std::make_shared( + [m_blockHeader = bcostars::BlockHeader()]() mutable { return &m_blockHeader; }); + blockHeader->setNumber(1); + blockHeader->setVersion((uint32_t)bcos::protocol::BlockVersion::MAX_VERSION); + + std::vector parentInfos{ + {{blockHeader->number() - 1, h256(blockHeader->number() - 1)}}}; + blockHeader->setParentInfo(parentInfos); + ledger->setBlockNumber(blockHeader->number() - 1); + blockHeader->calculateHash(*cryptoSuite->hashImpl()); + std::promise nextPromise; + newExecutor->nextBlockHeader(0, blockHeader, [&](bcos::Error::Ptr&& error) { + BOOST_CHECK(!error); + nextPromise.set_value(); + }); + nextPromise.get_future().get(); + + // -------------------------- + // Deploy + // -------------------------- + std::promise executePromise; + newExecutor->executeTransaction(std::move(params1), + [&](bcos::Error::UniquePtr&& error, bcos::protocol::ExecutionMessage::UniquePtr&& result) { + BOOST_CHECK(!error); + executePromise.set_value(std::move(result)); + }); + auto result = executePromise.get_future().get(); + BOOST_CHECK(result); + + BOOST_CHECK_EQUAL(result->type(), NativeExecutionMessage::FINISHED); + BOOST_CHECK_EQUAL(result->status(), 0); + BOOST_CHECK_EQUAL(result->evmStatus(), 0); +} BOOST_AUTO_TEST_SUITE_END() } // namespace test diff --git a/bcos-executor/test/unittest/libexecutor/TestExecutiveStackFlow.cpp b/bcos-executor/test/unittest/libexecutor/TestExecutiveStackFlow.cpp index 6fc0785b9d..ba2d0af6d0 100644 --- a/bcos-executor/test/unittest/libexecutor/TestExecutiveStackFlow.cpp +++ b/bcos-executor/test/unittest/libexecutor/TestExecutiveStackFlow.cpp @@ -83,7 +83,7 @@ struct ExecutiveStackFlowFixture LedgerCache::Ptr ledgerCache = std::make_shared(std::make_shared()); blockContext = std::make_shared( - nullptr, ledgerCache, nullptr, 0, h256(), 0, 0, FiscoBcosSchedule, false, false); + nullptr, ledgerCache, nullptr, 0, h256(), 0, 0, false, false); executiveFactory = std::make_shared( *blockContext, nullptr, nullptr, nullptr, nullptr); diff --git a/bcos-executor/test/unittest/libexecutor/TestExecutiveState.cpp b/bcos-executor/test/unittest/libexecutor/TestExecutiveState.cpp index fec3b2c5d7..53a0e59b69 100644 --- a/bcos-executor/test/unittest/libexecutor/TestExecutiveState.cpp +++ b/bcos-executor/test/unittest/libexecutor/TestExecutiveState.cpp @@ -28,7 +28,7 @@ struct ExecutiveStateFixture input->contextID = 1; input->seq = 1; blockContext = std::make_shared( - nullptr, ledgerCache, nullptr, 0, h256(), 0, 0, FiscoBcosSchedule, false, false); + nullptr, ledgerCache, nullptr, 0, h256(), 0, 0, false, false); executiveFactory = std::make_shared( *blockContext, nullptr, nullptr, nullptr, nullptr); diff --git a/bcos-executor/test/unittest/libprecompiled/CryptoPrecompiledTest.cpp b/bcos-executor/test/unittest/libprecompiled/CryptoPrecompiledTest.cpp index a5109ada21..df7d67faab 100644 --- a/bcos-executor/test/unittest/libprecompiled/CryptoPrecompiledTest.cpp +++ b/bcos-executor/test/unittest/libprecompiled/CryptoPrecompiledTest.cpp @@ -303,10 +303,9 @@ class SM2VerifyPrecompiledFixture m_cryptoSuite = std::make_shared( std::make_shared(), std::make_shared(), nullptr); m_cryptoPrecompiled = std::make_shared(m_cryptoSuite->hashImpl()); - m_blockContext = - std::make_shared(nullptr, m_ledgerCache, m_cryptoSuite->hashImpl(), 0, - h256(), utcTime(), (uint32_t)(bcos::protocol::BlockVersion::V3_0_VERSION), - FiscoBcosSchedule, false, false); + m_blockContext = std::make_shared(nullptr, m_ledgerCache, + m_cryptoSuite->hashImpl(), 0, h256(), utcTime(), + (uint32_t)(bcos::protocol::BlockVersion::V3_0_VERSION), false, false); m_executive = std::make_shared(*m_blockContext, "", 100, 0, m_gasInjector); m_abi = std::make_shared(*m_cryptoSuite->hashImpl()); diff --git a/bcos-executor/test/unittest/libprecompiled/GroupSigPrecompiledTest.cpp b/bcos-executor/test/unittest/libprecompiled/GroupSigPrecompiledTest.cpp index c47142aaf5..faa86ed7f2 100644 --- a/bcos-executor/test/unittest/libprecompiled/GroupSigPrecompiledTest.cpp +++ b/bcos-executor/test/unittest/libprecompiled/GroupSigPrecompiledTest.cpp @@ -49,8 +49,8 @@ struct GroupSigPrecompiledFixture m_hashImpl = std::make_shared(); m_groupSigPrecompiled = std::make_shared(m_hashImpl); m_ledgerCache = std::make_shared(std::make_shared()); - m_blockContext = std::make_shared(nullptr, m_ledgerCache, m_hashImpl, 0, - h256(), utcTime(), 0, FiscoBcosSchedule, false, false); + m_blockContext = std::make_shared( + nullptr, m_ledgerCache, m_hashImpl, 0, h256(), utcTime(), 0, false, false); m_executive = std::make_shared(*m_blockContext, "", 100, 0, m_gasInjector); } diff --git a/bcos-executor/test/unittest/libprecompiled/PrecompiledTest.cpp b/bcos-executor/test/unittest/libprecompiled/PrecompiledTest.cpp new file mode 100644 index 0000000000..901f8e0efa --- /dev/null +++ b/bcos-executor/test/unittest/libprecompiled/PrecompiledTest.cpp @@ -0,0 +1,84 @@ +/** + * Copyright (C) 2021 FISCO BCOS. + * SPDX-License-Identifier: Apache-2.0 + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +using namespace bcos; +using namespace bcos::precompiled; +using namespace bcos::executor; +using namespace bcos::storage; + +namespace bcos::test +{ +BOOST_AUTO_TEST_SUITE(PrecompiledTest) + +BOOST_AUTO_TEST_CASE(PointEvaluatePrecompiledTest) +{ + static constexpr intx::uint256 kBlsModulus{intx::from_string( + "52435875175126190479447740508185965837690552500527637822603658699938581184513")}; + + bytes in = *bcos::fromHexString( + "014edfed8547661f6cb416eba53061a2f6dce872c0497e6dd485a876fe2567f1564c0a11a0f704f4fc3e8acfe0" + "f8245f0ad1347b378fbf96e206da11a5d363066d928e13fe443e957d82e3e71d48cb65d51028eb4483e719bf8e" + "fcdf12f7c321a421e229565952cfff4ef3517100a97da1d4fe57956fa50a442f92af03b1bf37adacc8ad4ed209" + "b31287ea5bb94d9d06a444d6bb5aadc3ceb615b50d6606bd54bfe529f59247987cd1ab848d19de599a9052f183" + "5fb0d0d44cf70183e19a68c9"); + static std::string pointE("point_evaluation"); + PrecompiledExecutor const& executor = PrecompiledRegistrar::executor(pointE); + bytesConstRef input_ref(in.data(), in.size()); + std::pair out = executor(input_ref); + BOOST_CHECK(out.first); + BOOST_CHECK((out.second.size() == 64)); + intx::uint256 fieldElementsPerBlob{intx::be::unsafe::load(out.second.data())}; + BOOST_CHECK(fieldElementsPerBlob == 4096); + intx::uint256 blsModulus{intx::be::unsafe::load(out.second.data() + 32)}; + BOOST_CHECK(blsModulus == kBlsModulus); + + // change hash version + in[0] = 0x2; + bytesConstRef input_ref1(in.data(), in.size()); + auto out1 = executor(input_ref1); + BOOST_CHECK(!out1.first); + in[0] = 0x1; + + // truncate input + in.pop_back(); + bytesConstRef input_ref2(in.data(), in.size()); + auto out2 = executor(input_ref2); + BOOST_CHECK(!out2.first); + in.push_back(0xba); + + // extra input + in.push_back(0); + bytesConstRef input_ref3(in.data(), in.size()); + auto out3 = executor(input_ref3); + BOOST_CHECK(!out3.first); + in.pop_back(); + + // Try z > BLS_MODULUS + intx::uint256 z{intx::le::unsafe::load(&in[32])}; + z += kBlsModulus; + intx::le::unsafe::store(&in[32], z); + bytesConstRef input_ref4(in.data(), in.size()); + auto out4 = executor(input_ref4); + BOOST_CHECK(!out4.first); +} + +BOOST_AUTO_TEST_SUITE_END() + +} // namespace bcos::test \ No newline at end of file diff --git a/bcos-executor/test/unittest/libprecompiled/RingSigPrecompiledTest.cpp b/bcos-executor/test/unittest/libprecompiled/RingSigPrecompiledTest.cpp index 5f0703425b..0e7bfda9cd 100644 --- a/bcos-executor/test/unittest/libprecompiled/RingSigPrecompiledTest.cpp +++ b/bcos-executor/test/unittest/libprecompiled/RingSigPrecompiledTest.cpp @@ -49,8 +49,8 @@ struct RingSigPrecompiledFixture m_hashImpl = std::make_shared(); m_ringSigPrecompiled = std::make_shared(m_hashImpl); m_ledgerCache = std::make_shared(std::make_shared()); - m_blockContext = std::make_shared(nullptr, m_ledgerCache, m_hashImpl, 0, - h256(), utcTime(), 0, FiscoBcosSchedule, false, false); + m_blockContext = std::make_shared( + nullptr, m_ledgerCache, m_hashImpl, 0, h256(), utcTime(), 0, false, false); m_executive = std::make_shared(*m_blockContext, "", 100, 0, m_gasInjector); } diff --git a/bcos-executor/test/unittest/libprecompiled/SystemConfigPrecompileTest.cpp b/bcos-executor/test/unittest/libprecompiled/SystemConfigPrecompileTest.cpp index 61fa1a30fd..ae7c671dd7 100644 --- a/bcos-executor/test/unittest/libprecompiled/SystemConfigPrecompileTest.cpp +++ b/bcos-executor/test/unittest/libprecompiled/SystemConfigPrecompileTest.cpp @@ -47,10 +47,9 @@ struct SystemConfigPrecompiledFixture : public bcos::test::PrecompiledFixture std::shared_ptr backendStorage = std::make_shared(nullptr, false); std::shared_ptr stateStorage = std::make_shared(backendStorage, false); - std::shared_ptr blockContext = - std::make_shared(stateStorage, ledgerCache, hashImpl, 0, h256(), utcTime(), - static_cast(protocol::BlockVersion::V3_1_VERSION), FiscoBcosSchedule, false, - false, backendStorage); + std::shared_ptr blockContext = std::make_shared(stateStorage, + ledgerCache, hashImpl, 0, h256(), utcTime(), + static_cast(protocol::BlockVersion::V3_1_VERSION), false, false, backendStorage); std::shared_ptr executive = std::make_shared(*blockContext, "", 100, 0, *gasInjector); }; @@ -114,8 +113,8 @@ BOOST_AUTO_TEST_CASE(getAndSetFeature) std::make_shared(std::make_shared()); std::shared_ptr newBlockContext = std::make_shared( executive->blockContext().storage(), ledgerCache, executive->blockContext().hashHandler(), - 1, h256(), utcTime(), static_cast(protocol::BlockVersion::V3_1_VERSION), - FiscoBcosSchedule, false, false, backendStorage); + 1, h256(), utcTime(), static_cast(protocol::BlockVersion::V3_1_VERSION), false, + false, backendStorage); std::shared_ptr newExecutive = std::make_shared(*newBlockContext, "", 100, 0, *gasInjector); setInput = codec.encodeWithSig("setValueByKey(string,string)", diff --git a/bcos-executor/test/unittest/libprecompiled/VRFPrecompiledTest.cpp b/bcos-executor/test/unittest/libprecompiled/VRFPrecompiledTest.cpp index a190f10193..b60eea9f15 100644 --- a/bcos-executor/test/unittest/libprecompiled/VRFPrecompiledTest.cpp +++ b/bcos-executor/test/unittest/libprecompiled/VRFPrecompiledTest.cpp @@ -67,9 +67,8 @@ class VRFPrecompiledFixture } m_cryptoPrecompiled = std::make_shared(m_cryptoSuite->hashImpl()); m_ledgerCache = std::make_shared(std::make_shared()); - m_blockContext = - std::make_shared(nullptr, m_ledgerCache, m_cryptoSuite->hashImpl(), 0, - h256(), utcTime(), _blockVersion, FiscoBcosSchedule, false, false); + m_blockContext = std::make_shared(nullptr, m_ledgerCache, + m_cryptoSuite->hashImpl(), 0, h256(), utcTime(), _blockVersion, false, false); m_executive = std::make_shared(*m_blockContext, "", 100, 0, m_gasInjector); m_abi = std::make_shared(*m_cryptoSuite->hashImpl()); diff --git a/bcos-executor/test/unittest/mock/MockExecutiveFactory.h b/bcos-executor/test/unittest/mock/MockExecutiveFactory.h index 6969e21255..b7a4149a64 100644 --- a/bcos-executor/test/unittest/mock/MockExecutiveFactory.h +++ b/bcos-executor/test/unittest/mock/MockExecutiveFactory.h @@ -31,7 +31,7 @@ class MockExecutiveFactory : public bcos::executor::ExecutiveFactory { auto ledgerCache = std::make_shared(std::make_shared()); blockContext = std::make_shared( - nullptr, ledgerCache, nullptr, 0, h256(), 0, 0, FiscoBcosSchedule, false, false); + nullptr, ledgerCache, nullptr, 0, h256(), 0, 0, false, false); auto executive = std::make_shared(*blockContext, "0x00", 0, 0, instruction); return executive; diff --git a/bcos-framework/CMakeLists.txt b/bcos-framework/CMakeLists.txt index d5aa1c7e3f..a37d3e4ac3 100644 --- a/bcos-framework/CMakeLists.txt +++ b/bcos-framework/CMakeLists.txt @@ -27,13 +27,7 @@ add_library(bcos-framework INTERFACE) target_include_directories(bcos-framework INTERFACE $ $) - -if (PRECOMPILED_HEADER) - target_link_libraries(bcos-framework INTERFACE bcos-task Microsoft.GSL::GSL precompiled-headers) - target_precompile_headers(bcos-framework REUSE_FROM precompiled-headers) -else() - target_link_libraries(bcos-framework INTERFACE bcos-task Microsoft.GSL::GSL fmt::fmt) -endif() +target_link_libraries(bcos-framework INTERFACE bcos-task Microsoft.GSL::GSL fmt::fmt) if (TESTS) enable_testing() diff --git a/bcos-framework/bcos-framework/ledger/Features.h b/bcos-framework/bcos-framework/ledger/Features.h index 3b032cbfce..0a0ad1b59e 100644 --- a/bcos-framework/bcos-framework/ledger/Features.h +++ b/bcos-framework/bcos-framework/ledger/Features.h @@ -55,7 +55,8 @@ class Features feature_balance, feature_balance_precompiled, feature_balance_policy1, - feature_paillier_add_raw + feature_paillier_add_raw, + feature_evm_cancun, }; private: diff --git a/bcos-framework/bcos-framework/ledger/LedgerInterface.h b/bcos-framework/bcos-framework/ledger/LedgerInterface.h index da86497aab..c55797e099 100644 --- a/bcos-framework/bcos-framework/ledger/LedgerInterface.h +++ b/bcos-framework/bcos-framework/ledger/LedgerInterface.h @@ -28,7 +28,6 @@ #include "../storage/StorageInterface.h" #include "LedgerTypeDef.h" #include -#include #include #include #include diff --git a/bcos-framework/bcos-framework/protocol/Protocol.h b/bcos-framework/bcos-framework/protocol/Protocol.h index f8332650ff..528ddae4c6 100644 --- a/bcos-framework/bcos-framework/protocol/Protocol.h +++ b/bcos-framework/bcos-framework/protocol/Protocol.h @@ -114,6 +114,7 @@ enum ProtocolVersion : uint32_t enum class BlockVersion : uint32_t { + V3_10_0_VERSION = 0x030a0000, V3_9_0_VERSION = 0x03090000, V3_8_0_VERSION = 0x03080000, V3_7_3_VERSION = 0x03070300, @@ -136,7 +137,7 @@ enum class BlockVersion : uint32_t V3_0_VERSION = 0x03000000, RC4_VERSION = 4, MIN_VERSION = RC4_VERSION, - MAX_VERSION = V3_9_0_VERSION, + MAX_VERSION = V3_10_0_VERSION, }; enum class TransactionVersion : uint32_t @@ -151,7 +152,7 @@ const std::string RC4_VERSION_STR = "3.0.0-rc4"; const std::string RC_VERSION_PREFIX = "3.0.0-rc"; const std::string V3_9_VERSION_STR = "3.9.0"; -const BlockVersion DEFAULT_VERSION = bcos::protocol::BlockVersion::V3_9_0_VERSION; +const BlockVersion DEFAULT_VERSION = bcos::protocol::BlockVersion::V3_10_0_VERSION; const std::string DEFAULT_VERSION_STR = V3_9_VERSION_STR; const uint8_t MAX_MAJOR_VERSION = std::numeric_limits::max(); const uint8_t MIN_MAJOR_VERSION = 3; diff --git a/bcos-framework/bcos-framework/storage/LegacyStorageMethods.h b/bcos-framework/bcos-framework/storage/LegacyStorageMethods.h index 1e3d703f8e..4e1034b699 100644 --- a/bcos-framework/bcos-framework/storage/LegacyStorageMethods.h +++ b/bcos-framework/bcos-framework/storage/LegacyStorageMethods.h @@ -20,7 +20,7 @@ inline task::Task> tag_invoke(storage2::tag_t, std::exception_ptr> m_result; constexpr static bool await_ready() noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { m_storage.asyncGetRow(m_table, m_key, [this, handle](Error::UniquePtr error, std::optional entry) mutable { @@ -98,7 +98,7 @@ inline task::Task tag_invoke(storage2::tag_t /*unused* std::variant m_result; constexpr static bool await_ready() noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { m_storage.asyncSetRow( m_table, m_key, std::move(m_entry), [this, handle](Error::UniquePtr error) mutable { diff --git a/bcos-framework/bcos-framework/storage2/MemoryStorage.h b/bcos-framework/bcos-framework/storage2/MemoryStorage.h index 0515eae50a..6a819d7978 100644 --- a/bcos-framework/bcos-framework/storage2/MemoryStorage.h +++ b/bcos-framework/bcos-framework/storage2/MemoryStorage.h @@ -197,7 +197,8 @@ class MemoryStorage } friend task::AwaitableValue> tag_invoke( - storage2::tag_t /*unused*/, MemoryStorage& storage, auto&& key) + storage2::tag_t /*unused*/, MemoryStorage& storage, auto&& key, + auto&&... args) { task::AwaitableValue> result; auto& bucket = storage.getBucket(key); diff --git a/bcos-framework/bcos-framework/testutils/faker/FakeTransactionReceipt.h b/bcos-framework/bcos-framework/testutils/faker/FakeTransactionReceipt.h index 62e7529063..55c7b6f92e 100644 --- a/bcos-framework/bcos-framework/testutils/faker/FakeTransactionReceipt.h +++ b/bcos-framework/bcos-framework/testutils/faker/FakeTransactionReceipt.h @@ -65,7 +65,8 @@ inline void checkReceipts(Hash::Ptr hashImpl, bcos::protocol::TransactionReceipt // check LogEntries BOOST_CHECK(decodedReceipt->logEntries().size() == 2); BOOST_CHECK(decodedReceipt->logEntries().size() == receipt->logEntries().size()); - auto& logEntry = (decodedReceipt->logEntries())[1]; + auto logEntries = decodedReceipt->logEntries(); + const auto& logEntry = logEntries[1]; auto expectedTopic = hashImpl->hash(std::to_string(1)); BOOST_CHECK(logEntry.topics()[0] == expectedTopic); diff --git a/bcos-framework/bcos-framework/transaction-scheduler/TransactionScheduler.h b/bcos-framework/bcos-framework/transaction-scheduler/TransactionScheduler.h index 7264bcb5b8..c56eb9409c 100644 --- a/bcos-framework/bcos-framework/transaction-scheduler/TransactionScheduler.h +++ b/bcos-framework/bcos-framework/transaction-scheduler/TransactionScheduler.h @@ -1,9 +1,9 @@ #pragma once -#include "../protocol/Block.h" +#include "../protocol/BlockHeader.h" +#include "../protocol/TransactionReceipt.h" #include "bcos-task/Task.h" #include "bcos-task/Trait.h" -#include "bcos-utilities/Ranges.h" namespace bcos::transaction_scheduler { diff --git a/bcos-framework/test/unittests/interfaces/FeaturesTest.cpp b/bcos-framework/test/unittests/interfaces/FeaturesTest.cpp index 34a6fd2e61..1270936a93 100644 --- a/bcos-framework/test/unittests/interfaces/FeaturesTest.cpp +++ b/bcos-framework/test/unittests/interfaces/FeaturesTest.cpp @@ -155,7 +155,8 @@ BOOST_AUTO_TEST_CASE(feature) "feature_balance", "feature_balance_precompiled", "feature_balance_policy1", - "feature_paillier_add_raw" + "feature_paillier_add_raw", + "feature_evm_cancun" }; // clang-format on for (size_t i = 0; i < keys.size(); ++i) diff --git a/bcos-front/bcos-front/FrontImpl.h b/bcos-front/bcos-front/FrontImpl.h index df93ab2e00..19239433a3 100644 --- a/bcos-front/bcos-front/FrontImpl.h +++ b/bcos-front/bcos-front/FrontImpl.h @@ -40,7 +40,7 @@ class FrontImpl : public bcos::concepts::front::FrontBase {} constexpr bool await_ready() const noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { bcos::concepts::getRef(m_gateway).asyncGetPeers( [this, m_handle = handle](Error::Ptr error, const gateway::GatewayInfo::Ptr&, @@ -123,7 +123,7 @@ class FrontImpl : public bcos::concepts::front::FrontBase { constexpr bool await_ready() const { return false; } - void await_suspend(CO_STD::coroutine_handle::promise_type> handle) + void await_suspend(std::coroutine_handle::promise_type> handle) { FRONT_LOG(DEBUG) << "P2P client send message: " << m_moduleID << " | " << m_nodeID->hex() << " | " << m_requestBuffer.size(); diff --git a/bcos-ledger/src/libledger/LedgerMethods.cpp b/bcos-ledger/src/libledger/LedgerMethods.cpp index 5a932c9728..44a0b0dc32 100644 --- a/bcos-ledger/src/libledger/LedgerMethods.cpp +++ b/bcos-ledger/src/libledger/LedgerMethods.cpp @@ -22,7 +22,7 @@ bcos::task::Task bcos::ledger::prewriteBlockToStorage(LedgerInterface& led Error::Ptr m_error; constexpr static bool await_ready() noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { m_ledger.asyncPrewriteBlock( m_storage, std::move(m_transactions), std::move(m_block), @@ -74,7 +74,7 @@ bcos::task::Task bcos::ledger::tag_invoke( std::variant m_result; constexpr static bool await_ready() noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { m_ledger.asyncGetBlockDataByNumber(m_blockNumber, m_blockFlag, [this, handle](Error::Ptr error, bcos::protocol::Block::Ptr block) { @@ -113,7 +113,7 @@ bcos::task::Task bcos::ledger::tag_invoke( std::variant m_result; constexpr static bool await_ready() noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { m_ledger.asyncGetTotalTransactionCount( [this, handle](Error::Ptr error, int64_t total, int64_t failed, @@ -155,7 +155,7 @@ bcos::task::Task bcos::ledger::tag_invoke( std::variant m_result; constexpr static bool await_ready() noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { m_ledger.asyncGetBlockNumber( [this, handle](Error::Ptr error, bcos::protocol::BlockNumber blockNumber) { @@ -195,7 +195,7 @@ bcos::task::Task bcos::ledger::tag_invoke( std::variant m_result; constexpr static bool await_ready() noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { m_ledger.asyncGetBlockHashByNumber( m_blockNumber, [this, handle](Error::Ptr error, crypto::HashType hash) { @@ -236,7 +236,7 @@ bcos::task::Task bcos::ledger::tag_invoke( std::variant m_result; constexpr static bool await_ready() noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { m_ledger.asyncGetBlockNumberByHash( m_hash, [this, handle](bcos::Error::Ptr error, bcos::protocol::BlockNumber number) { @@ -275,7 +275,7 @@ bcos::task::Task> bcos::ledger::t std::variant> m_result; constexpr static bool await_ready() noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { m_ledger.asyncGetSystemConfigByKey( m_key, [this, handle](Error::Ptr error, std::string value, @@ -325,7 +325,7 @@ bcos::task::Task bcos::ledger::tag_invoke( std::variant m_result; constexpr static bool await_ready() noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { m_ledger.asyncGetNodeListByType( m_type, [this, handle](Error::Ptr error, @@ -485,7 +485,7 @@ bcos::task::Task bcos::ledger::tag std::variant m_result; constexpr static bool await_ready() noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { m_ledger.asyncGetTransactionReceiptByHash(m_hash, false, [this, handle](bcos::Error::Ptr error, @@ -526,7 +526,7 @@ bcos::task::Task bcos::ledger::tag_invoke( std::variant m_result; constexpr static bool await_ready() noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { m_ledger.asyncGetBatchTxsByHashList( std::move(m_hashes), false, [this, handle](auto&& error, auto&& txs, auto&&) { diff --git a/bcos-rpc/bcos-rpc/util.cpp b/bcos-rpc/bcos-rpc/util.cpp index 3d8ded0329..c2f6f24e3b 100644 --- a/bcos-rpc/bcos-rpc/util.cpp +++ b/bcos-rpc/bcos-rpc/util.cpp @@ -31,6 +31,10 @@ using namespace bcos::rpc; std::tuple bcos::rpc::getBlockNumberByTag( protocol::BlockNumber latest, std::string_view blockTag) { + if (blockTag.data() == nullptr || blockTag.empty()) + { + return std::make_tuple(latest, true); + } if (blockTag == EarliestBlock) { return std::make_tuple(0, false); diff --git a/bcos-rpc/bcos-rpc/web3jsonrpc/endpoints/EthEndpoint.cpp b/bcos-rpc/bcos-rpc/web3jsonrpc/endpoints/EthEndpoint.cpp index decf6d9a53..ea2d2e8098 100644 --- a/bcos-rpc/bcos-rpc/web3jsonrpc/endpoints/EthEndpoint.cpp +++ b/bcos-rpc/bcos-rpc/web3jsonrpc/endpoints/EthEndpoint.cpp @@ -36,6 +36,7 @@ #include #include #include +#include using namespace bcos; using namespace bcos::rpc; @@ -348,35 +349,35 @@ task::Task EthEndpoint::getCode(const Json::Value& request, Json::Value& r struct Awaitable { bcos::scheduler::SchedulerInterface::Ptr m_scheduler; - std::string m_address; + std::string& m_address; std::variant m_result{}; constexpr static bool await_ready() noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) noexcept + void await_suspend(std::coroutine_handle<> handle) noexcept { m_scheduler->getCode(m_address, [this, handle](auto&& error, auto&& code) { if (error) { - m_result.emplace(std::move(error)); + m_result.emplace(std::forward(error)); } else { - m_result.emplace(std::move(code)); + m_result.emplace(std::forward(code)); } handle.resume(); }); } - bcos::bytes await_resume() noexcept + bcos::bytes await_resume() { if (std::holds_alternative(m_result)) { BOOST_THROW_EXCEPTION(*std::get(m_result)); } - return std::move(std::get(m_result)); + return std::get(m_result); } }; auto const code = co_await Awaitable{ .m_scheduler = scheduler, - .m_address = std::move(addressStr), + .m_address = addressStr, }; Json::Value result = toHexStringWithPrefix(code); buildJsonContent(result, response); @@ -475,70 +476,68 @@ task::Task EthEndpoint::call(const Json::Value& request, Json::Value& resp BOOST_THROW_EXCEPTION( JsonRpcException(JsonRpcError::InternalError, "Scheduler not available!")); } - auto [valid, call] = decodeCallRequest(request[0u]); + auto [valid, call] = decodeCallRequest(request[0U]); if (!valid) { BOOST_THROW_EXCEPTION(JsonRpcException(InvalidParams, "Invalid call request!")); } - auto const blockTag = toView(request[1u]); + auto const blockTag = toView(request[1U]); auto [blockNumber, _] = co_await getBlockNumberByTag(blockTag); if (c_fileLogLevel == TRACE) { WEB3_LOG(TRACE) << LOG_DESC("eth_call") << LOG_KV("call", call) << LOG_KV("blockTag", blockTag) << LOG_KV("blockNumber", blockNumber); } - auto&& tx = call.takeToTransaction(m_nodeService->blockFactory()->transactionFactory()); - // TODO: ignore params blockNumber here, use it after historical data is available - - // MOVE it into a new file + auto tx = call.takeToTransaction(m_nodeService->blockFactory()->transactionFactory()); struct Awaitable { bcos::scheduler::SchedulerInterface& m_scheduler; - bcos::protocol::Transaction::Ptr m_tx; - std::variant m_result{}; + bcos::protocol::Transaction::Ptr& m_tx; + Error::Ptr m_error; + Json::Value& m_response; + constexpr static bool await_ready() noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) noexcept + void await_suspend(std::coroutine_handle<> handle) { m_scheduler.call(m_tx, [this, handle](Error::Ptr&& error, auto&& result) { if (error) { - m_result.emplace(std::move(error)); + m_error = std::move(error); } else { - m_result.emplace(std::move(result)); + auto output = toHexStringWithPrefix(result->output()); + if (result->status() == static_cast(protocol::TransactionStatus::None)) + { + m_response["jsonrpc"] = "2.0"; + m_response["result"] = output; + } + else + { + // https://docs.infura.io/api/networks/ethereum/json-rpc-methods/eth_call#returns + Json::Value jsonResult = Json::objectValue; + jsonResult["code"] = result->status(); + jsonResult["message"] = result->message(); + jsonResult["data"] = output; + m_response["jsonrpc"] = "2.0"; + m_response["error"] = std::move(jsonResult); + } } + handle.resume(); }); } - protocol::TransactionReceipt::Ptr await_resume() noexcept + void await_resume() { - if (std::holds_alternative(m_result)) + if (m_error) { - BOOST_THROW_EXCEPTION(*std::get(m_result)); + BOOST_THROW_EXCEPTION(*m_error); } - return std::move(std::get(m_result)); } }; - auto const result = co_await Awaitable{.m_scheduler = *scheduler, .m_tx = std::move(tx)}; - - auto output = toHexStringWithPrefix(result->output()); - if (result->status() == static_cast(protocol::TransactionStatus::None)) - { - response["jsonrpc"] = "2.0"; - response["result"] = std::move(output); - } - else - { - // https://docs.infura.io/api/networks/ethereum/json-rpc-methods/eth_call#returns - Json::Value jsonResult = Json::objectValue; - jsonResult["code"] = result->status(); - jsonResult["message"] = result->message(); - jsonResult["data"] = std::move(output); - response["jsonrpc"] = "2.0"; - response["error"] = std::move(jsonResult); - } - co_return; + Awaitable awaitable{ + .m_scheduler = *scheduler, .m_tx = tx, .m_error = {}, .m_response = response}; + co_await awaitable; } task::Task EthEndpoint::estimateGas(const Json::Value& request, Json::Value& response) { diff --git a/bcos-rpc/bcos-rpc/web3jsonrpc/model/BlockResponse.h b/bcos-rpc/bcos-rpc/web3jsonrpc/model/BlockResponse.h index f0b5a5476e..1957ceb200 100644 --- a/bcos-rpc/bcos-rpc/web3jsonrpc/model/BlockResponse.h +++ b/bcos-rpc/bcos-rpc/web3jsonrpc/model/BlockResponse.h @@ -48,7 +48,7 @@ namespace bcos::rpc result["totalDifficulty"] = "0x0"; result["extraData"] = toHexStringWithPrefix(block->blockHeader()->extraData()); result["size"] = "0xffff"; - result["gasLimit"] = toQuantity(3000000000ull); + result["gasLimit"] = toQuantity(30000000ull); result["gasUsed"] = toQuantity((uint64_t)block->blockHeader()->gasUsed()); result["timestamp"] = toQuantity(block->blockHeader()->timestamp()); if (fullTxs) diff --git a/bcos-sdk/bcos-cpp-sdk/tarsRPC/CoRPCClient.cpp b/bcos-sdk/bcos-cpp-sdk/tarsRPC/CoRPCClient.cpp index c7bf216b36..e787c839aa 100644 --- a/bcos-sdk/bcos-cpp-sdk/tarsRPC/CoRPCClient.cpp +++ b/bcos-sdk/bcos-cpp-sdk/tarsRPC/CoRPCClient.cpp @@ -4,10 +4,10 @@ class CoCallback : public bcos::sdk::Callback { private: - CO_STD::coroutine_handle<> m_handle; + std::coroutine_handle<> m_handle; public: - CoCallback(CO_STD::coroutine_handle<> handle) : m_handle(handle) {} + CoCallback(std::coroutine_handle<> handle) : m_handle(handle) {} void onMessage([[maybe_unused]] int seq) override { // Make sure we are in the io thread of tars! @@ -18,7 +18,7 @@ class CoCallback : public bcos::sdk::Callback bcos::sdk::async::Awaitable bcos::sdk::async::sendTransaction( RPCClient& rpcClient, const bcos::protocol::Transaction& transaction) { - return {[&](CO_STD::coroutine_handle<> handle) { + return {[&](std::coroutine_handle<> handle) { bcos::sdk::SendTransaction sendTransaction(rpcClient); sendTransaction.setCallback(std::make_shared(handle)); sendTransaction.send(transaction); @@ -29,7 +29,7 @@ bcos::sdk::async::Awaitable bcos::sdk::async::sendTr bcos::sdk::async::Awaitable bcos::sdk::async::call( RPCClient& rpcClient, const bcos::protocol::Transaction& transaction) { - return {[&](CO_STD::coroutine_handle<> handle) { + return {[&](std::coroutine_handle<> handle) { bcos::sdk::Call call(rpcClient); call.setCallback(std::make_shared(handle)); call.send(transaction); @@ -40,7 +40,7 @@ bcos::sdk::async::Awaitable bcos::sdk::async::call( bcos::sdk::async::Awaitable bcos::sdk::async::blockNumber( RPCClient& rpcClient) { - return {[&](CO_STD::coroutine_handle<> handle) { + return {[&](std::coroutine_handle<> handle) { bcos::sdk::BlockNumber blockNumber(rpcClient); blockNumber.setCallback(std::make_shared(handle)); blockNumber.send(); diff --git a/bcos-sdk/bcos-cpp-sdk/tarsRPC/CoRPCClient.h b/bcos-sdk/bcos-cpp-sdk/tarsRPC/CoRPCClient.h index d56acf37bb..71e8437cf6 100644 --- a/bcos-sdk/bcos-cpp-sdk/tarsRPC/CoRPCClient.h +++ b/bcos-sdk/bcos-cpp-sdk/tarsRPC/CoRPCClient.h @@ -1,9 +1,6 @@ #pragma once #include "RPCClient.h" -#include -#include -#include -#include +#include namespace bcos::sdk::async { @@ -12,14 +9,14 @@ template class Awaitable { private: - std::function)> m_applyCall; + std::function)> m_applyCall; std::optional m_handle; public: Awaitable(decltype(m_applyCall) applyCall) : m_applyCall(std::move(applyCall)) {} constexpr bool await_ready() const { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) { m_handle.emplace(m_applyCall(handle)); } + void await_suspend(std::coroutine_handle<> handle) { m_handle.emplace(m_applyCall(handle)); } Handle await_resume() { return std::move(*m_handle); } }; diff --git a/bcos-security/bcos-security/DataEncryption.cpp b/bcos-security/bcos-security/DataEncryption.cpp index 93a99ba60b..bedd846812 100644 --- a/bcos-security/bcos-security/DataEncryption.cpp +++ b/bcos-security/bcos-security/DataEncryption.cpp @@ -97,15 +97,12 @@ std::shared_ptr DataEncryption::decryptContents(const std::shared_ptr= static_cast(bcos::protocol::BlockVersion::V3_3_VERSION)) { - random_bytes_engine rbe; - std::vector ivData(16); - std::generate(std::begin(ivData), std::end(ivData), std::ref(rbe)); - + size_t const offsetIv = encFileBytes.size() - 16; + size_t const cipherDataSize = encFileBytes.size() - 16; decFileBytesBase64Ptr = m_symmetricEncrypt->symmetricDecrypt( - (const unsigned char*)encFileBytes.data(), encFileBytes.size(), - (const unsigned char*)m_dataKey.data(), m_dataKey.size(), ivData.data(), 16); - decFileBytesBase64Ptr->insert( - decFileBytesBase64Ptr->end(), ivData.begin(), ivData.end()); + reinterpret_cast(encFileBytes.data()), cipherDataSize, + reinterpret_cast(m_dataKey.data()), m_dataKey.size(), + reinterpret_cast(encFileBytes.data() + offsetIv), 16); } else { @@ -143,15 +140,12 @@ std::shared_ptr DataEncryption::decryptFile(const std::string& filename) if (m_compatibilityVersion >= static_cast(bcos::protocol::BlockVersion::V3_3_VERSION)) { - random_bytes_engine rbe; - std::vector ivData(16); - std::generate(std::begin(ivData), std::end(ivData), std::ref(rbe)); - + size_t const offsetIv = encFileBytes.size() - 16; + size_t const cipherDataSize = encFileBytes.size() - 16; decFileBytesBase64Ptr = m_symmetricEncrypt->symmetricDecrypt( - (const unsigned char*)encFileBytes.data(), encFileBytes.size(), - (const unsigned char*)m_dataKey.data(), m_dataKey.size(), ivData.data(), 16); - decFileBytesBase64Ptr->insert( - decFileBytesBase64Ptr->end(), ivData.begin(), ivData.end()); + reinterpret_cast(encFileBytes.data()), cipherDataSize, + reinterpret_cast(m_dataKey.data()), m_dataKey.size(), + reinterpret_cast(encFileBytes.data() + offsetIv), 16); } else { diff --git a/bcos-storage/CMakeLists.txt b/bcos-storage/CMakeLists.txt index a3cddd360c..fe5a83f5f1 100644 --- a/bcos-storage/CMakeLists.txt +++ b/bcos-storage/CMakeLists.txt @@ -12,13 +12,13 @@ list(APPEND SRC_LIST bcos-storage/RocksDBStorage.cpp) set(LIB_LIST ${TABLE_TARGET} bcos-framework Boost::serialization Boost::filesystem zstd::libzstd_static RocksDB::rocksdb ittapi) -if(WITH_TIKV) +if (WITH_TIKV) include(ProjectTiKVClient) list(APPEND SRC_LIST bcos-storage/TiKVStorage.cpp) list(APPEND LIB_LIST kv_client) # find_package(gRPC CONFIG REQUIRED) # list(APPEND LIB_LIST kv_client gRPC::gpr gRPC::upb gRPC::grpc gRPC::grpc++) -endif() +endif () add_library(${STORAGE_TARGET} ${SRC_LIST}) target_include_directories(${STORAGE_TARGET} PUBLIC diff --git a/bcos-storage/bcos-storage/RocksDBStorage2.h b/bcos-storage/bcos-storage/RocksDBStorage2.h index 806d5d3406..bbea384783 100644 --- a/bcos-storage/bcos-storage/RocksDBStorage2.h +++ b/bcos-storage/bcos-storage/RocksDBStorage2.h @@ -28,8 +28,12 @@ namespace bcos::storage2::rocksdb template concept Resolver = requires(ResolverType&& resolver) { - { resolver.encode(std::declval()) }; - { resolver.decode(std::string_view{}) } -> std::convertible_to; + { + resolver.encode(std::declval()) + }; + { + resolver.decode(std::string_view{}) + } -> std::convertible_to; }; // clang-format off @@ -125,7 +129,7 @@ class RocksDBStorage2 friend auto tag_invoke(storage2::tag_t /*unused*/, RocksDBStorage2& storage, RANGES::input_range auto&& keys) -> task::AwaitableValue(keys)))> + std::forward(keys)))> { return {executeReadSome(storage, std::forward(keys))}; } diff --git a/bcos-sync/bcos-sync/state/SyncPeerStatus.h b/bcos-sync/bcos-sync/state/SyncPeerStatus.h index 7b6c0035ec..cf2c62f1f5 100644 --- a/bcos-sync/bcos-sync/state/SyncPeerStatus.h +++ b/bcos-sync/bcos-sync/state/SyncPeerStatus.h @@ -77,8 +77,8 @@ class PeerStatus private: bcos::crypto::PublicPtr m_nodeId; - bcos::protocol::BlockNumber m_number; - bcos::protocol::BlockNumber m_archivedNumber; + bcos::protocol::BlockNumber m_number{}; + bcos::protocol::BlockNumber m_archivedNumber{}; bcos::crypto::HashType m_hash; bcos::crypto::HashType m_genesisHash; diff --git a/bcos-table/src/LegacyStorageWrapper.h b/bcos-table/src/LegacyStorageWrapper.h index a4ae7161ec..2784ae9045 100644 --- a/bcos-table/src/LegacyStorageWrapper.h +++ b/bcos-table/src/LegacyStorageWrapper.h @@ -9,6 +9,7 @@ #include "bcos-utilities/Error.h" #include #include +#include #include #include @@ -19,10 +20,10 @@ template class LegacyStorageWrapper : public virtual bcos::storage::StorageInterface { private: - Storage* m_storage; + std::reference_wrapper m_storage; public: - explicit LegacyStorageWrapper(Storage& m_storage) : m_storage(std::addressof(m_storage)) {} + explicit LegacyStorageWrapper(Storage& m_storage) : m_storage(m_storage) {} void asyncGetPrimaryKeys(std::string_view table, const std::optional& condition, @@ -35,7 +36,7 @@ class LegacyStorageWrapper : public virtual bcos::storage::StorageInterface size_t index = 0; auto [start, count] = condition->getLimit(); - auto range = co_await storage2::range(*self->m_storage); + auto range = co_await storage2::range(self->m_storage.get()); while (auto keyValue = co_await range.next()) { auto&& [key, value] = *keyValue; @@ -80,7 +81,7 @@ class LegacyStorageWrapper : public virtual bcos::storage::StorageInterface try { auto value = co_await storage2::readOne( - *self->m_storage, transaction_executor::StateKeyView{table, key}); + self->m_storage.get(), transaction_executor::StateKeyView{table, key}); callback(nullptr, std::move(value)); } catch (std::exception& e) @@ -105,7 +106,7 @@ class LegacyStorageWrapper : public virtual bcos::storage::StorageInterface return transaction_executor::StateKeyView{ table, std::forward(key)}; }) | RANGES::to(); - auto values = co_await storage2::readSome(*self->m_storage, stateKeys); + auto values = co_await storage2::readSome(self->m_storage.get(), stateKeys); std::vector> vectorValues( std::make_move_iterator(values.begin()), std::make_move_iterator(values.end())); @@ -128,11 +129,11 @@ class LegacyStorageWrapper : public virtual bcos::storage::StorageInterface if (entry.status() == storage::Entry::Status::DELETED) { co_await storage2::removeOne( - *self->m_storage, transaction_executor::StateKeyView(table, key)); + self->m_storage.get(), transaction_executor::StateKeyView(table, key)); } else { - co_await storage2::writeOne(*self->m_storage, + co_await storage2::writeOne(self->m_storage, transaction_executor::StateKey(table, key), std::move(entry)); } callback(nullptr); @@ -157,7 +158,7 @@ class LegacyStorageWrapper : public virtual bcos::storage::StorageInterface decltype(values)& values) -> task::Task { try { - co_await storage2::writeSome(*self->m_storage, + co_await storage2::writeSome(self->m_storage.get(), keys | RANGES::views::transform([&](std::string_view key) { return transaction_executor::StateKey{tableName, key}; }), @@ -195,7 +196,10 @@ class LegacyStateStorageWrapper : public virtual storage::StateStorageInterface, void rollback(const storage::Recoder& recoder) override { - BOOST_THROW_EXCEPTION(std::runtime_error("Unimplemented!")); + // 不要抛出异常,会导致TransactionExecutive::revert()后续的transientStateStorage->rollback无法执行 + // Do not throw an exception that will cause Tra::Revert () to follow the Trancintztat + // Stolag-> Rohrbak not to be executed + // BOOST_THROW_EXCEPTION(std::runtime_error("Unimplemented!")); } crypto::HashType hash( diff --git a/bcos-tars-protocol/bcos-tars-protocol/client/TxPoolServiceClient.h b/bcos-tars-protocol/bcos-tars-protocol/client/TxPoolServiceClient.h index f0b56df6c2..0045ede0d1 100644 --- a/bcos-tars-protocol/bcos-tars-protocol/client/TxPoolServiceClient.h +++ b/bcos-tars-protocol/bcos-tars-protocol/client/TxPoolServiceClient.h @@ -57,7 +57,7 @@ class TxPoolServiceClient : public bcos::txpool::TxPoolInterface m_handle.resume(); } - CO_STD::coroutine_handle<> m_handle; + std::coroutine_handle<> m_handle; std::variant m_submitResult; @@ -67,7 +67,7 @@ class TxPoolServiceClient : public bcos::txpool::TxPoolInterface struct Awaitable { constexpr bool await_ready() { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { m_callback->m_handle = handle; m_proxy->tars_set_timeout(600000)->async_submit(m_callback, diff --git a/bcos-tars-protocol/bcos-tars-protocol/tars/Transaction.tars b/bcos-tars-protocol/bcos-tars-protocol/tars/Transaction.tars index bb5b2c5ae1..fbf1844360 100644 --- a/bcos-tars-protocol/bcos-tars-protocol/tars/Transaction.tars +++ b/bcos-tars-protocol/bcos-tars-protocol/tars/Transaction.tars @@ -16,17 +16,18 @@ module bcostars { 14 optional vector extension; }; - struct Transaction { - 1 optional TransactionData data; - 2 optional vector dataHash; // type == 0, hash(data); type == 1, hash(extraTransactionBytes) - 3 optional vector signature; - 4 optional long importTime; - 5 optional int attribute; - // 6 optional string source; - 7 optional vector sender; - 8 optional string extraData; - 9 optional byte type; - 10 optional vector extraTransactionBytes; - 11 optional vector extraTransactionHash; // hash(rlp(10|3)) + struct Transaction + { + 1 optional TransactionData data; + 2 optional vector dataHash; // type == 0, hash(data); type == 1, hash(extraTransactionBytes) + 3 optional vector signature; + 4 optional long importTime; + 5 optional int attribute; + // 6 optional string source; + 7 optional vector sender; + 8 optional string extraData; + 9 optional byte type; + 10 optional vector extraTransactionBytes; + 11 optional vector extraTransactionHash; // hash(rlp(10|3)) }; }; diff --git a/bcos-txpool/bcos-txpool/txpool/storage/MemoryStorage.cpp b/bcos-txpool/bcos-txpool/txpool/storage/MemoryStorage.cpp index 6c2ec4de75..245d5c88e5 100644 --- a/bcos-txpool/bcos-txpool/txpool/storage/MemoryStorage.cpp +++ b/bcos-txpool/bcos-txpool/txpool/storage/MemoryStorage.cpp @@ -99,7 +99,7 @@ task::Task MemoryStorage::submitTransact struct Awaitable { [[maybe_unused]] constexpr bool await_ready() { return false; } - [[maybe_unused]] void await_suspend(CO_STD::coroutine_handle<> handle) + [[maybe_unused]] void await_suspend(std::coroutine_handle<> handle) { try { @@ -180,7 +180,7 @@ task::Task MemoryStorage::submitTransact struct Awaitable { [[maybe_unused]] constexpr bool await_ready() { return false; } - [[maybe_unused]] void await_suspend(CO_STD::coroutine_handle<> handle) + [[maybe_unused]] void await_suspend(std::coroutine_handle<> handle) { try { @@ -468,7 +468,7 @@ TransactionStatus MemoryStorage::insertWithoutLock(Transaction::Ptr transaction) { if (transaction->submitCallback() && !accessor->value()->submitCallback()) { - accessor->value()->setSubmitCallback(std::move(transaction->submitCallback())); + accessor->value()->setSubmitCallback(transaction->submitCallback()); return TransactionStatus::None; } return TransactionStatus::AlreadyInTxPool; diff --git a/cmake/CompilerSettings.cmake b/cmake/CompilerSettings.cmake index d55cff939d..9a9c44d24d 100644 --- a/cmake/CompilerSettings.cmake +++ b/cmake/CompilerSettings.cmake @@ -107,7 +107,6 @@ if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR("${CMAKE_CXX_COMPILER_ID}" MATC add_compile_options(-fstack-protector-strong) add_compile_options(-fstack-protector) - add_compile_options(-fno-omit-frame-pointer) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0) add_compile_options(-fcoroutines) @@ -127,6 +126,11 @@ if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR("${CMAKE_CXX_COMPILER_ID}" MATC add_compile_options(-Wno-array-bounds) add_compile_options(-Wno-aggressive-loop-optimizations) endif() + + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0) + set(CMAKE_CXX_STANDARD 23) + add_compile_options(-Wno-error=uninitialized) + endif() # add_compile_options(-fconcepts-diagnostics-depth=10) elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) @@ -172,7 +176,6 @@ if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR("${CMAKE_CXX_COMPILER_ID}" MATC endif() elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") add_compile_definitions(NOMINMAX) - #add_definitions(-DUSE_STD_RANGES) add_compile_options(/std:c++latest) add_compile_options(-bigobj) diff --git a/cmake/Options.cmake b/cmake/Options.cmake index 0d589906aa..54e1332356 100644 --- a/cmake/Options.cmake +++ b/cmake/Options.cmake @@ -56,7 +56,6 @@ macro(configure_project) default_option(SANITIZE_ADDRESS OFF) default_option(SANITIZE_THREAD OFF) default_option(IPO OFF) - default_option(PRECOMPILED_HEADER OFF) if(IPO) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) endif() @@ -156,7 +155,6 @@ macro(print_config NAME) message("-- TESTS Build tests ${TESTS}") message("-- NATIVE Build native binary ${NATIVE}") message("-- IPO Enable IPO optimization ${IPO}") - message("-- PRECOMPILED_HEADER Enable precompiled header ${PRECOMPILED_HEADER}") message("-- SANITIZE_ADDRESS Enable sanitize ${SANITIZE_ADDRESS}") message("-- SANITIZE_THREAD Enable sanitize ${SANITIZE_THREAD}") message("-- TOOLCHAIN_FILE CMake toolchain file ${CMAKE_TOOLCHAIN_FILE}") diff --git a/cmake/PrecompiledHeaders.cmake b/cmake/PrecompiledHeaders.cmake deleted file mode 100644 index fb74029a87..0000000000 --- a/cmake/PrecompiledHeaders.cmake +++ /dev/null @@ -1,104 +0,0 @@ -if (PRECOMPILED_HEADER) - add_library(precompiled-headers INTERFACE) - target_precompile_headers(precompiled-headers - INTERFACE - # STL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Boost - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # gsl - - - # fmt - - - # tbb - - - - - - - - - - - - - - # range - - ) - - include(GNUInstallDirs) - install(TARGETS precompiled-headers EXPORT fiscobcosTargets ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}") - install(DIRECTORY "precompiled-headers" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" FILES_MATCHING PATTERN "*.h") -endif() \ No newline at end of file diff --git a/cmake/ProjectBCOSWASM.cmake b/cmake/ProjectBCOSWASM.cmake index c576206f16..40d3db5547 100644 --- a/cmake/ProjectBCOSWASM.cmake +++ b/cmake/ProjectBCOSWASM.cmake @@ -72,7 +72,7 @@ ExternalProject_Add(bcos_wasm_project LOG_BUILD 0 LOG_INSTALL 1 BUILD_BYPRODUCTS /target/${BCOS_WASM_BUILD_MODE}/libbcos_wasm.a /FBWASM.h -) + ) ExternalProject_Get_Property(bcos_wasm_project SOURCE_DIR) set(HERA_INCLUDE_DIRS ${SOURCE_DIR}/include) diff --git a/cmake/ProjectBLST.cmake b/cmake/ProjectBLST.cmake new file mode 100644 index 0000000000..4bd2bd0bdc --- /dev/null +++ b/cmake/ProjectBLST.cmake @@ -0,0 +1,43 @@ +include(ExternalProject) +include(GNUInstallDirs) + +find_program(BASH_COMMAND NAMES bash REQUIRED PATHS "/bin") +set(BLST_BUILD_COMMAND "${BASH_COMMAND}" build.sh) + +if (NOT BASH_COMMAND) + message(FATAL_ERROR "bash not found") +endif () + +ExternalProject_Add(blst_project + PREFIX ${CMAKE_SOURCE_DIR}/deps + GIT_REPOSITORY https://${URL_BASE}/supranational/blst.git + GIT_TAG 3dd0f804b1819e5d03fb22ca2e6fac105932043a + GIT_SHALLOW 0 + + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND "" + BUILD_COMMAND ${BLST_BUILD_COMMAND} + INSTALL_COMMAND sh -c "cp /bindings/blst.h /include/ && cp /bindings/blst_aux.h /include/ && cp /libblst.a /lib/" + LOG_BUILD true + LOG_INSTALL true + LOG_CONFIGURE true + BUILD_BYPRODUCTS libblst.a + ) + +ExternalProject_Get_Property(blst_project INSTALL_DIR) +add_library(blst STATIC IMPORTED) + +set(BLST_LIBRARY ${INSTALL_DIR}/lib/libblst.a) +set(BLST_INCLUDE_DIR ${INSTALL_DIR}/include) +file(MAKE_DIRECTORY ${INSTALL_DIR}/lib/) +file(MAKE_DIRECTORY ${BLST_INCLUDE_DIR}) + +set_property(TARGET blst PROPERTY IMPORTED_LOCATION ${BLST_LIBRARY}) +set_property(TARGET blst PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${BLST_INCLUDE_DIR}) +add_dependencies(blst blst_project) +unset(INSTALL_DIR) + + + + diff --git a/cmake/ProjectTiKVClient.cmake b/cmake/ProjectTiKVClient.cmake index ccd3057c52..f85af6eed3 100644 --- a/cmake/ProjectTiKVClient.cmake +++ b/cmake/ProjectTiKVClient.cmake @@ -9,7 +9,7 @@ endif() if (NOT CMAKE_AR) set(CMAKE_AR ar) -endif() +endif () if (APPLE) set(CUSTOM_INSTALL_COMMAND ${CMAKE_AR} -dv /${TIKV_BUILD_MODE}/libtikvrust.a slice_buffer.cc.o) @@ -25,19 +25,19 @@ set(ENV{OPENSSL_DIR} ${OPENSSL_INCLUDE_DIR}/../) set(ENV{PROTOC} ${OPENSSL_INCLUDE_DIR}/../tools/protobuf/protoc) ExternalProject_Add(tikv_client_cpp - PREFIX ${CMAKE_SOURCE_DIR}/deps - GIT_REPOSITORY https://${URL_BASE}/FISCO-BCOS/tikv-client-cpp.git - GIT_TAG 7a2a2ffd293c2890fb2fe3bc38c204e80833e985 - - BUILD_IN_SOURCE true -# PATCH_COMMAND ${CARGO_COMMAND} install cxxbridge-cmd@1.0.75 -# BUILD_COMMAND ${CARGO_COMMAND} build && ${CARGO_COMMAND} build --release && make target/${TIKV_BUILD_MODE}/libtikv_client.a -# BUILD_COMMAND cmake -S . -B . && cmake --build . - CMAKE_ARGS -DPROTOC=${OPENSSL_INCLUDE_DIR}/../tools/protobuf/protoc -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DOPENSSL_DIR=${OPENSSL_INCLUDE_DIR}/../ - # INSTALL_COMMAND "${CUSTOM_INSTALL_COMMAND}" - INSTALL_COMMAND "" - BUILD_BYPRODUCTS /libtikvcpp.a /${TIKV_BUILD_MODE}/libtikvrust.a - LOG_BUILD true + PREFIX ${CMAKE_SOURCE_DIR}/deps + GIT_REPOSITORY https://${URL_BASE}/FISCO-BCOS/tikv-client-cpp.git + GIT_TAG 7a2a2ffd293c2890fb2fe3bc38c204e80833e985 + + BUILD_IN_SOURCE true + # PATCH_COMMAND ${CARGO_COMMAND} install cxxbridge-cmd@1.0.75 + # BUILD_COMMAND ${CARGO_COMMAND} build && ${CARGO_COMMAND} build --release && make target/${TIKV_BUILD_MODE}/libtikv_client.a + # BUILD_COMMAND cmake -S . -B . && cmake --build . + CMAKE_ARGS -DPROTOC=${OPENSSL_INCLUDE_DIR}/../tools/protobuf/protoc -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DOPENSSL_DIR=${OPENSSL_INCLUDE_DIR}/../ + # INSTALL_COMMAND "${CUSTOM_INSTALL_COMMAND}" + INSTALL_COMMAND "" + BUILD_BYPRODUCTS /libtikvcpp.a /${TIKV_BUILD_MODE}/libtikvrust.a + LOG_BUILD true LOG_INSTALL true ) diff --git a/docs/README_EN.md b/docs/README_EN.md index 530e268c00..827c3a93f6 100644 --- a/docs/README_EN.md +++ b/docs/README_EN.md @@ -12,9 +12,11 @@ In a single-chain configuration, the performance TPS can reach 100k. It fully su ## Version Information: -- Stable Version (for production environment): v3.2.3, version details can be found in [FISCO-BCOS v3.2.3 Release Notes](https://github.com/FISCO-BCOS/FISCO-BCOS/releases/tag/v3.2.3). +- Stable Version (for production environment): v3.2.3, version details can be found + in [FISCO-BCOS v3.2.3 Release Notes](https://github.com/FISCO-BCOS/FISCO-BCOS/releases/tag/v3.2.3). -- Latest Version (for experiencing new features): v3.7.1, version details can be found in [FISCO-BCOS v3.7.1 Release Notes](https://github.com/FISCO-BCOS/FISCO-BCOS/releases/tag/v3.7.1). +- Latest Version (for experiencing new features): v3.7.1, version details can be found + in [FISCO-BCOS v3.7.1 Release Notes](https://github.com/FISCO-BCOS/FISCO-BCOS/releases/tag/v3.7.1). ## System Overview The architecture of FISCO BCOS system consists of the basic layer, core layer, service layer, user layer, and access layer on the left-hand side, providing stable and secure blockchain underlying services. The middleware layer simplifies the process of managing the blockchain system through a visual interface. On the right-hand side, there are supporting components for development, operation, and security control, meeting the needs of different roles during the application implementation process. Meanwhile, privacy protection and cross-chain-related technology components are also provided to satisfy the application requirements in different scenarios. diff --git a/libinitializer/StorageInitializer.h b/libinitializer/StorageInitializer.h index 8428dd5ff0..7c6f153f81 100644 --- a/libinitializer/StorageInitializer.h +++ b/libinitializer/StorageInitializer.h @@ -24,6 +24,7 @@ */ #pragma once #include "bcos-storage/RocksDBStorage.h" +#include #ifdef WITH_TIKV #include "bcos-storage/TiKVStorage.h" #endif diff --git a/libtask/bcos-task/AwaitableValue.h b/libtask/bcos-task/AwaitableValue.h index 0c6bef4b38..6456130b60 100644 --- a/libtask/bcos-task/AwaitableValue.h +++ b/libtask/bcos-task/AwaitableValue.h @@ -1,6 +1,6 @@ #pragma once -#include "Coroutine.h" +#include #include namespace bcos::task @@ -13,7 +13,7 @@ class [[nodiscard]] AwaitableValue AwaitableValue() = default; AwaitableValue(Value&& value) : m_value(std::forward(value)) {} constexpr static bool await_ready() noexcept { return true; } - constexpr static bool await_suspend([[maybe_unused]] CO_STD::coroutine_handle<> handle) noexcept + constexpr static bool await_suspend([[maybe_unused]] std::coroutine_handle<> handle) noexcept { return false; } @@ -30,7 +30,7 @@ struct [[nodiscard]] AwaitableValue { AwaitableValue() = default; static constexpr bool await_ready() noexcept { return true; } - static constexpr bool await_suspend([[maybe_unused]] CO_STD::coroutine_handle<> handle) noexcept + static constexpr bool await_suspend([[maybe_unused]] std::coroutine_handle<> handle) noexcept { return false; } diff --git a/libtask/bcos-task/Coroutine.h b/libtask/bcos-task/Coroutine.h deleted file mode 100644 index e4388affd4..0000000000 --- a/libtask/bcos-task/Coroutine.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#if !__cpp_impl_coroutine -#include -namespace CO_STD = std::experimental; -#else -#include -namespace CO_STD = std; -#endif \ No newline at end of file diff --git a/libtask/bcos-task/Generator.h b/libtask/bcos-task/Generator.h index 8ba59c8647..9cb550e30f 100644 --- a/libtask/bcos-task/Generator.h +++ b/libtask/bcos-task/Generator.h @@ -1,16 +1,26 @@ #pragma once -// Fork from https://open-std.org/JTC1/SC22/WG21/docs/papers/2020/p2168r0.pdf -// Can be replace with std::generator +#include -#include "Coroutine.h" +#if __cpp_lib_generator >= 202207L +#include +namespace bcos::task +{ +template +using Generator = std::generator; +} +#else +#include #include #include +#include #include - namespace bcos::task { -template > +// Fork from https://open-std.org/JTC1/SC22/WG21/docs/papers/2020/p2168r0.pdf +// Can be replace with std::generator + +template , typename Alloc = void> class Generator { public: @@ -20,7 +30,7 @@ class Generator promise_type() : m_promise(this) {} Generator get_return_object() noexcept { - return Generator{CO_STD::coroutine_handle::from_promise(*this)}; + return Generator{std::coroutine_handle::from_promise(*this)}; } void unhandled_exception() @@ -34,21 +44,20 @@ class Generator void return_void() noexcept {} - CO_STD::suspend_always initial_suspend() noexcept { return {}; } + std::suspend_always initial_suspend() noexcept { return {}; } // Transfers control back to the parent of a nested coroutine struct final_awaiter { bool await_ready() noexcept { return false; } - CO_STD::coroutine_handle<> await_suspend( - CO_STD::coroutine_handle h) noexcept + std::coroutine_handle<> await_suspend(std::coroutine_handle h) noexcept { auto& promise = h.promise(); auto parent = h.promise().m_parent; if (parent) { promise.m_promise = parent; - return CO_STD::coroutine_handle::from_promise(*parent); + return std::coroutine_handle::from_promise(*parent); } return std::noop_coroutine(); } @@ -57,12 +66,12 @@ class Generator final_awaiter final_suspend() noexcept { return {}; } - CO_STD::suspend_always yield_value(Ref&& x) noexcept + std::suspend_always yield_value(Ref&& x) noexcept { m_promise->m_value = std::addressof(x); return {}; } - CO_STD::suspend_always yield_value(Ref& x) noexcept + std::suspend_always yield_value(Ref& x) noexcept { m_promise->m_value = std::addressof(x); return {}; @@ -83,7 +92,7 @@ class Generator // set the parent, root and exceptions pointer and // resume the nested coroutine - CO_STD::coroutine_handle<> await_suspend( + std::coroutine_handle<> await_suspend( std::coroutine_handle handle) noexcept { auto& current = handle.promise(); @@ -156,7 +165,7 @@ class Generator class Iterator { - using coroutine_handle = CO_STD::coroutine_handle; + using coroutine_handle = std::coroutine_handle; public: using iterator_category = std::input_iterator_tag; @@ -165,7 +174,6 @@ class Generator using reference = Ref; using pointer = std::add_pointer_t; - Iterator() noexcept = default; Iterator& operator=(const Iterator&) = delete; Iterator(const Iterator&) = delete; Iterator(Iterator&& o) noexcept { std::swap(coro_, o.coro_); } @@ -225,4 +233,5 @@ class Generator std::coroutine_handle coro_; }; -} // namespace bcos::task \ No newline at end of file +} // namespace bcos::task +#endif \ No newline at end of file diff --git a/libtask/bcos-task/TBBScheduler.h b/libtask/bcos-task/TBBScheduler.h index 1d34a4c46e..546735675f 100644 --- a/libtask/bcos-task/TBBScheduler.h +++ b/libtask/bcos-task/TBBScheduler.h @@ -1,6 +1,6 @@ #pragma once -#include "Coroutine.h" #include +#include namespace bcos::task::tbb { @@ -14,9 +14,9 @@ class TBBScheduler TBBScheduler(oneapi::tbb::task_group& taskGroup) : m_taskGroup(taskGroup) {} constexpr static bool await_ready() noexcept { return false; } - void await_suspend([[maybe_unused]] CO_STD::coroutine_handle<> handle) noexcept + void await_suspend([[maybe_unused]] std::coroutine_handle<> handle) noexcept { - m_taskGroup.run([handle]() { const_cast&>(handle).resume(); }); + m_taskGroup.run([handle]() { const_cast&>(handle).resume(); }); } constexpr static void await_resume() noexcept {} }; diff --git a/libtask/bcos-task/TBBWait.h b/libtask/bcos-task/TBBWait.h index 5b5e4e31e9..3758bbf1f2 100644 --- a/libtask/bcos-task/TBBWait.h +++ b/libtask/bcos-task/TBBWait.h @@ -43,7 +43,7 @@ constexpr inline struct SyncWait { if constexpr (std::is_void_v) { - co_await task; + co_await std::forward(task); } else { @@ -54,7 +54,7 @@ constexpr inline struct SyncWait } else { - result.template emplace(co_await task); + result.template emplace(co_await std::forward(task)); } } } diff --git a/libtask/bcos-task/Task.h b/libtask/bcos-task/Task.h index 9963238782..ea23cec4f7 100644 --- a/libtask/bcos-task/Task.h +++ b/libtask/bcos-task/Task.h @@ -1,10 +1,9 @@ #pragma once -#include "Coroutine.h" #include "bcos-concepts/Exception.h" #include #include +#include #include -#include #include #include @@ -15,83 +14,94 @@ struct NoReturnValue : public bcos::error::Exception { }; -template - requires(!std::is_reference_v) -class [[nodiscard]] Task +template +struct FinalAwaitable { -public: - using VariantType = - std::conditional_t, std::variant, - std::variant>; - - struct Continuation - { - CO_STD::coroutine_handle<> handle; - VariantType value; - }; - - template - struct PromiseBase + static constexpr bool await_ready() noexcept { return false; } + static constexpr std::coroutine_handle<> await_suspend( + std::coroutine_handle handle) noexcept { - constexpr CO_STD::suspend_always initial_suspend() noexcept { return {}; } - constexpr auto final_suspend() noexcept + std::coroutine_handle<> continuationHandle; + if (handle.promise().m_continuation) { - struct FinalAwaitable - { - constexpr bool await_ready() noexcept { return false; } - constexpr CO_STD::coroutine_handle<> await_suspend( - CO_STD::coroutine_handle handle) noexcept - { - CO_STD::coroutine_handle<> continuationHandle; - if (handle.promise().m_continuation) - { - continuationHandle = handle.promise().m_continuation->handle; - } - handle.destroy(); - - return continuationHandle ? continuationHandle : CO_STD::noop_coroutine(); - } - constexpr void await_resume() noexcept {} - }; - return FinalAwaitable{}; + continuationHandle = handle.promise().m_continuation->handle; } - Task get_return_object() - { - auto handle = CO_STD::coroutine_handle::from_promise( - *static_cast(this)); - return Task(handle); - } - void unhandled_exception() + handle.destroy(); + + return continuationHandle ? continuationHandle : std::noop_coroutine(); + } + constexpr void await_resume() noexcept {} +}; + +template +struct Continuation +{ + std::coroutine_handle<> handle; + VariantType value; +}; + +template +struct PromiseBase +{ + static constexpr std::suspend_always initial_suspend() noexcept { return {}; } + static constexpr auto final_suspend() noexcept { return FinalAwaitable{}; } + Task get_return_object() + { + auto handle = + std::coroutine_handle::from_promise(*static_cast(this)); + return Task{handle}; + } + void unhandled_exception() + { + if (!m_continuation) { - if (!m_continuation) - { - std::rethrow_exception(std::current_exception()); - } - m_continuation->value.template emplace(std::current_exception()); + auto handle = + std::coroutine_handle::from_promise(*static_cast(this)); + handle.destroy(); + std::rethrow_exception(std::current_exception()); } + m_continuation->value.template emplace(std::current_exception()); + } - Continuation* m_continuation = nullptr; - }; - struct PromiseVoid : public PromiseBase - { - constexpr void return_void() noexcept {} - }; - struct PromiseValue : public PromiseBase + Continuation* m_continuation{}; +}; + +template +struct PromiseVoid : public PromiseBase> +{ + static constexpr void return_void() noexcept {} +}; + +template +struct PromiseValue : public PromiseBase> +{ + void return_value(auto&& value) { - void return_value(auto&& value) + if (PromiseBase>::m_continuation) { - if (PromiseBase::m_continuation) - { - PromiseBase::m_continuation->value.template emplace( - std::forward(value)); - } + PromiseBase>::m_continuation->value + .template emplace(std::forward(value)); } - }; - using promise_type = std::conditional_t, PromiseVoid, PromiseValue>; + } +}; + +template + requires(!std::is_reference_v) +class [[nodiscard]] Task +{ +public: + using Value = ValueType; + using VariantType = std::conditional_t, + std::variant, + std::variant>; + + using promise_type = + std::conditional_t, PromiseVoid, PromiseValue>; struct Awaitable { - explicit Awaitable(Task const& task) : m_handle(task.m_handle){}; + explicit Awaitable(std::coroutine_handle handle) + : m_handle(std::move(handle)){}; Awaitable(const Awaitable&) = delete; Awaitable(Awaitable&&) noexcept = default; Awaitable& operator=(const Awaitable&) = delete; @@ -100,20 +110,20 @@ class [[nodiscard]] Task bool await_ready() const noexcept { return !m_handle || m_handle.done(); } template - CO_STD::coroutine_handle<> await_suspend(CO_STD::coroutine_handle handle) + std::coroutine_handle<> await_suspend(std::coroutine_handle handle) { m_continuation.handle = handle; m_handle.promise().m_continuation = std::addressof(m_continuation); return m_handle; } - Value await_resume() + ValueType await_resume() { if (std::holds_alternative(m_continuation.value)) { std::rethrow_exception(std::get(m_continuation.value)); } - if constexpr (!std::is_void_v) + if constexpr (!std::is_void_v) { if (!std::holds_alternative(m_continuation.value)) { @@ -124,17 +134,21 @@ class [[nodiscard]] Task } } - CO_STD::coroutine_handle m_handle; - Continuation m_continuation; + std::coroutine_handle m_handle; + Continuation m_continuation; }; - Awaitable operator co_await() { return Awaitable(*static_cast(this)); } + Awaitable operator co_await() const&& { return Awaitable(m_handle); } - explicit Task(CO_STD::coroutine_handle handle) : m_handle(handle) {} + explicit Task(std::coroutine_handle handle) : m_handle(handle) {} Task(const Task&) = delete; Task(Task&& task) noexcept : m_handle(task.m_handle) { task.m_handle = nullptr; } Task& operator=(const Task&) = delete; Task& operator=(Task&& task) noexcept { + if (m_handle) + { + m_handle.destroy(); + } m_handle = task.m_handle; task.m_handle = nullptr; } @@ -142,7 +156,7 @@ class [[nodiscard]] Task void start() { m_handle.resume(); } private: - CO_STD::coroutine_handle m_handle; + std::coroutine_handle m_handle; }; } // namespace bcos::task \ No newline at end of file diff --git a/libtask/bcos-task/Trait.h b/libtask/bcos-task/Trait.h index 9e4d2d84e7..f96405907f 100644 --- a/libtask/bcos-task/Trait.h +++ b/libtask/bcos-task/Trait.h @@ -7,11 +7,11 @@ namespace bcos::task { template -concept HasADLCoAwait = requires(Task task) { operator co_await(task); }; +concept HasADLCoAwait = requires(Task&& task) { operator co_await(task); }; template -concept HasMemberCoAwait = requires(Task task) { task.operator co_await(); }; +concept HasMemberCoAwait = requires(Task&& task) { std::forward(task).operator co_await(); }; template -concept HasAwaitable = requires(Awaitable awaitable) { awaitable.await_resume(); }; +concept HasAwaitable = requires(Awaitable&& awaitable) { awaitable.await_resume(); }; auto getAwaitable(auto&& task) { @@ -22,7 +22,7 @@ auto getAwaitable(auto&& task) } else if constexpr (HasMemberCoAwait) { - return task.operator co_await(); + return std::forward(task).operator co_await(); } else if constexpr (HasAwaitable) { diff --git a/libtask/bcos-task/Wait.h b/libtask/bcos-task/Wait.h index efb7309d28..de29ee5047 100644 --- a/libtask/bcos-task/Wait.h +++ b/libtask/bcos-task/Wait.h @@ -15,7 +15,7 @@ constexpr inline struct Wait void operator()(auto&& task) const requires std::is_rvalue_reference_v { - task.start(); + std::forward(task).start(); } } wait{}; @@ -41,7 +41,7 @@ constexpr inline struct SyncWait { if constexpr (std::is_void_v) { - co_await task; + co_await std::forward(task); } else { @@ -52,7 +52,7 @@ constexpr inline struct SyncWait } else { - result.template emplace(co_await task); + result.template emplace(co_await std::forward(task)); } } } diff --git a/libtask/tests/TestTask.cpp b/libtask/tests/TestTask.cpp index 33733059fa..e25e2e267c 100644 --- a/libtask/tests/TestTask.cpp +++ b/libtask/tests/TestTask.cpp @@ -1,6 +1,7 @@ #include "bcos-task/Generator.h" #include "bcos-task/TBBWait.h" #include "bcos-task/Task.h" +#include "bcos-task/Trait.h" #include "bcos-task/Wait.h" #include #include @@ -99,7 +100,7 @@ Task asyncLevel2(oneapi::tbb::task_group& taskGroup) { constexpr bool await_ready() const { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { std::cout << "Start run async thread: " << handle.address() << std::endl; taskGroup.run([this, m_handle = handle]() { @@ -169,7 +170,7 @@ struct SleepTask inline static oneapi::tbb::concurrent_vector> futures; constexpr static bool await_ready() { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { futures.emplace_back(std::async([m_handle = handle]() mutable { using namespace std::chrono_literals; @@ -198,57 +199,19 @@ BOOST_AUTO_TEST_CASE(generator) std::cout << "All outputed" << std::endl; } -struct ResumableTask +Task taskWithThrow() { - ResumableTask() = default; - ResumableTask(const ResumableTask&) = delete; - ResumableTask& operator=(const ResumableTask&) = delete; - ResumableTask(ResumableTask&&) = default; - ResumableTask& operator=(ResumableTask&&) = default; - ~ResumableTask() noexcept = default; - - CO_STD::coroutine_handle<> m_handle; - - constexpr bool static await_ready() { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) - { - std::cout << "Task suspend!" << std::endl; - m_handle = handle; - } - constexpr void await_resume() const {} -}; + throw std::runtime_error("error"); + co_return 0; +} -BOOST_AUTO_TEST_CASE(tbbWait) +BOOST_AUTO_TEST_CASE(memoryLeak) { - constexpr static auto count = 20; - std::vector tasks(count); - - ::tbb::task_arena arena(2); - ::tbb::task_group group1; - arena.execute([&]() { - for (auto i = 0; i < count; ++i) - { - group1.run([&tasks, i]() { - std::cout << "Task " << i << " started" << std::endl; - bcos::task::tbb::syncWait(tasks[i]); - std::cout << "Task " << i << " ended" << std::endl; - }); - } - - group1.run([&]() { - using namespace std::chrono_literals; - std::this_thread::sleep_for(1s); - - for (auto& task : tasks) - { - BOOST_REQUIRE(task.m_handle); - task.m_handle.resume(); - } - }); - }); - + bcos::task::syncWait( + []() -> Task { BOOST_CHECK_THROW(co_await taskWithThrow(), std::runtime_error); }()); - group1.wait(); + bcos::task::wait( + []() -> Task { BOOST_CHECK_THROW(co_await taskWithThrow(), std::runtime_error); }()); } BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file diff --git a/lightnode/bcos-lightnode/scheduler/SchedulerWrapperImpl.h b/lightnode/bcos-lightnode/scheduler/SchedulerWrapperImpl.h index 835eefae52..056994407e 100644 --- a/lightnode/bcos-lightnode/scheduler/SchedulerWrapperImpl.h +++ b/lightnode/bcos-lightnode/scheduler/SchedulerWrapperImpl.h @@ -29,14 +29,14 @@ class SchedulerWrapperImpl auto transactionImpl = std::make_shared( [&transaction]() { return const_cast(&transaction); }); - struct Awaitable : public CO_STD::suspend_always + struct Awaitable : public std::suspend_always { Awaitable(decltype(transactionImpl)& transactionImpl, SchedulerType& scheduler, std::remove_cvref_t& receipt) : m_transactionImpl(transactionImpl), m_scheduler(scheduler), m_receipt(receipt) {} - void await_suspend(CO_STD::coroutine_handle::promise_type> handle) + void await_suspend(std::coroutine_handle::promise_type> handle) { bcos::concepts::getRef(m_scheduler) .call(std::move(m_transactionImpl), diff --git a/lightnode/fisco-bcos-lightnode/client/P2PClientImpl.h b/lightnode/fisco-bcos-lightnode/client/P2PClientImpl.h index 42a059a149..480031c451 100644 --- a/lightnode/fisco-bcos-lightnode/client/P2PClientImpl.h +++ b/lightnode/fisco-bcos-lightnode/client/P2PClientImpl.h @@ -52,7 +52,7 @@ class P2PClientImpl {} constexpr bool await_ready() const { return false; } - void await_suspend(CO_STD::coroutine_handle::promise_type> handle) + void await_suspend(std::coroutine_handle::promise_type> handle) { LIGHTNODE_LOG(DEBUG) << "P2P client send message: " << m_moduleID << " | " << m_nodeID->hex() << " | " << m_requestBuffer.size(); @@ -112,7 +112,7 @@ class P2PClientImpl {} constexpr bool await_ready() const noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { bcos::concepts::getRef(m_gateway).asyncGetPeers( [this, m_handle = handle](Error::Ptr error, const gateway::GatewayInfo::Ptr&, @@ -212,7 +212,7 @@ class P2PClientImpl {} constexpr bool await_ready() const noexcept { return false; } - void await_suspend(CO_STD::coroutine_handle<> handle) + void await_suspend(std::coroutine_handle<> handle) { bcos::concepts::getRef(m_gateway).asyncGetPeers( [this, m_handle = handle](Error::Ptr error, const gateway::GatewayInfo::Ptr&, diff --git a/tools/.ci/pre-commit b/tools/.ci/pre-commit index 75684ba1c0..94f8834663 100644 --- a/tools/.ci/pre-commit +++ b/tools/.ci/pre-commit @@ -31,41 +31,37 @@ LOG_INFO() { execute_cmd() { command="${1}" - eval ${command} - ret=$? - if [ $ret -ne 0 ]; then - LOG_ERROR "FAILED of command: ${command}" - exit 1 - else - LOG_INFO "SUCCESS of command: ${command}" - fi + eval ${command} ret = $ ? if[$ret - ne 0]; + then LOG_ERROR "FAILED of command: ${command}" exit 1 else LOG_INFO + "SUCCESS of command: ${command}" fi } -function check_codeFormat() { - if [ "$(uname)" = "Darwin" ]; then - # if clang-format command not exist, print log and return directly - if ! command -v ${check_script} &>/dev/null; then - LOG_INFO "clang-format command not found, please install it, skip by default." - exit 0 - fi - # if clang-format first version less than 15 skip check - if [ $(clang-format --version | awk '{print $3}' | awk -F '.' '{print $1}') -lt 15 ]; then +function check_codeFormat() +{ + if + ["$(uname)" = "Darwin"]; + then +#if clang - format command not exist, print log and return directly + if !command - + v ${check_script}& > + / dev / null; + then LOG_INFO "clang-format command not found, please install it, skip by default." exit 0 fi +#if clang - format first version less than 15 skip check + if[$(clang - format-- version | awk '{print $3}' | awk - F '.' '{print $1}') - lt 15]; then LOG_INFO "clang-format version less than 15, skip check." exit 0 fi - # Redirect output to stderr. +#Redirect output to stderr. exec 1>&2 sum=0 - for file in $(git diff-index --name-status HEAD^ -- | grep -v D | grep -E '\.[ch](pp)?$' | awk '{print $2}'); do + for file in $(git diff-index --name-status HEAD^ -- | grep -v D | grep -E '\.[ch](pp)?$' | awk '{print $2}'); + do clang-format -style=file -i $file --dry-run --Werror sum=$(expr ${sum} + $?) execute_cmd "$check_script -style=file -i $file" done - if [ ${sum} -ne 0 ]; then - echo "######### ERROR: Format check failed, please adjust them before commit" - exit 1 - fi - fi + if [ ${sum} -ne 0 ]; + then echo "######### ERROR: Format check failed, please adjust them before commit" exit 1 fi fi } check_codeFormat diff --git a/tools/.ci/rpcapi_ci_prepare.sh b/tools/.ci/rpcapi_ci_prepare.sh index bf2f3b828d..732b96aa19 100644 --- a/tools/.ci/rpcapi_ci_prepare.sh +++ b/tools/.ci/rpcapi_ci_prepare.sh @@ -35,12 +35,11 @@ wait_and_start() init() { - sm_option="${1}" cd ${current_path} echo " ==> fisco-bcos version: " ${fisco_bcos_path} -v clear_node - bash ${build_chain_path} -l "127.0.0.1:4" -e ${fisco_bcos_path} "${sm_option}" + bash ${build_chain_path} -p 30300,20200 -l "127.0.0.1:4" -e ${fisco_bcos_path} open_disablessl cd .. wait_and_start @@ -79,4 +78,4 @@ open_disablessl(){ -init "" \ No newline at end of file +init \ No newline at end of file diff --git a/tools/BcosAirBuilder/build_chain.sh b/tools/BcosAirBuilder/build_chain.sh index 3aa1478a1f..760e820a01 100755 --- a/tools/BcosAirBuilder/build_chain.sh +++ b/tools/BcosAirBuilder/build_chain.sh @@ -39,7 +39,7 @@ ca_dir="" prometheus_dir="" config_path="" docker_mode= -default_version="v3.9.0" +default_version="v3.10.0" compatibility_version=${default_version} default_mtail_version="3.0.0-rc49" compatibility_mtail_version=${default_mtail_version} @@ -71,11 +71,11 @@ log_level="info" # for pro or max default setting bcos_builder_package=BcosBuilder.tgz -bcos_builder_version=v3.9.0 +bcos_builder_version=v3.10.0 use_exist_binary="false" download_specific_binary_flag="false" download_service_binary_type="cdn" -service_binary_version="v3.9.0" +service_binary_version="v3.10.0" download_service_binary_path="binary" download_service_binary_path_flag="false" service_type="all" diff --git a/tools/BcosBuilder/max/conf/config-build-example.toml b/tools/BcosBuilder/max/conf/config-build-example.toml index 893aa78c92..fe89d61191 100644 --- a/tools/BcosBuilder/max/conf/config-build-example.toml +++ b/tools/BcosBuilder/max/conf/config-build-example.toml @@ -36,7 +36,7 @@ consensus_type = "pbft" # transaction gas limit gas_limit = "3000000000" # compatible version, can be dynamically upgraded through setSystemConfig -compatibility_version="3.9.0" +compatibility_version = "3.10.0" [[agency]] name = "agencyA" diff --git a/tools/BcosBuilder/max/conf/config-deploy-example.toml b/tools/BcosBuilder/max/conf/config-deploy-example.toml index 4725a0c514..2e07ff7adf 100644 --- a/tools/BcosBuilder/max/conf/config-deploy-example.toml +++ b/tools/BcosBuilder/max/conf/config-deploy-example.toml @@ -36,7 +36,7 @@ consensus_type = "pbft" # transaction gas limit gas_limit = "3000000000" # compatible version, can be dynamically upgraded through setSystemConfig -compatibility_version="3.9.0" +compatibility_version = "3.10.0" [[agency]] name = "agencyA" diff --git a/tools/BcosBuilder/pro/conf/config-build-example.toml b/tools/BcosBuilder/pro/conf/config-build-example.toml index 8a0e545580..50eb5d0979 100644 --- a/tools/BcosBuilder/pro/conf/config-build-example.toml +++ b/tools/BcosBuilder/pro/conf/config-build-example.toml @@ -34,7 +34,7 @@ consensus_type = "pbft" # transaction gas limit gas_limit = "3000000000" # compatible version, can be dynamically upgraded through setSystemConfig -compatibility_version="3.9.0" +compatibility_version = "3.10.0" [[agency]] name = "agencyA" diff --git a/tools/BcosBuilder/pro/conf/config-deploy-example.toml b/tools/BcosBuilder/pro/conf/config-deploy-example.toml index 4f671a6937..2158b6c5ac 100644 --- a/tools/BcosBuilder/pro/conf/config-deploy-example.toml +++ b/tools/BcosBuilder/pro/conf/config-deploy-example.toml @@ -36,7 +36,7 @@ consensus_type = "pbft" # transaction gas limit gas_limit = "3000000000" # compatible version, can be dynamically upgraded through setSystemConfig -compatibility_version="3.9.0" +compatibility_version = "3.10.0" [[agency]] name = "agencyA" diff --git a/tools/BcosBuilder/src/common/utilities.py b/tools/BcosBuilder/src/common/utilities.py index 3fc63d01f0..054585de27 100644 --- a/tools/BcosBuilder/src/common/utilities.py +++ b/tools/BcosBuilder/src/common/utilities.py @@ -99,7 +99,7 @@ class CommandInfo: network_add_vxlan = "add-vxlan" download_binary = "download_binary" download_type = ["cdn", "git"] - default_binary_version = "v3.9.0" + default_binary_version = "v3.10.0" command_list = [gen_config, upload, deploy, upgrade, undeploy, expand, start, stop] service_command_list_str = ', '.join(command_list) diff --git a/tools/BcosBuilder/src/tpl/config.genesis b/tools/BcosBuilder/src/tpl/config.genesis index 8f10bd9e81..84738bc33a 100644 --- a/tools/BcosBuilder/src/tpl/config.genesis +++ b/tools/BcosBuilder/src/tpl/config.genesis @@ -22,7 +22,7 @@ [version] ; compatible version, can be dynamically upgraded through setSystemConfig - compatibility_version=3.9.0 + compatibility_version=3.10.0 [tx] ; transaction gas limit diff --git a/tools/archive-tool/archive-reader/Cargo.lock b/tools/archive-tool/archive-reader/Cargo.lock index 6f24662106..a978a7e635 100644 --- a/tools/archive-tool/archive-reader/Cargo.lock +++ b/tools/archive-tool/archive-reader/Cargo.lock @@ -77,7 +77,7 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ - "memchr", + "memchr", ] [[package]] @@ -92,7 +92,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" dependencies = [ - "libc", + "libc", ] [[package]] @@ -128,8 +128,8 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5" dependencies = [ - "quote", - "syn 1.0.109", + "quote", + "syn 1.0.109", ] [[package]] @@ -138,9 +138,9 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ - "concurrent-queue", - "event-listener 2.5.3", - "futures-core", + "concurrent-queue", + "event-listener 2.5.3", + "futures-core", ] [[package]] @@ -149,11 +149,11 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" dependencies = [ - "concurrent-queue", - "event-listener 5.2.0", - "event-listener-strategy 0.5.1", - "futures-core", - "pin-project-lite 0.2.14", + "concurrent-queue", + "event-listener 5.2.0", + "event-listener-strategy 0.5.1", + "futures-core", + "pin-project-lite 0.2.14", ] [[package]] @@ -162,8 +162,8 @@ version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c2886ab563af5038f79ec016dd7b87947ed138b794e8dd64992962c9cca0411" dependencies = [ - "async-lock 3.3.0", - "futures-io", + "async-lock 3.3.0", + "futures-io", ] [[package]] @@ -172,12 +172,12 @@ version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10b3e585719c2358d2660232671ca8ca4ddb4be4ce8a1842d6c2dc8685303316" dependencies = [ - "async-lock 3.3.0", - "async-task", - "concurrent-queue", - "fastrand 2.0.2", - "futures-lite 2.3.0", - "slab", + "async-lock 3.3.0", + "async-task", + "concurrent-queue", + "fastrand 2.0.2", + "futures-lite 2.3.0", + "slab", ] [[package]] @@ -186,14 +186,14 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" dependencies = [ - "async-channel 2.2.0", - "async-executor", - "async-io 2.3.2", - "async-lock 3.3.0", - "blocking", - "futures-lite 2.3.0", - "once_cell", - "tokio", + "async-channel 2.2.0", + "async-executor", + "async-io 2.3.2", + "async-lock 3.3.0", + "blocking", + "futures-lite 2.3.0", + "once_cell", + "tokio", ] [[package]] @@ -202,15 +202,15 @@ version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d1d1dae8cb2c4258a79d6ed088b7fb9b4763bf4e9b22d040779761e046a2971" dependencies = [ - "async-channel 1.9.0", - "async-dup", - "async-global-executor", - "async-io 1.13.0", - "futures-lite 1.13.0", - "http-types", - "httparse", - "log", - "pin-project", + "async-channel 1.9.0", + "async-dup", + "async-global-executor", + "async-io 1.13.0", + "futures-lite 1.13.0", + "http-types", + "httparse", + "log", + "pin-project", ] [[package]] @@ -219,18 +219,18 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ - "async-lock 2.8.0", - "autocfg", - "cfg-if 1.0.0", - "concurrent-queue", - "futures-lite 1.13.0", - "log", - "parking", - "polling 2.8.0", - "rustix 0.37.27", - "slab", - "socket2 0.4.10", - "waker-fn", + "async-lock 2.8.0", + "autocfg", + "cfg-if 1.0.0", + "concurrent-queue", + "futures-lite 1.13.0", + "log", + "parking", + "polling 2.8.0", + "rustix 0.37.27", + "slab", + "socket2 0.4.10", + "waker-fn", ] [[package]] @@ -239,17 +239,17 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcccb0f599cfa2f8ace422d3555572f47424da5648a4382a9dd0310ff8210884" dependencies = [ - "async-lock 3.3.0", - "cfg-if 1.0.0", - "concurrent-queue", - "futures-io", - "futures-lite 2.3.0", - "parking", - "polling 3.6.0", - "rustix 0.38.32", - "slab", - "tracing", - "windows-sys 0.52.0", + "async-lock 3.3.0", + "cfg-if 1.0.0", + "concurrent-queue", + "futures-io", + "futures-lite 2.3.0", + "parking", + "polling 3.6.0", + "rustix 0.38.32", + "slab", + "tracing", + "windows-sys 0.52.0", ] [[package]] @@ -258,7 +258,7 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ - "event-listener 2.5.3", + "event-listener 2.5.3", ] [[package]] @@ -267,9 +267,9 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" dependencies = [ - "event-listener 4.0.3", - "event-listener-strategy 0.4.0", - "pin-project-lite 0.2.14", + "event-listener 4.0.3", + "event-listener-strategy 0.4.0", + "pin-project-lite 0.2.14", ] [[package]] @@ -278,15 +278,15 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea6438ba0a08d81529c69b36700fa2f95837bfe3e776ab39cde9c14d9149da88" dependencies = [ - "async-io 1.13.0", - "async-lock 2.8.0", - "async-signal", - "blocking", - "cfg-if 1.0.0", - "event-listener 3.1.0", - "futures-lite 1.13.0", - "rustix 0.38.32", - "windows-sys 0.48.0", + "async-io 1.13.0", + "async-lock 2.8.0", + "async-signal", + "blocking", + "cfg-if 1.0.0", + "event-listener 3.1.0", + "futures-lite 1.13.0", + "rustix 0.38.32", + "windows-sys 0.48.0", ] [[package]] @@ -295,9 +295,9 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7d78656ba01f1b93024b7c3a0467f1608e4be67d725749fdcd7d2c7678fd7a2" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -311,14 +311,14 @@ dependencies = [ "async-trait", "base64 0.12.3", "bincode", - "blake3", - "chrono", - "hmac 0.8.1", - "kv-log-macro", - "rand 0.7.3", - "serde", - "serde_json", - "sha2", + "blake3", + "chrono", + "hmac 0.8.1", + "kv-log-macro", + "rand 0.7.3", + "serde", + "serde_json", + "sha2", ] [[package]] @@ -327,16 +327,16 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" dependencies = [ - "async-io 2.3.2", - "async-lock 2.8.0", - "atomic-waker", - "cfg-if 1.0.0", - "futures-core", - "futures-io", - "rustix 0.38.32", - "signal-hook-registry", - "slab", - "windows-sys 0.48.0", + "async-io 2.3.2", + "async-lock 2.8.0", + "atomic-waker", + "cfg-if 1.0.0", + "futures-core", + "futures-io", + "rustix 0.38.32", + "signal-hook-registry", + "slab", + "windows-sys 0.48.0", ] [[package]] @@ -345,12 +345,12 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53bba003996b8fd22245cd0c59b869ba764188ed435392cf2796d03b805ade10" dependencies = [ - "async-channel 1.9.0", - "async-std", - "http-types", - "log", - "memchr", - "pin-project-lite 0.1.12", + "async-channel 1.9.0", + "async-std", + "http-types", + "log", + "memchr", + "pin-project-lite 0.1.12", ] [[package]] @@ -359,26 +359,26 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" dependencies = [ - "async-attributes", - "async-channel 1.9.0", - "async-global-executor", - "async-io 1.13.0", - "async-lock 2.8.0", - "async-process", - "crossbeam-utils", - "futures-channel", - "futures-core", - "futures-io", - "futures-lite 1.13.0", - "gloo-timers", - "kv-log-macro", - "log", - "memchr", - "once_cell", - "pin-project-lite 0.2.14", - "pin-utils", - "slab", - "wasm-bindgen-futures", + "async-attributes", + "async-channel 1.9.0", + "async-global-executor", + "async-io 1.13.0", + "async-lock 2.8.0", + "async-process", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite 1.13.0", + "gloo-timers", + "kv-log-macro", + "log", + "memchr", + "once_cell", + "pin-project-lite 0.2.14", + "pin-utils", + "slab", + "wasm-bindgen-futures", ] [[package]] @@ -387,9 +387,9 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" dependencies = [ - "async-stream-impl", - "futures-core", - "pin-project-lite 0.2.14", + "async-stream-impl", + "futures-core", + "pin-project-lite 0.2.14", ] [[package]] @@ -398,9 +398,9 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.57", + "proc-macro2", + "quote", + "syn 2.0.57", ] [[package]] @@ -415,9 +415,9 @@ version = "0.1.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.57", + "proc-macro2", + "quote", + "syn 2.0.57", ] [[package]] @@ -432,9 +432,9 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", + "hermit-abi 0.1.19", + "libc", + "winapi", ] [[package]] @@ -449,26 +449,26 @@ version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ - "async-trait", - "axum-core", - "bitflags 1.3.2", - "bytes", - "futures-util", - "http", - "http-body", - "hyper", - "itoa", - "matchit", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite 0.2.14", - "rustversion", - "serde", - "sync_wrapper", - "tower", - "tower-layer", - "tower-service", + "async-trait", + "axum-core", + "bitflags 1.3.2", + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite 0.2.14", + "rustversion", + "serde", + "sync_wrapper", + "tower", + "tower-layer", + "tower-service", ] [[package]] @@ -477,15 +477,15 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" dependencies = [ - "async-trait", - "bytes", - "futures-util", - "http", - "http-body", - "mime", - "rustversion", - "tower-layer", - "tower-service", + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "mime", + "rustversion", + "tower-layer", + "tower-service", ] [[package]] @@ -494,13 +494,13 @@ version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ - "addr2line", - "cc", - "cfg-if 1.0.0", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", + "addr2line", + "cc", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", ] [[package]] @@ -533,7 +533,7 @@ version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ - "serde", + "serde", ] [[package]] @@ -542,18 +542,18 @@ version = "0.64.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" dependencies = [ - "bitflags 1.3.2", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "peeking_take_while", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn 1.0.109", + "bitflags 1.3.2", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 1.0.109", ] [[package]] @@ -574,9 +574,9 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b64485778c4f16a6a5a9d335e80d449ac6c70cdd6a06d2af18a6f6f775a125b3" dependencies = [ - "arrayref", - "arrayvec", - "cc", + "arrayref", + "arrayvec", + "cc", "cfg-if 0.1.10", "constant_time_eq", "crypto-mac 0.8.0", @@ -598,14 +598,14 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ - "async-channel 2.2.0", - "async-lock 3.3.0", - "async-task", - "fastrand 2.0.2", - "futures-io", - "futures-lite 2.3.0", - "piper", - "tracing", + "async-channel 2.2.0", + "async-lock 3.3.0", + "async-task", + "fastrand 2.0.2", + "futures-io", + "futures-lite 2.3.0", + "piper", + "tracing", ] [[package]] @@ -643,8 +643,8 @@ version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" dependencies = [ - "jobserver", - "libc", + "jobserver", + "libc", ] [[package]] @@ -674,13 +674,13 @@ version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" dependencies = [ - "android-tzdata", - "iana-time-zone", - "js-sys", - "num-traits", - "serde", - "wasm-bindgen", - "windows-targets 0.52.4", + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-targets 0.52.4", ] [[package]] @@ -698,9 +698,9 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" dependencies = [ - "glob", - "libc", - "libloading", + "glob", + "libc", + "libloading", ] [[package]] @@ -709,13 +709,13 @@ version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim", - "textwrap", - "unicode-width", - "vec_map", + "ansi_term", + "atty", + "bitflags 1.3.2", + "strsim", + "textwrap", + "unicode-width", + "vec_map", ] [[package]] @@ -724,7 +724,7 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" dependencies = [ - "crossbeam-utils", + "crossbeam-utils", ] [[package]] @@ -745,15 +745,15 @@ version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03a5d7b21829bc7b4bf4754a978a241ae54ea55a40f92bb20216e54096f4b951" dependencies = [ - "aes-gcm", - "base64 0.13.1", - "hkdf", - "hmac 0.10.1", - "percent-encoding", - "rand 0.8.5", - "sha2", - "time", - "version_check", + "aes-gcm", + "base64 0.13.1", + "hkdf", + "hmac 0.10.1", + "percent-encoding", + "rand 0.8.5", + "sha2", + "time", + "version_check", ] [[package]] @@ -762,8 +762,8 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ - "core-foundation-sys", - "libc", + "core-foundation-sys", + "libc", ] [[package]] @@ -778,7 +778,7 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ - "libc", + "libc", ] [[package]] @@ -809,8 +809,8 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6" dependencies = [ - "generic-array", - "subtle", + "generic-array", + "subtle", ] [[package]] @@ -828,9 +828,9 @@ version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3418329ca0ad70234b9735dc4ceed10af4df60eff9c8e7b06cb5e520d92c3535" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -860,7 +860,7 @@ version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 1.0.0", ] [[package]] @@ -888,7 +888,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b73807008a3c7f171cc40312f37d95ef0396e048b5848d775f54b1a4dd4a0d3" dependencies = [ - "serde", + "serde", ] [[package]] @@ -897,8 +897,8 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "libc", - "windows-sys 0.52.0", + "libc", + "windows-sys 0.52.0", ] [[package]] @@ -913,9 +913,9 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite 0.2.14", + "concurrent-queue", + "parking", + "pin-project-lite 0.2.14", ] [[package]] @@ -924,9 +924,9 @@ version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite 0.2.14", + "concurrent-queue", + "parking", + "pin-project-lite 0.2.14", ] [[package]] @@ -935,9 +935,9 @@ version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b5fb89194fa3cad959b833185b3063ba881dbfc7030680b314250779fb4cc91" dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite 0.2.14", + "concurrent-queue", + "parking", + "pin-project-lite 0.2.14", ] [[package]] @@ -946,8 +946,8 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" dependencies = [ - "event-listener 4.0.3", - "pin-project-lite 0.2.14", + "event-listener 4.0.3", + "pin-project-lite 0.2.14", ] [[package]] @@ -956,8 +956,8 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "332f51cb23d20b0de8458b86580878211da09bcd4503cb579c225b3d124cabb3" dependencies = [ - "event-listener 5.2.0", - "pin-project-lite 0.2.14", + "event-listener 5.2.0", + "pin-project-lite 0.2.14", ] [[package]] @@ -966,9 +966,9 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3be3c61c59fdc91f5dbc3ea31ee8623122ce80057058be560654c5d410d181a6" dependencies = [ - "lazy_static", - "log", - "rand 0.7.3", + "lazy_static", + "log", + "rand 0.7.3", ] [[package]] @@ -977,7 +977,7 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ - "instant", + "instant", ] [[package]] @@ -992,9 +992,9 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc04871e5ae3aa2952d552dae6b291b3099723bf779a8054281c1366a54613ef" dependencies = [ - "cfg-if 1.0.0", - "js-sys", - "log", + "cfg-if 1.0.0", + "js-sys", + "log", "serde", "serde_derive", "serde_json", @@ -1006,17 +1006,17 @@ dependencies = [ name = "fisco-bcos-archive-reader" version = "0.1.0" dependencies = [ - "async-std", - "env_logger", - "log", - "prefix-hex", - "rocksdb", - "serde", - "serde_json", - "structopt", - "tide", - "tikv-client", - "tokio", + "async-std", + "env_logger", + "log", + "prefix-hex", + "rocksdb", + "serde", + "serde_json", + "structopt", + "tide", + "tikv-client", + "tokio", ] [[package]] @@ -1046,7 +1046,7 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ - "percent-encoding", + "percent-encoding", ] [[package]] @@ -1055,13 +1055,13 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", ] [[package]] @@ -1070,8 +1070,8 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ - "futures-core", - "futures-sink", + "futures-core", + "futures-sink", ] [[package]] @@ -1086,9 +1086,9 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ - "futures-core", - "futures-task", - "futures-util", + "futures-core", + "futures-task", + "futures-util", ] [[package]] @@ -1103,13 +1103,13 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" dependencies = [ - "fastrand 1.9.0", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite 0.2.14", - "waker-fn", + "fastrand 1.9.0", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite 0.2.14", + "waker-fn", ] [[package]] @@ -1118,11 +1118,11 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ - "fastrand 2.0.2", - "futures-core", - "futures-io", - "parking", - "pin-project-lite 0.2.14", + "fastrand 2.0.2", + "futures-core", + "futures-io", + "parking", + "pin-project-lite 0.2.14", ] [[package]] @@ -1131,9 +1131,9 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.57", + "proc-macro2", + "quote", + "syn 2.0.57", ] [[package]] @@ -1154,16 +1154,16 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite 0.2.14", - "pin-utils", - "slab", + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite 0.2.14", + "pin-utils", + "slab", ] [[package]] @@ -1172,8 +1172,8 @@ version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ - "typenum", - "version_check", + "typenum", + "version_check", ] [[package]] @@ -1193,9 +1193,9 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "cfg-if 1.0.0", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -1226,10 +1226,10 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", ] [[package]] @@ -1238,17 +1238,17 @@ version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap 2.2.6", - "slab", - "tokio", - "tokio-util", - "tracing", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", ] [[package]] @@ -1269,7 +1269,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" dependencies = [ - "unicode-segmentation", + "unicode-segmentation", ] [[package]] @@ -1278,7 +1278,7 @@ version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ - "libc", + "libc", ] [[package]] @@ -1319,8 +1319,8 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ - "crypto-mac 0.10.0", - "digest", + "crypto-mac 0.10.0", + "digest", ] [[package]] @@ -1329,9 +1329,9 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ - "bytes", - "fnv", - "itoa", + "bytes", + "fnv", + "itoa", ] [[package]] @@ -1340,9 +1340,9 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ - "bytes", - "http", - "pin-project-lite 0.2.14", + "bytes", + "http", + "pin-project-lite 0.2.14", ] [[package]] @@ -1363,20 +1363,20 @@ version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e9b187a72d63adbfba487f48095306ac823049cb504ee195541e91c7775f5ad" dependencies = [ - "anyhow", - "async-channel 1.9.0", - "async-std", - "base64 0.13.1", - "cookie", - "futures-lite 1.13.0", - "infer", - "pin-project-lite 0.2.14", - "rand 0.7.3", - "serde", - "serde_json", - "serde_qs", - "serde_urlencoded", - "url", + "anyhow", + "async-channel 1.9.0", + "async-std", + "base64 0.13.1", + "cookie", + "futures-lite 1.13.0", + "infer", + "pin-project-lite 0.2.14", + "rand 0.7.3", + "serde", + "serde_json", + "serde_qs", + "serde_urlencoded", + "url", ] [[package]] @@ -1403,22 +1403,22 @@ version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite 0.2.14", - "socket2 0.5.6", - "tokio", - "tower-service", - "tracing", - "want", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite 0.2.14", + "socket2 0.5.6", + "tokio", + "tower-service", + "tracing", + "want", ] [[package]] @@ -1427,10 +1427,10 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper", - "pin-project-lite 0.2.14", - "tokio", - "tokio-io-timeout", + "hyper", + "pin-project-lite 0.2.14", + "tokio", + "tokio-io-timeout", ] [[package]] @@ -1439,9 +1439,9 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ - "bytes", - "hyper", - "native-tls", + "bytes", + "hyper", + "native-tls", "tokio", "tokio-native-tls", ] @@ -1452,12 +1452,12 @@ version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", ] [[package]] @@ -1466,7 +1466,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ - "cc", + "cc", ] [[package]] @@ -1475,8 +1475,8 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "unicode-bidi", + "unicode-normalization", ] [[package]] @@ -1485,8 +1485,8 @@ version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ - "autocfg", - "hashbrown 0.12.3", + "autocfg", + "hashbrown 0.12.3", ] [[package]] @@ -1495,8 +1495,8 @@ version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ - "equivalent", - "hashbrown 0.14.3", + "equivalent", + "hashbrown 0.14.3", ] [[package]] @@ -1511,7 +1511,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 1.0.0", ] [[package]] @@ -1520,9 +1520,9 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.9", - "libc", - "windows-sys 0.48.0", + "hermit-abi 0.3.9", + "libc", + "windows-sys 0.48.0", ] [[package]] @@ -1537,7 +1537,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" dependencies = [ - "either", + "either", ] [[package]] @@ -1552,7 +1552,7 @@ version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" dependencies = [ - "libc", + "libc", ] [[package]] @@ -1561,7 +1561,7 @@ version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ - "wasm-bindgen", + "wasm-bindgen", ] [[package]] @@ -1597,8 +1597,8 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ - "cfg-if 1.0.0", - "windows-targets 0.52.4", + "cfg-if 1.0.0", + "windows-targets 0.52.4", ] [[package]] @@ -1607,13 +1607,13 @@ version = "0.8.3+7.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "557b255ff04123fcc176162f56ed0c9cd42d8f357cf55b3fabeb60f7413741b3" dependencies = [ - "bindgen", - "bzip2-sys", - "cc", - "glob", - "libc", - "libz-sys", - "zstd-sys", + "bindgen", + "bzip2-sys", + "cc", + "glob", + "libc", + "libz-sys", + "zstd-sys", ] [[package]] @@ -1622,9 +1622,9 @@ version = "1.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e143b5e666b2695d28f6bca6497720813f699c9602dd7f5cac91008b8ada7f9" dependencies = [ - "cc", - "pkg-config", - "vcpkg", + "cc", + "pkg-config", + "vcpkg", ] [[package]] @@ -1651,8 +1651,8 @@ version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ - "autocfg", - "scopeguard", + "autocfg", + "scopeguard", ] [[package]] @@ -1661,8 +1661,8 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" dependencies = [ - "serde", - "value-bag", + "serde", + "value-bag", ] [[package]] @@ -1695,7 +1695,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ - "adler", + "adler", ] [[package]] @@ -1704,9 +1704,9 @@ version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.48.0", ] [[package]] @@ -1733,8 +1733,8 @@ version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ - "memchr", - "minimal-lexical", + "memchr", + "minimal-lexical", ] [[package]] @@ -1743,7 +1743,7 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ - "autocfg", + "autocfg", ] [[package]] @@ -1752,8 +1752,8 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.9", - "libc", + "hermit-abi 0.3.9", + "libc", ] [[package]] @@ -1762,7 +1762,7 @@ version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ - "memchr", + "memchr", ] [[package]] @@ -1783,13 +1783,13 @@ version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.5.0", - "cfg-if 1.0.0", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", + "bitflags 2.5.0", + "cfg-if 1.0.0", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", ] [[package]] @@ -1798,9 +1798,9 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.57", + "proc-macro2", + "quote", + "syn 2.0.57", ] [[package]] @@ -1815,10 +1815,10 @@ version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", + "cc", + "libc", + "pkg-config", + "vcpkg", ] [[package]] @@ -1833,8 +1833,8 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ - "lock_api", - "parking_lot_core", + "lock_api", + "parking_lot_core", ] [[package]] @@ -1843,11 +1843,11 @@ version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ - "cfg-if 1.0.0", - "libc", - "redox_syscall", - "smallvec", - "windows-targets 0.48.5", + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.48.5", ] [[package]] @@ -1868,7 +1868,7 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ - "pin-project-internal", + "pin-project-internal", ] [[package]] @@ -1877,9 +1877,9 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.57", + "proc-macro2", + "quote", + "syn 2.0.57", ] [[package]] @@ -1906,9 +1906,9 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" dependencies = [ - "atomic-waker", - "fastrand 2.0.2", - "futures-io", + "atomic-waker", + "fastrand 2.0.2", + "futures-io", ] [[package]] @@ -1923,14 +1923,14 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ - "autocfg", - "bitflags 1.3.2", - "cfg-if 1.0.0", - "concurrent-queue", - "libc", - "log", - "pin-project-lite 0.2.14", - "windows-sys 0.48.0", + "autocfg", + "bitflags 1.3.2", + "cfg-if 1.0.0", + "concurrent-queue", + "libc", + "log", + "pin-project-lite 0.2.14", + "windows-sys 0.48.0", ] [[package]] @@ -1939,13 +1939,13 @@ version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0c976a60b2d7e99d6f229e414670a9b85d13ac305cc6d1e9c134de58c5aaaf6" dependencies = [ - "cfg-if 1.0.0", - "concurrent-queue", - "hermit-abi 0.3.9", - "pin-project-lite 0.2.14", - "rustix 0.38.32", - "tracing", - "windows-sys 0.52.0", + "cfg-if 1.0.0", + "concurrent-queue", + "hermit-abi 0.3.9", + "pin-project-lite 0.2.14", + "rustix 0.38.32", + "tracing", + "windows-sys 0.52.0", ] [[package]] @@ -1954,8 +1954,8 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" dependencies = [ - "cpuid-bool", - "opaque-debug", + "cpuid-bool", + "opaque-debug", "universal-hash", ] @@ -1980,11 +1980,11 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", ] [[package]] @@ -2010,7 +2010,7 @@ version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ - "unicode-ident", + "unicode-ident", ] [[package]] @@ -2019,11 +2019,11 @@ version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1de8dacb0873f77e6aefc6d71e044761fcc68060290f5b1089fcdf84626bb69" dependencies = [ - "bitflags 1.3.2", - "byteorder", - "hex", - "lazy_static", - "rustix 0.36.17", + "bitflags 1.3.2", + "byteorder", + "hex", + "lazy_static", + "rustix 0.36.17", ] [[package]] @@ -2032,15 +2032,15 @@ version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "449811d15fbdf5ceb5c1144416066429cf82316e2ec8ce0c1f6f8a02e7bbcf8c" dependencies = [ - "cfg-if 1.0.0", - "fnv", - "lazy_static", - "libc", - "memchr", - "parking_lot", - "procfs", - "protobuf", - "reqwest", + "cfg-if 1.0.0", + "fnv", + "lazy_static", + "libc", + "memchr", + "parking_lot", + "procfs", + "protobuf", + "reqwest", "thiserror", ] @@ -2050,8 +2050,8 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" dependencies = [ - "bytes", - "prost-derive", + "bytes", + "prost-derive", ] [[package]] @@ -2060,11 +2060,11 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn 2.0.57", + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.57", ] [[package]] @@ -2079,7 +2079,7 @@ version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ - "proc-macro2", + "proc-macro2", ] [[package]] @@ -2141,7 +2141,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.12", + "getrandom 0.2.12", ] [[package]] @@ -2159,7 +2159,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ - "bitflags 1.3.2", + "bitflags 1.3.2", ] [[package]] @@ -2168,10 +2168,10 @@ version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", ] [[package]] @@ -2180,9 +2180,9 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", + "aho-corasick", + "memchr", + "regex-syntax", ] [[package]] @@ -2197,38 +2197,38 @@ version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "hyper-tls", - "ipnet", - "js-sys", - "log", - "mime", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite 0.2.14", - "rustls-pemfile", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper", - "system-configuration", - "tokio", - "tokio-native-tls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", + "base64 0.21.7", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite 0.2.14", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", ] [[package]] @@ -2237,13 +2237,13 @@ version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ - "cc", - "cfg-if 1.0.0", - "getrandom 0.2.12", - "libc", - "spin", - "untrusted", - "windows-sys 0.52.0", + "cc", + "cfg-if 1.0.0", + "getrandom 0.2.12", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", ] [[package]] @@ -2252,8 +2252,8 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e9562ea1d70c0cc63a34a22d977753b50cca91cc6b6527750463bd5dd8697bc" dependencies = [ - "libc", - "librocksdb-sys", + "libc", + "librocksdb-sys", ] [[package]] @@ -2289,12 +2289,12 @@ version = "0.36.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "305efbd14fde4139eb501df5f136994bb520b033fa9fbdce287507dc23b8c7ed" dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.1.4", - "windows-sys 0.45.0", + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.1.4", + "windows-sys 0.45.0", ] [[package]] @@ -2303,12 +2303,12 @@ version = "0.37.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", ] [[package]] @@ -2317,11 +2317,11 @@ version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.5.0", - "errno", - "libc", - "linux-raw-sys 0.4.13", - "windows-sys 0.52.0", + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys 0.4.13", + "windows-sys 0.52.0", ] [[package]] @@ -2330,10 +2330,10 @@ version = "0.21.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ - "log", - "ring", - "rustls-webpki", - "sct", + "log", + "ring", + "rustls-webpki", + "sct", ] [[package]] @@ -2342,7 +2342,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "base64 0.21.7", + "base64 0.21.7", ] [[package]] @@ -2351,8 +2351,8 @@ version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring", - "untrusted", + "ring", + "untrusted", ] [[package]] @@ -2373,7 +2373,7 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.52.0", ] [[package]] @@ -2388,8 +2388,8 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring", - "untrusted", + "ring", + "untrusted", ] [[package]] @@ -2398,11 +2398,11 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", + "bitflags 1.3.2", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", ] [[package]] @@ -2411,8 +2411,8 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" dependencies = [ - "core-foundation-sys", - "libc", + "core-foundation-sys", + "libc", ] [[package]] @@ -2442,7 +2442,7 @@ version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ - "serde_derive", + "serde_derive", ] [[package]] @@ -2451,9 +2451,9 @@ version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.57", + "proc-macro2", + "quote", + "syn 2.0.57", ] [[package]] @@ -2462,7 +2462,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d4ddca14104cd60529e8c7f7ba71a2c8acd8f7f5cfcdc2faf97eeb7c3010a4" dependencies = [ - "serde", + "serde", ] [[package]] @@ -2471,9 +2471,9 @@ version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ - "itoa", - "ryu", - "serde", + "itoa", + "ryu", + "serde", ] [[package]] @@ -2539,7 +2539,7 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ - "libc", + "libc", ] [[package]] @@ -2548,7 +2548,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ - "autocfg", + "autocfg", ] [[package]] @@ -2563,8 +2563,8 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ - "libc", - "winapi", + "libc", + "winapi", ] [[package]] @@ -2573,8 +2573,8 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" dependencies = [ - "libc", - "windows-sys 0.52.0", + "libc", + "windows-sys 0.52.0", ] [[package]] @@ -2589,7 +2589,7 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" dependencies = [ - "version_check", + "version_check", ] [[package]] @@ -2612,11 +2612,11 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" dependencies = [ - "proc-macro2", - "quote", - "serde", - "serde_derive", - "syn 1.0.109", + "proc-macro2", + "quote", + "serde", + "serde_derive", + "syn 1.0.109", ] [[package]] @@ -2625,14 +2625,14 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" dependencies = [ - "base-x", - "proc-macro2", - "quote", - "serde", - "serde_derive", - "serde_json", - "sha1", - "syn 1.0.109", + "base-x", + "proc-macro2", + "quote", + "serde", + "serde_derive", + "serde_json", + "sha1", + "syn 1.0.109", ] [[package]] @@ -2664,11 +2664,11 @@ version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" dependencies = [ - "heck", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -2689,8 +2689,8 @@ version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96e860aef60e9cbf37888d4953a13445abf523c534640d1f6174d310917c410d" dependencies = [ - "sval", - "sval_ref", + "sval", + "sval_ref", ] [[package]] @@ -2699,7 +2699,7 @@ version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea3f2b07929a1127d204ed7cb3905049381708245727680e9139dac317ed556f" dependencies = [ - "sval", + "sval", ] [[package]] @@ -2708,9 +2708,9 @@ version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4e188677497de274a1367c4bda15bd2296de4070d91729aac8f0a09c1abf64d" dependencies = [ - "itoa", - "ryu", - "sval", + "itoa", + "ryu", + "sval", ] [[package]] @@ -2719,9 +2719,9 @@ version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32f456c07dae652744781f2245d5e3b78e6a9ebad70790ac11eb15dbdbce5282" dependencies = [ - "itoa", - "ryu", - "sval", + "itoa", + "ryu", + "sval", ] [[package]] @@ -2730,9 +2730,9 @@ version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "886feb24709f0476baaebbf9ac10671a50163caa7e439d7a7beb7f6d81d0a6fb" dependencies = [ - "sval", - "sval_buffer", - "sval_ref", + "sval", + "sval_buffer", + "sval_ref", ] [[package]] @@ -2741,7 +2741,7 @@ version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be2e7fc517d778f44f8cb64140afa36010999565528d48985f55e64d45f369ce" dependencies = [ - "sval", + "sval", ] [[package]] @@ -2750,9 +2750,9 @@ version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79bf66549a997ff35cd2114a27ac4b0c2843280f2cfa84b240d169ecaa0add46" dependencies = [ - "serde", - "sval", - "sval_nested", + "serde", + "sval", + "sval_nested", ] [[package]] @@ -2761,9 +2761,9 @@ version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] @@ -2772,9 +2772,9 @@ version = "2.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35" dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] @@ -2789,9 +2789,9 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", ] [[package]] @@ -2800,8 +2800,8 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" dependencies = [ - "core-foundation-sys", - "libc", + "core-foundation-sys", + "libc", ] [[package]] @@ -2816,10 +2816,10 @@ version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ - "cfg-if 1.0.0", - "fastrand 2.0.2", - "rustix 0.38.32", - "windows-sys 0.52.0", + "cfg-if 1.0.0", + "fastrand 2.0.2", + "rustix 0.38.32", + "windows-sys 0.52.0", ] [[package]] @@ -2828,7 +2828,7 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ - "winapi-util", + "winapi-util", ] [[package]] @@ -2846,7 +2846,7 @@ version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ - "thiserror-impl", + "thiserror-impl", ] [[package]] @@ -2855,9 +2855,9 @@ version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.57", + "proc-macro2", + "quote", + "syn 2.0.57", ] [[package]] @@ -2867,20 +2867,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c459573f0dd2cc734b539047f57489ea875af8ee950860ded20cf93a79a1dee0" dependencies = [ "async-h1", - "async-session", - "async-sse", - "async-std", - "async-trait", - "femme", - "futures-util", - "http-client", - "http-types", - "kv-log-macro", - "log", - "pin-project-lite 0.2.14", - "route-recognizer", - "serde", - "serde_json", + "async-session", + "async-sse", + "async-std", + "async-trait", + "femme", + "futures-util", + "http-client", + "http-types", + "kv-log-macro", + "log", + "pin-project-lite 0.2.14", + "route-recognizer", + "serde", + "serde_json", ] [[package]] @@ -2888,27 +2888,27 @@ name = "tikv-client" version = "0.3.0" source = "git+https://github.com/FISCO-BCOS/tikv-client-rust.git?rev=de5fb411a10ff92ea75d6cf382a0fdffa8c6955a#de5fb411a10ff92ea75d6cf382a0fdffa8c6955a" dependencies = [ - "async-recursion", - "async-trait", - "derive-new", - "either", - "fail", - "futures", - "lazy_static", - "log", - "pin-project", - "prometheus", - "prost", - "rand 0.8.5", - "regex", - "semver 1.0.22", - "serde", - "serde_derive", - "serde_json", - "take_mut", - "thiserror", - "tokio", - "tonic", + "async-recursion", + "async-trait", + "derive-new", + "either", + "fail", + "futures", + "lazy_static", + "log", + "pin-project", + "prometheus", + "prost", + "rand 0.8.5", + "regex", + "semver 1.0.22", + "serde", + "serde_derive", + "serde_json", + "take_mut", + "thiserror", + "tokio", + "tonic", ] [[package]] @@ -2917,13 +2917,13 @@ version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" dependencies = [ - "const_fn", - "libc", - "standback", - "stdweb", - "time-macros", - "version_check", - "winapi", + "const_fn", + "libc", + "standback", + "stdweb", + "time-macros", + "version_check", + "winapi", ] [[package]] @@ -2942,11 +2942,11 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "standback", - "syn 1.0.109", + "proc-macro-hack", + "proc-macro2", + "quote", + "standback", + "syn 1.0.109", ] [[package]] @@ -2970,15 +2970,15 @@ version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ - "backtrace", - "bytes", - "libc", - "mio", - "num_cpus", - "pin-project-lite 0.2.14", - "socket2 0.5.6", - "tokio-macros", - "windows-sys 0.48.0", + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "pin-project-lite 0.2.14", + "socket2 0.5.6", + "tokio-macros", + "windows-sys 0.48.0", ] [[package]] @@ -2987,8 +2987,8 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" dependencies = [ - "pin-project-lite 0.2.14", - "tokio", + "pin-project-lite 0.2.14", + "tokio", ] [[package]] @@ -2997,9 +2997,9 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.57", + "proc-macro2", + "quote", + "syn 2.0.57", ] [[package]] @@ -3008,8 +3008,8 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" dependencies = [ - "native-tls", - "tokio", + "native-tls", + "tokio", ] [[package]] @@ -3018,8 +3018,8 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls", - "tokio", + "rustls", + "tokio", ] [[package]] @@ -3028,9 +3028,9 @@ version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ - "futures-core", - "pin-project-lite 0.2.14", - "tokio", + "futures-core", + "pin-project-lite 0.2.14", + "tokio", ] [[package]] @@ -3039,12 +3039,12 @@ version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite 0.2.14", - "tokio", - "tracing", + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite 0.2.14", + "tokio", + "tracing", ] [[package]] @@ -3053,28 +3053,28 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" dependencies = [ - "async-stream", - "async-trait", - "axum", - "base64 0.21.7", - "bytes", - "h2", - "http", - "http-body", - "hyper", - "hyper-timeout", - "percent-encoding", - "pin-project", - "prost", - "rustls", - "rustls-pemfile", - "tokio", - "tokio-rustls", - "tokio-stream", - "tower", - "tower-layer", - "tower-service", - "tracing", + "async-stream", + "async-trait", + "axum", + "base64 0.21.7", + "bytes", + "h2", + "http", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost", + "rustls", + "rustls-pemfile", + "tokio", + "tokio-rustls", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", ] [[package]] @@ -3083,18 +3083,18 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ - "futures-core", - "futures-util", - "indexmap 1.9.3", - "pin-project", - "pin-project-lite 0.2.14", - "rand 0.8.5", - "slab", - "tokio", - "tokio-util", - "tower-layer", - "tower-service", - "tracing", + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite 0.2.14", + "rand 0.8.5", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", ] [[package]] @@ -3115,9 +3115,9 @@ version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "pin-project-lite 0.2.14", - "tracing-attributes", - "tracing-core", + "pin-project-lite 0.2.14", + "tracing-attributes", + "tracing-core", ] [[package]] @@ -3126,9 +3126,9 @@ version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.57", + "proc-macro2", + "quote", + "syn 2.0.57", ] [[package]] @@ -3137,7 +3137,7 @@ version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ - "once_cell", + "once_cell", ] [[package]] @@ -3170,7 +3170,7 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ - "tinyvec", + "tinyvec", ] [[package]] @@ -3191,8 +3191,8 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" dependencies = [ - "generic-array", - "subtle", + "generic-array", + "subtle", ] [[package]] @@ -3207,10 +3207,10 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", - "serde", + "form_urlencoded", + "idna", + "percent-encoding", + "serde", ] [[package]] @@ -3219,8 +3219,8 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74797339c3b98616c009c7c3eb53a0ce41e85c8ec66bd3db96ed132d20cfdee8" dependencies = [ - "value-bag-serde1", - "value-bag-sval2", + "value-bag-serde1", + "value-bag-sval2", ] [[package]] @@ -3229,9 +3229,9 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc35703541cbccb5278ef7b589d79439fc808ff0b5867195a3230f9a47421d39" dependencies = [ - "erased-serde", - "serde", - "serde_fmt", + "erased-serde", + "serde", + "serde_fmt", ] [[package]] @@ -3240,13 +3240,13 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "285b43c29d0b4c0e65aad24561baee67a1b69dc9be9375d4a85138cbf556f7f8" dependencies = [ - "sval", - "sval_buffer", - "sval_dynamic", - "sval_fmt", - "sval_json", - "sval_ref", - "sval_serde", + "sval", + "sval_buffer", + "sval_dynamic", + "sval_fmt", + "sval_json", + "sval_ref", + "sval_serde", ] [[package]] @@ -3279,7 +3279,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" dependencies = [ - "try-lock", + "try-lock", ] [[package]] @@ -3300,10 +3300,10 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ - "cfg-if 1.0.0", - "serde", - "serde_json", - "wasm-bindgen-macro", + "cfg-if 1.0.0", + "serde", + "serde_json", + "wasm-bindgen-macro", ] [[package]] @@ -3312,13 +3312,13 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.57", - "wasm-bindgen-shared", + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.57", + "wasm-bindgen-shared", ] [[package]] @@ -3327,10 +3327,10 @@ version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ - "cfg-if 1.0.0", - "js-sys", - "wasm-bindgen", - "web-sys", + "cfg-if 1.0.0", + "js-sys", + "wasm-bindgen", + "web-sys", ] [[package]] @@ -3339,8 +3339,8 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ - "quote", - "wasm-bindgen-macro-support", + "quote", + "wasm-bindgen-macro-support", ] [[package]] @@ -3349,11 +3349,11 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.57", - "wasm-bindgen-backend", - "wasm-bindgen-shared", + "proc-macro2", + "quote", + "syn 2.0.57", + "wasm-bindgen-backend", + "wasm-bindgen-shared", ] [[package]] @@ -3368,8 +3368,8 @@ version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ - "js-sys", - "wasm-bindgen", + "js-sys", + "wasm-bindgen", ] [[package]] @@ -3394,7 +3394,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ - "winapi", + "winapi", ] [[package]] @@ -3409,7 +3409,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.4", ] [[package]] @@ -3418,7 +3418,7 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets 0.42.2", + "windows-targets 0.42.2", ] [[package]] @@ -3427,7 +3427,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.5", + "windows-targets 0.48.5", ] [[package]] @@ -3436,7 +3436,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.4", ] [[package]] @@ -3445,13 +3445,13 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -3460,13 +3460,13 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -3475,13 +3475,13 @@ version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] @@ -3616,8 +3616,8 @@ version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "cfg-if 1.0.0", - "windows-sys 0.48.0", + "cfg-if 1.0.0", + "windows-sys 0.48.0", ] [[package]] @@ -3626,6 +3626,6 @@ version = "2.0.10+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" dependencies = [ - "cc", - "pkg-config", + "cc", + "pkg-config", ] diff --git a/transaction-executor/CMakeLists.txt b/transaction-executor/CMakeLists.txt index 7b09746166..73633f6bc3 100644 --- a/transaction-executor/CMakeLists.txt +++ b/transaction-executor/CMakeLists.txt @@ -10,9 +10,9 @@ find_package(jsoncpp REQUIRED) add_library(transaction-executor bcos-transaction-executor/vm/VMInstance.cpp bcos-transaction-executor/precompiled/PrecompiledManager.cpp - bcos-transaction-executor/precompiled/PrecompiledImpl.cpp - bcos-transaction-executor/vm/HostContext.cpp - bcos-transaction-executor/TransactionExecutorImpl.cpp + bcos-transaction-executor/precompiled/PrecompiledImpl.cpp + bcos-transaction-executor/vm/HostContext.cpp + bcos-transaction-executor/TransactionExecutorImpl.cpp ) target_include_directories(transaction-executor PUBLIC $ diff --git a/transaction-executor/bcos-transaction-executor/TransactionExecutorImpl.h b/transaction-executor/bcos-transaction-executor/TransactionExecutorImpl.h index fb0941879b..567bebe6d7 100644 --- a/transaction-executor/bcos-transaction-executor/TransactionExecutorImpl.h +++ b/transaction-executor/bcos-transaction-executor/TransactionExecutorImpl.h @@ -38,102 +38,86 @@ class TransactionExecutorImpl protocol::BlockHeader const& blockHeader, protocol::Transaction const& transaction, int contextID, ledger::LedgerConfig const& ledgerConfig, auto&& waitOperator) { - int64_t gasLimit{}; protocol::TransactionReceipt::Ptr receipt; - try + if (c_fileLogLevel <= LogLevel::TRACE) { - if (c_fileLogLevel <= LogLevel::TRACE) - { - TRANSACTION_EXECUTOR_LOG(TRACE) - << "Execte transaction: " << toHex(transaction.hash()); - } - - Rollbackable> rollbackableStorage(storage); - gasLimit = static_cast(std::get<0>(ledgerConfig.gasLimit())); - auto evmcMessage = newEVMCMessage(transaction, gasLimit); + TRANSACTION_EXECUTOR_LOG(TRACE) << "Execute transaction: " << toHex(transaction.hash()); + } - if (blockHeader.number() == 0 && - transaction.to() == precompiled::AUTH_COMMITTEE_ADDRESS) - { - evmcMessage.kind = EVMC_CREATE; - } + Rollbackable> rollbackableStorage(storage); + // create a transient storage + using MemoryStorageType = + bcos::storage2::memory_storage::MemoryStorage; + MemoryStorageType transientStorage; + Rollbackable rollbackableTransientStorage(transientStorage); + auto gasLimit = static_cast(std::get<0>(ledgerConfig.gasLimit())); + auto evmcMessage = newEVMCMessage(transaction, gasLimit); + + if (blockHeader.number() == 0 && transaction.to() == precompiled::AUTH_COMMITTEE_ADDRESS) + { + evmcMessage.kind = EVMC_CREATE; + } - int64_t seq = 0; - HostContext hostContext(rollbackableStorage, blockHeader, - evmcMessage, evmcMessage.sender, transaction.abi(), contextID, seq, + int64_t seq = 0; + HostContext + hostContext(rollbackableStorage, rollbackableTransientStorage, blockHeader, evmcMessage, + evmcMessage.sender, transaction.abi(), contextID, seq, executor.m_precompiledManager, ledgerConfig, *executor.m_hashImpl, std::forward(waitOperator)); - waitOperator(hostContext.prepare()); - co_yield receipt; // 完成第一步 Complete the first step - - auto evmcResult = waitOperator(hostContext.execute()); - co_yield receipt; // 完成第二步 Complete the second step - - std::string newContractAddress; - if (evmcMessage.kind == EVMC_CREATE && evmcResult.status_code == EVMC_SUCCESS) - { - newContractAddress.reserve(sizeof(evmcResult.create_address) * 2); - boost::algorithm::hex_lower(evmcResult.create_address.bytes, - evmcResult.create_address.bytes + sizeof(evmcResult.create_address.bytes), - std::back_inserter(newContractAddress)); - } - auto output = bcos::bytesConstRef{evmcResult.output_data, evmcResult.output_size}; + waitOperator(hostContext.prepare()); + co_yield receipt; // 完成第一步 Complete the first step - if (evmcResult.status_code != 0) - { - TRANSACTION_EXECUTOR_LOG(DEBUG) << "Transaction revert: " << evmcResult.status_code; - } + auto evmcResult = waitOperator(hostContext.execute()); + co_yield receipt; // 完成第二步 Complete the second step - int32_t receiptStatus = - evmcResult.status_code == EVMC_REVERT ? - static_cast(protocol::TransactionStatus::RevertInstruction) : - evmcResult.status_code; - auto const& logEntries = hostContext.logs(); - auto transactionVersion = - static_cast(transaction.version()); - switch (transactionVersion) - { - case bcos::protocol::TransactionVersion::V0_VERSION: - receipt = executor.m_receiptFactory.get().createReceipt( - gasLimit - evmcResult.gas_left, newContractAddress, logEntries, receiptStatus, - output, blockHeader.number()); - break; - case bcos::protocol::TransactionVersion::V1_VERSION: - case bcos::protocol::TransactionVersion::V2_VERSION: - receipt = executor.m_receiptFactory.get().createReceipt2( - gasLimit - evmcResult.gas_left, newContractAddress, logEntries, receiptStatus, - output, blockHeader.number(), "", transactionVersion); - break; - default: - BOOST_THROW_EXCEPTION(std::runtime_error( - "Invalid receipt version: " + std::to_string(transaction.version()))); - } - } - catch (NotFoundCodeError& e) + std::string newContractAddress; + if (evmcMessage.kind == EVMC_CREATE && evmcResult.status_code == EVMC_SUCCESS) { - TRANSACTION_EXECUTOR_LOG(DEBUG) - << "Not found code exception: " << boost::diagnostic_information(e); - - receipt = executor.m_receiptFactory.get().createReceipt( - 0, {}, {}, EVMC_REVERT, {}, blockHeader.number()); - receipt->setMessage(boost::diagnostic_information(e)); + newContractAddress.reserve(sizeof(evmcResult.create_address) * 2); + boost::algorithm::hex_lower(evmcResult.create_address.bytes, + evmcResult.create_address.bytes + sizeof(evmcResult.create_address.bytes), + std::back_inserter(newContractAddress)); } - catch (std::exception& e) + auto output = bcos::bytesConstRef{evmcResult.output_data, evmcResult.output_size}; + + if (evmcResult.status_code != 0) { - TRANSACTION_EXECUTOR_LOG(DEBUG) - << "Execute exception: " << boost::diagnostic_information(e); + TRANSACTION_EXECUTOR_LOG(DEBUG) << "Transaction revert: " << evmcResult.status_code; + } - receipt = executor.m_receiptFactory.get().createReceipt( - 0, {}, {}, EVMC_INTERNAL_ERROR, {}, blockHeader.number()); - receipt->setMessage(boost::diagnostic_information(e)); + int32_t receiptStatus = + evmcResult.status_code == EVMC_REVERT ? + static_cast(protocol::TransactionStatus::RevertInstruction) : + evmcResult.status_code; + auto const& logEntries = hostContext.logs(); + auto transactionVersion = + static_cast(transaction.version()); + switch (transactionVersion) + { + case bcos::protocol::TransactionVersion::V0_VERSION: + receipt = executor.m_receiptFactory.get().createReceipt(gasLimit - evmcResult.gas_left, + newContractAddress, logEntries, receiptStatus, output, blockHeader.number()); + break; + case bcos::protocol::TransactionVersion::V1_VERSION: + case bcos::protocol::TransactionVersion::V2_VERSION: + receipt = executor.m_receiptFactory.get().createReceipt2(gasLimit - evmcResult.gas_left, + newContractAddress, logEntries, receiptStatus, output, blockHeader.number(), "", + transactionVersion); + break; + default: + BOOST_THROW_EXCEPTION(std::runtime_error( + "Invalid receipt version: " + std::to_string(transaction.version()))); } if (c_fileLogLevel <= LogLevel::TRACE) { TRANSACTION_EXECUTOR_LOG(TRACE) - << "Execte transaction finished" - << ", gasUsed: " << receipt->gasUsed() + << "Execte transaction finished" << ", gasUsed: " << receipt->gasUsed() << ", newContractAddress: " << receipt->contractAddress() << ", logEntries: " << receipt->logEntries().size() << ", status: " << receipt->status() << ", output: " << toHex(receipt->output()) diff --git a/transaction-executor/bcos-transaction-executor/precompiled/Precompiled.h b/transaction-executor/bcos-transaction-executor/precompiled/Precompiled.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/transaction-executor/bcos-transaction-executor/precompiled/PrecompiledImpl.h b/transaction-executor/bcos-transaction-executor/precompiled/PrecompiledImpl.h index 3980db0e7d..aff37ac1c5 100644 --- a/transaction-executor/bcos-transaction-executor/precompiled/PrecompiledImpl.h +++ b/transaction-executor/bcos-transaction-executor/precompiled/PrecompiledImpl.h @@ -38,8 +38,7 @@ inline auto buildLegacyExecutive(auto& storage, protocol::BlockHeader const& blo storage); auto blockContext = std::make_unique(storageWrapper, nullptr, - executor::GlobalHashImpl::g_hashImpl, blockHeader, bcos::executor::VMSchedule{}, false, - authCheck); + executor::GlobalHashImpl::g_hashImpl, blockHeader, false, authCheck); return std::make_shared< ExecutiveWrapper>>( std::move(blockContext), std::move(contractAddress), contextID, seq, wasm::GasInjector{}, diff --git a/transaction-executor/bcos-transaction-executor/vm/EVMHostInterface.h b/transaction-executor/bcos-transaction-executor/vm/EVMHostInterface.h index affa99df5a..b8b29b6250 100644 --- a/transaction-executor/bcos-transaction-executor/vm/EVMHostInterface.h +++ b/transaction-executor/bcos-transaction-executor/vm/EVMHostInterface.h @@ -51,6 +51,13 @@ struct EVMHostInterface return waitOperator(hostContext.get(key)); } + static evmc_bytes32 getTransientStorage(evmc_host_context* context, + [[maybe_unused]] const evmc_address* addr, const evmc_bytes32* key) noexcept + { + auto& hostContext = static_cast(*context); + return waitOperator(hostContext.getTransientStorage(key)); + } + static evmc_storage_status setStorage(evmc_host_context* context, [[maybe_unused]] const evmc_address* addr, const evmc_bytes32* key, const evmc_bytes32* value) noexcept @@ -67,6 +74,14 @@ struct EVMHostInterface return status; } + static void setTransientStorage(evmc_host_context* context, + [[maybe_unused]] const evmc_address* addr, const evmc_bytes32* key, + const evmc_bytes32* value) noexcept + { + auto& hostContext = static_cast(*context); + waitOperator(hostContext.setTransientStorage(key, value)); + } + static evmc_bytes32 getBalance([[maybe_unused]] evmc_host_context* context, [[maybe_unused]] const evmc_address* addr) noexcept { @@ -153,6 +168,9 @@ struct EVMHostInterface .block_prev_randao = {}, .chain_id = hostContext.chainId(), .block_base_fee = {}, + .blob_base_fee = {}, + .blob_hashes = {}, + .blob_hashes_count = 0, }; return result; } @@ -200,6 +218,8 @@ const evmc_host_interface* getHostInterface(auto&& waitOperator) HostContextImpl::log, HostContextImpl::accessAccount, HostContextImpl::accessStorage, + HostContextImpl::getTransientStorage, + HostContextImpl::setTransientStorage, }; return &fnTable; } diff --git a/transaction-executor/bcos-transaction-executor/vm/HostContext.cpp b/transaction-executor/bcos-transaction-executor/vm/HostContext.cpp index ad5088ef77..95e34a5cf8 100644 --- a/transaction-executor/bcos-transaction-executor/vm/HostContext.cpp +++ b/transaction-executor/bcos-transaction-executor/vm/HostContext.cpp @@ -6,11 +6,6 @@ evmc_bytes32 bcos::transaction_executor::evm_hash_fn(const uint8_t* data, size_t return toEvmC(executor::GlobalHashImpl::g_hashImpl->hash(bytesConstRef(data, size))); } -bcos::executor::VMSchedule const& bcos::transaction_executor::vmSchedule() -{ - return executor::FiscoBcosScheduleV320; -} - std::variant bcos::transaction_executor::getMessage( const evmc_message& inputMessage, protocol::BlockNumber blockNumber, int64_t contextID, int64_t seq, crypto::Hash const& hashImpl) @@ -63,3 +58,19 @@ std::variant bcos::transaction_executor::getM } return message; } + +bcos::transaction_executor::CacheExecutables& bcos::transaction_executor::getCacheExecutables() +{ + struct CacheExecutables + { + bcos::transaction_executor::CacheExecutables m_cachedExecutables; + + CacheExecutables() + { + constexpr static auto maxContracts = 100; + m_cachedExecutables.setMaxCapacity(sizeof(std::shared_ptr) * maxContracts); + } + } static cachedExecutables; + + return cachedExecutables.m_cachedExecutables; +} diff --git a/transaction-executor/bcos-transaction-executor/vm/HostContext.h b/transaction-executor/bcos-transaction-executor/vm/HostContext.h index a680bf5c3d..cac96102b6 100644 --- a/transaction-executor/bcos-transaction-executor/vm/HostContext.h +++ b/transaction-executor/bcos-transaction-executor/vm/HostContext.h @@ -68,8 +68,6 @@ struct NotFoundCodeError : public bcos::Error {}; // clang-format on evmc_bytes32 evm_hash_fn(const uint8_t* data, size_t size); -executor::VMSchedule const& vmSchedule(); -static const auto mode = toRevision(vmSchedule()); std::variant getMessage(const evmc_message& inputMessage, protocol::BlockNumber blockNumber, int64_t contextID, int64_t seq, @@ -77,13 +75,14 @@ std::variant getMessage(const evmc_message& i struct Executable { - explicit Executable(storage::Entry code) + Executable(storage::Entry code, evmc_revision revision) : m_code(std::make_optional(std::move(code))), m_vmInstance(VMFactory::create(VMKind::evmone, - bytesConstRef(reinterpret_cast(m_code->data()), m_code->size()), mode)) + bytesConstRef(reinterpret_cast(m_code->data()), m_code->size()), + revision)) {} - explicit Executable(bytesConstRef code) - : m_vmInstance(VMFactory::create(VMKind::evmone, code, mode)) + explicit Executable(bytesConstRef code, evmc_revision revision) + : m_vmInstance(VMFactory::create(VMKind::evmone, code, revision)) {} std::optional m_code; @@ -93,16 +92,17 @@ struct Executable template using Account = ledger::account::EVMAccount; -inline task::Task> getExecutable( - auto& storage, const evmc_address& address) -{ - static storage2::memory_storage::MemoryStorage, +using CacheExecutables = + storage2::memory_storage::MemoryStorage, storage2::memory_storage::Attribute( storage2::memory_storage::LRU | storage2::memory_storage::CONCURRENT), - std::hash> - cachedExecutables; + std::hash>; +CacheExecutables& getCacheExecutables(); - if (auto executable = co_await storage2::readOne(cachedExecutables, address)) +inline task::Task> getExecutable( + auto& storage, const evmc_address& address, const evmc_revision& revision) +{ + if (auto executable = co_await storage2::readOne(getCacheExecutables(), address)) { co_return std::move(*executable); } @@ -110,18 +110,19 @@ inline task::Task> getExecutable( Account> account(storage, address); if (auto codeEntry = co_await ledger::account::code(account)) { - auto executable = std::make_shared(Executable(std::move(*codeEntry))); - co_await storage2::writeOne(cachedExecutables, address, executable); + auto executable = std::make_shared(Executable(std::move(*codeEntry), revision)); + co_await storage2::writeOne(getCacheExecutables(), address, executable); co_return executable; } co_return std::shared_ptr{}; } -template +template class HostContext : public evmc_host_context { private: std::reference_wrapper m_rollbackableStorage; + std::reference_wrapper m_rollbackableTransientStorage; std::reference_wrapper m_blockHeader; std::reference_wrapper m_origin; std::string_view m_abi; @@ -133,6 +134,7 @@ class HostContext : public evmc_host_context std::variant m_message; Account m_myAccount; + evmc_revision m_revision; std::vector m_logs; std::shared_ptr m_executable; const bcos::transaction_executor::Precompiled* m_preparedPrecompiled{}; @@ -162,7 +164,7 @@ class HostContext : public evmc_host_context { } innerConstructor{}; - HostContext(InnerConstructor /*unused*/, Storage& storage, + HostContext(InnerConstructor /*unused*/, Storage& storage, TransientStorage& transientStorage, const protocol::BlockHeader& blockHeader, const evmc_message& message, const evmc_address& origin, std::string_view abi, int contextID, int64_t& seq, PrecompiledManager const& precompiledManager, ledger::LedgerConfig const& ledgerConfig, @@ -174,6 +176,7 @@ class HostContext : public evmc_host_context .version = 0, .metrics = std::addressof(executor::ethMetrics)}, m_rollbackableStorage(storage), + m_rollbackableTransientStorage(transientStorage), m_blockHeader(blockHeader), m_origin(origin), m_abi(abi), @@ -185,15 +188,25 @@ class HostContext : public evmc_host_context m_message( getMessage(message, m_blockHeader.get().number(), m_contextID, m_seq, m_hashImpl)), m_myAccount(getMyAccount()) - {} + { + if (m_ledgerConfig.get().features().get(ledger::Features::Flag::feature_evm_cancun)) + { + m_revision = EVMC_CANCUN; + } + else + { + m_revision = EVMC_PARIS; + } + } public: - HostContext(Storage& storage, protocol::BlockHeader const& blockHeader, - const evmc_message& message, const evmc_address& origin, std::string_view abi, - int contextID, int64_t& seq, PrecompiledManager const& precompiledManager, - ledger::LedgerConfig const& ledgerConfig, crypto::Hash const& hashImpl, auto&& waitOperator) - : HostContext(innerConstructor, storage, blockHeader, message, origin, abi, contextID, seq, - precompiledManager, ledgerConfig, hashImpl, + HostContext(Storage& storage, TransientStorage& transientStorage, + protocol::BlockHeader const& blockHeader, const evmc_message& message, + const evmc_address& origin, std::string_view abi, int contextID, int64_t& seq, + PrecompiledManager const& precompiledManager, ledger::LedgerConfig const& ledgerConfig, + crypto::Hash const& hashImpl, auto&& waitOperator) + : HostContext(innerConstructor, storage, transientStorage, blockHeader, message, origin, abi, + contextID, seq, precompiledManager, ledgerConfig, hashImpl, getHostInterface(std::forward(waitOperator))) {} @@ -213,9 +226,50 @@ class HostContext : public evmc_host_context co_await ledger::account::setStorage(m_myAccount, *key, *value); } + task::Task getTransientStorage(const evmc_bytes32* key) + { + auto valueEntry = co_await storage2::readOne(m_rollbackableTransientStorage.get(), + transaction_executor::StateKeyView{ + concepts::bytebuffer::toView(co_await ledger::account::path(m_myAccount)), + concepts::bytebuffer::toView(key->bytes)}); + evmc_bytes32 value; + if (valueEntry) + { + auto field = valueEntry->get(); + std::uninitialized_copy_n(field.data(), sizeof(value), value.bytes); + } + else + { + std::uninitialized_fill_n(value.bytes, sizeof(value), 0); + } + if (c_fileLogLevel <= LogLevel::TRACE) + { + HOST_CONTEXT_LOG(TRACE) + << "getTransientStorage:" << LOG_KV("key", concepts::bytebuffer::toView(key->bytes)) + << LOG_KV("value", concepts::bytebuffer::toView(value.bytes)); + } + co_return value; + } + + task::Task setTransientStorage(const evmc_bytes32* key, const evmc_bytes32* value) + { + storage::Entry valueEntry(concepts::bytebuffer::toView(value->bytes)); + StateKey stateKey = + StateKey{concepts::bytebuffer::toView(co_await ledger::account::path(m_myAccount)), + concepts::bytebuffer::toView(key->bytes)}; + if (c_fileLogLevel <= LogLevel::TRACE) + { + HOST_CONTEXT_LOG(TRACE) << "setTransientStorage:" + << LOG_KV("key", concepts::bytebuffer::toView(key->bytes)); + } + co_await storage2::writeOne( + m_rollbackableTransientStorage.get(), stateKey, std::move(valueEntry)); + } + task::Task> code(const evmc_address& address) { - if (auto executable = co_await getExecutable(m_rollbackableStorage.get(), address); + if (auto executable = + co_await getExecutable(m_rollbackableStorage.get(), address, m_revision); executable && executable->m_code) { co_return executable->m_code; @@ -312,6 +366,7 @@ class HostContext : public evmc_host_context } auto savepoint = m_rollbackableStorage.get().current(); + auto transientSavepoint = m_rollbackableTransientStorage.get().current(); std::optional evmResult; if (m_ledgerConfig.get().authCheckStatus() != 0U) { @@ -327,23 +382,63 @@ class HostContext : public evmc_host_context }; } - if (!evmResult) + try { - if (ref.kind == EVMC_CREATE || ref.kind == EVMC_CREATE2) + if (!evmResult) { - evmResult.emplace(co_await executeCreate()); - } - else - { - evmResult.emplace(co_await executeCall()); + if (ref.kind == EVMC_CREATE || ref.kind == EVMC_CREATE2) + { + evmResult.emplace(co_await executeCreate()); + } + else + { + evmResult.emplace(co_await executeCall()); + } } } + catch (NotFoundCodeError& e) + { + HOST_CONTEXT_LOG(DEBUG) + << "Not found code exception: " << boost::diagnostic_information(e); + bcos::codec::abi::ContractABICodec abi(m_hashImpl); + auto codecOutput = abi.abiIn("Error(string)", std::string("Call address error.")); + auto errorBuffer = std::unique_ptr(new uint8_t[codecOutput.size()]); + std::uninitialized_copy(codecOutput.begin(), codecOutput.end(), errorBuffer.get()); + + // Static call或delegate call时,合约不存在要返回EVMC_SUCCESS + // STATIC_CALL or DELEGATE_CALL, the EVMC_SUCCESS is returned when the contract does not + // exist + co_return EVMCResult{evmc_result{ + .status_code = (ref.flags == EVMC_STATIC || ref.kind == EVMC_DELEGATECALL) ? + EVMC_SUCCESS : + (evmc_status_code)protocol::TransactionStatus::CallAddressError, + .gas_left = ref.gas, + .gas_refund = 0, + .output_data = errorBuffer.release(), + .output_size = codecOutput.size(), + .release = [](const struct evmc_result* result) { delete[] result->output_data; }, + .create_address = {}, + .padding = {}}}; + } + catch (std::exception& e) + { + HOST_CONTEXT_LOG(DEBUG) << "Execute exception: " << boost::diagnostic_information(e); + co_return EVMCResult{evmc_result{.status_code = EVMC_INTERNAL_ERROR, + .gas_left = ref.gas, + .gas_refund = 0, + .output_data = nullptr, + .output_size = 0, + .release = nullptr, + .create_address = {}, + .padding = {}}}; + } // 如果本次调用系统合约失败,不消耗gas // If the call to system contract failed, the gasUsed is cleared to zero if (evmResult->status_code != EVMC_SUCCESS) { co_await m_rollbackableStorage.get().rollback(savepoint); + co_await m_rollbackableTransientStorage.get().rollback(transientSavepoint); if (auto hexAddress = address2FixedArray(ref.code_address); bcos::precompiled::c_systemTxsAddress.find(concepts::bytebuffer::toView( @@ -390,40 +485,19 @@ class HostContext : public evmc_host_context << " recipient:" << address2HexString(message.recipient) << " gas:" << message.gas; } - HostContext hostcontext(innerConstructor, m_rollbackableStorage.get(), m_blockHeader, - message, m_origin, {}, m_contextID, m_seq, m_precompiledManager.get(), m_ledgerConfig, - m_hashImpl, interface); + HostContext hostcontext(innerConstructor, m_rollbackableStorage.get(), + m_rollbackableTransientStorage.get(), m_blockHeader, message, m_origin, {}, m_contextID, + m_seq, m_precompiledManager.get(), m_ledgerConfig, m_hashImpl, interface); - try + co_await hostcontext.prepare(); + auto result = co_await hostcontext.execute(); + auto& logs = hostcontext.logs(); + if (result.status_code == EVMC_SUCCESS && !logs.empty()) { - co_await hostcontext.prepare(); - auto result = co_await hostcontext.execute(); - auto& logs = hostcontext.logs(); - if (result.status_code == EVMC_SUCCESS && !logs.empty()) - { - m_logs.reserve(m_logs.size() + RANGES::size(logs)); - RANGES::move(logs, std::back_inserter(m_logs)); - } - co_return result; - } - catch (NotFoundCodeError& e) - { - // Static call或delegate call时,合约不存在要返回EVMC_SUCCESS - // STATIC_CALL or DELEGATE_CALL, the EVMC_SUCCESS is returned when the contract does not - // exist - co_return EVMCResult{evmc_result{ - .status_code = - ((message.flags == EVMC_STATIC || message.kind == EVMC_DELEGATECALL) ? - EVMC_SUCCESS : - EVMC_REVERT), - .gas_left = message.gas, - .gas_refund = 0, - .output_data = nullptr, - .output_size = 0, - .release = nullptr, - .create_address = {}, - .padding = {}}}; + m_logs.reserve(m_logs.size() + RANGES::size(logs)); + RANGES::move(logs, std::back_inserter(m_logs)); } + co_return result; } std::vector& logs() & { return m_logs; } @@ -432,7 +506,7 @@ class HostContext : public evmc_host_context void prepareCreate() { bytesConstRef createCode(message().input_data, message().input_size); - m_executable = std::make_shared(createCode); + m_executable = std::make_shared(createCode, m_revision); } task::Task executeCreate() @@ -446,16 +520,15 @@ class HostContext : public evmc_host_context auto& ref = message(); co_await ledger::account::create(m_myAccount); - auto result = m_executable->m_vmInstance.execute( - interface, this, mode, std::addressof(ref), message().input_data, message().input_size); + auto result = m_executable->m_vmInstance.execute(interface, this, m_revision, + std::addressof(ref), message().input_data, message().input_size); if (result.status_code == 0) { auto code = bytesConstRef(result.output_data, result.output_size); auto codeHash = m_hashImpl.get().hash(code); co_await ledger::account::setCode( m_myAccount, code.toBytes(), std::string(m_abi), codeHash); - - result.gas_left -= result.output_size * vmSchedule().createDataGas; + result.gas_left -= result.output_size * bcos::executor::VMSchedule().createDataGas; result.create_address = message().code_address; // Clear the output @@ -489,7 +562,8 @@ class HostContext : public evmc_host_context } } - m_executable = co_await getExecutable(m_rollbackableStorage.get(), message().code_address); + m_executable = + co_await getExecutable(m_rollbackableStorage.get(), message().code_address, m_revision); if (m_executable && hasPrecompiledPrefix(m_executable->m_code->data())) { if (std::holds_alternative(m_message)) @@ -555,18 +629,19 @@ class HostContext : public evmc_host_context { if (!m_executable) { - m_executable = - co_await getExecutable(m_rollbackableStorage.get(), ref.code_address); + m_executable = co_await getExecutable( + m_rollbackableStorage.get(), ref.code_address, m_revision); } if (!m_executable) { BOOST_THROW_EXCEPTION(NotFoundCodeError()); } - co_return m_executable->m_vmInstance.execute(interface, this, mode, std::addressof(ref), - (const uint8_t*)m_executable->m_code->data(), m_executable->m_code->size()); + co_return m_executable->m_vmInstance.execute(interface, this, m_revision, + std::addressof(ref), (const uint8_t*)m_executable->m_code->data(), + m_executable->m_code->size()); } } }; -} // namespace bcos::transaction_executor +} // namespace bcos::transaction_executor \ No newline at end of file diff --git a/transaction-executor/bcos-transaction-executor/vm/VMInstance.cpp b/transaction-executor/bcos-transaction-executor/vm/VMInstance.cpp index 1610096b85..1dedbe1629 100644 --- a/transaction-executor/bcos-transaction-executor/vm/VMInstance.cpp +++ b/transaction-executor/bcos-transaction-executor/vm/VMInstance.cpp @@ -1,4 +1,6 @@ #include "VMInstance.h" +#include "bcos-transaction-executor/TransactionExecutorImpl.h" +using bytes_view = std::basic_string_view; bcos::transaction_executor::VMInstance::VMInstance( std::shared_ptr instance) noexcept @@ -10,20 +12,17 @@ bcos::transaction_executor::EVMCResult bcos::transaction_executor::VMInstance::e const evmc_message* msg, const uint8_t* code, size_t codeSize) { static auto const* evm = evmc_create_evmone(); - static thread_local std::unique_ptr - localExecutionState; + static thread_local std::unique_ptr localExecutionState; auto executionState = std::move(localExecutionState); if (!executionState) { - executionState = std::make_unique(); + executionState = std::make_unique(); } - executionState->reset( - *msg, rev, *host, context, std::basic_string_view(code, codeSize)); + *msg, rev, *host, context, std::basic_string_view(code, codeSize), {}); auto result = EVMCResult(evmone::baseline::execute( *static_cast(evm), msg->gas, *executionState, *m_instance)); - if (!localExecutionState) { localExecutionState = std::move(executionState); diff --git a/transaction-executor/tests/StorageContract.sol b/transaction-executor/tests/StorageContract.sol new file mode 100644 index 0000000000..a34a8a7685 --- /dev/null +++ b/transaction-executor/tests/StorageContract.sol @@ -0,0 +1,113 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +import "./StorageSlot.sol"; + +contract StorageContract { + using StorageSlot for *; + + StorageSlot.AddressSlotType private addressSlot = StorageSlot.asAddress(keccak256("address_slot")); + StorageSlot.BooleanSlotType private booleanSlot = StorageSlot.asBoolean(keccak256("boolean_slot")); + StorageSlot.Bytes32SlotType private bytes32Slot = StorageSlot.asBytes32(keccak256("bytes32_slot")); + StorageSlot.Uint256SlotType private uint256Slot = StorageSlot.asUint256(keccak256("uint256_slot")); + StorageSlot.Int256SlotType private int256Slot = StorageSlot.asInt256(keccak256("int256_slot")); + + function setAddress(address _value) public { + addressSlot.tstore(_value); + } + + function getAddress() public view returns (address) { + return addressSlot.tload(); + } + + function setBoolean(bool _value) public { + booleanSlot.tstore(_value); + } + + function getBoolean() public view returns (bool) { + return booleanSlot.tload(); + } + + function setBytes32(bytes32 _value) public { + bytes32Slot.tstore(_value); + } + + function getBytes32() public view returns (bytes32) { + return bytes32Slot.tload(); + } + + function setUint256(uint256 _value) public { + uint256Slot.tstore(_value); + } + + function getUint256() public view returns (uint256) { + return uint256Slot.tload(); + } + + function setInt256(int256 _value) public { + int256Slot.tstore(_value); + } + + function getInt256() public view returns (int256) { + return int256Slot.tload(); + } + + function storeIntTest(int256 _value) public returns (int256) { + int256Slot.tstore(_value); + return int256Slot.tload(); + } +} +// Path: transaction-executor/tests/ContractA.sol +pragma solidity ^0.8.25; + +import "./StorageSlot.sol"; +import "./ContractB.sol"; + +contract ContractA { + using StorageSlot for *; + + StorageSlot.Int256SlotType private intSlot; + constructor(int256 value){ + StorageSlot.tstore(intSlot, value); + } + + function getData() public view returns (int256) { + return StorageSlot.tload(intSlot); + } + + function callContractB() public returns (int256){ + ContractB b = new ContractB(); + return b.callContractA(address(this)); + } + +} + +// Path: transaction-executor/tests/ContractA.sol +import "./StorageSlot.sol"; +import "./ContractA.sol"; + + +contract ContractB { + + function callContractA(address a) public returns (int256){ + ContractA a = ContractA(a); + int256 result = a.getData(); + return result; + } + +} +// Path: transaction-executor/tests/MainContract.sol +import "./StorageSlot.sol"; +import "./ContractA.sol"; +import "./ContractB.sol"; + +contract MainContract { + + + function checkAndVerifyIntValue(int256 value) public returns (bool) { + ContractA a = new ContractA(value); + int256 result = a.callContractB(); + require(result == value, "store value not equal tload result"); + return true; + } +} \ No newline at end of file diff --git a/transaction-executor/tests/StorageSlot.sol b/transaction-executor/tests/StorageSlot.sol new file mode 100644 index 0000000000..56c13ef290 --- /dev/null +++ b/transaction-executor/tests/StorageSlot.sol @@ -0,0 +1,193 @@ +pragma solidity ^0.8.24; + +library StorageSlot { + struct AddressSlot { + address value; + } + + struct BooleanSlot { + bool value; + } + + struct Bytes32Slot { + bytes32 value; + } + + struct Uint256Slot { + uint256 value; + } + + struct Int256Slot { + int256 value; + } + + struct StringSlot { + string value; + } + + struct BytesSlot { + bytes value; + } + + function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { + assembly { + r.slot := slot + } + } + + function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { + /// @solidity memory-safe-assembly + assembly { + r.slot := slot + } + } + + function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { + /// @solidity memory-safe-assembly + assembly { + r.slot := slot + } + } + + function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { + /// @solidity memory-safe-assembly + assembly { + r.slot := slot + } + } + + function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) { + /// @solidity memory-safe-assembly + assembly { + r.slot := slot + } + } + + function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { + /// @solidity memory-safe-assembly + assembly { + r.slot := slot + } + } + + function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { + /// @solidity memory-safe-assembly + assembly { + r.slot := store.slot + } + } + + function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { + /// @solidity memory-safe-assembly + assembly { + r.slot := slot + } + } + + function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { + /// @solidity memory-safe-assembly + assembly { + r.slot := store.slot + } + } + + type AddressSlotType is bytes32; + + function asAddress(bytes32 slot) internal pure returns (AddressSlotType) { + return AddressSlotType.wrap(slot); + } + + type BooleanSlotType is bytes32; + + function asBoolean(bytes32 slot) internal pure returns (BooleanSlotType) { + return BooleanSlotType.wrap(slot); + } + + type Bytes32SlotType is bytes32; + + function asBytes32(bytes32 slot) internal pure returns (Bytes32SlotType) { + return Bytes32SlotType.wrap(slot); + } + + type Uint256SlotType is bytes32; + + function asUint256(bytes32 slot) internal pure returns (Uint256SlotType) { + return Uint256SlotType.wrap(slot); + } + + type Int256SlotType is bytes32; + + function asInt256(bytes32 slot) internal pure returns (Int256SlotType) { + return Int256SlotType.wrap(slot); + } + + function tload(AddressSlotType slot) internal view returns (address value) { + /// @solidity memory-safe-assembly + assembly { + value := tload(slot) + } + } + + function tstore(AddressSlotType slot, address value) internal { + /// @solidity memory-safe-assembly + assembly { + tstore(slot, value) + } + } + + function tload(BooleanSlotType slot) internal view returns (bool value) { + /// @solidity memory-safe-assembly + assembly { + value := tload(slot) + } + } + + function tstore(BooleanSlotType slot, bool value) internal { + /// @solidity memory-safe-assembly + assembly { + tstore(slot, value) + } + } + + function tload(Bytes32SlotType slot) internal view returns (bytes32 value) { + /// @solidity memory-safe-assembly + assembly { + value := tload(slot) + } + } + + function tstore(Bytes32SlotType slot, bytes32 value) internal { + /// @solidity memory-safe-assembly + assembly { + tstore(slot, value) + } + } + + function tload(Uint256SlotType slot) internal view returns (uint256 value) { + /// @solidity memory-safe-assembly + assembly { + value := tload(slot) + } + } + + function tstore(Uint256SlotType slot, uint256 value) internal { + /// @solidity memory-safe-assembly + assembly { + tstore(slot, value) + } + } + + function tload(Int256SlotType slot) internal view returns (int256 value) { + /// @solidity memory-safe-assembly + assembly { + value := tload(slot) + } + } + + function tstore(Int256SlotType slot, int256 value) internal { + /// @solidity memory-safe-assembly + assembly { + tstore(slot, value) + } + } +} \ No newline at end of file diff --git a/transaction-executor/tests/TestBytecode.h b/transaction-executor/tests/TestBytecode.h index 702cb47eb6..d944e08a98 100644 --- a/transaction-executor/tests/TestBytecode.h +++ b/transaction-executor/tests/TestBytecode.h @@ -100,3 +100,96 @@ constexpr static std::string_view helloworldBytecode = "91905056fea2646970667358221220e9141740b756058419edad30ed9f3b98314f47beee1c386ba04f8485ae35d717" "64736f6c634300080a0033a26469706673582212200692dc7416f6db8191416414b44b00119f89a987f74b784a6e50" "264d2d9bca4d64736f6c634300080a0033"; + +constexpr static std::string_view transientStorageBytecode = + "60806040526100337fbad128a9c9f118267291de46fed9cb24d9fbbe19a927cfee43cdc3b8e4eba17161010e60201b" + "60201c565b5f556100647fe51529ae218841954601d43f697e9bb24b282c1a2ddf95745a7e79ee1b4b7b7d61011760" + "201b60201c565b6001556100967f5d4010ae4473cd3ede543746d54ec6f990232434c2d4884f06e3cc4ac77168e561" + "012060201b60201c565b6002556100c87fb734117ebc01eac75f020b05b2620ab71735dfa2175ac8e98f85bd7f529b" + "b96f61012960201b60201c565b6003556100fa7feb7753d6e9a22bf47d9682cdc6f111b5defde6c206047689bad231" + "20af3743bd61013260201b60201c565b600455348015610108575f80fd5b5061013b565b5f819050919050565b5f81" + "9050919050565b5f819050919050565b5f819050919050565b5f819050919050565b610653806101485f395ff3fe60" + "8060405234801561000f575f80fd5b50600436106100a7575f3560e01c8063a65e939e1161006f578063a65e939e14" + "610153578063c2b12a7314610183578063d2282dc51461019f578063e30081a0146101bb578063f5b53e17146101d7" + "578063f8462a0f146101f5576100a7565b80631f903037146100ab5780632d1be94d146100c957806338cc48311461" + "00e75780636889597914610105578063a53b1c1e14610123575b5f80fd5b6100b3610211565b6040516100c0919061" + "036a565b60405180910390f35b6100d1610222565b6040516100de919061039d565b60405180910390f35b6100ef61" + "0233565b6040516100fc91906103f5565b60405180910390f35b61010d610243565b60405161011a9190610426565b" + "60405180910390f35b61013d60048036038101906101389190610476565b610254565b60405161014a919061039d56" + "5b60405180910390f35b61016d60048036038101906101689190610476565b610273565b60405161017a91906104b0" + "565b60405180910390f35b61019d600480360381019061019891906104f3565b61028d565b005b6101b96004803603" + "8101906101b49190610548565b6102a5565b005b6101d560048036038101906101d0919061059d565b6102bd565b00" + "5b6101df6102d4565b6040516101ec91906104b0565b60405180910390f35b61020f600480360381019061020a9190" + "6105f2565b6102e5565b005b5f61021d6002546102fd565b905090565b5f61022e600154610307565b905090565b5f" + "61023e5f54610311565b905090565b5f61024f60035461031b565b905090565b5f61026a8260045461032590919063" + "ffffffff16565b60019050919050565b5f61027d82610254565b506102866102d4565b9050919050565b6102a28160" + "025461032c90919063ffffffff16565b50565b6102ba8160035461033390919063ffffffff16565b50565b6102d181" + "5f5461033a90919063ffffffff16565b50565b5f6102e0600454610341565b905090565b6102fa8160015461034b90" + "919063ffffffff16565b50565b5f815c9050919050565b5f815c9050919050565b5f815c9050919050565b5f815c90" + "50919050565b80825d5050565b80825d5050565b80825d5050565b80825d5050565b5f815c9050919050565b80825d" + "5050565b5f819050919050565b61036481610352565b82525050565b5f60208201905061037d5f83018461035b565b" + "92915050565b5f8115159050919050565b61039781610383565b82525050565b5f6020820190506103b05f83018461" + "038e565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6103df8261" + "03b6565b9050919050565b6103ef816103d5565b82525050565b5f6020820190506104085f8301846103e6565b9291" + "5050565b5f819050919050565b6104208161040e565b82525050565b5f6020820190506104395f830184610417565b" + "92915050565b5f80fd5b5f819050919050565b61045581610443565b811461045f575f80fd5b50565b5f8135905061" + "04708161044c565b92915050565b5f6020828403121561048b5761048a61043f565b5b5f6104988482850161046256" + "5b91505092915050565b6104aa81610443565b82525050565b5f6020820190506104c35f8301846104a1565b929150" + "50565b6104d281610352565b81146104dc575f80fd5b50565b5f813590506104ed816104c9565b92915050565b5f60" + "2082840312156105085761050761043f565b5b5f610515848285016104df565b91505092915050565b610527816104" + "0e565b8114610531575f80fd5b50565b5f813590506105428161051e565b92915050565b5f6020828403121561055d" + "5761055c61043f565b5b5f61056a84828501610534565b91505092915050565b61057c816103d5565b811461058657" + "5f80fd5b50565b5f8135905061059781610573565b92915050565b5f602082840312156105b2576105b161043f565b" + "5b5f6105bf84828501610589565b91505092915050565b6105d181610383565b81146105db575f80fd5b50565b5f81" + "3590506105ec816105c8565b92915050565b5f602082840312156106075761060661043f565b5b5f61061484828501" + "6105de565b9150509291505056fea2646970667358221220d88517d2dffabcb325b3b34f932814eb3c9b3a6167aa58" + "814fcc57b116d57fbb64736f6c63430008190033"; + +constexpr static std::string_view transientStorageContractTestByteCode = + "6080604052348015600e575f80fd5b506108748061001c5f395ff3fe608060405234801561000f575f80fd5b506004" + "3610610029575f3560e01c8063fa3e317e1461002d575b5f80fd5b6100476004803603810190610042919061019456" + "5b61005d565b60405161005491906101d9565b60405180910390f35b5f808260405161006c90610150565b61007691" + "90610201565b604051809103905ff08015801561008f573d5f803e3d5ffd5b5090505f8173ffffffffffffffffffff" + "ffffffffffffffffffff16636428f3dc6040518163ffffffff1660e01b81526004016020604051808303815f875af1" + "1580156100dd573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610101919061" + "022e565b9050838114610145576040517f08c379a00000000000000000000000000000000000000000000000000000" + "0000815260040161013c906102d9565b60405180910390fd5b600192505050919050565b610547806102f883390190" + "565b5f80fd5b5f819050919050565b61017381610161565b811461017d575f80fd5b50565b5f8135905061018e8161" + "016a565b92915050565b5f602082840312156101a9576101a861015d565b5b5f6101b684828501610180565b915050" + "92915050565b5f8115159050919050565b6101d3816101bf565b82525050565b5f6020820190506101ec5f83018461" + "01ca565b92915050565b6101fb81610161565b82525050565b5f6020820190506102145f8301846101f2565b929150" + "50565b5f815190506102288161016a565b92915050565b5f602082840312156102435761024261015d565b5b5f6102" + "508482850161021a565b91505092915050565b5f82825260208201905092915050565b7f73746f72652076616c7565" + "206e6f7420657175616c20746c6f616420726573755f8201527f6c7400000000000000000000000000000000000000" + "0000000000000000000000602082015250565b5f6102c3602283610259565b91506102ce82610269565b6040820190" + "50919050565b5f6020820190508181035f8301526102f0816102b7565b905091905056fe6080604052348015600e57" + "5f80fd5b506040516105473803806105478339818101604052810190602e9190607b565b603d5f5482604260201b60" + "201c565b5060a1565b80825d5050565b5f80fd5b5f819050919050565b605d81604d565b81146066575f80fd5b5056" + "5b5f815190506075816056565b92915050565b5f60208284031215608d57608c6049565b5b5f609884828501606956" + "5b91505092915050565b610499806100ae5f395ff3fe608060405234801561000f575f80fd5b506004361061003457" + "5f3560e01c80633bc5de30146100385780636428f3dc14610056575b5f80fd5b610040610074565b60405161004d91" + "9061015c565b60405180910390f35b61005e610084565b60405161006b919061015c565b60405180910390f35b5f61" + "007f5f5461012d565b905090565b5f8060405161009290610137565b604051809103905ff0801580156100ab573d5f" + "803e3d5ffd5b5090508073ffffffffffffffffffffffffffffffffffffffff1663c1df0f48306040518263ffffffff" + "1660e01b81526004016100e791906101b4565b6020604051808303815f875af1158015610103573d5f803e3d5ffd5b" + "505050506040513d601f19601f8201168201806040525081019061012791906101fb565b91505090565b5f815c9050" + "919050565b61023d8061022783390190565b5f819050919050565b61015681610144565b82525050565b5f60208201" + "905061016f5f83018461014d565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff8216905091" + "9050565b5f61019e82610175565b9050919050565b6101ae81610194565b82525050565b5f6020820190506101c75f" + "8301846101a5565b92915050565b5f80fd5b6101da81610144565b81146101e4575f80fd5b50565b5f815190506101" + "f5816101d1565b92915050565b5f602082840312156102105761020f6101cd565b5b5f61021d848285016101e7565b" + "9150509291505056fe6080604052348015600e575f80fd5b506102218061001c5f395ff3fe60806040523480156100" + "0f575f80fd5b5060043610610029575f3560e01c8063c1df0f481461002d575b5f80fd5b6100476004803603810190" + "610042919061013a565b61005d565b604051610054919061017d565b60405180910390f35b5f808290505f8173ffff" + "ffffffffffffffffffffffffffffffffffff16633bc5de306040518163ffffffff1660e01b81526004016020604051" + "80830381865afa1580156100ac573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101" + "906100d091906101c0565b90508092505050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffff" + "ffff82169050919050565b5f610109826100e0565b9050919050565b610119816100ff565b8114610123575f80fd5b" + "50565b5f8135905061013481610110565b92915050565b5f6020828403121561014f5761014e6100dc565b5b5f6101" + "5c84828501610126565b91505092915050565b5f819050919050565b61017781610165565b82525050565b5f602082" + "0190506101905f83018461016e565b92915050565b61019f81610165565b81146101a9575f80fd5b50565b5f815190" + "506101ba81610196565b92915050565b5f602082840312156101d5576101d46100dc565b5b5f6101e2848285016101" + "ac565b9150509291505056fea2646970667358221220b74855b53bcf2b3cc2261d3f57e16507da8b24f81ff5196991" + "91e34ce025bc8664736f6c63430008190033a26469706673582212201eb1e02998c84b08c3db1bdb2487184ca8357f" + "1d2739ec65daa47ffe3e89316a64736f6c63430008190033a2646970667358221220bad0e7bec379be9bb4f446b845" + "050f59959e8bd9da49d83f3c9f669a63e5e51e64736f6c63430008190033"; \ No newline at end of file diff --git a/transaction-executor/tests/TestHostContext.cpp b/transaction-executor/tests/TestHostContext.cpp index f8f3a78700..ceb05f55fe 100644 --- a/transaction-executor/tests/TestHostContext.cpp +++ b/transaction-executor/tests/TestHostContext.cpp @@ -39,12 +39,21 @@ class TestHostContextFixture bcos::crypto::Hash::Ptr hashImpl = std::make_shared(); MutableStorage storage; Rollbackable rollbackableStorage; + using MemoryStorageType = + bcos::storage2::memory_storage::MemoryStorage; + MemoryStorageType transientStorage; + Rollbackable rollbackableTransientStorage; evmc_address helloworldAddress; int64_t seq = 0; std::optional precompiledManager; bcos::ledger::LedgerConfig ledgerConfig; - TestHostContextFixture() : rollbackableStorage(storage) + TestHostContextFixture() + : rollbackableStorage(storage), rollbackableTransientStorage(transientStorage) { bcos::executor::GlobalHashImpl::g_hashImpl = std::make_shared(); precompiledManager.emplace(hashImpl); @@ -75,9 +84,10 @@ class TestHostContextFixture .code_address = {}}; evmc_address origin = {}; - HostContext hostContext(rollbackableStorage, blockHeader, - message, origin, "", 0, seq, *precompiledManager, ledgerConfig, *hashImpl, - bcos::task::syncWait); + HostContext + hostContext(rollbackableStorage, rollbackableTransientStorage, blockHeader, message, + origin, "", 0, seq, *precompiledManager, ledgerConfig, *hashImpl, + bcos::task::syncWait); syncWait(hostContext.prepare()); auto result = syncWait(hostContext.execute()); BOOST_REQUIRE_EQUAL(result.status_code, 0); @@ -117,9 +127,10 @@ class TestHostContextFixture .code_address = address}; evmc_address origin = {}; - HostContext hostContext(rollbackableStorage, blockHeader, - message, origin, "", 0, seq, *precompiledManager, ledgerConfig, *hashImpl, - bcos::task::syncWait); + HostContext + hostContext(rollbackableStorage, rollbackableTransientStorage, blockHeader, message, + origin, "", 0, seq, *precompiledManager, ledgerConfig, *hashImpl, + bcos::task::syncWait); co_await hostContext.prepare(); auto result = co_await hostContext.execute(); @@ -348,9 +359,10 @@ BOOST_AUTO_TEST_CASE(precompiled) .code_address = callAddress}; evmc_address origin = {}; - HostContext hostContext(rollbackableStorage, blockHeader, - message, origin, "", 0, seq, *precompiledManager, ledgerConfig, *hashImpl, - bcos::task::syncWait); + HostContext + hostContext(rollbackableStorage, rollbackableTransientStorage, blockHeader, message, + origin, "", 0, seq, *precompiledManager, ledgerConfig, *hashImpl, + bcos::task::syncWait); syncWait(hostContext.prepare()); BOOST_CHECK_NO_THROW(auto result = syncWait(hostContext.execute())); } @@ -379,19 +391,28 @@ BOOST_AUTO_TEST_CASE(precompiled) .code_address = callAddress}; evmc_address origin = {}; - HostContext hostContext(rollbackableStorage, blockHeader, - message, origin, "", 0, seq, *precompiledManager, ledgerConfig, *hashImpl, - bcos::task::syncWait); + HostContext + hostContext(rollbackableStorage, rollbackableTransientStorage, blockHeader, message, + origin, "", 0, seq, *precompiledManager, ledgerConfig, *hashImpl, + bcos::task::syncWait); syncWait(hostContext.prepare()); - BOOST_CHECK_THROW(result.emplace(syncWait(hostContext.execute())), - bcos::transaction_executor::NotFoundCodeError); + auto notFoundResult = syncWait(hostContext.execute()); + BOOST_CHECK_EQUAL(notFoundResult.status_code, + (evmc_status_code)bcos::protocol::TransactionStatus::CallAddressError); + + bcos::codec::abi::ContractABICodec abi(*hashImpl); + std::string errorMessage; + BOOST_REQUIRE_GT(notFoundResult.output_size, 4); + abi.abiOut({notFoundResult.output_data + 4, notFoundResult.output_size - 4}, errorMessage); + BOOST_CHECK_EQUAL(errorMessage, "Call address error."); auto& features = const_cast(ledgerConfig.features()); features.set(bcos::ledger::Features::Flag::feature_sharding); - HostContext hostContext2(rollbackableStorage, blockHeader, - message, origin, "", 0, seq, *precompiledManager, ledgerConfig, *hashImpl, - bcos::task::syncWait); + HostContext + hostContext2(rollbackableStorage, rollbackableTransientStorage, blockHeader, message, + origin, "", 0, seq, *precompiledManager, ledgerConfig, *hashImpl, + bcos::task::syncWait); syncWait(hostContext2.prepare()); BOOST_CHECK_NO_THROW(result.emplace(syncWait(hostContext2.execute()))); } @@ -447,9 +468,10 @@ BOOST_AUTO_TEST_CASE(codeSize) evmc_message message{}; - HostContext codeSizeHostContext(rollbackableStorage, - blockHeader, message, {}, "", 0, seq, *precompiledManager, ledgerConfig, *hashImpl, - bcos::task::syncWait); + HostContext + codeSizeHostContext(rollbackableStorage, rollbackableTransientStorage, blockHeader, + message, {}, "", 0, seq, *precompiledManager, ledgerConfig, *hashImpl, + bcos::task::syncWait); auto builtinAddress = bcos::unhexAddress("0000000000000000000000000000000000000001"); auto size = co_await codeSizeHostContext.codeSizeAt(builtinAddress); diff --git a/transaction-executor/tests/TestTransactionExecutor.cpp b/transaction-executor/tests/TestTransactionExecutor.cpp index a3cb07586e..b4f3593875 100644 --- a/transaction-executor/tests/TestTransactionExecutor.cpp +++ b/transaction-executor/tests/TestTransactionExecutor.cpp @@ -73,5 +73,98 @@ BOOST_AUTO_TEST_CASE(execute) BOOST_CHECK_EQUAL(getIntResult, 10099); }()); } +BOOST_AUTO_TEST_CASE(transientStorageTest) +{ + task::syncWait([this]() mutable -> task::Task { + MutableStorage storage; + + auto cryptoSuite = std::make_shared( + bcos::executor::GlobalHashImpl::g_hashImpl, nullptr, nullptr); + bcostars::protocol::TransactionReceiptFactoryImpl receiptFactory(cryptoSuite); + + bcos::transaction_executor::TransactionExecutorImpl executor( + receiptFactory, bcos::executor::GlobalHashImpl::g_hashImpl); + bcostars::protocol::BlockHeaderImpl blockHeader( + [inner = bcostars::BlockHeader()]() mutable { return std::addressof(inner); }); + blockHeader.setVersion((uint32_t)bcos::protocol::BlockVersion::V3_7_0_VERSION); + blockHeader.calculateHash(*bcos::executor::GlobalHashImpl::g_hashImpl); + + bcostars::protocol::TransactionFactoryImpl transactionFactory(cryptoSuite); + + // turn on evm_cancun feature + ledger::Features features; + features.set(ledger::Features::Flag::feature_evm_cancun); + ledgerConfig.setFeatures(features); + + bcos::bytes transientStorageBinary; + boost::algorithm::unhex( + transientStorageBytecode, std::back_inserter(transientStorageBinary)); + // First deploy + auto transaction = + transactionFactory.createTransaction(0, "", transientStorageBinary, {}, 0, "", "", 0); + auto receipt = co_await bcos::transaction_executor::executeTransaction( + executor, storage, blockHeader, *transaction, 3, ledgerConfig, task::syncWait); + BOOST_CHECK_EQUAL(receipt->status(), 0); + + // test read and write transient storage + bcos::codec::abi::ContractABICodec abiCodec(*bcos::executor::GlobalHashImpl::g_hashImpl); + auto input = abiCodec.abiIn("storeIntTest(int256)", bcos::s256(10000)); + auto transaction2 = transactionFactory.createTransaction( + 0, std::string(receipt->contractAddress()), input, {}, 0, "", "", 0); + auto receipt2 = co_await bcos::transaction_executor::executeTransaction( + executor, storage, blockHeader, *transaction2, 4, ledgerConfig, task::syncWait); + BOOST_CHECK_EQUAL(receipt2->status(), 0); + bcos::s256 getIntResult = -1; + abiCodec.abiOut(receipt2->output(), getIntResult); + BOOST_CHECK_EQUAL(getIntResult, 10000); + }()); +} + +BOOST_AUTO_TEST_CASE(transientStorageContractTest) +{ + task::syncWait([this]() mutable -> task::Task { + MutableStorage storage; + + auto cryptoSuite = std::make_shared( + bcos::executor::GlobalHashImpl::g_hashImpl, nullptr, nullptr); + bcostars::protocol::TransactionReceiptFactoryImpl receiptFactory(cryptoSuite); + + bcos::transaction_executor::TransactionExecutorImpl executor( + receiptFactory, bcos::executor::GlobalHashImpl::g_hashImpl); + bcostars::protocol::BlockHeaderImpl blockHeader( + [inner = bcostars::BlockHeader()]() mutable { return std::addressof(inner); }); + blockHeader.setVersion((uint32_t)bcos::protocol::BlockVersion::V3_1_VERSION); + blockHeader.calculateHash(*bcos::executor::GlobalHashImpl::g_hashImpl); + + bcostars::protocol::TransactionFactoryImpl transactionFactory(cryptoSuite); + + // turn on evm_cancun feature + ledger::Features features; + features.set(ledger::Features::Flag::feature_evm_cancun); + ledgerConfig.setFeatures(features); + + bcos::bytes transientStorageBinary; + boost::algorithm::unhex( + transientStorageContractTestByteCode, std::back_inserter(transientStorageBinary)); + // First deploy + auto transaction = + transactionFactory.createTransaction(0, "", transientStorageBinary, {}, 0, "", "", 0); + auto receipt = co_await bcos::transaction_executor::executeTransaction( + executor, storage, blockHeader, *transaction, 5, ledgerConfig, task::syncWait); + BOOST_CHECK_EQUAL(receipt->status(), 0); + + // test read and write transient storage + bcos::codec::abi::ContractABICodec abiCodec(*bcos::executor::GlobalHashImpl::g_hashImpl); + auto input = abiCodec.abiIn("checkAndVerifyIntValue(int256)", bcos::h256(12345)); + auto transaction2 = transactionFactory.createTransaction( + 0, std::string(receipt->contractAddress()), input, {}, 0, "", "", 0); + auto receipt2 = co_await bcos::transaction_executor::executeTransaction( + executor, storage, blockHeader, *transaction2, 6, ledgerConfig, task::syncWait); + BOOST_CHECK_EQUAL(receipt2->status(), 0); + bool checkResult = false; + abiCodec.abiOut(receipt2->output(), checkResult); + BOOST_CHECK_EQUAL(checkResult, true); + }()); +} BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file diff --git a/transaction-scheduler/bcos-transaction-scheduler/SchedulerParallelImpl.h b/transaction-scheduler/bcos-transaction-scheduler/SchedulerParallelImpl.h index d1d29d3aa0..4d84243676 100644 --- a/transaction-scheduler/bcos-transaction-scheduler/SchedulerParallelImpl.h +++ b/transaction-scheduler/bcos-transaction-scheduler/SchedulerParallelImpl.h @@ -40,7 +40,7 @@ struct ExecutionContext { ExecutionContext(int contextID, std::reference_wrapper transaction, std::reference_wrapper receipt, - std::optional coro, typename CoroType::Iterator iterator) + std::optional coro, std::optionalbegin())> iterator) : contextID(contextID), transaction(transaction), receipt(receipt), @@ -51,7 +51,7 @@ struct ExecutionContext std::reference_wrapper transaction; std::reference_wrapper receipt; std::optional coro; - typename CoroType::Iterator iterator; + std::optionalbegin())> iterator; }; template @@ -101,8 +101,8 @@ class ChunkStatus context.coro.emplace(transaction_executor::execute3Step(m_executor.get(), m_readWriteSetStorage, blockHeader, context.transaction.get(), context.contextID, ledgerConfig, task::tbb::syncWait)); - context.iterator = context.coro->begin(); - context.receipt.get() = *context.iterator; + context.iterator.emplace(context.coro->begin()); + context.receipt.get() = *(*context.iterator); } } @@ -119,9 +119,9 @@ class ChunkStatus << " transactions"; break; } - if (!context.receipt.get() && context.iterator != context.coro->end()) + if (!context.receipt.get() && *context.iterator != context.coro->end()) { - context.receipt.get() = *(++context.iterator); + context.receipt.get() = *(++(*context.iterator)); } } } @@ -132,9 +132,9 @@ class ChunkStatus ittapi::ITT_DOMAINS::instance().EXECUTE_CHUNK3); for (auto& context : m_contextRange) { - if (!context.receipt.get() && context.iterator != context.coro->end()) + if (!context.receipt.get() && *context.iterator != context.coro->end()) { - context.receipt.get() = *(++context.iterator); + context.receipt.get() = *(++(*context.iterator)); } } } diff --git a/transaction-scheduler/bcos-transaction-scheduler/SchedulerSerialImpl.h b/transaction-scheduler/bcos-transaction-scheduler/SchedulerSerialImpl.h index a729ea013b..4a1947833d 100644 --- a/transaction-scheduler/bcos-transaction-scheduler/SchedulerSerialImpl.h +++ b/transaction-scheduler/bcos-transaction-scheduler/SchedulerSerialImpl.h @@ -38,7 +38,7 @@ class SchedulerSerialImpl struct ExecutionContext { std::optional coro; - typename CoroType::Iterator iterator; + std::optionalbegin())> iterator; protocol::TransactionReceipt::Ptr receipt; }; @@ -76,8 +76,8 @@ class SchedulerSerialImpl coro.emplace( transaction_executor::execute3Step(executor, storage, blockHeader, transactions[i], i, ledgerConfig, task::tbb::syncWait)); - iterator = coro->begin(); - receipt = *iterator; + iterator.emplace(coro->begin()); + receipt = *(*iterator); } return range; }) & @@ -90,7 +90,7 @@ class SchedulerSerialImpl auto& [coro, iterator, receipt] = contexts[i]; if (!receipt) { - receipt = *(++iterator); + receipt = *(++(*iterator)); } } return range; @@ -104,7 +104,7 @@ class SchedulerSerialImpl auto& [coro, iterator, receipt] = contexts[i]; if (!receipt) { - receipt = *(++iterator); + receipt = *(++(*iterator)); } coro.reset(); } diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index 9f06c28d2b..3cc3a2ad93 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -3,7 +3,7 @@ { "kind": "git", "repository": "https://github.com/FISCO-BCOS/registry", - "baseline": "f08e2b4c2907bdfafa383dded27c3d484cc35f5f", + "baseline": "748c50ba0a5e69297b9527d64a6b2ca76447b7a7", "packages": [ "openssl", "evmone", diff --git a/vcpkg.json b/vcpkg.json index cb22c6dfbd..cbfc33f938 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,6 +1,6 @@ { "name": "fiscobcos", - "version-string": "3.9.0", + "version-string": "3.10.0", "homepage": "https://github.com/FISCO-BCOS/FISCO-BCOS", "description": "FISCO BCOS", "dependencies": [ @@ -28,7 +28,6 @@ "boost-container-hash", "boost-multiprecision", "boost-program-options", - "boost-mp11", "ms-gsl", "tbb", { @@ -56,11 +55,11 @@ "dependencies": [ { "name": "evmone", - "version>=": "0.10.0" + "version>=": "0.11.0" }, { "name": "evmc", - "version>=": "10.1.0" + "version>=": "11.0.1" }, { "name": "boost-coroutine2", @@ -220,7 +219,7 @@ }, { "name": "rocksdb", - "version": "6.27.3" + "version": "8.5.3" }, { "name": "magic-enum", @@ -280,7 +279,7 @@ }, { "name": "redis-plus-plus", - "version": "1.3.2" + "version": "1.3.10" }, { "name": "protobuf", @@ -296,19 +295,11 @@ }, { "name": "tarscpp", - "version": "3.0.3-1#1" + "version": "3.0.3-2" }, { "name": "wedprcrypto", "version": "1.3.1#1" - }, - { - "name": "evmc", - "version": "10.1.0" - }, - { - "name": "evmone", - "version": "0.10.0" } ] } \ No newline at end of file