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

Commit 7eb211d

Browse files
authored
Disable account versioning in Istanbul (#5703)
Disable account versioning in Istanbul
2 parents 41000c2 + 0936b21 commit 7eb211d

File tree

4 files changed

+57
-87
lines changed

4 files changed

+57
-87
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
- Added: [#5593](https://github.com/ethereum/aleth/pull/5593) Dynamically updating host ENR.
1414
- Added: [#5624](https://github.com/ethereum/aleth/pull/5624) Remove useless peers from peer list.
1515
- Added: [#5634](https://github.com/ethereum/aleth/pull/5634) Bootnodes for Rinkeby and Goerli.
16-
- Added: [#5640](https://github.com/ethereum/aleth/pull/5640) Istanbul support: EIP-1702 Generalized Account Versioning Scheme.
16+
- Added: [#5640](https://github.com/ethereum/aleth/pull/5640) Support EIP-1702 Generalized Account Versioning Scheme (active only in Experimental fork.)
1717
- Added: [#5690](https://github.com/ethereum/aleth/issues/5690) Istanbul support: EIP-2028 transaction data gas cost reduction.
1818
- Changed: [#5532](https://github.com/ethereum/aleth/pull/5532) The leveldb is upgraded to 1.22. This is breaking change on Windows and the old databases are not compatible.
1919
- Changed: [#5559](https://github.com/ethereum/aleth/pull/5559) Update peer validation error messages.

libethcore/EVMSchedule.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,23 +149,23 @@ static const EVMSchedule ConstantinopleFixSchedule = [] {
149149

150150
static const EVMSchedule IstanbulSchedule = [] {
151151
EVMSchedule schedule = ConstantinopleFixSchedule;
152-
schedule.accountVersion = 1;
153152
schedule.txDataNonZeroGas = 16;
154153
return schedule;
155154
}();
156155

157156
static const EVMSchedule ExperimentalSchedule = [] {
158157
EVMSchedule schedule = IstanbulSchedule;
158+
schedule.accountVersion = 1;
159159
schedule.blockhashGas = 800;
160160
return schedule;
161161
}();
162162

163163
inline EVMSchedule const& latestScheduleForAccountVersion(u256 const& _version)
164164
{
165165
if (_version == 0)
166-
return ConstantinopleFixSchedule;
167-
else if (_version == IstanbulSchedule.accountVersion)
168166
return IstanbulSchedule;
167+
else if (_version == ExperimentalSchedule.accountVersion)
168+
return ExperimentalSchedule;
169169
else
170170
{
171171
// This should not happen, as all existing accounts

libevm/EVMC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace
1414
{
1515
evmc_revision toRevision(EVMSchedule const& _schedule) noexcept
1616
{
17-
if (_schedule.accountVersion == IstanbulSchedule.accountVersion)
17+
if (_schedule.txDataNonZeroGas == 16)
1818
return EVMC_ISTANBUL;
1919
if (_schedule.haveCreate2 && !_schedule.eip1283Mode)
2020
return EVMC_PETERSBURG;

test/unittests/libethereum/ExtVMTest.cpp

Lines changed: 52 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -26,88 +26,6 @@ using namespace dev;
2626
using namespace dev::eth;
2727
using namespace dev::test;
2828

29-
class ExtVMIstanbulTestFixture : public TestOutputHelperFixture
30-
{
31-
public:
32-
ExtVMIstanbulTestFixture()
33-
: networkSelector(eth::Network::IstanbulTransitionTest),
34-
testBlockchain(TestBlockChain::defaultGenesisBlock()),
35-
genesisBlock(testBlockchain.testGenesis()),
36-
genesisDB(genesisBlock.state().db()),
37-
blockchain(testBlockchain.getInterface())
38-
{
39-
TestBlock testBlock;
40-
// block 1 - before Istanbul
41-
testBlock.mine(testBlockchain);
42-
testBlockchain.addBlock(testBlock);
43-
preIstanbulBlockHash = testBlock.blockHeader().hash();
44-
45-
// block 2 - first Istanbul block
46-
testBlock.mine(testBlockchain);
47-
testBlockchain.addBlock(testBlock);
48-
istanbulBlockHash = testBlock.blockHeader().hash();
49-
}
50-
51-
NetworkSelector networkSelector;
52-
TestBlockChain testBlockchain;
53-
TestBlock const& genesisBlock;
54-
OverlayDB const& genesisDB;
55-
BlockChain const& blockchain;
56-
h256 preIstanbulBlockHash;
57-
h256 istanbulBlockHash;
58-
};
59-
60-
BOOST_FIXTURE_TEST_SUITE(ExtVmIstanbulSuite, ExtVMIstanbulTestFixture)
61-
62-
BOOST_AUTO_TEST_CASE(ScheduleAccordingToForkBeforeIstanbul)
63-
{
64-
Block block = blockchain.genesisBlock(genesisDB);
65-
block.sync(blockchain, preIstanbulBlockHash);
66-
67-
TestLastBlockHashes lastBlockHashes({});
68-
EnvInfo envInfo(block.info(), lastBlockHashes, 0);
69-
Address addr("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b");
70-
ExtVM extVM(block.mutableState(), envInfo, *blockchain.sealEngine(), addr, addr, addr, 0, 0, {},
71-
{}, {}, 0, 0, false, false);
72-
73-
BOOST_CHECK_EQUAL(extVM.evmSchedule().accountVersion, 0);
74-
BOOST_CHECK(extVM.evmSchedule().haveCreate2 && !extVM.evmSchedule().eip1283Mode);
75-
}
76-
77-
BOOST_AUTO_TEST_CASE(PetersburgScheduleForVersionZeroInIstanbul)
78-
{
79-
Block block = blockchain.genesisBlock(genesisDB);
80-
block.sync(blockchain, istanbulBlockHash);
81-
82-
TestLastBlockHashes lastBlockHashes({});
83-
EnvInfo envInfo(block.info(), lastBlockHashes, 0);
84-
Address addr("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b");
85-
u256 const version = 0;
86-
ExtVM extVM(block.mutableState(), envInfo, *blockchain.sealEngine(), addr, addr, addr, 0, 0, {},
87-
{}, {}, version, 0, false, false);
88-
89-
BOOST_CHECK_EQUAL(extVM.evmSchedule().accountVersion, version);
90-
BOOST_CHECK(extVM.evmSchedule().haveCreate2 && !extVM.evmSchedule().eip1283Mode);
91-
}
92-
93-
BOOST_AUTO_TEST_CASE(IstanbulScheduleForVersionOneInIstanbul)
94-
{
95-
Block block = blockchain.genesisBlock(genesisDB);
96-
block.sync(blockchain, istanbulBlockHash);
97-
98-
TestLastBlockHashes lastBlockHashes({});
99-
EnvInfo envInfo(block.info(), lastBlockHashes, 0);
100-
Address addr("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b");
101-
u256 const version = 1;
102-
ExtVM extVM(block.mutableState(), envInfo, *blockchain.sealEngine(), addr, addr, addr, 0, 0, {},
103-
{}, {}, version, 0, false, false);
104-
105-
BOOST_CHECK_EQUAL(extVM.evmSchedule().accountVersion, version);
106-
}
107-
108-
109-
BOOST_AUTO_TEST_SUITE_END()
110-
11129
class ExtVMExperimentalTestFixture : public TestOutputHelperFixture
11230
{
11331
public:
@@ -122,17 +40,21 @@ class ExtVMExperimentalTestFixture : public TestOutputHelperFixture
12240
// block 1 - before Experimental
12341
testBlock.mine(testBlockchain);
12442
testBlockchain.addBlock(testBlock);
43+
preExperimentalBlockHash = testBlock.blockHeader().hash();
12544

12645
// block 2 - first Experimental block
12746
testBlock.mine(testBlockchain);
12847
testBlockchain.addBlock(testBlock);
48+
experimentalBlockHash = testBlock.blockHeader().hash();
12949
}
13050

13151
NetworkSelector networkSelector;
13252
TestBlockChain testBlockchain;
13353
TestBlock const& genesisBlock;
13454
OverlayDB const& genesisDB;
13555
BlockChain const& blockchain;
56+
h256 preExperimentalBlockHash;
57+
h256 experimentalBlockHash;
13658
};
13759

13860
BOOST_FIXTURE_TEST_SUITE(ExtVmExperimentalSuite, ExtVMExperimentalTestFixture)
@@ -193,5 +115,53 @@ BOOST_AUTO_TEST_CASE(BlockhashDoesntNeedLastHashesInExperimental)
193115
BOOST_REQUIRE_EQUAL(hash, blockchain.numberHash(200));
194116
}
195117

118+
BOOST_AUTO_TEST_CASE(ScheduleAccordingToForkBeforeExperimental)
119+
{
120+
Block block = blockchain.genesisBlock(genesisDB);
121+
block.sync(blockchain, preExperimentalBlockHash);
122+
123+
TestLastBlockHashes lastBlockHashes({});
124+
EnvInfo envInfo(block.info(), lastBlockHashes, 0);
125+
Address addr("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b");
126+
ExtVM extVM(block.mutableState(), envInfo, *blockchain.sealEngine(), addr, addr, addr, 0, 0, {},
127+
{}, {}, 0, 0, false, false);
128+
129+
BOOST_CHECK_EQUAL(extVM.evmSchedule().accountVersion, 0);
130+
BOOST_CHECK(
131+
extVM.evmSchedule().txDataNonZeroGas == 16 && extVM.evmSchedule().blockhashGas == 20);
132+
}
133+
134+
BOOST_AUTO_TEST_CASE(IstanbulScheduleForVersionZeroInExperimental)
135+
{
136+
Block block = blockchain.genesisBlock(genesisDB);
137+
block.sync(blockchain, experimentalBlockHash);
138+
139+
TestLastBlockHashes lastBlockHashes({});
140+
EnvInfo envInfo(block.info(), lastBlockHashes, 0);
141+
Address addr("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b");
142+
u256 const version = 0;
143+
ExtVM extVM(block.mutableState(), envInfo, *blockchain.sealEngine(), addr, addr, addr, 0, 0, {},
144+
{}, {}, version, 0, false, false);
145+
146+
BOOST_CHECK_EQUAL(extVM.evmSchedule().accountVersion, version);
147+
BOOST_CHECK(
148+
extVM.evmSchedule().txDataNonZeroGas == 16 && extVM.evmSchedule().blockhashGas == 20);
149+
}
150+
151+
BOOST_AUTO_TEST_CASE(ExperimentalScheduleForVersionOneInExperimental)
152+
{
153+
Block block = blockchain.genesisBlock(genesisDB);
154+
block.sync(blockchain, experimentalBlockHash);
155+
156+
TestLastBlockHashes lastBlockHashes({});
157+
EnvInfo envInfo(block.info(), lastBlockHashes, 0);
158+
Address addr("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b");
159+
u256 const version = 1;
160+
ExtVM extVM(block.mutableState(), envInfo, *blockchain.sealEngine(), addr, addr, addr, 0, 0, {},
161+
{}, {}, version, 0, false, false);
162+
163+
BOOST_CHECK_EQUAL(extVM.evmSchedule().accountVersion, version);
164+
}
165+
196166

197167
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)