Skip to content

Commit

Permalink
Merge branch 'release-2.0.3' of https://github.com/FISCO-BCOS/FISCO-BCOS
Browse files Browse the repository at this point in the history
 into release-2.0.3
  • Loading branch information
JimmyShi22 committed Mar 28, 2019
2 parents 75f2689 + 83b8cff commit 685d479
Show file tree
Hide file tree
Showing 50 changed files with 492 additions and 263 deletions.
8 changes: 4 additions & 4 deletions cmake/EthCompilerSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,19 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
set(CMAKE_CXX_FLAGS "-g --coverage ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-g --coverage ${CMAKE_C_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "--coverage ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "--coverage ${CMAKE_EXE_LINKER_FLAGS}")
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
add_compile_options(-Wno-unused-command-line-argument)
set(CMAKE_CXX_FLAGS "-g -fprofile-arcs -ftest-coverage ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-g -fprofile-arcs -ftest-coverage ${CMAKE_C_FLAGS}")
endif()
set(CMAKE_SHARED_LINKER_FLAGS "--coverage ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "--coverage ${CMAKE_EXE_LINKER_FLAGS}")
find_program(LCOV_TOOL lcov)
message(STATUS "lcov tool: ${LCOV_TOOL}")
if (LCOV_TOOL)
add_custom_target(coverage
COMMAND ${LCOV_TOOL} -o ${CMAKE_BINARY_DIR}/coverage.info -c -d ${CMAKE_BINARY_DIR}
COMMAND ${LCOV_TOOL} -o ${CMAKE_BINARY_DIR}/coverage.info -r ${CMAKE_BINARY_DIR}/coverage.info '/usr*' '${CMAKE_BINARY_DIR}/deps/*' '${CMAKE_SOURCE_DIR}/deps/*' '*evmc*'
COMMAND ${LCOV_TOOL} -o ${CMAKE_BINARY_DIR}/coverage.info.in -c -d ${CMAKE_BINARY_DIR}/
COMMAND ${LCOV_TOOL} -r ${CMAKE_BINARY_DIR}/coverage.info.in '/usr*' '${CMAKE_SOURCE_DIR}/deps**' '${CMAKE_SOURCE_DIR}/evmc*' ${CMAKE_SOURCE_DIR}/utils*’ -o ${CMAKE_BINARY_DIR}/coverage.info
COMMAND genhtml -q -o ${CMAKE_BINARY_DIR}/CodeCoverage ${CMAKE_BINARY_DIR}/coverage.info)
endif()
endif ()
Expand Down
2 changes: 1 addition & 1 deletion fisco-bcos/blockverifier/verifierMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int main(int argc, char* argv[])
auto blockChain = std::make_shared<dev::blockchain::BlockChainImp>();
blockChain->setStateStorage(storage);
dev::blockchain::GenesisBlockParam initParam = {
"std", dev::h512s(), dev::h512s(), "", "", "", 1000, 300000000};
"std", dev::h512s(), dev::h512s(), "", "", "", 1000, 300000000, 0};
blockChain->checkAndBuildGenesisBlock(initParam);

auto stateFactory = std::make_shared<dev::storagestate::StorageStateFactory>(dev::u256(0));
Expand Down
2 changes: 1 addition & 1 deletion fisco-bcos/para/para_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static void startExecute(int _totalUser, int _totalTxs)
blockChain->setStateStorage(dbInitializer->storage());

GenesisBlockParam initParam = {"", dev::h512s(), dev::h512s(), "consensusType", "storageType",
"stateType", 5000, 300000000};
"stateType", 5000, 300000000, 0};
bool ret = blockChain->checkAndBuildGenesisBlock(initParam);
assert(ret == true);

