Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #5539 from ethereum/dao-fork-block
Browse files Browse the repository at this point in the history
Fix logic used to determine if Aleth should request dao fork block header from potential peer
  • Loading branch information
chfast authored Apr 2, 2019
2 parents e52571a + a32de03 commit b09e9ad
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 57 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
- Fixed: [#5519](https://github.com/ethereum/aleth/pull/5519) Correctly handle Discovery messages with known public key but unknown endpoint.
- Fixed: [#5523](https://github.com/ethereum/aleth/pull/5523) [#5533](https://github.com/ethereum/aleth/pull/5533) Fix syncing terminating prematurely because of race condition.
- Added: [#5526](https://github.com/ethereum/aleth/pull/5526) Improved logging when loading chain config json containing syntax error.
- Fixed: [#5539](https://github.com/ethereum/aleth/pull/5539) Fix logic for determining if dao hard fork block header should be requested

[1.6.0]: https://github.com/ethereum/aleth/compare/v1.6.0-alpha.1...master
20 changes: 10 additions & 10 deletions libethcore/ChainOperationParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class PrecompiledContract
u256 m_startingBlock = 0;
};

static constexpr int64_t c_infiniteBlockNumer = std::numeric_limits<int64_t>::max();
constexpr int64_t c_infiniteBlockNumber = std::numeric_limits<int64_t>::max();

struct ChainOperationParams
{
Expand All @@ -87,15 +87,15 @@ struct ChainOperationParams
u256 minGasLimit;
u256 maxGasLimit;
u256 gasLimitBoundDivisor;
u256 homesteadForkBlock = c_infiniteBlockNumer;
u256 EIP150ForkBlock = c_infiniteBlockNumer;
u256 EIP158ForkBlock = c_infiniteBlockNumer;
u256 byzantiumForkBlock = c_infiniteBlockNumer;
u256 eWASMForkBlock = c_infiniteBlockNumer;
u256 constantinopleForkBlock = c_infiniteBlockNumer;
u256 constantinopleFixForkBlock = c_infiniteBlockNumer;
u256 daoHardforkBlock = c_infiniteBlockNumer;
u256 experimentalForkBlock = c_infiniteBlockNumer;
u256 homesteadForkBlock = c_infiniteBlockNumber;
u256 EIP150ForkBlock = c_infiniteBlockNumber;
u256 EIP158ForkBlock = c_infiniteBlockNumber;
u256 byzantiumForkBlock = c_infiniteBlockNumber;
u256 eWASMForkBlock = c_infiniteBlockNumber;
u256 constantinopleForkBlock = c_infiniteBlockNumber;
u256 constantinopleFixForkBlock = c_infiniteBlockNumber;
u256 daoHardforkBlock = c_infiniteBlockNumber;
u256 experimentalForkBlock = c_infiniteBlockNumber;
int chainID = 0; // Distinguishes different chains (mainnet, Ropsten, etc).
int networkID = 0; // Distinguishes different sub protocols.

Expand Down
36 changes: 9 additions & 27 deletions libethereum/BlockChainSync.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum 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.
cpp-ethereum 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 cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file BlockChainSync.cpp
* @author Gav Wood <i@gavwood.com>
* @date 2014
*/
/// Aleth: Ethereum C++ client, tools and libraries.
// Copyright 2019 Aleth Authors.
// Licensed under the GNU General Public License, Version 3.

#include "BlockChainSync.h"

Expand All @@ -35,11 +18,6 @@ using namespace std;
using namespace dev;
using namespace dev::eth;

unsigned const c_maxPeerUknownNewBlocks = 1024; /// Max number of unknown new blocks peer can give us
unsigned const c_maxRequestHeaders = 1024;
unsigned const c_maxRequestBodies = 1024;


std::ostream& dev::eth::operator<<(std::ostream& _out, SyncStatus const& _sync)
{
_out << "protocol: " << _sync.protocolVersion << endl;
Expand All @@ -52,6 +30,10 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, SyncStatus const& _sync)
namespace // Helper functions.
{

constexpr unsigned c_maxPeerUknownNewBlocks = 1024; /// Max number of unknown new blocks peer can give us
constexpr unsigned c_maxRequestHeaders = 1024;
constexpr unsigned c_maxRequestBodies = 1024;

template<typename T> bool haveItem(std::map<unsigned, T>& _container, unsigned _number)
{
if (_container.empty())
Expand Down Expand Up @@ -230,8 +212,8 @@ void BlockChainSync::onPeerStatus(EthereumPeer const& _peer)
bool BlockChainSync::requestDaoForkBlockHeader(NodeID const& _peerID)
{
// DAO challenge
unsigned const daoHardfork = static_cast<unsigned>(host().chain().sealEngine()->chainParams().daoHardforkBlock);
if (daoHardfork == 0)
u256 const daoHardfork = host().chain().sealEngine()->chainParams().daoHardforkBlock;
if (daoHardfork == 0 || daoHardfork == c_infiniteBlockNumber)
return false;

m_daoChallengedPeers.insert(_peerID);
Expand Down
23 changes: 3 additions & 20 deletions libethereum/BlockChainSync.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum 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.
cpp-ethereum 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 cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file BlockChainSync.h
* @author Gav Wood <i@gavwood.com>
* @date 2014
*/
// Aleth: Ethereum C++ client, tools and libraries.
// Copyright 2019 Aleth Authors.
// Licensed under the GNU General Public License, Version 3.

#pragma once

Expand Down

0 comments on commit b09e9ad

Please sign in to comment.