Skip to content

Commit b738d1e

Browse files
authored
sync code from release-3.15.0 (FISCO-BCOS#4861)
2 parents 3c29314 + d19dcbf commit b738d1e

File tree

131 files changed

+2192
-1650
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+2192
-1650
lines changed

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
Checks: 'readability-*,clang-diagnostic-*,clang-analyzer-*,bugprone-*,cppcoreguidelines-*,modernize-*,performance-*,-modernize-use-trailing-return-type,-modernize-use-nodiscard'
2+
Checks: 'readability-*,clang-diagnostic-*,clang-analyzer-*,bugprone-*,cppcoreguidelines-*,modernize-*,performance-*,-modernize-use-trailing-return-type,-modernize-use-nodiscard,-cppcoreguidelines-avoid-reference-coroutine-parameters'
33
WarningsAsErrors: ''
44
HeaderFilterRegex: ''
55
FormatStyle: none

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ endif()
66

77
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
88

9-
set(VERSION "3.14.0")
9+
set(VERSION "3.15.0")
1010
set(VERSION_SUFFIX "")
1111
include(Options)
1212
configure_project()

bcos-crypto/bcos-crypto/ChecksumAddress.h

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
#include <bcos-crypto/hash/Keccak256.h>
2626
#include <bcos-crypto/interfaces/crypto/Hash.h>
2727
#include <bcos-utilities/DataConvertUtility.h>
28+
#include <evmc/evmc.h>
2829
#include <fmt/format.h>
2930
#include <boost/algorithm/string.hpp>
31+
#include <memory>
3032
#include <string>
3133

3234
namespace bcos
@@ -120,26 +122,37 @@ inline std::string newEVMAddress(
120122
return newEVMAddress(*_hashImpl, blockNumber, contextID, seq);
121123
}
122124

123-
124125
// keccak256(rlp.encode([normalize_address(sender), nonce]))[12:]
125-
inline std::string newLegacyEVMAddress(bytesConstRef sender, u256 nonce) noexcept
126+
inline evmc_address newLegacyEVMAddress(bytesConstRef sender, const u256& nonce) noexcept
126127
{
127-
codec::rlp::Header header{true, 1 + sender.size()};
128+
codec::rlp::Header header{.isList = true, .payloadLength = 1 + sender.size()};
128129
header.payloadLength += codec::rlp::length(nonce);
129130
bcos::bytes rlp;
130131
codec::rlp::encodeHeader(rlp, header);
131132
codec::rlp::encode(rlp, sender);
132133
codec::rlp::encode(rlp, nonce);
133134
auto hash = bcos::crypto::keccak256Hash(ref(rlp));
135+
evmc_address address;
136+
std::uninitialized_copy(hash.begin() + 12, hash.end(), address.bytes);
137+
138+
return address;
139+
}
140+
141+
inline std::string newLegacyEVMAddressString(bytesConstRef sender, const u256& nonce) noexcept
142+
{
143+
auto address = newLegacyEVMAddress(sender, nonce);
144+
auto view = std::span{address.bytes};
134145
std::string out;
135-
boost::algorithm::hex_lower(hash.begin() + 12, hash.end(), std::back_inserter(out));
146+
out.reserve(view.size() * 2);
147+
boost::algorithm::hex_lower(view.begin(), view.end(), std::back_inserter(out));
136148
return out;
137149
}
138150

139-
inline std::string newLegacyEVMAddress(bytesConstRef sender, std::string const& nonce) noexcept
151+
inline std::string newLegacyEVMAddressString(
152+
bytesConstRef sender, std::string const& nonce) noexcept
140153
{
141154
const auto uNonce = hex2u(nonce);
142-
return newLegacyEVMAddress(sender, uNonce);
155+
return newLegacyEVMAddressString(sender, uNonce);
143156
}
144157

145158
// EIP-1014

bcos-crypto/test/unittests/AddressTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,21 @@ BOOST_AUTO_TEST_CASE(testCreatLegacyEVMAddress)
5757
{
5858
{
5959
auto sender = fromHex("fbe0afcd7658ba86be41922059dd879c192d4c73"sv);
60-
auto newAddress = newLegacyEVMAddress(ref(sender), u256(0));
60+
auto newAddress = newLegacyEVMAddressString(ref(sender), u256(0));
6161
BOOST_CHECK_EQUAL(newAddress, "c669eaad75042be84daaf9b461b0e868b9ac1871");
6262
}
6363

6464
{
6565
auto sender = fromHex("f39Fd6e51aad88F6F4ce6aB8827279cffFb92266"sv);
66-
auto newAddress = newLegacyEVMAddress(ref(sender), u256(0));
66+
auto newAddress = newLegacyEVMAddressString(ref(sender), u256(0));
6767
BOOST_CHECK_EQUAL(newAddress, "5fbdb2315678afecb367f032d93f642f64180aa3");
6868
}
6969

7070
// string nonce
7171
{
7272
auto sender = fromHex("f39Fd6e51aad88F6F4ce6aB8827279cffFb92266"sv);
7373
auto nonce = "0";
74-
auto newAddress = newLegacyEVMAddress(ref(sender), nonce);
74+
auto newAddress = newLegacyEVMAddressString(ref(sender), nonce);
7575
BOOST_CHECK_EQUAL(newAddress, "5fbdb2315678afecb367f032d93f642f64180aa3");
7676
}
7777
}

bcos-executor/src/Common.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include <evmc/evmc.h>
3838
#include <evmc/instructions.h>
3939
#include <boost/algorithm/string/case_conv.hpp>
40-
#include <algorithm>
4140
#include <iterator>
4241
#include <memory>
4342
#include <set>
@@ -324,7 +323,7 @@ std::array<char, sizeof(evmc_address) * 2> address2HexArray(const evmc_address&
324323
task::Task<bool> checkTransferPermission(auto& storage, std::string_view sender)
325324
{
326325
if (co_await storage2::existsOne(
327-
storage, transaction_executor::StateKeyView{ledger::SYS_BALANCE_CALLER, sender}))
326+
storage, executor_v1::StateKeyView{ledger::SYS_BALANCE_CALLER, sender}))
328327
{
329328
co_return true;
330329
}

bcos-executor/src/executive/TransactionExecutive.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ CallParameters::UniquePtr TransactionExecutive::externalCall(CallParameters::Uni
116116
if (m_blockContext.features().get(ledger::Features::Flag::feature_evm_address))
117117
{
118118
auto senderBytes = fromHex(input->senderAddress);
119-
newAddress = bcos::newLegacyEVMAddress(ref(senderBytes), input->nonce);
119+
newAddress = bcos::newLegacyEVMAddressString(ref(senderBytes), input->nonce);
120120
}
121121
else
122122
{

bcos-executor/src/precompiled/CastPrecompiled.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include "../vm/Precompiled.h"
4-
#include "bcos-executor/src/precompiled/common/Common.h"
54
#include <bcos-crypto/interfaces/crypto/CommonType.h>
65

76
namespace bcos::precompiled
@@ -16,6 +15,5 @@ class CastPrecompiled : public Precompiled
1615
std::shared_ptr<PrecompiledExecResult> call(
1716
std::shared_ptr<executor::TransactionExecutive> _executive,
1817
PrecompiledExecResult::Ptr _callParameters) override;
19-
2018
};
21-
} // namespace precompiled
19+
} // namespace bcos::precompiled