Expand Down
4 changes: 2 additions & 2 deletions libblockchain/BlockChainImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ bool BlockChainImp::checkAndBuildGenesisBlock(GenesisBlockParam& initParam)
if (block == nullptr)
{
block = std::make_shared<Block>();
block->setEmptyBlock();
/// modification 2019.3.20: set timestamp to block header
block->setEmptyBlock(initParam.timeStamp);
block->header().appendExtraDataArray(asBytes(initParam.groupMark));
shared_ptr<MemoryTableFactory> mtb = getMemoryTableFactory();
Table::Ptr tb = mtb->openTable(SYS_NUMBER_2_HASH, false);
Expand Down Expand Up @@ -517,7 +518,6 @@ bool BlockChainImp::checkAndBuildGenesisBlock(GenesisBlockParam& initParam)
try
{
boost::split(s, extraData, boost::is_any_of("-"), boost::token_compress_on);
assert(s.size() == 7);
initParam.consensusType = s[2];
initParam.storageType = s[3];
initParam.stateType = s[4];
Expand Down
3 changes: 3 additions & 0 deletions libblockchain/BlockChainInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ enum class CommitResult
};
// Configuration item written to the table of genesis block,
// groupMark/consensusType/storageType/stateType excluded.
// modification 2019.3.20: add timestamp filed into the GenesisBlockParam for setting the timestamp
// for the zero block
struct GenesisBlockParam
{
std::string groupMark; // Data written to extra data of genesis block.
Expand All @@ -54,6 +56,7 @@ struct GenesisBlockParam
std::string stateType; // the type of state, now mpt/storage
uint64_t txCountLimit; // the maximum number of transactions recorded in a block
uint64_t txGasLimit; // the maximum gas required to execute a transaction
uint64_t timeStamp; /// the timestamp of genesis block
};
class BlockChainInterface
{
Expand Down
1 change: 1 addition & 0 deletions libblockverifier/BlockVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ ExecutiveContext::Ptr BlockVerifier::parallelExecuteBlock(
while (!txDag->hasFinished() && utcTime() < parallelTimeOut)
{
txDag->executeUnit();
memoryTableFactory->getChangeLog().clear();
}
}));
}
Expand Down
2 changes: 1 addition & 1 deletion libblockverifier/ExecutiveContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ExecutiveContext : public std::enable_shared_from_this<ExecutiveContext>

ExecutiveContext() {}

virtual ~ExecutiveContext(){};
virtual ~ExecutiveContext() { m_memoryTableFactory->getChangeLog().clear(); };

virtual bytes call(Address const& origin, Address address, bytesConstRef param);

Expand Down
5 changes: 0 additions & 5 deletions libblockverifier/Precompiled.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ class Precompiled : public std::enable_shared_from_this<Precompiled>
std::shared_ptr<dev::storage::Table> openTable(
std::shared_ptr<dev::blockverifier::ExecutiveContext> _context,
const std::string& tableName);
virtual dev::storage::AccessOptions::Ptr getOptions(Address const& origin)
{
return std::make_shared<dev::storage::AccessOptions>(origin);
}

std::shared_ptr<dev::storage::Table> createTable(
std::shared_ptr<dev::blockverifier::ExecutiveContext> _context,
const std::string& _tableName, const std::string& _keyField, const std::string& _valueField,
Expand Down
16 changes: 1 addition & 15 deletions libconfig/GlobalConfigure.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,7 @@ 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;
}
}
void setVersion(VERSION _version) { m_version = _version; }

