Skip to content

Commit

Permalink
Merge branch 'release-3.10.2' into sync_from_3.10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kyonRay committed Sep 18, 2024
2 parents ce7c03e + 7ba690f commit 4d2377b
Show file tree
Hide file tree
Showing 14 changed files with 108 additions and 49 deletions.
6 changes: 6 additions & 0 deletions bcos-executor/src/executive/BlockContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ BlockContext::BlockContext(std::shared_ptr<storage::StateStorageInterface> stora
}

task::syncWait(readFromStorage(m_features, *m_storage, m_blockNumber));
task::syncWait(readFromStorage(m_configs, *m_storage, m_blockNumber));
setVMSchedule();
}

Expand Down Expand Up @@ -189,3 +190,8 @@ const bcos::ledger::Features& bcos::executor::BlockContext::features() const
{
return m_features;
}

const bcos::ledger::SystemConfigs& BlockContext::configs() const
{
return m_configs;
}
6 changes: 4 additions & 2 deletions bcos-executor/src/executive/BlockContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class BlockContext : public std::enable_shared_from_this<BlockContext>

uint64_t txGasLimit() const { return m_ledgerCache->fetchTxGasLimit(); }

auto getTxCriticals(
const protocol::Transaction::ConstPtr& _tx) -> std::shared_ptr<std::vector<std::string>>;
auto getTxCriticals(const protocol::Transaction::ConstPtr& _tx)
-> std::shared_ptr<std::vector<std::string>>;

crypto::Hash::Ptr hashHandler() const { return m_hashImpl; }
bool isWasm() const { return m_isWasm; }
Expand Down Expand Up @@ -138,6 +138,7 @@ class BlockContext : public std::enable_shared_from_this<BlockContext>
auto keyPageIgnoreTables() const { return m_keyPageIgnoreTables; }

const ledger::Features& features() const;
const ledger::SystemConfigs& configs() const;
storage::EntryCachePtr getCodeCache() const { return m_codeCache; }
storage::EntryCachePtr getCodeHashCache() const { return m_codeHashCache; }
auto backendStorage() const { return m_backendStorage; }
Expand Down Expand Up @@ -169,6 +170,7 @@ class BlockContext : public std::enable_shared_from_this<BlockContext>
storage::EntryCachePtr m_codeHashCache = std::make_shared<storage::EntryCache>();
bcos::storage::StorageInterface::Ptr m_backendStorage;
ledger::Features m_features;
ledger::SystemConfigs m_configs;
};

} // namespace bcos::executor
11 changes: 9 additions & 2 deletions bcos-executor/src/executive/TransactionExecutive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,17 @@ CallParameters::UniquePtr TransactionExecutive::execute(CallParameters::UniquePt
ledger::Features::Flag::feature_balance))
<< LOG_KV("value", callParameters->value);
}
// policy1 disable transfer balance
bool disableTransfer =
m_blockContext.features().get(ledger::Features::Flag::feature_balance_policy1);

if (m_blockContext.features().get(ledger::Features::Flag::feature_balance_policy1))
if (auto const& balanceTransfer =
m_blockContext.configs().get(ledger::SystemConfig::balance_transfer))
{
disableTransfer = (balanceTransfer.value() == "0");
}
if (disableTransfer)
{
// policy1 disable transfer balance
callParameters->value = 0;
}

Expand Down
4 changes: 4 additions & 0 deletions bcos-executor/src/precompiled/SystemConfigPrecompiled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ SystemConfigPrecompiled::SystemConfigPrecompiled(crypto::Hash::Ptr hashImpl) : P
defaultCmp(SYSTEM_KEY_RPBFT_EPOCH_SEALER_NUM, _value, RPBFT_EPOCH_SEALER_NUM_MIN,
version, BlockVersion::V3_5_VERSION);
}));
m_sysValueCmp.insert(
std::make_pair(ENABLE_BALANCE_TRANSFER, [defaultCmp](int64_t _value, uint32_t version) {
defaultCmp(ENABLE_BALANCE_TRANSFER, _value, 0, version, BlockVersion::V3_10_2_VERSION);
}));
// for compatibility
// Note: the compatibility_version is not compatibility
m_sysValueCmp.insert(
Expand Down
1 change: 1 addition & 0 deletions bcos-executor/src/vm/gas_meter/Metric.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
#pragma once
#include <array>
#include <cstdint>
#include <string>

// #define WASM_FLOAT_ENABLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,23 @@ BOOST_AUTO_TEST_CASE(sysConfig_test)
simpleSetFunc(number++, 110, std::string{ledger::SYSTEM_KEY_TX_GAS_PRICE},
std::string("error"), bcos::protocol::TransactionStatus::PrecompiledError);
}