bcos-executor/src/precompiled/SystemConfigPrecompiled.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "bcos-executor/src/precompiled/common/PrecompiledResult.h"
2323
#include "bcos-executor/src/precompiled/common/Utilities.h"
2424
#include "bcos-framework/ledger/Features.h"
25+
#include "bcos-framework/ledger/SystemConfigs.h"
2526
#include "bcos-framework/storage/LegacyStorageMethods.h"
2627
#include "bcos-task/Wait.h"
2728
#include <bcos-framework/ledger/LedgerTypeDef.h>
@@ -103,6 +104,11 @@ SystemConfigPrecompiled::SystemConfigPrecompiled(crypto::Hash::Ptr hashImpl) : P
103104
std::make_pair(ENABLE_BALANCE_TRANSFER, [defaultCmp](int64_t _value, uint32_t version) {
104105
defaultCmp(ENABLE_BALANCE_TRANSFER, _value, 0, version, BlockVersion::V3_10_2_VERSION);
105106
}));
107+
m_sysValueCmp.emplace(magic_enum::enum_name(ledger::SystemConfig::executor_version),
108+
[defaultCmp](int64_t _value, uint32_t version) {
109+
defaultCmp(magic_enum::enum_name(ledger::SystemConfig::executor_version), _value, 0,
110+
version, BlockVersion::V3_15_0_VERSION);
111+
});
106112
// for compatibility
107113
// Note: the compatibility_version is not compatibility
108114
m_sysValueCmp.insert(

bcos-executor/src/precompiled/TableManagerPrecompiled.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ void TableManagerPrecompiled::openTable(
311311
// if link
312312
auto addressEntry = _executive->storage().getRow(absolutePath, FS_LINK_ADDRESS);
313313
auto contractAddress = std::string(addressEntry->get());
314-
auto codecAddress = codec.encode(Address(std::move(contractAddress)));
314+
auto codecAddress = codec.encode(Address(contractAddress));
315315
_callParameters->setExecResult(std::move(codecAddress));
316316
return;
317317
}

bcos-executor/src/precompiled/TableManagerPrecompiled.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
#include "../executive/TransactionExecutive.h"
2424
#include "../vm/Precompiled.h"
25-
#include "bcos-executor/src/precompiled/common/Common.h"
26-
#include "bcos-executor/src/precompiled/common/Utilities.h"
2725
#include <bcos-crypto/interfaces/crypto/CommonType.h>
2826
#include <bcos-framework/storage/Table.h>
2927

0 commit comments

Comments
 (0)