VERSION const& version() const { return m_version; }
void setCompress(bool const& compress) { m_compress = compress; }
Expand Down
22 changes: 11 additions & 11 deletions libconsensus/pbft/PBFTEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,16 +391,16 @@ bool PBFTEngine::sendMsg(dev::network::NodeID const& nodeId, unsigned const& pac
}
for (auto session : sessions)
{
if (session.nodeID == nodeId)
if (session.nodeID() == nodeId)
{
m_service->asyncSendMessageByNodeID(
session.nodeID, transDataToMessage(data, packetType, ttl), nullptr);
session.nodeID(), transDataToMessage(data, packetType, ttl), nullptr);
PBFTENGINE_LOG(DEBUG) << LOG_DESC("sendMsg") << LOG_KV("packetType", packetType)
<< LOG_KV("dstNodeId", nodeId.abridged())
<< LOG_KV("remote_endpoint", session.nodeIPEndpoint.name())
<< LOG_KV("nodeIdx", nodeIdx())
<< LOG_KV("myNode", m_keyPair.pub().abridged());
broadcastMark(session.nodeID, packetType, key);
broadcastMark(session.nodeID(), packetType, key);
return true;
}
}
Expand All @@ -427,25 +427,25 @@ bool PBFTEngine::broadcastMsg(unsigned const& packetType, std::string const& key
for (auto session : sessions)
{
/// get node index of the sealer from m_sealerList failed ?
if (getIndexBySealer(session.nodeID) < 0)
if (getIndexBySealer(session.nodeID()) < 0)
continue;
/// peer is in the _filter list ?
if (filter.count(session.nodeID))
if (filter.count(session.nodeID()))
{
broadcastMark(session.nodeID, packetType, key);
broadcastMark(session.nodeID(), packetType, key);
continue;
}
/// packet has been broadcasted?
if (broadcastFilter(session.nodeID, packetType, key))
if (broadcastFilter(session.nodeID(), packetType, key))
continue;
PBFTENGINE_LOG(TRACE) << LOG_DESC("broadcastMsg") << LOG_KV("packetType", packetType)
<< LOG_KV("dstNodeId", session.nodeID.abridged())
<< LOG_KV("dstNodeId", session.nodeID().abridged())
<< LOG_KV("dstIp", session.nodeIPEndpoint.name())
<< LOG_KV("ttl", (ttl == 0 ? maxTTL : ttl))
<< LOG_KV("nodeIdx", nodeIdx())
<< LOG_KV("myNode", session.nodeID.abridged());
nodeIdList.push_back(session.nodeID);
broadcastMark(session.nodeID, packetType, key);
<< LOG_KV("myNode", session.nodeID().abridged());
nodeIdList.push_back(session.nodeID());
broadcastMark(session.nodeID(), packetType, key);
}
/// send messages according to node id
m_service->asyncMulticastMessageByNodeIDList(
Expand Down
2 changes: 1 addition & 1 deletion libconsensus/pbft/TimeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct TimeManager
{
m_lastConsensusTime = 0;
m_lastSignTime = 0;
/// m_changeCycle = 0;
m_changeCycle = 0;
}

inline void updateChangeCycle()
Expand Down
12 changes: 6 additions & 6 deletions libconsensus/raft/RaftEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,14 +901,14 @@ void RaftEngine::broadcastMsg(P2PMessage::Ptr _data)
m_connectedNode = sessions.size();
for (auto session : sessions)
{
if (getIndexBySealer(session.nodeID) < 0)
if (getIndexBySealer(session.nodeID()) < 0)
{
continue;
}

m_service->asyncSendMessageByNodeID(session.nodeID, _data, nullptr);
m_service->asyncSendMessageByNodeID(session.nodeID(), _data, nullptr);
RAFTENGINE_LOG(TRACE) << LOG_DESC("[#broadcastMsg]Raft msg sent")
<< LOG_KV("peer", session.nodeID);
<< LOG_KV("peer", session.nodeID());
}
}

Expand Down Expand Up @@ -1215,13 +1215,13 @@ bool RaftEngine::sendResponse(
auto sessions = m_service->sessionInfosByProtocolID(m_protocolId);
for (auto session : sessions)
{
if (session.nodeID != _node || getIndexBySealer(session.nodeID) < 0)
if (session.nodeID() != _node || getIndexBySealer(session.nodeID()) < 0)
{
continue;
}

m_service->asyncSendMessageByNodeID(
session.nodeID, transDataToMessage(ref(ts.out()), _packetType, m_protocolId), nullptr);
m_service->asyncSendMessageByNodeID(session.nodeID(),
transDataToMessage(ref(ts.out()), _packetType, m_protocolId), nullptr);
RAFTENGINE_LOG(TRACE) << LOG_DESC("[#sendResponse]Response sent");
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion libethcore/Block.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,12 @@ class Block
noteReceiptChange();
}

void setEmptyBlock()
void setEmptyBlock(uint64_t timeStamp)
{
m_blockHeader.setNumber(0);
m_blockHeader.setGasUsed(u256(0));
m_blockHeader.setSealer(u256(0));
m_blockHeader.setTimestamp(timeStamp);
noteChange();
noteReceiptChange();
}
Expand Down
3 changes: 3 additions & 0 deletions libethcore/BlockHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,13 @@ class BlockHeader
bool appendExtraDataItem(bytes const& _content, unsigned int _index = 0)
{
if (_index >= m_extraData.size())
{
return false;
}
else
{
m_extraData[_index] = _content;
noteDirty();
return true;
}
}
Expand Down
52 changes: 26 additions & 26 deletions libexecutive/ExecutionResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,32 @@ namespace executive
enum class TransactionException : int
{
None = 0,
Unknown,
BadRLP,
InvalidFormat,
OutOfGasIntrinsic, ///< Too little gas to pay for the base transaction cost.
InvalidSignature,
InvalidNonce,
NotEnoughCash,
OutOfGasBase, ///< Too little gas to pay for the base transaction cost.
BlockGasLimitReached,
BadInstruction,
BadJumpDestination,
OutOfGas, ///< Ran out of gas executing code of the transaction.
OutOfStack, ///< Ran out of stack executing code of the transaction.
StackUnderflow,
NonceCheckFail, // noncecheck ok() == false
BlockLimitCheckFail,
FilterCheckFail,
NoDeployPermission,
NoCallPermission,
NoTxPermission,
PrecompiledError,
RevertInstruction,
InvalidZeroSignatureFormat,
AddressAlreadyUsed,
PermissionDenied,
CallAddressError
Unknown = 1,
BadRLP = 2,
InvalidFormat = 3,
OutOfGasIntrinsic = 4, ///< Too little gas to pay for the base transaction cost.
InvalidSignature = 5,
InvalidNonce = 6,
NotEnoughCash = 7,
OutOfGasBase = 8, ///< Too little gas to pay for the base transaction cost.
BlockGasLimitReached = 9,
BadInstruction = 10,
BadJumpDestination = 11,
OutOfGas = 12, ///< Ran out of gas executing code of the transaction.
OutOfStack = 13, ///< Ran out of stack executing code of the transaction.
StackUnderflow = 14,
NonceCheckFail = 15, // noncecheck ok() == false
BlockLimitCheckFail = 16,
FilterCheckFail = 17,
NoDeployPermission = 18,
NoCallPermission = 19,
NoTxPermission = 20,
PrecompiledError = 21,
RevertInstruction = 22,
InvalidZeroSignatureFormat = 23,
AddressAlreadyUsed = 24,
PermissionDenied = 25,
CallAddressError = 26
};

enum class CodeDeposit
Expand Down
12 changes: 10 additions & 2 deletions libinitializer/GlobalConfigureInitializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@ void GlobalConfigureInitializer::initConfig(const boost::property_tree::ptree& _
_pt.get<std::string>("data_secure.cipher_data_key", "");

/// init version
std::string version = _pt.get<std::string>("supported_compatibility.version", "");
g_BCOSConfig.setVersion(version);
std::string version = _pt.get<std::string>("compatibility.supported_version", "2.0.0-rc1");
if (dev::stringCmpIgnoreCase(version, "2.0.0-rc2") == 0)
{
g_BCOSConfig.setVersion(RC2_VERSION);
}
/// default is RC1
else
{
g_BCOSConfig.setVersion(RC1_VERSION);
}

/// compress related option, default enable
bool enableCompress = _pt.get<bool>("p2p.enable_compress", true);
Expand Down
9 changes: 5 additions & 4 deletions libinitializer/P2PInitializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@ void P2PInitializer::initConfig(boost::property_tree::ptree const& _pt)
asioInterface->setType(dev::network::ASIOInterface::SSL);

std::shared_ptr<P2PMessageFactory> messageFactory = nullptr;
if (g_BCOSConfig.version() <= dev::RC1_VERSION)

if (g_BCOSConfig.version() >= dev::RC2_VERSION)
{
messageFactory = std::make_shared<P2PMessageFactory>();
messageFactory = std::make_shared<P2PMessageFactoryRC2>();
}
else
else if (g_BCOSConfig.version() <= dev::RC1_VERSION)
{
messageFactory = std::make_shared<P2PMessageFactoryRC2>();
messageFactory = std::make_shared<P2PMessageFactory>();
}

auto host = std::make_shared<dev::network::Host>();
Expand Down
16 changes: 14 additions & 2 deletions libledger/Ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ void Ledger::initConfig(std::string const& configPath)
initDBConfig(pt);
/// init params related to tx
initTxConfig(pt);
/// init params related to genesis: timestamp
initGenesisConfig(pt);
}
catch (std::exception& e)
{
Expand Down Expand Up @@ -271,6 +273,15 @@ void Ledger::initTxConfig(boost::property_tree::ptree const& pt)
<< LOG_KV("txGasLimit", m_param->mutableTxParam().txGasLimit);
}

/// init genesis configuration
void Ledger::initGenesisConfig(boost::property_tree::ptree const& pt)
{
/// use UTCTime directly as timeStamp in case of the clock differences between machines
m_param->mutableGenesisParam().timeStamp = pt.get<uint64_t>("group.timestamp", 0);
Ledger_LOG(DEBUG) << LOG_BADGE("initGenesisConfig")
<< LOG_KV("timestamp", m_param->mutableGenesisParam().timeStamp);
}

/// init mark of this group
void Ledger::initMark()
{
Expand All @@ -281,7 +292,8 @@ void Ledger::initMark()
s << m_param->mutableStorageParam().type << "-";
s << m_param->mutableStateParam().type << "-";
s << m_param->mutableConsensusParam().maxTransactions << "-";
s << m_param->mutableTxParam().txGasLimit;
s << m_param->mutableTxParam().txGasLimit << "-";
s << m_param->mutableGenesisParam().timeStamp; /// add timeStamp of the genesis block
m_param->mutableGenesisParam().genesisMark = s.str();
Ledger_LOG(DEBUG) << LOG_BADGE("initMark")
<< LOG_KV("genesisMark", m_param->mutableGenesisParam().genesisMark);
Expand Down Expand Up @@ -352,7 +364,7 @@ bool Ledger::initBlockChain()
GenesisBlockParam initParam = {m_param->mutableGenesisParam().genesisMark,
m_param->mutableConsensusParam().sealerList, m_param->mutableConsensusParam().observerList,
consensusType, storageType, stateType, m_param->mutableConsensusParam().maxTransactions,
m_param->mutableTxParam().txGasLimit};
m_param->mutableTxParam().txGasLimit, m_param->mutableGenesisParam().timeStamp};
bool ret = m_blockChain->checkAndBuildGenesisBlock(initParam);
if (!ret)
{
Expand Down
Loading

0 comments on commit 685d479

Please sign in to comment.