// balance_transfer
{
simpleSetFunc(
number++, 111, std::string{ledger::ENABLE_BALANCE_TRANSFER}, std::string("1"));
auto value = getValueByKey(number++, std::string{ledger::ENABLE_BALANCE_TRANSFER});
BOOST_CHECK_EQUAL(value, "1");

simpleSetFunc(
number++, 111, std::string{ledger::ENABLE_BALANCE_TRANSFER}, std::string("0"));

value = getValueByKey(number++, std::string{ledger::ENABLE_BALANCE_TRANSFER});
BOOST_CHECK_EQUAL(value, "0");

simpleSetFunc(number++, 111, std::string{ledger::ENABLE_BALANCE_TRANSFER},
std::string("error"), bcos::protocol::TransactionStatus::PrecompiledError);
}
}

BOOST_AUTO_TEST_CASE(consensus_test)
Expand Down
20 changes: 20 additions & 0 deletions bcos-framework/bcos-framework/ledger/LedgerTypeDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ constexpr static std::string_view SYSTEM_KEY_RPBFT_SWITCH = magic_enum::enum_nam
constexpr static std::string_view SYSTEM_KEY_BALANCE_PRECOMPILED_SWITCH = magic_enum::enum_name(SystemConfig::feature_balance_precompiled);
// notify rotate key for rpbft
constexpr static std::string_view INTERNAL_SYSTEM_KEY_NOTIFY_ROTATE = "feature_rpbft_notify_rotate";
constexpr static std::string_view ENABLE_BALANCE_TRANSFER = magic_enum::enum_name(SystemConfig::balance_transfer);
// clang-format on
constexpr static std::string_view PBFT_CONSENSUS_TYPE = "pbft";
constexpr static std::string_view RPBFT_CONSENSUS_TYPE = "rpbft";
Expand Down Expand Up @@ -158,4 +159,23 @@ struct StorageState
std::string nonce;
std::string balance;
};
inline task::Task<void> readFromStorage(SystemConfigs& configs, auto&& storage, long blockNumber)
{
decltype(auto) keys = bcos::ledger::SystemConfigs::supportConfigs();
auto entries = co_await storage2::readSome(std::forward<decltype(storage)>(storage),
keys | RANGES::views::transform([](std::string_view key) {
return transaction_executor::StateKeyView(ledger::SYS_CONFIG, key);
}));
for (auto&& [key, entry] : RANGES::views::zip(keys, entries))
{
if (entry)
{
auto [value, enableNumber] = entry->template getObject<ledger::SystemConfigEntry>();
if (blockNumber >= enableNumber)
{
configs.set(key, value);
}
}
}
}
} // namespace bcos::ledger
21 changes: 20 additions & 1 deletion bcos-framework/bcos-framework/ledger/SystemConfigs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
*/

#pragma once
#include "../protocol/Protocol.h"
#include "../storage/Entry.h"
#include "../storage/LegacyStorageMethods.h"
#include "../storage2/Storage.h"
#include "../transaction-executor/StateKey.h"
#include "bcos-framework/ledger/LedgerTypeDef.h"
#include "bcos-task/Task.h"
#include "bcos-tool/Exceptions.h"
#include "bcos-utilities/Exceptions.h"
#include "bcos-utilities/Ranges.h"
#include <boost/throw_exception.hpp>
Expand All @@ -45,6 +53,7 @@ enum class SystemConfig
feature_rpbft_epoch_sealer_num,
feature_balance_precompiled,
web3_chain_id,
balance_transfer,
};
class SystemConfigs
{
Expand All @@ -61,7 +70,17 @@ class SystemConfigs
return *value;
}

