Skip to content

Commit

Permalink
Merge branch 'release-2.0.3' into release-2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
morebtcg authored Mar 27, 2019
2 parents d51ca47 + cba8d63 commit 3bc6b55
Show file tree
Hide file tree
Showing 37 changed files with 813 additions and 171 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ install: |
bash tools/ci/check-commit.sh;
script: |
mkdir -p build && cd build && CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake .. && make -j2 && \
../tools/build_chain.sh -l "127.0.0.1:4" -e bin/fisco-bcos && cd nodes/127.0.0.1 && bash start_all.sh && sleep 2 && [ $(bash .transTest.sh | grep "result" | wc -l) -eq 1 ]
cd ../tools && bash ci/ci_check.sh
after_success:
# if [ $TRAVIS_OS_NAME == linux ]; then
# cd $TRAVIS_BUILD_DIR && bash <(curl -s https://codecov.io/bash)
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ English / [中文](docs/README_CN.md)

![](docs/images/FISCO_BCOS_Logo.svg)

**FISCO BCOS** is an open-sourced, cross-industry, collaborative, and secure blockchain platform. Based on BCOS platform, FISCO BCOS strives to integrate and coordinate research resources to advance financial blockchain technology, as well as promote synergy and collaboration for blockchain-based financial application research. With these establishments, it seeks to facilitate the members' R&D capabilities to apply financial consortium blockchain in business scenarios.
**FISCO BCOS** is a collaborative, secure, and high-performance open-source blockchain platform led by FISCO community. Evolved from BCOS project, FISCO BCOS strives to advance blockchain technology to promote effortless collaboration and innovation of blockchain-based financial applications. By focusing on performance, security and privacy, application adaptability, and operation optimization, FISCO BCOS helps community members to explore new business scenarios with state-of-the-art consortium blockchain technology.

