-
Notifications
You must be signed in to change notification settings - Fork 29
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
CREATE
tests
#1572
base: arith-dev
Are you sure you want to change the base?
CREATE
tests
#1572
Changes from 27 commits
e0f6dd9
0c986fe
2044895
a271c07
8826713
98f63a4
50f85d7
14afa73
b18f6dd
e8cd37f
66019d9
7744321
356dc8e
efdc33b
b3fd26f
aa81fba
c8c5aaa
03a90c8
3eb1d33
818e692
2bc38d7
0611e0e
581a7ab
1cf202e
64fe94b
ba8e12c
3bdae0c
4a45440
117b776
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,7 +130,7 @@ public CreateSection(Hub hub, MessageFrame frame) { | |
return; | ||
} | ||
|
||
final StpCall stpCall = new StpCall(hub, mxpCall.getGasMxp()); | ||
final StpCall stpCall = new StpCall(hub, frame, mxpCall.getGasMxp()); | ||
imcFragment.callStp(stpCall); | ||
|
||
checkArgument(stpCall.outOfGasException() == Exceptions.outOfGasException(exceptions)); | ||
|
@@ -206,6 +206,7 @@ public CreateSection(Hub hub, MessageFrame frame) { | |
if (failedCreate) { | ||
finalContextFragment = ContextFragment.nonExecutionProvidesEmptyReturnData(hub); | ||
scenarioFragment.setScenario(CREATE_FAILURE_CONDITION_WONT_REVERT); | ||
commonValues.payGasPaidOutOfPocket(hub); | ||
hub.failureConditionForCreates = true; | ||
return; | ||
} | ||
|
@@ -220,13 +221,15 @@ public CreateSection(Hub hub, MessageFrame frame) { | |
// Finally, non-exceptional, non-aborting, non-failing, non-emptyInitCode create | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
// we charge for the gas paid out of pocket | ||
commonValues.payGasPaidOutOfPocket(hub); | ||
|
||
// we capture revert information about the child context: CCSR and CCRS | ||
hub.defers().scheduleForContextReEntry(imcFragment, hub.currentFrame()); | ||
|
||
// The current execution context pays (63/64)ths of it current gas to the child context | ||
commonValues.payGasPaidOutOfPocket(hub); | ||
hub.defers() | ||
.scheduleForContextReEntry(this, callFrame); // To get the success bit of the CREATE(2) | ||
// To get the success bit of the CREATE(2) operation | ||
hub.defers().scheduleForContextReEntry(this, callFrame); | ||
|
||
requiresRomLex = true; | ||
hub.romLex().callRomLex(frame); | ||
|
@@ -361,8 +364,8 @@ private void finishAbort(final Hub hub) { | |
hub.factories().accountFragment(); | ||
final AccountFragment creatorAccountFragment = | ||
accountFragmentFactory.make( | ||
preOpcodeCreateeSnapshot, | ||
preOpcodeCreateeSnapshot, | ||
preOpcodeCreatorSnapshot, | ||
preOpcodeCreatorSnapshot, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo |
||
DomSubStampsSubFragment.standardDomSubStamps(this.hubStamp(), 0)); | ||
|
||
final ContextFragment updatedCurrentContextFragment = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,7 +109,13 @@ public void callRlpAddrCreate2(MessageFrame frame, Bytes32 salt, Bytes32 hash) { | |
final Address currentAddress = frame.getRecipientAddress(); | ||
final Bytes32 rawCreate2Address = getCreate2RawAddress(currentAddress, salt, hash); | ||
final RlpAddrOperation operation = | ||
new RlpAddrOperation(rawCreate2Address, OpCode.CREATE2, currentAddress, salt, hash); | ||
new RlpAddrOperation( | ||
rawCreate2Address, | ||
OpCode.CREATE2, | ||
currentAddress, | ||
salt, | ||
hash, | ||
longToUnsignedBigInteger(frame.getWorldUpdater().get(currentAddress).getNonce())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even though it's unnecessary, the nonce is part of the HUB -> RLPADDR lookup for CREATE2. |
||
operations.add(operation); | ||
hub.trm().callTrimming(rawCreate2Address); | ||
} | ||
|
@@ -118,6 +124,8 @@ private void traceCreate2(int stamp, RlpAddrOperation chunk, Trace trace) { | |
final Bytes rawAddressHi = chunk.rawHash().slice(0, LLARGE); | ||
final long depAddressHi = rawAddressHi.slice(12, 4).toLong(); | ||
final Bytes depAddressLo = chunk.rawHash().slice(LLARGE, LLARGE); | ||
final BigInteger nonce = chunk.nonce().orElseThrow(); | ||
final Bytes nonceBytes = bigIntegerToBytes(nonce); | ||
|
||
for (int ct = 0; ct <= MAX_CT_CREATE2; ct++) { | ||
trace | ||
|
@@ -134,6 +142,7 @@ private void traceCreate2(int stamp, RlpAddrOperation chunk, Trace trace) { | |
.saltLo(chunk.salt().orElseThrow().slice(LLARGE, LLARGE)) | ||
.kecHi(chunk.keccak().orElseThrow().slice(0, LLARGE)) | ||
.kecLo(chunk.keccak().orElseThrow().slice(LLARGE, LLARGE)) | ||
.nonce(nonceBytes) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We trace the nonce in all cases. |
||
.lc(true) | ||
.index(UnsignedByte.of(ct)) | ||
.counter(UnsignedByte.of(ct)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,8 +49,13 @@ public RlpAddrOperation(Bytes32 rawDepAddress, OpCode opCode, BigInteger nonce, | |
|
||
// CREATE2 operation | ||
public RlpAddrOperation( | ||
Bytes32 rawHash, OpCode opCode, Address address, Bytes32 salt, Bytes32 kec) { | ||
this(rawHash, opCode, Optional.empty(), address, Optional.of(salt), Optional.of(kec)); | ||
Bytes32 rawHash, | ||
OpCode opCode, | ||
Address address, | ||
Bytes32 salt, | ||
Bytes32 kec, | ||
BigInteger nonce) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding the nonce to the interface |
||
this(rawHash, opCode, Optional.of(nonce), address, Optional.of(salt), Optional.of(kec)); | ||
} | ||
|
||
@Override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,12 +52,13 @@ public long largestOffset() { | |
@Override | ||
public long gasPaidOutOfPocket() { | ||
long currentGas = frame.getRemainingGas(); | ||
long gasCost = this.staticGas() + this.memoryExpansion(); | ||
long upfrontGasCost = this.upfrontGasCost(); | ||
|
||
if (gasCost > currentGas) { | ||
if (upfrontGasCost > currentGas) { | ||
return 0; | ||
} else { | ||
return currentGas - currentGas / 64; | ||
} | ||
|
||
long gasMinusUpfront = currentGas - upfrontGasCost; | ||
return gasMinusUpfront - gasMinusUpfront / 64; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a genuine mistake. the 63/64-ths business happens after paying the upfront gas cost. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,13 +57,15 @@ public long linearPerWord() { | |
@Override | ||
public long gasPaidOutOfPocket() { | ||
long currentGas = frame.getRemainingGas(); | ||
long gasCost = this.staticGas() + this.memoryExpansion() + this.linearPerWord(); | ||
long upfrontGasCost = this.upfrontGasCost(); | ||
|
||
if (gasCost > currentGas) { | ||
if (upfrontGasCost > currentGas) { | ||
return 0; | ||
} else { | ||
return currentGas - currentGas / 64; | ||
} | ||
|
||
final long gasMinusUpfrontGasCost = currentGas - upfrontGasCost; | ||
|
||
return gasMinusUpfrontGasCost - gasMinusUpfrontGasCost / 64; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same mistake for CREATE2 |
||
} | ||
|
||
@Override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright Consensys Software Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package net.consensys.linea.zktracer.instructionprocessing.createTests; | ||
|
||
public enum CreateType { | ||
CREATE, | ||
CREATE2 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Consensys Software Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package net.consensys.linea.zktracer.instructionprocessing.createTests; | ||
|
||
public enum OffsetParameter { | ||
ZERO, | ||
THREE, | ||
SIXTEEN, | ||
SIXTEEN_BYTE_INT, | ||
THIRTY_TWO_BYTE_INT, | ||
MAX, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright Consensys Software Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package net.consensys.linea.zktracer.instructionprocessing.createTests; | ||
|
||
public enum SizeParameter { | ||
ZERO, | ||
TWELVE, // - 3 - 1 | ||
THIRTEEN, // - 3 + 0 | ||
FOURTEEN, // - 3 + 1 | ||
THIRTY_TWO, | ||
MSIZE, | ||
MAX; | ||
|
||
public boolean isAnyOf(SizeParameter... sizeParameters) { | ||
for (SizeParameter sizeParameter : sizeParameters) { | ||
if (this == sizeParameter) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public boolean willRaiseException() { | ||
return this.isAnyOf(MAX); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright Consensys Software Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package net.consensys.linea.zktracer.instructionprocessing.createTests; | ||
|
||
public enum ValueParameter { | ||
ZERO, | ||
ONE, | ||
SELFBALANCE, | ||
SELFBALANCE_PLUS_ONE, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright Consensys Software Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package net.consensys.linea.zktracer.instructionprocessing.createTests; | ||
|
||
public enum WhenToTestParameter { | ||
BEFORE, | ||
AFTER, | ||
BEFORE_AND_AFTER | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omission