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 #4347 from ethereum/eip96-to-constantinople
Browse files Browse the repository at this point in the history
Move EIP96 to Constantinople
  • Loading branch information
pirapira authored Aug 17, 2017
2 parents c27db2a + 61e7e0d commit 779db0c
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 20 deletions.
3 changes: 3 additions & 0 deletions libethashseal/GenesisInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ using namespace dev;
#include "genesis/test/byzantiumTest.cpp"
#include "genesis/test/byzantiumTransitionTest.cpp"
#include "genesis/test/constantinopleTest.cpp"
#include "genesis/test/constantinopleTransitionTest.cpp"

//Transition configurations
#include "genesis/test/frontierToHomesteadAt5Test.cpp"
Expand Down Expand Up @@ -61,6 +62,7 @@ std::string const& dev::eth::genesisInfo(Network _n)
case Network::ByzantiumTest: return c_genesisInfoByzantiumTest;
case Network::ByzantiumTransitionTest: return c_genesisInfoByzantiumTransitionTest;
case Network::ConstantinopleTest: return c_genesisInfoConstantinopleTest;
case Network::ConstantinopleTransitionTest: return c_genesisInfoConstantinopleTransitionTest;

//Transition test genesis
case Network::FrontierToHomesteadAt5: return c_genesisInfoFrontierToHomesteadAt5Test;
Expand Down Expand Up @@ -88,6 +90,7 @@ h256 const& dev::eth::genesisStateRoot(Network _n)
case Network::EIP158Test:
case Network::ByzantiumTest:
case Network::ConstantinopleTest:
case Network::ConstantinopleTransitionTest:
return c_genesisDefaultStateRoot;
default:
throw std::invalid_argument("Invalid network value");
Expand Down
2 changes: 1 addition & 1 deletion libethashseal/GenesisInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ enum class Network
ByzantiumTransitionTest = 76, ///< EIP158Test + Byzantium active from block 2
FrontierNoProofTest = 77, ///< Frontier rules + NoProof seal engine
ConstantinopleTest = 78, ///< ByzantiumTest + Constantinople active from block 0

ConstantinopleTransitionTest = 79, ///< ByzantiumTest + Constantinople active from block 2

//TransitionTest networks
FrontierToHomesteadAt5 = 100,
Expand Down
65 changes: 65 additions & 0 deletions libethashseal/genesis/test/constantinopleTransitionTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
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/>.
*/
#include "../../GenesisInfo.h"

