diff --git a/libethashseal/GenesisInfo.cpp b/libethashseal/GenesisInfo.cpp index 6ae840462c6..a0330eed66a 100644 --- a/libethashseal/GenesisInfo.cpp +++ b/libethashseal/GenesisInfo.cpp @@ -24,8 +24,10 @@ using namespace dev; #include "genesis/ropsten.cpp" //Test configurations +#include "genesis/test/byzantiumNoProofTest.cpp" #include "genesis/test/byzantiumTest.cpp" #include "genesis/test/byzantiumTransitionTest.cpp" +#include "genesis/test/constantinopleNoProofTest.cpp" #include "genesis/test/constantinopleTest.cpp" #include "genesis/test/eip150Test.cpp" #include "genesis/test/eip158Test.cpp" @@ -62,8 +64,13 @@ std::string const& dev::eth::genesisInfo(Network _n) case Network::EIP150Test: return c_genesisInfoEIP150Test; case Network::EIP158Test: return c_genesisInfoEIP158Test; case Network::ByzantiumTest: return c_genesisInfoByzantiumTest; + case Network::ByzantiumNoProofTest: + return c_genesisInfoByzantiumNoProofTest; case Network::ByzantiumTransitionTest: return c_genesisInfoByzantiumTransitionTest; - case Network::ConstantinopleTest: return c_genesisInfoConstantinopleTest; + case Network::ConstantinopleTest: + return c_genesisInfoConstantinopleTest; + case Network::ConstantinopleNoProofTest: + return c_genesisInfoConstantinopleNoProofTest; case Network::ExperimentalTransitionTest: return c_genesisInfoExperimentalTransitionTest; diff --git a/libethashseal/GenesisInfo.h b/libethashseal/GenesisInfo.h index 3308f63c619..f73a8d943d2 100644 --- a/libethashseal/GenesisInfo.h +++ b/libethashseal/GenesisInfo.h @@ -61,6 +61,10 @@ enum class Network ExperimentalTransitionTest = 79, /// MainNetwork rules without genesis accounts + NoProof seal engine MainNetworkNoProofTest = 80, + /// Byzantium rules + NoProof seal engine + ByzantiumNoProofTest = 81, + /// Constantinople rules + NoProof seal engine + ConstantinopleNoProofTest = 82, // TransitionTest networks FrontierToHomesteadAt5 = 100, diff --git a/libethashseal/genesis/test/byzantiumNoProofTest.cpp b/libethashseal/genesis/test/byzantiumNoProofTest.cpp new file mode 100644 index 00000000000..f2a43d0179c --- /dev/null +++ b/libethashseal/genesis/test/byzantiumNoProofTest.cpp @@ -0,0 +1,62 @@ +/* + 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_genesisInfoByzantiumNoProofTest = R"E( +{ + "sealEngine": "NoProof", + "params": { + "accountStartNonce": "0x00", + "maximumExtraDataSize": "0x20", + "homesteadForkBlock": "0x00", + "EIP150ForkBlock": "0x00", + "EIP158ForkBlock": "0x00", + "byzantiumForkBlock": "0x00", + "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": "0x020000", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "author": "0x0000000000000000000000000000000000000000", + "timestamp": "0x00", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", + "gasLimit": "0x1388" + }, + "accounts": { + "0000000000000000000000000000000000000001": { "precompiled": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } }, + "0000000000000000000000000000000000000002": { "precompiled": { "name": "sha256", "linear": { "base": 60, "word": 12 } } }, + "0000000000000000000000000000000000000003": { "precompiled": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } }, + "0000000000000000000000000000000000000004": { "precompiled": { "name": "identity", "linear": { "base": 15, "word": 3 } } }, + "0000000000000000000000000000000000000005": { "precompiled": { "name": "modexp" } }, + "0000000000000000000000000000000000000006": { "precompiled": { "name": "alt_bn128_G1_add", "linear": { "base": 500, "word": 0 } } }, + "0000000000000000000000000000000000000007": { "precompiled": { "name": "alt_bn128_G1_mul", "linear": { "base": 40000, "word": 0 } } }, + "0000000000000000000000000000000000000008": { "precompiled": { "name": "alt_bn128_pairing_product" } } + } +} +)E"; diff --git a/libethashseal/genesis/test/constantinopleNoProofTest.cpp b/libethashseal/genesis/test/constantinopleNoProofTest.cpp new file mode 100644 index 00000000000..c39cf9778ae --- /dev/null +++ b/libethashseal/genesis/test/constantinopleNoProofTest.cpp @@ -0,0 +1,63 @@ +/* + 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_genesisInfoConstantinopleNoProofTest = R"E( +{ + "sealEngine": "NoProof", + "params": { + "accountStartNonce": "0x00", + "maximumExtraDataSize": "0x20", + "homesteadForkBlock": "0x00", + "EIP150ForkBlock": "0x00", + "EIP158ForkBlock": "0x00", + "byzantiumForkBlock": "0x00", + "constantinopleForkBlock": "0x00", + "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": "0x020000", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "author": "0x0000000000000000000000000000000000000000", + "timestamp": "0x00", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", + "gasLimit": "0x1388" + }, + "accounts": { + "0000000000000000000000000000000000000001": { "precompiled": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } }, + "0000000000000000000000000000000000000002": { "precompiled": { "name": "sha256", "linear": { "base": 60, "word": 12 } } }, + "0000000000000000000000000000000000000003": { "precompiled": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } }, + "0000000000000000000000000000000000000004": { "precompiled": { "name": "identity", "linear": { "base": 15, "word": 3 } } }, + "0000000000000000000000000000000000000005": { "precompiled": { "name": "modexp" } }, + "0000000000000000000000000000000000000006": { "precompiled": { "name": "alt_bn128_G1_add", "linear": { "base": 500, "word": 0 } } }, + "0000000000000000000000000000000000000007": { "precompiled": { "name": "alt_bn128_G1_mul", "linear": { "base": 40000, "word": 0 } } }, + "0000000000000000000000000000000000000008": { "precompiled": { "name": "alt_bn128_pairing_product" } } + } +} +)E"; diff --git a/test/tools/libtesteth/BlockChainHelper.h b/test/tools/libtesteth/BlockChainHelper.h index 91a50f2fa00..3a2b7b6e375 100644 --- a/test/tools/libtesteth/BlockChainHelper.h +++ b/test/tools/libtesteth/BlockChainHelper.h @@ -195,5 +195,21 @@ class MainNetworkNoProofTestFixture : public TestOutputHelperFixture NetworkSelector networkSelector; }; + +class ByzantiumTestFixture : public TestOutputHelperFixture +{ +public: + ByzantiumTestFixture() : networkSelector(Network::ByzantiumNoProofTest) {} + + NetworkSelector networkSelector; +}; + +class ConstantinopleTestFixture : public TestOutputHelperFixture +{ +public: + ConstantinopleTestFixture() : networkSelector(Network::ConstantinopleNoProofTest) {} + + NetworkSelector networkSelector; +}; } } diff --git a/test/unittests/libethereum/Block.cpp b/test/unittests/libethereum/Block.cpp index 97148d0a2e0..79c90bb9364 100644 --- a/test/unittests/libethereum/Block.cpp +++ b/test/unittests/libethereum/Block.cpp @@ -224,6 +224,37 @@ BOOST_AUTO_TEST_CASE(bGetReceiptOverflow) BOOST_CHECK_THROW(block.receipt(123), std::out_of_range); } + +BOOST_FIXTURE_TEST_SUITE(ByzantiumBlockSuite, ByzantiumTestFixture) + +BOOST_AUTO_TEST_CASE(bByzantiumBlockReward) +{ + TestBlockChain testBlockchain; + TestBlock testBlock; + testBlock.mine(testBlockchain); + testBlockchain.addBlock(testBlock); + + TestBlock const& topBlock = testBlockchain.topBlock(); + BOOST_REQUIRE_EQUAL(topBlock.state().balance(topBlock.beneficiary()), 3 * ether); +} + +BOOST_AUTO_TEST_SUITE_END() + +BOOST_FIXTURE_TEST_SUITE(ConstantinopleBlockSuite, ConstantinopleTestFixture) + +BOOST_AUTO_TEST_CASE(bConstantinopleBlockReward) +{ + TestBlockChain testBlockchain; + TestBlock testBlock; + testBlock.mine(testBlockchain); + testBlockchain.addBlock(testBlock); + + TestBlock const& topBlock = testBlockchain.topBlock(); + BOOST_REQUIRE_EQUAL(topBlock.state().balance(topBlock.beneficiary()), 2 * ether); +} + +BOOST_AUTO_TEST_SUITE_END() + class ExperimentalTransitionTestFixture : public TestOutputHelperFixture { public: