diff --git a/libethashseal/GenesisInfo.cpp b/libethashseal/GenesisInfo.cpp index caf2aeedd96..921540e730e 100644 --- a/libethashseal/GenesisInfo.cpp +++ b/libethashseal/GenesisInfo.cpp @@ -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" @@ -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; @@ -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"); diff --git a/libethashseal/GenesisInfo.h b/libethashseal/GenesisInfo.h index cdfa3db90bd..94e826e2ab4 100644 --- a/libethashseal/GenesisInfo.h +++ b/libethashseal/GenesisInfo.h @@ -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, diff --git a/libethashseal/genesis/test/constantinopleTransitionTest.cpp b/libethashseal/genesis/test/constantinopleTransitionTest.cpp new file mode 100644 index 00000000000..a7f349a80dd --- /dev/null +++ b/libethashseal/genesis/test/constantinopleTransitionTest.cpp @@ -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 . +*/ +#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"; diff --git a/libethcore/Common.cpp b/libethcore/Common.cpp index 4271983acca..f888e82688f 100644 --- a/libethcore/Common.cpp +++ b/libethcore/Common.cpp @@ -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) { diff --git a/libethcore/EVMSchedule.h b/libethcore/EVMSchedule.h index 9820e887a20..d0baa9518a6 100644 --- a/libethcore/EVMSchedule.h +++ b/libethcore/EVMSchedule.h @@ -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; @@ -116,6 +115,7 @@ static const EVMSchedule ByzantiumSchedule = [] static const EVMSchedule ConstantinopleSchedule = [] { EVMSchedule schedule = ByzantiumSchedule; + schedule.blockhashGas = 800; schedule.haveCreate2 = true; return schedule; }(); diff --git a/libethereum/Block.cpp b/libethereum/Block.cpp index b2b688c5535..3cd1ff022ae 100644 --- a/libethereum/Block.cpp +++ b/libethereum/Block.cpp @@ -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); diff --git a/libethereum/ExtVM.cpp b/libethereum/ExtVM.cpp index 50ee2b380d8..8190d2de099 100644 --- a/libethereum/ExtVM.cpp +++ b/libethereum/ExtVM.cpp @@ -149,7 +149,7 @@ h256 ExtVM::blockHash(u256 _number) if (_number >= currentNumber || _number < (std::max(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); diff --git a/test/jsontests b/test/jsontests index 40d28e6407d..8d668d9b4c2 160000 --- a/test/jsontests +++ b/test/jsontests @@ -1 +1 @@ -Subproject commit 40d28e6407d1a6700e9b239ffaf0519dea05898a +Subproject commit 8d668d9b4c21f7b4024ca30093729f226da61640 diff --git a/test/unittests/libethereum/Block.cpp b/test/unittests/libethereum/Block.cpp index 8cc2e929a19..118732fc53d 100644 --- a/test/unittests/libethereum/Block.cpp +++ b/test/unittests/libethereum/Block.cpp @@ -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(); @@ -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) { diff --git a/test/unittests/libethereum/ExtVMTest.cpp b/test/unittests/libethereum/ExtVMTest.cpp index 38ec7703d61..bada90a646a 100644 --- a/test/unittests/libethereum/ExtVMTest.cpp +++ b/test/unittests/libethereum/ExtVMTest.cpp @@ -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); } @@ -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); @@ -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) {