[![codecov](https://codecov.io/gh/FISCO-BCOS/FISCO-BCOS/branch/master/graph/badge.svg)](https://codecov.io/gh/FISCO-BCOS/FISCO-BCOS) [![CodeFactor](https://www.codefactor.io/repository/github/fisco-bcos/FISCO-BCOS/badge)](https://www.codefactor.io/repository/github/fisco-bcos/FISCO-BCOS) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/08552871ee104fe299b00bc79f8a12b9)](https://www.codacy.com/app/fisco-dev/FISCO-BCOS?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=FISCO-BCOS/FISCO-BCOS&amp;utm_campaign=Badge_Grade) [![GitHub All Releases](https://img.shields.io/github/downloads/FISCO-BCOS/FISCO-BCOS/total.svg)](https://github.com/FISCO-BCOS/FISCO-BCOS)

[![CircleCI](https://circleci.com/gh/FISCO-BCOS/FISCO-BCOS.svg?style=shield)](https://circleci.com/gh/FISCO-BCOS/FISCO-BCOS) [![Build Status](https://travis-ci.org/FISCO-BCOS/FISCO-BCOS.svg)](https://travis-ci.org/FISCO-BCOS/FISCO-BCOS)
[![Code Lines](https://tokei.rs/b1/github/FISCO-BCOS/FISCO-BCOS?category=code)](https://github.com/FISCO-BCOS/FISCO-BCOS)


## Documentation
Expand All @@ -19,25 +20,28 @@ Version 2.0 introduces new internal block data formats and network protocols for

## Developing & Contributing

- Star our Github.
- Pull requests. See [CONTRIBUTING](CONTRIBUTING.md) and [CODING_STYLE](CODING_STYLE.md).
- Star our project.
- Submit pull requests. See [CONTRIBUTING](CONTRIBUTING.md) and [CODING_STYLE](CODING_STYLE.md).
- [Ask questions](https://github.com/FISCO-BCOS/FISCO-BCOS/issues).
- Discuss in [WeChat group](docs/images/WeChatQR.jpeg) or [Gitter](https://gitter.im/fisco-bcos/Lobby).
- Join the discussion in [WeChat](docs/images/WeChatQR.jpeg) or [Gitter](https://gitter.im/fisco-bcos/Lobby).

## Features

**Security**: Support the sensitive financial business scenarios by providing advanced security features including node access management, data permission control, CA certificate verification, guomi crypto support.

**Performance**: Tackle high transaction throughput with optimization technologies including parallel transaction processing, precompiled smart contracts, advanced mass database.

**Reliability**: Verified by multiple running cross-organization financial applications.

**Usability**: Offer user-friendly and comprehensive toolkits including interactive console, deployment tools, block browsers, SDK, and other supporting tools.

## Featured Cases

Since FISCO BCOS launched, dozens of applications have been implemented. See [FEATURED CASES](http://www.fisco-bcos.org/assets/docs/FISCO%20BCOS%20-%20Featured%20Cases.pdf).
Since FISCO BCOS launched, dozens of applications have been implemented and launched. See [FEATURED CASES](http://www.fisco-bcos.org/assets/docs/FISCO%20BCOS%20-%20Featured%20Cases.pdf).

## Community

By the end of 2018, Financial Blockchain Shenzhen Consortium (FISCO) has attracted and admitted more than 100 members from 6 sectors including banking, fund management, securities brokerage, insurance, regional equity exchanges, and financial information service companies. The first members include the following organizations: Beyondsoft, Huawei, Shenzhen Securities Communications, Digital China, Forms Syntron, Tencent, WeBank, Yuexiu FinTech.
By 2019, Financial Blockchain Shenzhen Consortium (FISCO) has been well recognized by more than 100 members from 6 industrial sectors including banking, fund management, securities brokerage, insurance, regional equity exchanges, and financial information service companies. The first group of members includes the following organizations: Beyondsoft, Huawei, Shenzhen Securities Communications, Digital China, Forms Syntron, Tencent, WeBank, and Yuexiu FinTech.

- Join our WeChat [![Scan](https://img.shields.io/badge/style-Scan_QR_Code-green.svg?logo=wechat&longCache=false&style=social&label=Group)](docs/images/WeChatQR.jpeg)

Expand Down
30 changes: 30 additions & 0 deletions cmake/templates/UserPrecompiled.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

/*
This file is part of FISCO-BCOS
FISCO-BCOS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

FISCO-BCOS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with FISCO-BCOS. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file: UserPrecompiled.h
* @author: bxq
* @date: 2019
*/

#include "libblockverifier/ExecutiveContextFactory.h"
@USER_PRECOMPILED_HEADER@

void dev::blockverifier::ExecutiveContextFactory::registerUserPrecompiled(dev::blockverifier::ExecutiveContext::Ptr context)
{
// Address should in [0x5001,0xffff]
// context->setAddress2Precompiled(Address(0x5001), std::make_shared<dev::precompiled::HelloWorldPrecompiled>());
}
3 changes: 2 additions & 1 deletion docs/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[![codecov](https://codecov.io/gh/FISCO-BCOS/FISCO-BCOS/branch/master/graph/badge.svg)](https://codecov.io/gh/FISCO-BCOS/FISCO-BCOS) [![CodeFactor](https://www.codefactor.io/repository/github/fisco-bcos/FISCO-BCOS/badge)](https://www.codefactor.io/repository/github/fisco-bcos/FISCO-BCOS) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/08552871ee104fe299b00bc79f8a12b9)](https://www.codacy.com/app/fisco-dev/FISCO-BCOS?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=FISCO-BCOS/FISCO-BCOS&amp;utm_campaign=Badge_Grade) [![GitHub All Releases](https://img.shields.io/github/downloads/FISCO-BCOS/FISCO-BCOS/total.svg)](https://github.com/FISCO-BCOS/FISCO-BCOS)

[![CircleCI](https://circleci.com/gh/FISCO-BCOS/FISCO-BCOS.svg?style=shield)](https://circleci.com/gh/FISCO-BCOS/FISCO-BCOS) [![Build Status](https://travis-ci.org/FISCO-BCOS/FISCO-BCOS.svg)](https://travis-ci.org/FISCO-BCOS/FISCO-BCOS)
[![Code Lines](https://tokei.rs/b1/github/FISCO-BCOS/FISCO-BCOS?category=code)](https://github.com/FISCO-BCOS/FISCO-BCOS)

## 文档

Expand Down Expand Up @@ -52,4 +53,4 @@ FISCO BCOS有很多的应用案例。此处提供一些具有代表性的[落地

[![](https://img.shields.io/github/license/FISCO-BCOS/FISCO-BCOS.svg)](../LICENSE)

FISCO BCOS的开源协议为[GPL 3.0](https://www.gnu.org/licenses/gpl-3.0.en.html)。详情参见[LICENSE](../LICENSE)
FISCO BCOS的开源协议为[GPL 3.0](https://www.gnu.org/licenses/gpl-3.0.en.html)。详情参见[LICENSE](../LICENSE)
3 changes: 2 additions & 1 deletion libblockverifier/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ add_library(blockverifier ${SRC_LIST} ${HEADERS})

target_include_directories(blockverifier PRIVATE ..)
target_link_libraries(blockverifier PUBLIC executivecontext devcore TBB)
target_link_libraries(blockverifier PRIVATE storage precompiled extension)
target_link_libraries(blockverifier PRIVATE storage precompiled)
target_compile_options(blockverifier BEFORE PRIVATE -Wno-unused-parameter)
7 changes: 3 additions & 4 deletions libblockverifier/ExecutiveContextFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @date 20180921
*/
#include "ExecutiveContextFactory.h"
#include "include/UserPrecompiled.h"
#include <libdevcore/Common.h>
#include <libprecompiled/AuthorityPrecompiled.h>
#include <libprecompiled/CNSPrecompiled.h>
Expand All @@ -27,7 +28,6 @@
#include <libprecompiled/DagTransferPrecompiled.h>
#include <libprecompiled/ParallelConfigPrecompiled.h>
#include <libprecompiled/SystemConfigPrecompiled.h>
#include <libprecompiled/extension/HelloWorldPrecompiled.h>
#include <libstorage/MemoryTableFactory.h>
#include <libstorage/TableFactoryPrecompiled.h>

Expand Down Expand Up @@ -64,10 +64,9 @@ void ExecutiveContextFactory::initExecutiveContext(
Address(0x1006), std::make_shared<dev::precompiled::DagTransferPrecompiled>());
context->setAddress2Precompiled(
Address(0x1007), std::make_shared<dev::precompiled::ParallelConfigPrecompiled>());
context->setAddress2Precompiled(
Address(0x5001), std::make_shared<dev::precompiled::HelloWorldPrecompiled>());
// register User developed Precompiled contract
registerUserPrecompiled(context);
context->setMemoryTableFactory(memoryTableFactory);

context->setBlockInfo(blockInfo);
context->setPrecompiledContract(m_precompiledContract);
context->setState(m_stateFactoryInterface->getState(stateRoot, memoryTableFactory));
Expand Down
1 change: 1 addition & 0 deletions libblockverifier/ExecutiveContextFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class ExecutiveContextFactory : public std::enable_shared_from_this<ExecutiveCon
std::unordered_map<Address, dev::eth::PrecompiledContract> m_precompiledContract;

void setTxGasLimitToContext(ExecutiveContext::Ptr context);
void registerUserPrecompiled(ExecutiveContext::Ptr context);
};

} // namespace blockverifier
Expand Down
34 changes: 33 additions & 1 deletion libconfig/GlobalConfigure.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@

namespace dev
{
enum VERSION
{
RC1_VERSION = 1,
RC2_VERSION = 2,
LATEST_VERSION
};
class GlobalConfigure
{
public:
Expand All @@ -34,6 +40,26 @@ class GlobalConfigure
static GlobalConfigure ins;
return ins;
}
void setVersion(std::string const& versionStr)
{
if (dev::stringCmpIgnoreCase(versionStr, "2.0.0-rc1") == 0)
{
m_version = RC1_VERSION;
}
else if (dev::stringCmpIgnoreCase(versionStr, "2.0.0-rc2") == 0)
{
m_version = RC2_VERSION;
}
else
{
m_version = LATEST_VERSION;
}
}

VERSION const& version() const { return m_version; }
void setCompress(bool const& compress) { m_compress = compress; }

bool compressEnabled() const { return m_compress; }

struct DiskEncryption
{
Expand All @@ -43,13 +69,19 @@ class GlobalConfigure
std::string cipherDataKey;
} diskEncryption;


/// default block time
const unsigned c_intervalBlockTime = 1000;
/// omit empty block or not
const bool c_omitEmptyBlock = true;
/// default blockLimit
const unsigned c_blockLimit = 1000;

/// default compress threshold: 1KB
const uint64_t c_compressThreshold = 1024;

private:
VERSION m_version;
bool m_compress;
};

#define g_BCOSConfig GlobalConfigure::instance()
Expand Down
16 changes: 8 additions & 8 deletions libconsensus/pbft/PBFTEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ bool PBFTEngine::generatePrepare(Block const& block)
if (prepare_req.pBlock->getTransactionSize() == 0 && m_omitEmptyBlock)
{
m_leaderFailed = true;
changeViewForEmptyBlock();
changeViewForFastViewChange();
return true;
}
handlePrepareMsg(prepare_req);
Expand Down Expand Up @@ -423,6 +423,7 @@ bool PBFTEngine::broadcastMsg(unsigned const& packetType, std::string const& key
{
auto sessions = m_service->sessionInfosByProtocolID(m_protocolId);
m_connectedNode = sessions.size();
NodeIDs nodeIdList;
for (auto session : sessions)
{
/// get node index of the sealer from m_sealerList failed ?
Expand All @@ -443,11 +444,12 @@ bool PBFTEngine::broadcastMsg(unsigned const& packetType, std::string const& key
<< LOG_KV("ttl", (ttl == 0 ? maxTTL : ttl))
<< LOG_KV("nodeIdx", nodeIdx())
<< LOG_KV("myNode", session.nodeID.abridged());
/// send messages
m_service->asyncSendMessageByNodeID(
session.nodeID, transDataToMessage(data, packetType, ttl), nullptr);
nodeIdList.push_back(session.nodeID);
broadcastMark(session.nodeID, packetType, key);
}
/// send messages according to node id
m_service->asyncMulticastMessageByNodeIDList(
nodeIdList, transDataToMessage(data, packetType, ttl));
return true;
}

Expand Down Expand Up @@ -809,7 +811,7 @@ bool PBFTEngine::handlePrepareMsg(PrepareReq const& prepareReq, std::string cons
/// whether to omit empty block
if (needOmit(workingSealing))
{
changeViewForEmptyBlock();
changeViewForFastViewChange();
return true;
}

Expand Down Expand Up @@ -1190,13 +1192,11 @@ bool PBFTEngine::handleViewChangeMsg(ViewChangeReq& viewChange_req, PBFTMsgPacke
min_view, m_f, m_toView, m_highestBlock, m_consensusBlockNumber);
if (should_trigger)
{
m_timeManager.changeView();
m_toView = min_view - 1;
m_fastViewChange = true;
PBFTENGINE_LOG(INFO) << LOG_DESC("Trigger fast-viewchange") << LOG_KV("view", m_view)
<< LOG_KV("toView", m_toView) << LOG_KV("minView", min_view)
<< LOG_KV("INFO", oss.str());
m_signalled.notify_all();
changeViewForFastViewChange();
}
}
PBFTENGINE_LOG(DEBUG) << LOG_DESC("handleViewChangeMsg Succ ") << oss.str();
Expand Down
8 changes: 4 additions & 4 deletions libconsensus/pbft/PBFTEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <libsync/SyncStatus.h>
#include <sstream>

#include <libp2p/P2PMessage.h>
#include <libp2p/P2PMessageFactory.h>
#include <libp2p/P2PSession.h>
#include <libp2p/Service.h>

Expand Down Expand Up @@ -293,7 +293,8 @@ class PBFTEngine : public ConsensusEngineBase
inline dev::p2p::P2PMessage::Ptr transDataToMessage(bytesConstRef data,
PACKET_TYPE const& packetType, PROTOCOL_ID const& protocolId, unsigned const& ttl)
{
dev::p2p::P2PMessage::Ptr message = std::make_shared<dev::p2p::P2PMessage>();
dev::p2p::P2PMessage::Ptr message = std::dynamic_pointer_cast<dev::p2p::P2PMessage>(
m_service->p2pMessageFactory()->buildMessage());
// std::shared_ptr<dev::bytes> p_data = std::make_shared<dev::bytes>();
bytes ret_data;
PBFTMsgPacket packet;
Expand Down Expand Up @@ -508,10 +509,9 @@ class PBFTEngine : public ConsensusEngineBase
/// check block
bool checkBlock(dev::eth::Block const& block);
void execBlock(Sealing& sealing, PrepareReq const& req, std::ostringstream& oss);
void changeViewForEmptyBlock()
void changeViewForFastViewChange()
{
m_timeManager.changeView();
m_timeManager.m_changeCycle = 0;
m_fastViewChange = true;
m_signalled.notify_all();
}
Expand Down
14 changes: 13 additions & 1 deletion libconsensus/pbft/PBFTSealer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class PBFTSealer : public Sealer
std::shared_ptr<dev::blockchain::BlockChainInterface> _blockChain,
std::shared_ptr<dev::sync::SyncInterface> _blockSync,
std::shared_ptr<dev::blockverifier::BlockVerifierInterface> _blockVerifier,
int16_t const& _protocolId, std::string const& _baseDir, KeyPair const& _key_pair,
dev::PROTOCOL_ID const& _protocolId, std::string const& _baseDir, KeyPair const& _key_pair,
h512s const& _sealerList = h512s())
: Sealer(_txPool, _blockChain, _blockSync)
{
Expand Down Expand Up @@ -93,6 +93,18 @@ class PBFTSealer : public Sealer
/// reset block when view changes
void resetBlockForViewChange()
{
/// in case of that:
/// time1: checkTimeout, blockNumber = n - 1
/// time2: Report block, blockNumber = n
/// time2: handleBlock, seal a new block, blockNumber(m_sealing) = n + 1, and broadcast the
/// prepare request time3: callback onViewChange, reset the sealed block time4: seal again,
/// blockNumber(m_sealing) = n + 1 the result is: generate two block with the same block in
/// a period solution: if there has been a higher sealed block, return directly without
/// reset
if (m_sealing.block.isSealed() && shouldHandleBlock())
{
return;
}
{
DEV_WRITE_GUARDED(x_sealing)
resetSealingBlock();
Expand Down
3 changes: 2 additions & 1 deletion libconsensus/raft/RaftEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,8 @@ void RaftEngine::broadcastVoteReq()
P2PMessage::Ptr RaftEngine::transDataToMessage(
bytesConstRef _data, RaftPacketType const& _packetType, PROTOCOL_ID const& _protocolId)
{
dev::p2p::P2PMessage::Ptr message = std::make_shared<dev::p2p::P2PMessage>();
dev::p2p::P2PMessage::Ptr message = std::dynamic_pointer_cast<dev::p2p::P2PMessage>(
m_service->p2pMessageFactory()->buildMessage());
std::shared_ptr<dev::bytes> dataPtr = std::make_shared<dev::bytes>();
RaftMsgPacket packet;

Expand Down
2 changes: 1 addition & 1 deletion libconsensus/raft/RaftEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <libethcore/Block.h>
#include <libnetwork/Common.h>
#include <libp2p/P2PInterface.h>
#include <libp2p/P2PMessage.h>
#include <libp2p/P2PMessageFactory.h>
#include <libp2p/P2PSession.h>
#include <libstorage/Storage.h>
#include <libsync/SyncInterface.h>
Expand Down
2 changes: 1 addition & 1 deletion libdevcore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ add_library(devcore ${SRC_LIST} ${HEADERS})
target_include_directories(devcore SYSTEM BEFORE PUBLIC ${BOOST_INCLUDE_DIR})
# set_source_files_properties(${SRC_LIST} ${HEADERS} PROPERTIES COMPILE_FLAGS -Wno-unused-function)
target_compile_options(devcore BEFORE PRIVATE -Wno-error -Wno-unused-variable -Wno-unused-function -Wno-uninitialized)
target_link_libraries(devcore PUBLIC LevelDB Boost::Log Boost::Filesystem Boost::Thread)
target_link_libraries(devcore PUBLIC LevelDB Boost::Log Boost::Filesystem Boost::Thread Snappy)
add_dependencies(devcore BuildInfo.h LevelDB)

# get_property(dirs TARGET devcore PROPERTY INCLUDE_DIRECTORIES)
Expand Down
9 changes: 9 additions & 0 deletions libdevcore/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,13 @@ uint64_t utcTime()
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}

/// get utc time(us)
uint64_t utcTimeUs()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000000 + tv.tv_usec;
}

} // namespace dev
3 changes: 3 additions & 0 deletions libdevcore/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ enum class WithExisting : int
/// Get the current time in seconds since the epoch in UTC(ms)
uint64_t utcTime();

/// Get the current time in seconds since the epoch in UTC(us)
uint64_t utcTimeUs();

/// Reference to a slice of buffer that also owns the buffer.
///
/// This is extension to the concept C++ STL library names as array_view
Expand Down
Loading

0 comments on commit 3bc6b55

Please sign in to comment.