diff --git a/CMakeLists.txt b/CMakeLists.txt index 143d6a6324..9e6c2c60bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ endif() list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) -set(VERSION "3.11.0") +set(VERSION "3.12.0") set(VERSION_SUFFIX "") include(Options) configure_project() diff --git a/bcos-crypto/bcos-crypto/ChecksumAddress.h b/bcos-crypto/bcos-crypto/ChecksumAddress.h index abc128df48..99080f08da 100644 --- a/bcos-crypto/bcos-crypto/ChecksumAddress.h +++ b/bcos-crypto/bcos-crypto/ChecksumAddress.h @@ -132,7 +132,7 @@ inline std::string newLegacyEVMAddress(bytesConstRef sender, u256 nonce) noexcep inline std::string newLegacyEVMAddress(bytesConstRef sender, std::string const& nonce) noexcept { - const auto uNonce = u256(nonce); + const auto uNonce = hex2u(nonce); return newLegacyEVMAddress(sender, uNonce); } diff --git a/bcos-crypto/test/unittests/AddressTest.cpp b/bcos-crypto/test/unittests/AddressTest.cpp index 1825688263..c760564e70 100644 --- a/bcos-crypto/test/unittests/AddressTest.cpp +++ b/bcos-crypto/test/unittests/AddressTest.cpp @@ -66,6 +66,14 @@ BOOST_AUTO_TEST_CASE(testCreatLegacyEVMAddress) auto newAddress = newLegacyEVMAddress(ref(sender), u256(0)); BOOST_CHECK_EQUAL(newAddress, "5fbdb2315678afecb367f032d93f642f64180aa3"); } + + // string nonce + { + auto sender = fromHex("f39Fd6e51aad88F6F4ce6aB8827279cffFb92266"sv); + auto nonce = "0"; + auto newAddress = newLegacyEVMAddress(ref(sender), nonce); + BOOST_CHECK_EQUAL(newAddress, "5fbdb2315678afecb367f032d93f642f64180aa3"); + } } BOOST_AUTO_TEST_CASE(testCreate2Address) diff --git a/bcos-executor/src/executive/TransactionExecutive.cpp b/bcos-executor/src/executive/TransactionExecutive.cpp index 2fc42f0607..88289b67d3 100644 --- a/bcos-executor/src/executive/TransactionExecutive.cpp +++ b/bcos-executor/src/executive/TransactionExecutive.cpp @@ -307,8 +307,9 @@ CallParameters::UniquePtr TransactionExecutive::execute(CallParameters::UniquePt co_await ledger::account::create(addr); } auto const nonceInStorage = co_await ledger::account::nonce(addr); - auto const baseNonce = u256(nonceInStorage.value_or("0")); - auto const newNonce = std::max(callNonce, baseNonce) + 1; + // FIXME)) : only web3 tx use this + auto const storageNonce = u256(nonceInStorage.value_or("0")); + auto const newNonce = std::max(callNonce, storageNonce) + 1; co_await ledger::account::setNonce(addr, newNonce.convert_to()); }(std::move(address), callParameters->nonce)); } diff --git a/bcos-executor/src/executor/TransactionExecutor.cpp b/bcos-executor/src/executor/TransactionExecutor.cpp index cb43eefd87..4442bff1ea 100644 --- a/bcos-executor/src/executor/TransactionExecutor.cpp +++ b/bcos-executor/src/executor/TransactionExecutor.cpp @@ -2629,6 +2629,12 @@ void TransactionExecutor::removeCommittedState() m_ledgerCache->clearCacheByNumber(number); } +/** + * call when scheduler ExecutionMessage::MESSAGE + * @param input scheduler input + * @param staticCall whether static call + * @return callParameters + */ std::unique_ptr TransactionExecutor::createCallParameters( bcos::protocol::ExecutionMessage& input, bool staticCall) { @@ -2734,6 +2740,12 @@ std::unique_ptr TransactionExecutor::createCallParameters( return callParameters; } +/** + * call when scheduler ExecutionMessage::TXHASH + * @param input scheduler input + * @param tx transaction + * @return callParameters + */ std::unique_ptr TransactionExecutor::createCallParameters( bcos::protocol::ExecutionMessage& input, const bcos::protocol::Transaction& tx) { @@ -2764,7 +2776,8 @@ std::unique_ptr TransactionExecutor::createCallParameters( callParameters->gasLimit = input.gasLimit(); callParameters->maxFeePerGas = u256(input.maxFeePerGas()); callParameters->maxPriorityFeePerGas = u256(input.maxPriorityFeePerGas()); - callParameters->nonce = u256(input.nonce()); + // TODO: depends on whether web3 tx? + callParameters->nonce = hex2u(input.nonce()); if (!m_isWasm && !callParameters->create) { diff --git a/bcos-executor/src/precompiled/ConsensusPrecompiled.cpp b/bcos-executor/src/precompiled/ConsensusPrecompiled.cpp index e49c030dca..4f02215d50 100644 --- a/bcos-executor/src/precompiled/ConsensusPrecompiled.cpp +++ b/bcos-executor/src/precompiled/ConsensusPrecompiled.cpp @@ -180,8 +180,8 @@ static int addSealerImpl(bool isConsensus, // version >= 3.1.0, only allow adding sealer in observer list return CODE_ADD_SEALER_SHOULD_IN_OBSERVER; } - consensusList.emplace_back(nodeIDPtr, consensus::Type::consensus_sealer, voteWeight, 0, - blockContext.number() + 1); + consensusList.emplace_back(consensus::ConsensusNode{nodeIDPtr, + consensus::Type::consensus_sealer, voteWeight, 0, blockContext.number() + 1}); } node->enableNumber = blockContext.number() + 1; } @@ -205,8 +205,8 @@ static int addSealerImpl(bool isConsensus, } else { - consensusList.emplace_back( - nodeIDPtr, consensus::Type::consensus_observer, 0, 0, blockContext.number() + 1); + consensusList.emplace_back(consensus::ConsensusNode{ + nodeIDPtr, consensus::Type::consensus_observer, 0, 0, blockContext.number() + 1}); } } diff --git a/bcos-executor/src/precompiled/common/WorkingSealerManagerImpl.cpp b/bcos-executor/src/precompiled/common/WorkingSealerManagerImpl.cpp index c96d2dff3b..ceae0d67a0 100644 --- a/bcos-executor/src/precompiled/common/WorkingSealerManagerImpl.cpp +++ b/bcos-executor/src/precompiled/common/WorkingSealerManagerImpl.cpp @@ -375,7 +375,7 @@ static WorkingSealer pickNodeByWeight( auto weight = nodeIt->offset - ((nodeWeightRanges.begin() == nodeIt) ? 0LU : (nodeIt - 1)->offset); totalWeight -= weight; - for (auto& it : RANGES::subrange(nodeIt + 1, nodeWeightRanges.end())) + for (auto& it : RANGES::subrange(nodeIt + 1, nodeWeightRanges.end())) { it.offset -= weight; } diff --git a/bcos-executor/src/vm/HostContext.cpp b/bcos-executor/src/vm/HostContext.cpp index 0ac97556b0..085e4a3ef0 100644 --- a/bcos-executor/src/vm/HostContext.cpp +++ b/bcos-executor/src/vm/HostContext.cpp @@ -251,6 +251,7 @@ evmc_result HostContext::externalRequest(const evmc_message* _msg) *m_executive->storage().getRawStorage(), request->senderAddress); request->nonce = task::syncWait([](decltype(account) contract) -> task::Task { auto const nonceString = co_await ledger::account::nonce(contract); + // uint in storage auto const nonce = u256(nonceString.value_or("0")); co_return nonce; }(std::move(account))); @@ -702,6 +703,11 @@ uint32_t HostContext::blockVersion() const uint64_t HostContext::timestamp() const { + if (m_executive->blockContext().features().get(ledger::Features::Flag::feature_evm_timestamp)) + { + // millisecond to second + return m_executive->blockContext().timestamp() / 1000; + } return m_executive->blockContext().timestamp(); } diff --git a/bcos-executor/test/unittest/libprecompiled/WorkingSealerManagerTest.cpp b/bcos-executor/test/unittest/libprecompiled/WorkingSealerManagerTest.cpp index 3acb8d091c..c8c7259124 100644 --- a/bcos-executor/test/unittest/libprecompiled/WorkingSealerManagerTest.cpp +++ b/bcos-executor/test/unittest/libprecompiled/WorkingSealerManagerTest.cpp @@ -67,14 +67,18 @@ BOOST_AUTO_TEST_CASE(testRotate) // Node list consensus::ConsensusNodeList nodeList; - nodeList.emplace_back(std::make_shared(fromHex(node1)), - consensus::Type::consensus_candidate_sealer, 0, 70, 0); - nodeList.emplace_back(std::make_shared(fromHex(node2)), - consensus::Type::consensus_candidate_sealer, 0, 20, 0); - nodeList.emplace_back(std::make_shared(fromHex(node3)), - consensus::Type::consensus_candidate_sealer, 0, 7, 0); - nodeList.emplace_back(std::make_shared(fromHex(node4)), - consensus::Type::consensus_candidate_sealer, 0, 3, 0); + nodeList.emplace_back( + consensus::ConsensusNode{std::make_shared(fromHex(node1)), + consensus::Type::consensus_candidate_sealer, 0, 70, 0}); + nodeList.emplace_back( + consensus::ConsensusNode{std::make_shared(fromHex(node2)), + consensus::Type::consensus_candidate_sealer, 0, 20, 0}); + nodeList.emplace_back( + consensus::ConsensusNode{std::make_shared(fromHex(node3)), + consensus::Type::consensus_candidate_sealer, 0, 7, 0}); + nodeList.emplace_back( + consensus::ConsensusNode{std::make_shared(fromHex(node4)), + consensus::Type::consensus_candidate_sealer, 0, 3, 0}); co_await ledger::setNodeList(storage, nodeList); auto storageWrapper = diff --git a/bcos-framework/bcos-framework/ledger/Features.h b/bcos-framework/bcos-framework/ledger/Features.h index e403a202e7..9c5acab514 100644 --- a/bcos-framework/bcos-framework/ledger/Features.h +++ b/bcos-framework/bcos-framework/ledger/Features.h @@ -58,8 +58,9 @@ class Features feature_paillier_add_raw, feature_evm_cancun, feature_calculate_gasPrice, + feature_evm_timestamp, feature_evm_address, - feature_ethereum_compatible, // will enbale all bugfixes, all features about evm + feature_ethereum_compatible, // will enable all bugfixes, all features about evm feature_rpbft_term_weight, }; @@ -77,6 +78,11 @@ class Features return *value; } + static bool contains(std::string_view flag) + { + return magic_enum::enum_cast(flag).has_value(); + } + void validate(std::string_view flag) const { auto value = magic_enum::enum_cast(flag); @@ -114,36 +120,46 @@ class Features } bool get(std::string_view flag) const { return get(string2Flag(flag)); } - void set(Flag flag) - { - auto index = magic_enum::enum_index(flag); - if (!index) - { - BOOST_THROW_EXCEPTION(NoSuchFeatureError{}); - } - - validate(flag); - m_flags[*index] = true; - turnOnMainSwitch(flag); - } - - void turnOnMainSwitch(Flag flag) + // DO NOT use now, there is some action after set feature in systemPrecompiled + static auto getFeatureDependencies(Flag flag) { + /// NOTE:请不要在此处添加旧版本feature依赖!否则会出现数据不一致! + /// Do NOT add old version feature dependencies here! Otherwise, data inconsistency will + /// occur! const auto mainSwitchDependence = std::unordered_map>( {{Flag::feature_ethereum_compatible, { Flag::feature_balance, Flag::feature_balance_precompiled, Flag::feature_calculate_gasPrice, + Flag::feature_evm_timestamp, Flag::feature_evm_address, Flag::feature_evm_cancun, }}}); if (mainSwitchDependence.contains(flag)) { - for (const auto& dependence : mainSwitchDependence.at(flag)) - { - set(dependence); - } + return mainSwitchDependence.at(flag); } + return std::set(); + } + void enableDependencyFeatures(Flag flag) + { + for (const auto& dependence : getFeatureDependencies(flag)) + { + set(dependence); + } + } + + void set(Flag flag) + { + auto index = magic_enum::enum_index(flag); + if (!index) + { + BOOST_THROW_EXCEPTION(NoSuchFeatureError{}); + } + + validate(flag); + m_flags[*index] = true; + // enableDependencyFeatures(flag); } void set(std::string_view flag) { set(string2Flag(flag)); } diff --git a/bcos-framework/bcos-framework/protocol/Protocol.h b/bcos-framework/bcos-framework/protocol/Protocol.h index ed80855521..c9ee28309f 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_12_0_VERSION = 0x030c0000, // 3.12.0 V3_11_0_VERSION = 0x030b0000, V3_10_0_VERSION = 0x030a0000, V3_9_0_VERSION = 0x03090000, @@ -138,7 +139,7 @@ enum class BlockVersion : uint32_t V3_0_VERSION = 0x03000000, RC4_VERSION = 4, MIN_VERSION = RC4_VERSION, - MAX_VERSION = V3_11_0_VERSION, + MAX_VERSION = V3_12_0_VERSION, // 3.12.0 }; enum class TransactionVersion : uint32_t @@ -153,10 +154,10 @@ 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_11_0_VERSION; +constexpr BlockVersion DEFAULT_VERSION = bcos::protocol::BlockVersion::V3_12_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; +constexpr uint8_t MAX_MAJOR_VERSION = std::numeric_limits::max(); +constexpr uint8_t MIN_MAJOR_VERSION = 3; [[nodiscard]] inline int versionCompareTo( std::variant const& _v1, BlockVersion const& _v2) diff --git a/bcos-framework/test/unittests/interfaces/FeaturesTest.cpp b/bcos-framework/test/unittests/interfaces/FeaturesTest.cpp index 65eed6dae4..aaa160f236 100644 --- a/bcos-framework/test/unittests/interfaces/FeaturesTest.cpp +++ b/bcos-framework/test/unittests/interfaces/FeaturesTest.cpp @@ -157,6 +157,7 @@ BOOST_AUTO_TEST_CASE(feature) "feature_paillier_add_raw", "feature_evm_cancun", "feature_calculate_gasPrice", + "feature_evm_timestamp", "feature_evm_address", "feature_ethereum_compatible", "feature_rpbft_term_weight", @@ -394,4 +395,16 @@ BOOST_AUTO_TEST_CASE(genesis) } } + +BOOST_AUTO_TEST_CASE(testDependenciesFeatures) +{ + Features features; + features.set(ledger::Features::Flag::feature_ethereum_compatible); + // BOOST_CHECK(features.get(ledger::Features::Flag::feature_balance)); + // BOOST_CHECK(features.get(ledger::Features::Flag::feature_balance_precompiled)); + // BOOST_CHECK(features.get(ledger::Features::Flag::feature_calculate_gasPrice)); + // BOOST_CHECK(features.get(ledger::Features::Flag::feature_evm_address)); + // BOOST_CHECK(features.get(ledger::Features::Flag::feature_evm_cancun)); +} + BOOST_AUTO_TEST_SUITE_END() diff --git a/bcos-ledger/bcos-ledger/Ledger.cpp b/bcos-ledger/bcos-ledger/Ledger.cpp index 06be5e0f0d..9beb5d4c87 100644 --- a/bcos-ledger/bcos-ledger/Ledger.cpp +++ b/bcos-ledger/bcos-ledger/Ledger.cpp @@ -443,14 +443,14 @@ task::Task> Ledger::getStorageState( { co_return std::nullopt; } - state.nonce = std::stoull(std::string(nonceEntry->get())); + state.nonce = std::string(nonceEntry->get()); auto const balanceEntry = co_await getStorageAt(_address, ACCOUNT_TABLE_FIELDS::BALANCE, _blockNumber); if (!balanceEntry.has_value()) { co_return std::nullopt; } - state.balance = std::stoull(std::string(balanceEntry->get())); + state.balance = std::string(balanceEntry->get()); co_return state; } diff --git a/bcos-ledger/test/unittests/ledger/LedgerTest.cpp b/bcos-ledger/test/unittests/ledger/LedgerTest.cpp index 6748d838a3..da29e89a8e 100644 --- a/bcos-ledger/test/unittests/ledger/LedgerTest.cpp +++ b/bcos-ledger/test/unittests/ledger/LedgerTest.cpp @@ -167,14 +167,14 @@ class LedgerFixture : public TestPromptFixture auto signImpl = std::make_shared(); consensus::ConsensusNodeList consensusNodeList; consensus::ConsensusNodeList observerNodeList; - for (int i = 0; i < 4; ++i) + for (size_t i = 0; i < 4; ++i) { - auto node = consensus::ConsensusNode(signImpl->generateKeyPair()->publicKey(), - consensus::Type::consensus_sealer, 10 + i, 0, 0); + auto node = consensus::ConsensusNode{signImpl->generateKeyPair()->publicKey(), + consensus::Type::consensus_sealer, 10 + i, 0, 0}; consensusNodeList.emplace_back(node); } - auto observer_node = consensus::ConsensusNode(signImpl->generateKeyPair()->publicKey(), - consensus::Type::consensus_observer, -1, 0, 0); + auto observer_node = consensus::ConsensusNode{signImpl->generateKeyPair()->publicKey(), + consensus::Type::consensus_observer, uint64_t(-1), 0, 0}; observerNodeList.emplace_back(observer_node); m_param->setConsensusNodeList(consensusNodeList); @@ -733,8 +733,9 @@ BOOST_AUTO_TEST_CASE(testNodeListByType) std::promise setSealer1; auto nodeList = task::syncWait(ledger::getNodeList(*m_storage)); - nodeList.emplace_back(std::make_shared(bcos::crypto::HashType("56789").asBytes()), - consensus::Type::consensus_sealer, 100, 0, 5); + nodeList.emplace_back(consensus::ConsensusNode{ + std::make_shared(bcos::crypto::HashType("56789").asBytes()), + consensus::Type::consensus_sealer, 100, 0, 5}); task::syncWait(ledger::setNodeList(*m_storage, nodeList)); std::promise p2; diff --git a/bcos-pbft/test/unittests/pbft/PBFTFixture.h b/bcos-pbft/test/unittests/pbft/PBFTFixture.h index c640c0934a..2294b73c2e 100644 --- a/bcos-pbft/test/unittests/pbft/PBFTFixture.h +++ b/bcos-pbft/test/unittests/pbft/PBFTFixture.h @@ -328,7 +328,7 @@ class PBFTFixture void appendConsensusNode(PublicPtr _nodeId) { - auto node = ConsensusNode(_nodeId, consensus::Type::consensus_sealer, 1, 0, 0); + auto node = ConsensusNode{_nodeId, consensus::Type::consensus_sealer, 1, 0, 0}; appendConsensusNode(node); } diff --git a/bcos-rpbft/test/unittests/config/RPBFTConfigTest.cpp b/bcos-rpbft/test/unittests/config/RPBFTConfigTest.cpp index 2403431d0d..12e41fb9c8 100644 --- a/bcos-rpbft/test/unittests/config/RPBFTConfigTest.cpp +++ b/bcos-rpbft/test/unittests/config/RPBFTConfigTest.cpp @@ -82,23 +82,23 @@ class RPBFTConfigFixture : public TestPromptFixture for (size_t i = 0; i < consensusNodeNum; ++i) { - ledgerConfig->mutableConsensusList().push_back(consensus::ConsensusNode( + ledgerConfig->mutableConsensusList().push_back(consensus::ConsensusNode{ m_cryptoSuite->signatureImpl()->generateKeyPair()->publicKey(), - consensus::Type::consensus_sealer, 1, 0, 0)); + consensus::Type::consensus_sealer, 1, 0, 0}); } for (size_t i = 0; i < observerNodeNum; ++i) { - ledgerConfig->mutableObserverList().push_back(consensus::ConsensusNode( + ledgerConfig->mutableObserverList().push_back(consensus::ConsensusNode{ m_cryptoSuite->signatureImpl()->generateKeyPair()->publicKey(), - consensus::Type::consensus_observer, 0, 0, 0)); + consensus::Type::consensus_observer, 0, 0, 0}); } for (size_t i = 0; i < candidateSealerNodeNum; ++i) { - ledgerConfig->mutableCandidateSealerNodeList().push_back(consensus::ConsensusNode( + ledgerConfig->mutableCandidateSealerNodeList().push_back(consensus::ConsensusNode{ m_cryptoSuite->signatureImpl()->generateKeyPair()->publicKey(), - consensus::Type::consensus_candidate_sealer, 1, 0, 0)); + consensus::Type::consensus_candidate_sealer, 1, 0, 0}); } return ledgerConfig; } diff --git a/bcos-rpc/test/unittests/common/RPCFixture.h b/bcos-rpc/test/unittests/common/RPCFixture.h index 6982c71474..c1eedc2e65 100644 --- a/bcos-rpc/test/unittests/common/RPCFixture.h +++ b/bcos-rpc/test/unittests/common/RPCFixture.h @@ -76,7 +76,7 @@ class RPCFixture : public TestPromptFixture factory = std::make_shared(chainId, gateway, cryptoSuite->keyFactory()); nodeConfig = std::make_shared(); - + nodeConfig->loadConfigFromString(configini); factory->setNodeConfig(nodeConfig); diff --git a/bcos-rpc/test/unittests/rpc/Web3TypeTest.cpp b/bcos-rpc/test/unittests/rpc/Web3TypeTest.cpp index d6e6225d05..65fc162e01 100644 --- a/bcos-rpc/test/unittests/rpc/Web3TypeTest.cpp +++ b/bcos-rpc/test/unittests/rpc/Web3TypeTest.cpp @@ -77,6 +77,39 @@ BOOST_AUTO_TEST_CASE(testLegacyTransactionDecode) BOOST_CHECK_EQUAL(rawTx, rawTx2); } +BOOST_AUTO_TEST_CASE(testConstructTx) +{ + Web3Transaction testTx; + testTx.value = 1000000000000000000; + testTx.type = rpc::TransactionType::Legacy; + testTx.data = {}; + testTx.to = Address("0x1e58529dAA467406645d0f4B63dec96CA0b87d70"); + testTx.nonce = 19; + testTx.gasLimit = 210000; + testTx.maxFeePerGas = 20000000000; + testTx.maxPriorityFeePerGas = 20000000000; + testTx.chainId = 31337; + + auto signData = testTx.encodeForSign(); + std::string priv = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"; + auto key = std::make_shared(fromHex(priv)); + auto newHash = crypto::keccak256Hash(ref(signData)); + auto signatureImpl = bcos::crypto::Secp256k1Crypto(); + auto keyPair = std::make_unique(key); + + auto signature = signatureImpl.sign(*keyPair, newHash, false); + auto [_, addr] = signatureImpl.recoverAddress(*hashImpl, newHash, ref(*signature)); + auto newAddr = toHex(addr); + BOOST_CHECK_EQUAL(newAddr, Address("C96aAa54E2d44c299564da76e1cD3184A2386B8D").hex()); + testTx.signatureR = {signature->begin(), signature->begin() + 32}; + testTx.signatureS = {signature->begin() + 32, signature->begin() + 64}; + testTx.signatureV = signature->back(); + bcos::bytes toData; + bcos::codec::rlp::encode(toData, testTx); + auto const newTx = toHexStringWithPrefix(toData); + BOOST_CHECK(!newTx.empty()); +} + BOOST_AUTO_TEST_CASE(testEIP2930Transaction) { // clang-format off diff --git a/bcos-sync/test/unittests/sync/SyncFixture.h b/bcos-sync/test/unittests/sync/SyncFixture.h index 1361199b15..4781e90c21 100644 --- a/bcos-sync/test/unittests/sync/SyncFixture.h +++ b/bcos-sync/test/unittests/sync/SyncFixture.h @@ -138,7 +138,7 @@ class SyncFixture void appendObserver(NodeIDPtr _nodeId) { - auto node = ConsensusNode(_nodeId, consensus::Type::consensus_observer, 0, 0, 0); + auto node = ConsensusNode{_nodeId, consensus::Type::consensus_observer, 0, 0, 0}; m_ledger->ledgerConfig()->mutableObserverList().emplace_back(node); m_sync->config()->setObserverList(m_ledger->ledgerConfig()->observerNodeList()); } @@ -149,7 +149,7 @@ class SyncFixture for (auto const& node : _nodeIdList) { m_ledger->ledgerConfig()->mutableConsensusList().emplace_back( - ConsensusNode(node, consensus::Type::consensus_sealer, 1, 0, 0)); + ConsensusNode{node, consensus::Type::consensus_sealer, 1, 0, 0}); } m_sync->config()->setConsensusNodeList(m_ledger->ledgerConfig()->consensusNodeList()); bcos::crypto::NodeIDSet nodeIdSet; @@ -174,7 +174,7 @@ class SyncFixture for (auto const& node : _nodeIdList) { m_ledger->ledgerConfig()->mutableObserverList().emplace_back( - ConsensusNode(node, consensus::Type::consensus_observer, 0, 0, 0)); + ConsensusNode{node, consensus::Type::consensus_observer, 0, 0, 0}); } m_sync->config()->setObserverList(m_ledger->ledgerConfig()->observerNodeList()); bcos::crypto::NodeIDSet nodeIdSet; diff --git a/bcos-tars-protocol/bcos-tars-protocol/Common.h b/bcos-tars-protocol/bcos-tars-protocol/Common.h index a2a73732fb..92400693dc 100644 --- a/bcos-tars-protocol/bcos-tars-protocol/Common.h +++ b/bcos-tars-protocol/bcos-tars-protocol/Common.h @@ -20,7 +20,7 @@ #pragma once // if windows, manual include tup/Tars.h first -#include "bcos-framework/consensus/ConsensusNode.h" +#include #ifdef _WIN32 #include #endif @@ -237,8 +237,11 @@ inline bcos::consensus::ConsensusNodeList toConsensusNodeList( { auto nodeID = _keyFactory->createKey( bcos::bytesConstRef((bcos::byte*)node.nodeID.data(), node.nodeID.size())); - consensusNodeList.push_back(bcos::consensus::ConsensusNode( - nodeID, type, node.voteWeight, node.termWeight, node.enableNumber)); + consensusNodeList.push_back(bcos::consensus::ConsensusNode{.nodeID = nodeID, + .type = type, + .voteWeight = static_cast(node.voteWeight), + .termWeight = static_cast(node.termWeight), + .enableNumber = node.enableNumber}); } return consensusNodeList; } diff --git a/bcos-tars-protocol/bcos-tars-protocol/protocol/ExecutionMessageImpl.cpp b/bcos-tars-protocol/bcos-tars-protocol/protocol/ExecutionMessageImpl.cpp index 66d4b39d51..c009fd466d 100644 --- a/bcos-tars-protocol/bcos-tars-protocol/protocol/ExecutionMessageImpl.cpp +++ b/bcos-tars-protocol/bcos-tars-protocol/protocol/ExecutionMessageImpl.cpp @@ -19,7 +19,6 @@ * @date 2022-05-09 */ #include "ExecutionMessageImpl.h" -#include "../Common.h" using namespace bcostars; using namespace bcostars::protocol; diff --git a/bcos-tars-protocol/bcos-tars-protocol/protocol/ExecutionMessageImpl.h b/bcos-tars-protocol/bcos-tars-protocol/protocol/ExecutionMessageImpl.h index 5ca78b5560..3780b87dc2 100644 --- a/bcos-tars-protocol/bcos-tars-protocol/protocol/ExecutionMessageImpl.h +++ b/bcos-tars-protocol/bcos-tars-protocol/protocol/ExecutionMessageImpl.h @@ -24,6 +24,7 @@ #pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wunused-parameter" +#include // if windows, manual include tup/Tars.h first #ifdef _WIN32 #include diff --git a/bcos-txpool/test/unittests/txpool/TxPoolFixture.h b/bcos-txpool/test/unittests/txpool/TxPoolFixture.h index b5dffbcdd1..7685b7475b 100644 --- a/bcos-txpool/test/unittests/txpool/TxPoolFixture.h +++ b/bcos-txpool/test/unittests/txpool/TxPoolFixture.h @@ -248,7 +248,7 @@ class TxPoolFixture TransactionSync::Ptr sync() { return m_sync; } void appendSealer(NodeIDPtr _nodeId) { - auto consensusNode = ConsensusNode(_nodeId, consensus::Type::consensus_sealer, 1, 0, 0); + auto consensusNode = ConsensusNode{_nodeId, consensus::Type::consensus_sealer, 1, 0, 0}; m_ledger->ledgerConfig()->mutableConsensusNodeList().emplace_back(consensusNode); m_txpool->notifyConsensusNodeList(m_ledger->ledgerConfig()->consensusNodeList(), nullptr); for (const auto& item : m_fakeGateWay->m_nodeId2TxPool) @@ -260,7 +260,7 @@ class TxPoolFixture } void appendObserver(NodeIDPtr _nodeId) { - auto consensusNode = ConsensusNode(_nodeId, consensus::Type::consensus_observer, 0, 0, 0); + auto consensusNode = ConsensusNode{_nodeId, consensus::Type::consensus_observer, 0, 0, 0}; m_ledger->ledgerConfig()->mutableObserverList().emplace_back(consensusNode); m_txpool->notifyObserverNodeList(m_ledger->ledgerConfig()->observerNodeList(), nullptr); for (const auto& item : m_fakeGateWay->m_nodeId2TxPool) diff --git a/bcos-utilities/bcos-utilities/Common.cpp b/bcos-utilities/bcos-utilities/Common.cpp index d2360c10f5..9402aead38 100644 --- a/bcos-utilities/bcos-utilities/Common.cpp +++ b/bcos-utilities/bcos-utilities/Common.cpp @@ -104,6 +104,20 @@ u256 s2u(s256 _u) else return u256(c_end + _u); } + +u256 hex2u(std::string_view _hexStr) +{ + if (_hexStr.empty()) + { + return u256{0}; + } + if (_hexStr.starts_with("0x") || _hexStr.starts_with("0X")) + { + return u256(_hexStr); + } + return u256("0x" + std::string(_hexStr)); +} + bool isalNumStr(std::string const& _stringData) { for (auto ch : _stringData) diff --git a/bcos-utilities/bcos-utilities/Common.h b/bcos-utilities/bcos-utilities/Common.h index 7d298d53d7..10566a66a2 100644 --- a/bcos-utilities/bcos-utilities/Common.h +++ b/bcos-utilities/bcos-utilities/Common.h @@ -106,6 +106,8 @@ s256 u2s(u256 _u); /// @returns the two's complement signed representation of the signed number _u. u256 s2u(s256 _u); +u256 hex2u(std::string_view _hexStr); + bool isalNumStr(std::string const& _stringData); inline bool isNumStr(std::string const& _stringData) diff --git a/bcos-utilities/bcos-utilities/DataConvertUtility.h b/bcos-utilities/bcos-utilities/DataConvertUtility.h index 13912a55c4..e985533162 100644 --- a/bcos-utilities/bcos-utilities/DataConvertUtility.h +++ b/bcos-utilities/bcos-utilities/DataConvertUtility.h @@ -134,7 +134,7 @@ inline uint64_t fromQuantity(std::string const& quantity) inline u256 fromBigQuantity(std::string_view quantity) { - return u256(quantity); + return hex2u(quantity); } /** diff --git a/tests/unittest/ConsensusNodeTest.cpp b/tests/unittest/ConsensusNodeTest.cpp index ebd1a4b1c2..ef4f2ae55e 100644 --- a/tests/unittest/ConsensusNodeTest.cpp +++ b/tests/unittest/ConsensusNodeTest.cpp @@ -36,14 +36,14 @@ BOOST_AUTO_TEST_CASE(testConsensusNode) std::string node1 = "123"; uint64_t weight = 1; auto nodeId = std::make_shared(bytes(node1.begin(), node1.end())); - auto consensusNode1 = ConsensusNode(nodeId, Type::consensus_sealer, weight, 0, 0); + auto consensusNode1 = ConsensusNode{nodeId, Type::consensus_sealer, weight, 0, 0}; std::string node2 = "1234"; auto nodeId2 = std::make_shared(bytes(node2.begin(), node2.end())); - auto consensusNode2 = ConsensusNode(nodeId2, Type::consensus_sealer, weight, 0, 0); + auto consensusNode2 = ConsensusNode{nodeId2, Type::consensus_sealer, weight, 0, 0}; auto nodeId3 = std::make_shared(bytes(node1.begin(), node1.end())); - auto consensusNode3 = ConsensusNode(nodeId3, Type::consensus_sealer, weight, 0, 0); + auto consensusNode3 = ConsensusNode{nodeId3, Type::consensus_sealer, weight, 0, 0}; // test set std::set consensusNodeList; diff --git a/tools/BcosAirBuilder/build_chain.sh b/tools/BcosAirBuilder/build_chain.sh index 07e0ef66e7..69deb25a32 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.11.0" +default_version="v3.12.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.11.0 +bcos_builder_version=v3.12.0 use_exist_binary="false" download_specific_binary_flag="false" download_service_binary_type="cdn" -service_binary_version="v3.11.0" +service_binary_version="v3.12.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 a7519ab5af..f1de894610 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.11.0" +compatibility_version = "3.12.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 4242b48ec3..377ac014d1 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.11.0" +compatibility_version = "3.12.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 6a377fc4c4..022d559dc7 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.11.0" +compatibility_version = "3.12.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 400e5f587d..6a1761db8d 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.11.0" +compatibility_version = "3.12.0" [[agency]] name = "agencyA" diff --git a/tools/BcosBuilder/src/common/utilities.py b/tools/BcosBuilder/src/common/utilities.py index ad89d8d076..64826643c7 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.11.0" + default_binary_version = "v3.12.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 a4687f103d..3a805dbad5 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.11.0 + compatibility_version=3.12.0 [tx] ; transaction gas limit diff --git a/vcpkg.json b/vcpkg.json index 4335c2a60c..6672c7a02f 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,6 +1,6 @@ { "name": "fiscobcos", - "version-string": "3.11.0", + "version-string": "3.12.0", "homepage": "https://github.com/FISCO-BCOS/FISCO-BCOS", "description": "FISCO BCOS", "dependencies": [