static std::string const c_genesisInfoConstantinopleTransitionTest = std::string() +
R"E(
{
"sealEngine": "NoProof",
"params": {
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"homsteadForkBlock": "0x00",
"daoHardforkBlock": "0xfffffffffffffff",
"EIP150ForkBlock": "0x00",
"EIP158ForkBlock": "0x00",
"byzantiumForkBlock": "0x00",
"constantinopleForkBlock": "0x02",
"minGasLimit": "0x1388",
"maxGasLimit": "7fffffffffffffff",
"tieBreakingGas": false,
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"networkID" : "0x1",
"chainID": "0x01",
"allowFutureBlocks" : true
},
"genesis": {
"nonce": "0x0000000000000042",
"difficulty": "0x400000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"author": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
"gasLimit": "0x1388"
},
"accounts": {
"0000000000000000000000000000000000000001": { "wei": "1", "precompiled": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
"0000000000000000000000000000000000000002": { "wei": "1", "precompiled": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
"0000000000000000000000000000000000000003": { "wei": "1", "precompiled": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
"0000000000000000000000000000000000000004": { "wei": "1", "precompiled": { "name": "identity", "linear": { "base": 15, "word": 3 } } },
"0000000000000000000000000000000000000005": { "wei": "1", "precompiled": { "name": "modexp", "startBlock": "0x02" } }
"0000000000000000000000000000000000000006": { "wei": "1", "precompiled": { "name": "alt_bn128_G1_add", "startBlock": "0x02", "linear": { "base": 500, "word": 0 } } },
"0000000000000000000000000000000000000007": { "wei": "1", "precompiled": { "name": "alt_bn128_G1_mul", "startBlock": "0x02", "linear": { "base": 2000, "word": 0 } } },
"0000000000000000000000000000000000000008": { "wei": "1", "precompiled": { "name": "alt_bn128_pairing_product", "startBlock": "0x02" } }
}
}
)E";
2 changes: 1 addition & 1 deletion libethcore/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const unsigned c_databaseVersionModifier = 0;
const unsigned c_databaseVersion = c_databaseBaseVersion + (c_databaseVersionModifier << 8) + (23 << 9);

const Address c_blockhashContractAddress(0xf0);
const bytes c_blockhashContractCode(fromHex("0x73fffffffffffffffffffffffffffffffffffffffe33141561006a5760014303600035610100820755610100810715156100455760003561010061010083050761010001555b6201000081071515610064576000356101006201000083050761020001555b5061013e565b4360003512151561008457600060405260206040f361013d565b61010060003543031315156100a857610100600035075460605260206060f361013c565b6101006000350715156100c55762010000600035430313156100c8565b60005b156100ea576101006101006000350507610100015460805260206080f361013b565b620100006000350715156101095763010000006000354303131561010c565b60005b1561012f57610100620100006000350507610200015460a052602060a0f361013a565b600060c052602060c0f35b5b5b5b5b"));
const bytes c_blockhashContractCode(fromHex("0x600073fffffffffffffffffffffffffffffffffffffffe33141561005957600143035b60011561005357600035610100820683015561010081061561004057005b6101008104905061010082019150610022565b506100e0565b4360003512156100d4576000356001814303035b61010081121515610085576000610100830614610088565b60005b156100a75761010083019250610100820491506101008104905061006d565b610100811215156100bd57600060a052602060a0f35b610100820683015460c052602060c0f350506100df565b600060e052602060e0f35b5b50"));

Address toAddress(std::string const& _s)
{
Expand Down
2 changes: 1 addition & 1 deletion libethcore/EVMSchedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ static const EVMSchedule EIP158Schedule = []
static const EVMSchedule ByzantiumSchedule = []
{
EVMSchedule schedule = EIP158Schedule;
schedule.blockhashGas = 800;
schedule.haveRevert = true;
schedule.haveReturnData = true;
schedule.haveStaticCall = true;
Expand All @@ -116,6 +115,7 @@ static const EVMSchedule ByzantiumSchedule = []
static const EVMSchedule ConstantinopleSchedule = []
{
EVMSchedule schedule = ByzantiumSchedule;
schedule.blockhashGas = 800;
schedule.haveCreate2 = true;
return schedule;
}();
Expand Down
6 changes: 3 additions & 3 deletions libethereum/Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,15 +702,15 @@ void Block::updateBlockhashContract()
{
u256 const blockNumber = info().number();

u256 const byzantiumForkBlock = m_sealEngine->chainParams().u256Param("byzantiumForkBlock");
if (blockNumber == byzantiumForkBlock)
u256 const constantinopleForkBlock = m_sealEngine->chainParams().u256Param("constantinopleForkBlock");
if (blockNumber == constantinopleForkBlock)
{
m_state.createContract(c_blockhashContractAddress);
m_state.setCode(c_blockhashContractAddress, bytes(c_blockhashContractCode));
m_state.commit(State::CommitBehaviour::KeepEmptyAccounts);
}

if (blockNumber >= byzantiumForkBlock)
if (blockNumber >= constantinopleForkBlock)
{
DummyLastBlockHashes lastBlockHashes; // assuming blockhash contract won't need BLOCKHASH itself
Executive e(*this, lastBlockHashes);
Expand Down
2 changes: 1 addition & 1 deletion libethereum/ExtVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ h256 ExtVM::blockHash(u256 _number)
if (_number >= currentNumber || _number < (std::max<u256>(256, currentNumber) - 256))
return h256();

if (currentNumber < m_sealEngine.chainParams().u256Param("byzantiumForkBlock") + 256)
if (currentNumber < m_sealEngine.chainParams().u256Param("constantinopleForkBlock") + 256)
{
h256 const parentHash = envInfo().header().parentHash();
h256s const lastHashes = envInfo().lastHashes().precedingHashes(parentHash);
Expand Down
2 changes: 1 addition & 1 deletion test/jsontests
Submodule jsontests updated 3123 files
12 changes: 6 additions & 6 deletions test/unittests/libethereum/Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,23 +269,23 @@ BOOST_AUTO_TEST_CASE(bGetReceiptOverflow)
BOOST_CHECK_THROW(block.receipt(123), std::out_of_range);
}

class ByzantiumTransitionTestFixture: public TestOutputHelper
class ConstantinopleTransitionTestFixture: public TestOutputHelper
{
public:
ByzantiumTransitionTestFixture():
networkSelector(Network::ByzantiumTransitionTest),
ConstantinopleTransitionTestFixture():
networkSelector(Network::ConstantinopleTransitionTest),
testBlockchain(TestBlockChain::defaultGenesisBlock()),
genesisBlock(testBlockchain.testGenesis()),
genesisDB(genesisBlock.state().db()),
blockchain(testBlockchain.interface())
{
TestBlock testBlock;
// block 1 - before Byzantium
// block 1 - before Constantinople
testBlock.mine(testBlockchain);
testBlockchain.addBlock(testBlock);
block1hash = blockchain.currentHash();

// block 2 - first Byzantium block
// block 2 - first Constantinople block
testBlock.mine(testBlockchain);
testBlockchain.addBlock(testBlock);
block2hash = blockchain.currentHash();
Expand All @@ -301,7 +301,7 @@ class ByzantiumTransitionTestFixture: public TestOutputHelper
h256 block2hash;
};

BOOST_FIXTURE_TEST_SUITE(ByzantiumBlockSuite, ByzantiumTransitionTestFixture)
BOOST_FIXTURE_TEST_SUITE(ConstantinopleBlockSuite, ConstantinopleTransitionTestFixture)

BOOST_AUTO_TEST_CASE(bBlockhashContractIsCreated)
{
Expand Down
12 changes: 6 additions & 6 deletions test/unittests/libethereum/ExtVMTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ class ExtVMTestFixture: public TestOutputHelper
{
public:
ExtVMTestFixture():
networkSelector(Network::ByzantiumTransitionTest),
networkSelector(Network::ConstantinopleTransitionTest),
testBlockchain(TestBlockChain::defaultGenesisBlock()),
genesisBlock(testBlockchain.testGenesis()),
genesisDB(genesisBlock.state().db()),
blockchain(testBlockchain.interface())
{
TestBlock testBlock;
// block 1 - before Byzantium
// block 1 - before Constantinople
testBlock.mine(testBlockchain);
testBlockchain.addBlock(testBlock);

// block 2 - first Byzantium block
// block 2 - first Constantinople block
testBlock.mine(testBlockchain);
testBlockchain.addBlock(testBlock);
}
Expand All @@ -71,7 +71,7 @@ BOOST_AUTO_TEST_CASE(BlockhashOutOfBoundsRetunsZero)
BOOST_CHECK_EQUAL(extVM.blockHash(100), h256());
}

BOOST_AUTO_TEST_CASE(BlockhashBeforeByzantiumReliesOnLastHashes)
BOOST_AUTO_TEST_CASE(BlockhashBeforeConstantinopleReliesOnLastHashes)
{
Block block = blockchain.genesisBlock(genesisDB);
block.sync(blockchain);
Expand All @@ -85,9 +85,9 @@ BOOST_AUTO_TEST_CASE(BlockhashBeforeByzantiumReliesOnLastHashes)
BOOST_REQUIRE_EQUAL(hash, lastHashes[0]);
}

BOOST_AUTO_TEST_CASE(BlockhashDoesntNeedLastHashesInByzantium)
BOOST_AUTO_TEST_CASE(BlockhashDoesntNeedLastHashesInConstantinople)
{
// BLOCKHASH starts to work through the call to a contract 256 block after Byzantium fork block
// BLOCKHASH starts to work through the call to a contract 256 block after Constantinople fork block
TestBlock testBlock;
for (int i = 0; i < 256; ++i)
{
Expand Down

0 comments on commit 779db0c

Please sign in to comment.