Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constantinople #1246

Merged
merged 26 commits into from
Dec 26, 2018
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
dc526a9
Fixed bug in using ethereumj.conf.file param
zilm13 Oct 15, 2018
ec34a3d
Merge branch 'develop' of github.com:ethereum/ethereumj into develop
zilm13 Oct 18, 2018
9ee7fef
Merge branch 'develop' of github.com:ethereum/ethereumj into develop
zilm13 Nov 15, 2018
7bde29e
Merge branch 'develop' of github.com:ethereum/ethereumj into develop
zilm13 Dec 19, 2018
8ce5dbb
Added Constantinople transition test
zilm13 Dec 19, 2018
6c1f26e
Add Constantinople BasicTest
zilm13 Dec 22, 2018
95f5d31
Bump commit and tree sha for tests unaffected by Constantinople
zilm13 Dec 22, 2018
979cc36
Transaction test moved to new format
zilm13 Dec 23, 2018
0b4856d
Add more modexp tests
zilm13 Dec 23, 2018
d28ba5c
Fixed: modexp returns incorrect length with 0 modulus
zilm13 Dec 23, 2018
89f8580
Fixed: Tck tests failed due to contract storage incorrect override
zilm13 Dec 24, 2018
6e8c218
Fixed: coinbase was not touched in Frontier on failed txs
zilm13 Dec 24, 2018
1209aa8
Finally fix frontier touch for coinbase
zilm13 Dec 24, 2018
f51bc29
Fixed: coinbase was not touched with bad txs or was removed later, te…
zilm13 Dec 24, 2018
eb6e7b1
Fixed all state tests (except ignored)
zilm13 Dec 24, 2018
0c6fa80
Fixed mark in Tck tests only comment
zilm13 Dec 24, 2018
17e2a54
Remove collision storage in Tck tests for vm called create/create2
zilm13 Dec 24, 2018
b115ae1
Fixed all Tck Constantinople state tests
zilm13 Dec 24, 2018
50db758
Fixed Tck blosk state tests for Constantinople
zilm13 Dec 24, 2018
9a1262b
Fixed rlp test parsing to handle 0x
zilm13 Dec 24, 2018
64e840c
Rebuilt contract storage clean before create to stop failing when not…
zilm13 Dec 24, 2018
7f5f5ee
Bump Tck(Github) tests to the latest commit as of X-Mas 2018
zilm13 Dec 24, 2018
f79c2d3
Schedule Constantinople fork on MainNet according to EIP-1013
zilm13 Dec 24, 2018
da8f69a
Removed empty comment
zilm13 Dec 25, 2018
913f6fc
Comments associated with account removal before tx execution updated…
zilm13 Dec 26, 2018
444e8dc
Fixed typos in comments
zilm13 Dec 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ public MainNetConfig() {
add(2_463_000, new Eip150HFConfig(new DaoHFConfig()));
add(2_675_000, new Eip160HFConfig(new DaoHFConfig()));
add(4_370_000, new ByzantiumConfig(new DaoHFConfig()));
add(7_080_000, new ConstantinopleConfig(new DaoHFConfig()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,24 @@ private void create() {
m_endGas = m_endGas.subtract(BigInteger.valueOf(basicTxCost));
result.spendGas(basicTxCost);
} else {
Repository originalRepo = track;
// Some TCK tests have storage only addresses (no code, zero none etc) - impossible situation in the real network
// So, we should clean up it before reuse, but as tx not always goes successful, state should be correctly
// reverted in that case too
if (cacheTrack.hasContractDetails(newContractAddress)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this call always return true?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And could you please share more details about the case which this workaround is made for?

Copy link
Collaborator Author

@zilm13 zilm13 Dec 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this call always return true?

Looks like you are right from the implementation.
But as we have such interface method for checking and as implementations could change in future, I'd keep this.

originalRepo = track.clone();
originalRepo.delete(newContractAddress);
}
ProgramInvoke programInvoke = programInvokeFactory.createProgramInvoke(tx, currentBlock,
cacheTrack, track, blockStore);
cacheTrack, originalRepo, blockStore);

this.vm = new VM(config, vmHook);
this.program = new Program(tx.getData(), programInvoke, tx, config, vmHook).withCommonConfig(commonConfig);

// reset storage if the contract with the same address already exists
// TCK test case only - normally this is near-impossible situation in the real network
// TODO make via Trie.clear() without keyset
// ContractDetails contractDetails = program.getStorage().getContractDetails(newContractAddress);
// for (DataWord key : contractDetails.getStorageKeys()) {
// program.storageSave(key, DataWord.ZERO);
// }
ContractDetails contractDetails = program.getStorage().getContractDetails(newContractAddress);
contractDetails.deleteStorage();
}

BigInteger endowment = toBI(tx.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public interface ContractDetails {

Set<DataWord> getStorageKeys();

// Removes all storage, key by key, if supported
void deleteStorage();

Map<DataWord,DataWord> getStorage(@Nullable Collection<DataWord> keys);

Map<DataWord, DataWord> getStorage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ public Set<DataWord> getStorageKeys() {
throw new RuntimeException("Not supported");
}

@Override
public void deleteStorage() {
// do nothing as getStorageKeys() is not supported
}

@Override
public Map<DataWord, DataWord> getStorage(@Nullable Collection<DataWord> keys) {
throw new RuntimeException("Not supported");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public Pair<Boolean, byte[]> execute(byte[] data) {

// check if modulus is zero
if (isZero(mod))
return Pair.of(true, EMPTY_BYTE_ARRAY);
return Pair.of(true, new byte[modLen]); // should keep length of the result

byte[] res = stripLeadingZeroes(base.modPow(exp, mod).toByteArray());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,17 @@ private void createContractImpl(DataWord value, byte[] programCode, byte[] newAd
// [5] COOK THE INVOKE AND EXECUTE
byte[] nonce = getStorage().getNonce(senderAddress).toByteArray();
InternalTransaction internalTx = addInternalTx(nonce, getGasLimit(), senderAddress, null, endowment, programCode, "create");
Repository originalRepo = this.invoke.getOrigRepository();
// Some TCK tests have storage only addresses (no code, zero none etc) - impossible situation in the real network
// So, we should clean up it before reuse, but as tx not always goes successful, state should be correctly
// reverted in that case too
if (!contractAlreadyExists && track.hasContractDetails(newAddress)) {
originalRepo = originalRepo.clone();
originalRepo.delete(newAddress);
}
ProgramInvoke programInvoke = programInvokeFactory.createProgramInvoke(
this, DataWord.of(newAddress), getOwnerAddress(), value, gasLimit,
newBalance, null, track, this.invoke.getOrigRepository(), this.invoke.getBlockStore(), false, byTestingSuite());
newBalance, null, track, originalRepo, this.invoke.getBlockStore(), false, byTestingSuite());

ProgramResult result = ProgramResult.createEmpty();

Expand All @@ -532,6 +540,10 @@ private void createContractImpl(DataWord value, byte[] programCode, byte[] newAd
} else if (isNotEmpty(programCode)) {
VM vm = new VM(config, vmHook);
Program program = new Program(programCode, programInvoke, internalTx, config, vmHook).withCommonConfig(commonConfig);
// reset storage if the contract with the same address already exists
// TCK test case only - normally this is near-impossible situation in the real network
ContractDetails contractDetails = program.getStorage().getContractDetails(newAddress);
contractDetails.deleteStorage();
vm.play(program);
result = program.getResult();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class GitHubBasicTest {

String commitSHA = "95a309203890e6244c6d4353ca411671973c13b5";
String commitSHA = "253e99861fe406c7b1daf3d6a0c40906e8a8fd8f";

@Test
public void btCrypto() throws IOException {
Expand All @@ -55,6 +55,11 @@ public void btDifficultyByzantium() throws IOException, ParseException {
runDifficultyTest(new ByzantiumConfig(new DaoHFConfig()), "BasicTests/difficultyByzantium.json", commitSHA);
}

@Test
public void btDifficultyConstantinople() throws IOException, ParseException {
runDifficultyTest(new ConstantinopleConfig(new DaoHFConfig()), "BasicTests/difficultyConstantinople.json", commitSHA);
}

@Test
@Ignore // due to CPP minimumDifficulty issue
public void btDifficultyCustomHomestead() throws IOException, ParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class GitHubBlockStateTest {

static String commitSHA = "7f638829311dfc1d341c1db85d8a891f57fa4da7";
static String treeSHA = "9b96943196bfbb8b49651eab5e479956d7dabcc7"; // https://github.com/ethereum/tests/tree/develop/BlockchainTests/GeneralStateTests/
static String commitSHA = "253e99861fe406c7b1daf3d6a0c40906e8a8fd8f";
static String treeSHA = "724427f69f5573ed0f504a534b3ecbcd3070fa28"; // https://github.com/ethereum/tests/tree/develop/BlockchainTests/GeneralStateTests/

static GitHubJSONTestSuite.Network[] targetNets = {
GitHubJSONTestSuite.Network.Frontier,
GitHubJSONTestSuite.Network.Homestead,
GitHubJSONTestSuite.Network.EIP150,
GitHubJSONTestSuite.Network.EIP158,
GitHubJSONTestSuite.Network.Byzantium
GitHubJSONTestSuite.Network.Byzantium,
GitHubJSONTestSuite.Network.Constantinople
};

static BlockchainTestSuite suite;
Expand Down Expand Up @@ -153,7 +154,6 @@ public void bcStPreCompiledContracts2() throws IOException {
}

@Test
@Ignore
public void bcStMemoryStressTest() throws IOException {
Set<String> excluded = new HashSet<>();
excluded.add("mload32bitBound_return2");// The test extends memory to 4Gb which can't be handled with Java arrays
Expand Down Expand Up @@ -302,42 +302,22 @@ public void stCodeCopyTest() throws IOException {
}

@Test
@Ignore("Broken tests format, delayed until resolved")
public void stExtCodeHashCallCode() throws IOException {
String commit = "10ab37c095bb87d2e781bcf112b6104912fccb44";
String filePath = "GeneralStateTests/stExtCodeHash/extCodeHashCallCode_d0g0v0.json";
BlockchainTestSuite.runSingle(filePath, commit, GitHubJSONTestSuite.Network.Constantinople);
BlockchainTestSuite.runSingle(filePath, commit, GitHubJSONTestSuite.Network.Byzantium);
}

@Test
@Ignore("Broken tests format, delayed until resolved")
public void stExtCodeHashCall() throws IOException {
String commit = "10ab37c095bb87d2e781bcf112b6104912fccb44";
String filePath = "GeneralStateTests/stExtCodeHash/extCodeHashCall_d0g0v0.json";
BlockchainTestSuite.runSingle(filePath, commit, GitHubJSONTestSuite.Network.Constantinople);
BlockchainTestSuite.runSingle(filePath, commit, GitHubJSONTestSuite.Network.Byzantium);
public void stExtCodeHash() throws IOException {
suite.runAll("stExtCodeHash");
}

@Test
@Ignore("Update after all tests could pass latest develop")
public void stShiftTest() throws IOException {
suite.runAll("stShift");
// TODO: Update all, this one passes with following settings:
// String commitSHA = "560e2cd6cf881821180d46d9cc4c542e19cfea1d";
// String treeSHA = "8457a6a49f53218575a349abc311c55939797bff";
// targetNets += GitHubJSONTestSuite.Network.Constantinople
}

@Test
@Ignore("Update after all tests could pass latest develop")
public void stCreate2Test() throws IOException {
suite.runAll("stCreate2", new HashSet<>(Arrays.asList(
"create2collisionStorage_d1g0v0" // Tests excluded because they test unreal prestate
))); // (nonce, balance 0, code empty, but some storage)
// TODO: Update all, this one passes with following settings:
// String commitSHA = "e2d84e1c00289bc259ad631efb6b42390e6a291a";
// String treeSHA = "d74573a79cf607744759acde258bf7c3cf849bf1";
// targetNets += GitHubJSONTestSuite.Network.Constantinople
suite.runAll("stCreate2");
}

@Test
public void stSstoreTest() throws IOException {
suite.runAll("stSStoreTest");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class GitHubBlockTest {

static String commitSHA = "7f638829311dfc1d341c1db85d8a891f57fa4da7";
static String treeSHA = "3f6a1117be5c0d6f801875118c7c580dc4200712"; // https://github.com/ethereum/tests/tree/develop/BlockchainTests/
static String commitSHA = "253e99861fe406c7b1daf3d6a0c40906e8a8fd8f";
static String treeSHA = "6c32ebcbce50112966427e18788069b9f7cbe285"; // https://github.com/ethereum/tests/tree/develop/BlockchainTests/
static GitHubJSONTestSuite.Network[] targetNets = {
GitHubJSONTestSuite.Network.Frontier,
GitHubJSONTestSuite.Network.Homestead,
GitHubJSONTestSuite.Network.EIP150,
GitHubJSONTestSuite.Network.EIP158,
GitHubJSONTestSuite.Network.Byzantium
GitHubJSONTestSuite.Network.Byzantium,
GitHubJSONTestSuite.Network.Constantinople
};

static BlockchainTestSuite suite;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ public enum Network {
FrontierToHomesteadAt5,
HomesteadToDaoAt5,
HomesteadToEIP150At5,
EIP158ToByzantiumAt5;
EIP158ToByzantiumAt5,
ByzantiumToConstantinopleAt5;

public BlockchainNetConfig getConfig() {
switch (this) {
Expand Down Expand Up @@ -356,6 +357,11 @@ public BlockchainNetConfig getConfig() {
add(5, new ByzantiumConfig(new HomesteadConfig()));
}};

case ByzantiumToConstantinopleAt5: return new BaseNetConfig() {{
add(0, new ByzantiumConfig(new HomesteadConfig()));
add(5, new ConstantinopleConfig(new HomesteadConfig()));
}};

default: throw new IllegalArgumentException("Unknown network value: " + this.name());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
public class GitHubPowTest {

private static final Logger logger = LoggerFactory.getLogger("TCK-Test");
public String shacommit = "b09975f0a37afe306f52d5b771f5e3836f53c8bc";
public String shacommit = "253e99861fe406c7b1daf3d6a0c40906e8a8fd8f";

@Test
public void runEthashTest() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class GitHubStateTest {

static String commitSHA = "7f638829311dfc1d341c1db85d8a891f57fa4da7";
static String treeSHA = "d1ece13ebfb2adb27061ae5a6155bd9ed9773d8f"; // https://github.com/ethereum/tests/tree/develop/GeneralStateTests/
static String commitSHA = "253e99861fe406c7b1daf3d6a0c40906e8a8fd8f";
static String treeSHA = "51fd8f9969ff488917f0832c57ece01f66516db2"; // https://github.com/ethereum/tests/tree/develop/GeneralStateTests/
static GitHubJSONTestSuite.Network[] targetNets = {
GitHubJSONTestSuite.Network.Frontier,
GitHubJSONTestSuite.Network.Homestead,
GitHubJSONTestSuite.Network.EIP150,
GitHubJSONTestSuite.Network.EIP158,
GitHubJSONTestSuite.Network.Byzantium
GitHubJSONTestSuite.Network.Byzantium,
GitHubJSONTestSuite.Network.Constantinople
};

static GeneralStateTestSuite suite;
Expand Down Expand Up @@ -152,7 +153,6 @@ public void stPreCompiledContracts2() throws IOException {
}

@Test
@Ignore
public void stMemoryStressTest() throws IOException {
Set<String> excluded = new HashSet<>();
excluded.add("mload32bitBound_return2");// The test extends memory to 4Gb which can't be handled with Java arrays
Expand All @@ -162,7 +162,6 @@ public void stMemoryStressTest() throws IOException {
}

@Test
@Ignore
public void stMemoryTest() throws IOException {
suite.runAll("stMemoryTest");
}
Expand Down Expand Up @@ -304,65 +303,23 @@ public void stCodeCopyTest() throws IOException {


@Test
@Ignore("Fails on pre-configured commit, update after test is merged in develop of Github tests")
public void stExtCodeHashCallCode() throws IOException {
String commit = "10ab37c095bb87d2e781bcf112b6104912fccb44";
String filePath = "stExtCodeHash/extCodeHashCallCode.json";
GeneralStateTestSuite.runSingle(filePath, commit, GitHubJSONTestSuite.Network.Constantinople);
GeneralStateTestSuite.runSingle(filePath, commit, GitHubJSONTestSuite.Network.Byzantium);
}

@Test
@Ignore("Fails on pre-configured commit, update after test is merged in develop of Github tests")
public void stExtCodeHashCall() throws IOException {
String commit = "10ab37c095bb87d2e781bcf112b6104912fccb44";
String filePath = "stExtCodeHash/extCodeHashCall.json";
GeneralStateTestSuite.runSingle(filePath, commit, GitHubJSONTestSuite.Network.Constantinople);
GeneralStateTestSuite.runSingle(filePath, commit, GitHubJSONTestSuite.Network.Byzantium);
public void stExtCodeHashTest() throws IOException {
suite.runAll("stExtCodeHash");
}

@Test
@Ignore("Update after all tests could pass latest develop")
public void stShiftTest() throws IOException {
suite.runAll("stShift");
// TODO: Update all, this one passes with following settings:
// String commit = "ad2184adca367c0b68c65b44519dba16e1d0b9e2";
// String treeSha = "4dd59a4f448dc06c3641bd5cb9c35cf6a099e438";
// targetNets += GitHubJSONTestSuite.Network.Constantinople
}

@Test
@Ignore("Update after all tests could pass latest develop")
public void stCreate2Test() throws IOException {
suite.runAll("stCreate2", new HashSet<>(Arrays.asList(
"RevertInCreateInInit", // Tests excluded because they test unreal prestate
"create2collisionStorage" // (nonce, balance 0, code empty, but some storage)
)));
// TODO: Update all, this one passes with following settings:
// String commitSHA = "95a309203890e6244c6d4353ca411671973c13b5";
// String treeSHA = "700fdc4aa7d74957a12fbda38785ecc7b846bcc0";
// targetNets += GitHubJSONTestSuite.Network.Constantinople
suite.runAll("stCreate2");
}

@Test
@Ignore("Update after all tests could pass latest develop")
public void stSstoreRefundBug() throws IOException {
final String commit = "9ff64743f0347952903287b9074803607e5855e8";

GeneralStateTestSuite.runSingle("stSStoreTest/SstoreCallToSelfSubRefundBelowZero.json", commit,
GitHubJSONTestSuite.Network.Constantinople);

GeneralStateTestSuite.runSingle("stSStoreTest/sstore_0to0.json", commit,
GitHubJSONTestSuite.Network.Constantinople);

GeneralStateTestSuite.runSingle("stSStoreTest/sstore_Xto0.json", commit,
GitHubJSONTestSuite.Network.Constantinople);

GeneralStateTestSuite.runSingle("stSStoreTest/sstore_XtoX.json", commit,
GitHubJSONTestSuite.Network.Constantinople);

GeneralStateTestSuite.runSingle("stSStoreTest/sstore_XtoY.json", commit,
GitHubJSONTestSuite.Network.Constantinople);
public void stSstoreTest() throws IOException {
suite.runAll("stSStoreTest");
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class GitHubTestNetTest {

static String commitSHA = "7f638829311dfc1d341c1db85d8a891f57fa4da7";
static String treeSHA = "12ee51045ace4a3075e39fe58128fdaa74b3fbd0"; // https://github.com/ethereum/tests/tree/develop/BlockchainTests/TransitionTests
static String commitSHA = "725dbc73a54649e22a00330bd0f4d6699a5060e5";
static String treeSHA = "36528084e10bf993fdb20cc304f3421c7324c2a4"; // https://github.com/ethereum/tests/tree/develop/BlockchainTests/TransitionTests

static BlockchainTestSuite suite;

Expand Down Expand Up @@ -65,4 +65,9 @@ public void bcHomesteadToEIP150() throws IOException {
public void bcEIP158ToByzantium() throws IOException {
suite.runAll("bcEIP158ToByzantium", GitHubJSONTestSuite.Network.EIP158ToByzantiumAt5);
}

@Test
public void byzantiumToConstantinople() throws IOException {
suite.runAll("bcByzantiumToConstantinople", GitHubJSONTestSuite.Network.ByzantiumToConstantinopleAt5);
}
}
Loading