From 793f149f96c0091fd2123181064cc46aede3d286 Mon Sep 17 00:00:00 2001 From: Adrian Sutton Date: Wed, 17 Oct 2018 06:48:50 +1000 Subject: [PATCH] [NC-1747] CREATE2 should use the recipient address when calculating the new contract address (#72) --- .../vm/operations/Create2Operation.java | 2 +- .../vm/BlockchainReferenceTestTools.java | 74 ------------------- .../vm/GeneralStateReferenceTestTools.java | 66 ----------------- .../vm/operations/Create2OperationTest.java | 2 +- 4 files changed, 2 insertions(+), 142 deletions(-) diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/vm/operations/Create2Operation.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/vm/operations/Create2Operation.java index ee8c7b5dad..abd895cbd6 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/vm/operations/Create2Operation.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/vm/operations/Create2Operation.java @@ -19,7 +19,7 @@ public class Create2Operation extends AbstractCreateOperation { @Override protected Address targetContractAddress(final MessageFrame frame) { - final Address sender = frame.getSenderAddress(); + final Address sender = frame.getRecipientAddress(); final UInt256 offset = frame.getStackItem(1).asUInt256(); final UInt256 length = frame.getStackItem(2).asUInt256(); final Bytes32 salt = frame.getStackItem(3); diff --git a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/vm/BlockchainReferenceTestTools.java b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/vm/BlockchainReferenceTestTools.java index 7a4bfd00ca..7800ebf65f 100644 --- a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/vm/BlockchainReferenceTestTools.java +++ b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/vm/BlockchainReferenceTestTools.java @@ -76,92 +76,21 @@ public class BlockchainReferenceTestTools { params.blacklist("Callcode1024BalanceTooLow_d0g0v0_Constantinople\\[Constantinople\\]"); params.blacklist("Call1024BalanceTooLow_d0g0v0_Constantinople\\[Constantinople\\]"); params.blacklist("Call1024PreCalls_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2InitCodes_d4g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2InitCodes_d5g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("Create2OnDepth1023_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2callPrecompiles_d6g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2callPrecompiles_d7g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist( - "create2collisionSelfdestructedRevert_d2g0v0_Constantinople\\[Constantinople\\]"); params.blacklist("create2collisionStorage_d0g0v0_Constantinople\\[Constantinople\\]"); params.blacklist("create2collisionStorage_d1g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist( - "create2collisionSelfdestructedRevert_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist( - "create2collisionSelfdestructedRevert_d1g0v0_Constantinople\\[Constantinople\\]"); params.blacklist("create2collisionStorage_d2g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("CREATE2_Suicide_d7g0v0_Constantinople\\[Constantinople\\]"); params.blacklist("RevertInCreateInInitCreate2_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist( - "call_outsize_then_create2_successful_then_returndatasize_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("CREATE2_Suicide_d10g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("CREATE2_Suicide_d11g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("CREATE2_Suicide_d9g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("CREATE2_Suicide_d5g0v0_Constantinople\\[Constantinople\\]"); params.blacklist("CreateMessageReverted_d0g1v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2callPrecompiles_d4g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2callPrecompiles_d5g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionNonce_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionNonce_d1g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist( - "Create2OOGafterInitCodeReturndata2_d0g1v0_Constantinople\\[Constantinople\\]"); - params.blacklist("Create2Recursive_d0g1v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2SmartInitCode_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2SmartInitCode_d1g0v0_Constantinople\\[Constantinople\\]"); params.blacklist( "returndatasize_following_successful_create_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionCode_d2g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("RevertDepthCreate2OOG_d1g1v1_Constantinople\\[Constantinople\\]"); - params.blacklist("create2InitCodes_d8g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2callPrecompiles_d2g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2callPrecompiles_d3g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("RevertDepthCreateAddressCollision_d1g1v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2InitCodes_d6g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2InitCodes_d7g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2InitCodes_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2checkFieldsInInitcode_d4g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2checkFieldsInInitcode_d5g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("RevertDepthCreateAddressCollision_d1g1v1_Constantinople\\[Constantinople\\]"); - params.blacklist("create2checkFieldsInInitcode_d2g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("Create2Recursive_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2checkFieldsInInitcode_d6g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionBalance_d1g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionSelfdestructedOOG_d2g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("RevertDepthCreate2OOG_d1g1v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionBalance_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionCode_d1g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2noCash_d1g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2callPrecompiles_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2callPrecompiles_d1g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionNonce_d2g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionSelfdestructed_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("Create2OnDepth1024_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionCode2_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionCode2_d1g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionSelfdestructed2_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionSelfdestructed2_d1g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("CREATE2_Suicide_d1g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionSelfdestructed_d1g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("CREATE2_Suicide_d3g0v0_Constantinople\\[Constantinople\\]"); params.blacklist("CreateMessageRevertedOOGInInit_d0g1v0_Constantinople\\[Constantinople\\]"); - params.blacklist( - "call_then_create2_successful_then_returndatasize_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionSelfdestructed_d2g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("CREATE2_Suicide_d8g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("Create2OOGafterInitCode_d0g1v0_Constantinople\\[Constantinople\\]"); params.blacklist( "returndatacopy_0_0_following_successful_create_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2checkFieldsInInitcode_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionBalance_d2g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionBalance_d3g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionSelfdestructedOOG_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionSelfdestructedOOG_d1g0v0_Constantinople\\[Constantinople\\]"); params.blacklist("Call1024OOG_d0g0v0_Constantinople\\[Constantinople\\]"); params.blacklist("Call1024PreCalls_d0g0v0_Constantinople\\[Constantinople\\]"); params.blacklist("CallRecursiveBombPreCall_d0g0v0_Constantinople\\[Constantinople\\]"); params.blacklist("Delegatecall1024_d0g0v0_Constantinople\\[Constantinople\\]"); params.blacklist("Call1024BalanceTooLow_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("create2collisionCode_d0g0v0_Constantinople\\[Constantinople\\]"); params.blacklist("Call1MB1024Calldepth_d0g1v0_Constantinople\\[Constantinople\\]"); params.blacklist("LoopCallsThenRevert_d0g0v0_Constantinople\\[Constantinople\\]"); params.blacklist("LoopCallsDepthThenRevert2_d0g0v0_Constantinople\\[Constantinople\\]"); @@ -181,9 +110,6 @@ public class BlockchainReferenceTestTools { params.blacklist("CallRecursiveBomb1_d0g0v0_Constantinople\\[Constantinople\\]"); params.blacklist( "CallRecursiveBomb0_OOG_atMaxCallDepth_d0g0v0_Constantinople\\[Constantinople\\]"); - params.blacklist("suicideStorageCheckVCreate2_Constantinople\\[Constantinople\\]"); - params.blacklist( - "create2collisionwithSelfdestructSameBlock_Constantinople\\[Constantinople\\]"); } public static Collection generateTestParametersForConfig(final String[] filePath) { diff --git a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/vm/GeneralStateReferenceTestTools.java b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/vm/GeneralStateReferenceTestTools.java index b072bbc556..ff32044771 100644 --- a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/vm/GeneralStateReferenceTestTools.java +++ b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/vm/GeneralStateReferenceTestTools.java @@ -144,84 +144,18 @@ public class GeneralStateReferenceTestTools { params.blacklist("Callcode1024BalanceTooLow-Constantinople"); params.blacklist("Call1024PreCalls-Constantinople"); params.blacklist("CallRecursiveBombLog2-Constantinople"); - params.blacklist("CREATE2_Suicide-Constantinople\\[10\\]"); - params.blacklist("CREATE2_Suicide-Constantinople\\[11\\]"); - params.blacklist("CREATE2_Suicide-Constantinople\\[1\\]"); - params.blacklist("CREATE2_Suicide-Constantinople\\[3\\]"); - params.blacklist("CREATE2_Suicide-Constantinople\\[5\\]"); - params.blacklist("CREATE2_Suicide-Constantinople\\[7\\]"); - params.blacklist("CREATE2_Suicide-Constantinople\\[8\\]"); - params.blacklist("CREATE2_Suicide-Constantinople\\[9\\]"); - params.blacklist("create2collisionSelfdestructed2-Constantinople\\[0\\]"); - params.blacklist("create2collisionSelfdestructed2-Constantinople\\[1\\]"); - params.blacklist("create2collisionSelfdestructedRevert-Constantinople\\[0\\]"); - params.blacklist("create2collisionSelfdestructedRevert-Constantinople\\[1\\]"); - params.blacklist("create2collisionSelfdestructedRevert-Constantinople\\[2\\]"); - params.blacklist("create2collisionNonce-Constantinople\\[0\\]"); - params.blacklist("create2collisionNonce-Constantinople\\[1\\]"); - params.blacklist("create2collisionNonce-Constantinople\\[2\\]"); params.blacklist("RevertInCreateInInitCreate2-Constantinople"); - params.blacklist("create2InitCodes-Constantinople\\[0\\]"); - params.blacklist("create2InitCodes-Constantinople\\[4\\]"); - params.blacklist("create2InitCodes-Constantinople\\[5\\]"); - params.blacklist("create2InitCodes-Constantinople\\[6\\]"); - params.blacklist("create2InitCodes-Constantinople\\[7\\]"); - params.blacklist("create2InitCodes-Constantinople\\[8\\]"); - params.blacklist("create2collisionCode-Constantinople\\[0\\]"); - params.blacklist("create2collisionCode-Constantinople\\[1\\]"); - params.blacklist("create2collisionCode-Constantinople\\[2\\]"); params.blacklist("returndatacopy_0_0_following_successful_create-Constantinople"); - params.blacklist("Create2OnDepth1024-Constantinople"); params.blacklist("CreateMessageRevertedOOGInInit-Constantinople\\[1\\]"); - params.blacklist("RevertDepthCreate2OOG-Constantinople\\[6\\]"); - params.blacklist("RevertDepthCreate2OOG-Constantinople\\[7\\]"); - params.blacklist("create2noCash-Constantinople\\[1\\]"); - params.blacklist("create2collisionCode2-Constantinople\\[0\\]"); - params.blacklist("create2collisionCode2-Constantinople\\[1\\]"); params.blacklist("returndatasize_following_successful_create-Constantinople"); - params.blacklist("RevertDepthCreateAddressCollision-Constantinople\\[6\\]"); - params.blacklist("RevertDepthCreateAddressCollision-Constantinople\\[7\\]"); - params.blacklist("call_outsize_then_create2_successful_then_returndatasize-Constantinople"); - params.blacklist("create2callPrecompiles-Constantinople\\[0\\]"); - params.blacklist("create2callPrecompiles-Constantinople\\[1\\]"); - params.blacklist("create2callPrecompiles-Constantinople\\[2\\]"); - params.blacklist("create2callPrecompiles-Constantinople\\[3\\]"); - params.blacklist("create2callPrecompiles-Constantinople\\[4\\]"); - params.blacklist("create2callPrecompiles-Constantinople\\[5\\]"); - params.blacklist("create2callPrecompiles-Constantinople\\[6\\]"); - params.blacklist("create2callPrecompiles-Constantinople\\[7\\]"); - params.blacklist("create2checkFieldsInInitcode-Constantinople\\[0\\]"); - params.blacklist("create2checkFieldsInInitcode-Constantinople\\[2\\]"); - params.blacklist("create2checkFieldsInInitcode-Constantinople\\[4\\]"); - params.blacklist("create2checkFieldsInInitcode-Constantinople\\[5\\]"); - params.blacklist("create2checkFieldsInInitcode-Constantinople\\[6\\]"); - params.blacklist("create2collisionBalance-Constantinople\\[0\\]"); - params.blacklist("create2collisionBalance-Constantinople\\[1\\]"); - params.blacklist("create2collisionBalance-Constantinople\\[2\\]"); - params.blacklist("create2collisionBalance-Constantinople\\[3\\]"); - params.blacklist("Create2OnDepth1023-Constantinople"); - params.blacklist("Create2Recursive-Constantinople\\[0\\]"); - params.blacklist("Create2Recursive-Constantinople\\[1\\]"); - params.blacklist("create2SmartInitCode-Constantinople\\[0\\]"); - params.blacklist("create2SmartInitCode-Constantinople\\[1\\]"); params.blacklist("create2collisionStorage-Constantinople\\[0\\]"); params.blacklist("create2collisionStorage-Constantinople\\[1\\]"); params.blacklist("create2collisionStorage-Constantinople\\[2\\]"); - params.blacklist("CreateMessageReverted-Constantinople\\[1\\]"); - params.blacklist("create2collisionSelfdestructedOOG-Constantinople\\[0\\]"); - params.blacklist("create2collisionSelfdestructedOOG-Constantinople\\[1\\]"); - params.blacklist("create2collisionSelfdestructedOOG-Constantinople\\[2\\]"); - params.blacklist("Create2OOGafterInitCodeReturndata2-Constantinople\\[1\\]"); - params.blacklist("call_then_create2_successful_then_returndatasize-Constantinople"); - params.blacklist("create2collisionSelfdestructed-Constantinople\\[0\\]"); - params.blacklist("create2collisionSelfdestructed-Constantinople\\[1\\]"); - params.blacklist("create2collisionSelfdestructed-Constantinople\\[2\\]"); params.blacklist("Call1024OOG-Constantinople"); params.blacklist("Delegatecall1024OOG-Constantinople"); params.blacklist("CallRecursiveBombPreCall-Constantinople"); params.blacklist("Call1024PreCalls-Constantinople"); params.blacklist("Delegatecall1024-Constantinople"); - params.blacklist("Create2OOGafterInitCode-Constantinople\\[1\\]"); params.blacklist("Call1MB1024Calldepth-Constantinople\\[1\\]"); params.blacklist("LoopCallsDepthThenRevert3-Constantinople"); params.blacklist("LoopCallsDepthThenRevert-Constantinople"); diff --git a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/vm/operations/Create2OperationTest.java b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/vm/operations/Create2OperationTest.java index 6d926121a2..3f784ea614 100644 --- a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/vm/operations/Create2OperationTest.java +++ b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/vm/operations/Create2OperationTest.java @@ -101,7 +101,7 @@ public class Create2OperationTest { @Before public void setUp() { - when(messageFrame.getSenderAddress()).thenReturn(Address.fromHexString(sender)); + when(messageFrame.getRecipientAddress()).thenReturn(Address.fromHexString(sender)); final Bytes32 memoryOffset = Bytes32.fromHexString("0xFF"); final BytesValue codeBytes = BytesValue.fromHexString(code); final UInt256 memoryLength = UInt256.of(codeBytes.size());