std::optional<std::string> get(SystemConfig config) const { return m_sysConfigs.at(config); }
std::optional<std::string> get(SystemConfig config) const
{
if (const auto it = m_sysConfigs.find(config); it != m_sysConfigs.end())
{
return it->second;
}
else
{
return std::nullopt;
}
}
std::optional<std::string> get(std::string_view config) const
{
return get(fromString(config));
Expand Down
1 change: 1 addition & 0 deletions bcos-framework/bcos-framework/protocol/Protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ enum class BlockVersion : uint32_t
{
V3_12_0_VERSION = 0x030c0000, // 3.12.0
V3_11_0_VERSION = 0x030b0000,
V3_10_2_VERSION = 0x030a0200,
V3_10_0_VERSION = 0x030a0000,
V3_9_0_VERSION = 0x03090000,
V3_8_0_VERSION = 0x03080000,
Expand Down
5 changes: 4 additions & 1 deletion bcos-pbft/bcos-pbft/pbft/config/PBFTConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ class PBFTConfig : public ConsensusConfig, public std::enable_shared_from_this<P
{
return false;
}
return m_committedProposal->index() < _index;
// Note: If the consensus and blockSync are executing the same block at the same time,
// the blockSync is executed first, and the consensus is still executing, the cache
// should be cleared.
return m_committedProposal->index() <= _index;
}

virtual void setTimeoutState(bool _timeoutState) { m_timeoutState.store(_timeoutState); }
Expand Down
2 changes: 1 addition & 1 deletion cmake/ProjectGroupSig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ file(MAKE_DIRECTORY ${GROUPSIG_INCLUDE_DIR}) # Must exist.

find_package(cryptopp CONFIG REQUIRED)
set_property(TARGET GroupSig PROPERTY IMPORTED_LOCATION ${GROUPSIG_LIBRARY})
set_property(TARGET GroupSig PROPERTY INTERFACE_LINK_LIBRARIES PbcSig Pbc Gmp cryptopp-static)
set_property(TARGET GroupSig PROPERTY INTERFACE_LINK_LIBRARIES PbcSig Pbc Gmp cryptopp::cryptopp)
set_property(TARGET GroupSig PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${GROUPSIG_INCLUDE_DIR} ${DEPS_INCLUDE_DIR})
add_dependencies(GroupSig GroupSigLib)
unset(SOURCE_DIR)
28 changes: 14 additions & 14 deletions tools/.ci/ci_check_air.sh
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ if [[ ${?} == "0" ]]; then
echo "java_sdk_integrationTest error"
exit 1
fi
bash ${current_path}/.ci/java_sdk_demo_ci_test.sh ${console_branch} "false" "${current_path}/nodes/127.0.0.1"
if [[ ${?} == "0" ]]; then
LOG_INFO "java_sdk_demo_ci_test success"
else
echo "java_sdk_demo_ci_test error"
exit 1
fi
#bash ${current_path}/.ci/java_sdk_demo_ci_test.sh ${console_branch} "false" "${current_path}/nodes/127.0.0.1"
#if [[ ${?} == "0" ]]; then
# LOG_INFO "java_sdk_demo_ci_test success"
# else
# echo "java_sdk_demo_ci_test error"
# exit 1
#fi
LOG_INFO "======== check non-sm success ========"

LOG_INFO "======== clear node after non-sm test ========"
Expand All @@ -217,13 +217,13 @@ if [[ ${?} == "0" ]]; then
echo "java_sdk_integrationTest error"
exit 1
fi
bash ${current_path}/.ci/java_sdk_demo_ci_test.sh ${console_branch} "true" "${current_path}/nodes/127.0.0.1"
if [[ ${?} == "0" ]]; then
LOG_INFO "java_sdk_demo_ci_test success"
else
echo "java_sdk_demo_ci_test error"
exit 1
fi
#bash ${current_path}/.ci/java_sdk_demo_ci_test.sh ${console_branch} "true" "${current_path}/nodes/127.0.0.1"
#if [[ ${?} == "0" ]]; then
# LOG_INFO "java_sdk_demo_ci_test success"
# else
# echo "java_sdk_demo_ci_test error"
# exit 1
#fi

LOG_INFO "======== check sm case success ========"
clear_node
Expand Down
12 changes: 6 additions & 6 deletions tools/archive-tool/archive-reader/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 1 addition & 22 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@
]
},
"zstd",
{
"name": "protobuf",
"version>=": "3.19.4"
},
{
"name": "cryptopp",
"version>=": "8.6.0"
Expand All @@ -103,6 +99,7 @@
"version>=": "1.3.2"
},
"zstd",
"protobuf",
"tarscpp"
]
},
Expand Down Expand Up @@ -244,11 +241,6 @@
"name": "tbb",
"version": "2021.8.0"
},
{
"name": "zlib",
"version": "1.2.12",
"port-version": 1
},
{
"name": "fmt",
"version": "8.1.1"
Expand All @@ -262,11 +254,6 @@
"version": "0.12.0",
"port-version": 1
},
{
"name": "grpc",
"version": "1.51.1",
"port-version": 1
},
{
"name": "abseil",
"version": "20230802.1"
Expand All @@ -283,14 +270,6 @@
"name": "redis-plus-plus",
"version": "1.3.10"
},
{
"name": "protobuf",
"version": "3.19.4"
},
{
"name": "cryptopp",
"version": "8.6.0"
},
{
"name": "hiredis",
"version": "1.0.2"
Expand Down

0 comments on commit 4d2377b

Please sign in to comment.