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

CREATE tests #1572

Merged
merged 52 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
e0f6dd9
first commit
OlivierBBB Nov 26, 2024
0c986fe
ras
OlivierBBB Nov 27, 2024
2044895
feat: wip tests
OlivierBBB Nov 27, 2024
a271c07
feat: root level CREATE tests
OlivierBBB Nov 27, 2024
8826713
ras
OlivierBBB Nov 27, 2024
98f63a4
fix: added missing salt parameter to genericCreate()
OlivierBBB Nov 27, 2024
50f85d7
feat: some abort tests for CREATE(2)
OlivierBBB Nov 27, 2024
14afa73
feat: abort / success and success / abort tests for CREATE(2)'s
OlivierBBB Nov 27, 2024
b18f6dd
feat: more tests
OlivierBBB Nov 27, 2024
e8cd37f
fix: documentation + no SUX for CREATE2 anymore
OlivierBBB Nov 27, 2024
66019d9
Merge branch 'arith-dev' into CREATE-tests
OlivierBBB Nov 27, 2024
7744321
spotless
OlivierBBB Nov 27, 2024
356dc8e
fix: make the test work
OlivierBBB Nov 27, 2024
efdc33b
Merge branch 'arith-dev' into CREATE-tests
OlivierBBB Nov 27, 2024
b3fd26f
spotless
OlivierBBB Nov 27, 2024
aa81fba
feat: added documentation for nontrivial CREATE tests
OlivierBBB Nov 28, 2024
c8c5aaa
feat: more CREATE test todo's
OlivierBBB Nov 29, 2024
03a90c8
Merge branch 'arith-dev' into CREATE-tests
OlivierBBB Nov 29, 2024
3eb1d33
ras
OlivierBBB Dec 2, 2024
818e692
fix: CREATE's gasPaidOutOfPocket()
OlivierBBB Dec 2, 2024
2bc38d7
fix: remove double use of CREATE's gasPaidOutOfPocket
OlivierBBB Dec 2, 2024
0611e0e
fix: using creator snapshots for creatorAccountFragment of CreateSection
OlivierBBB Dec 2, 2024
581a7ab
fix: CREATE2 gas pricing (similar error to CREATE pricing error)
OlivierBBB Dec 2, 2024
1cf202e
fix: CREATE2 address computations now trace the nonce
OlivierBBB Dec 2, 2024
64fe94b
ras
OlivierBBB Dec 2, 2024
ba8e12c
spotless
OlivierBBB Dec 2, 2024
3bdae0c
Merge branch 'arith-dev' into CREATE-tests
OlivierBBB Dec 2, 2024
4a45440
feat: upgraded the todo.md's to GitHub issues
OlivierBBB Dec 2, 2024
117b776
fix: RLPADDR needs to hash the nonce to disambiguate CREATE2's
OlivierBBB Dec 2, 2024
92af66d
Merge branch 'arith-dev' into CREATE-tests
OlivierBBB Dec 4, 2024
ce0677d
fix: documentation for CreateInducedFailureTest
OlivierBBB Dec 5, 2024
f201cc3
spotless
OlivierBBB Dec 5, 2024
e128e99
feat: Failure Condition F via nested CREATE2's
OlivierBBB Dec 5, 2024
39b017a
fix: the OOB related call for CREATE's only requires NONCE and HAS_CO…
OlivierBBB Dec 5, 2024
7b83f14
fix: minor test stuff
OlivierBBB Dec 5, 2024
1a5b4cf
spotless
OlivierBBB Dec 5, 2024
10d0166
feat: a little less messy, but still very messy
OlivierBBB Dec 5, 2024
8bafafc
feat: moving stuff around ...
OlivierBBB Dec 5, 2024
68b4e0f
fix: some wip refactoring on CreateSection
OlivierBBB Dec 6, 2024
212c827
ras: renaming for simpler interpretation of ParametricTests results
OlivierBBB Dec 6, 2024
9e44990
fix: get latest deployment info for CREATE's that revert
OlivierBBB Dec 6, 2024
aca3b39
fix: make SELFDESTRUCT finish on a single context row
OlivierBBB Dec 6, 2024
4acb628
fix: CallFrame's callValue (value) must be gleamed from the apparentV…
OlivierBBB Dec 6, 2024
cd93882
fix: constraints point back to master
OlivierBBB Dec 6, 2024
0d07309
Merge branch 'arith-dev' into CREATE-tests
OlivierBBB Dec 6, 2024
181ccfa
spotless
OlivierBBB Dec 6, 2024
7832cbf
fix: remove junit parallelism
OlivierBBB Dec 6, 2024
aa6c423
Merge branch 'arith-dev' into CREATE-tests
OlivierBBB Dec 6, 2024
0981d52
fix: re-did the type change for scenario/XXX_GAS columns
OlivierBBB Dec 6, 2024
d4ed209
feat: new simplified tests
OlivierBBB Dec 6, 2024
f21d390
Merge branch 'arith-dev' into CREATE-tests
OlivierBBB Dec 6, 2024
f9e21d5
spotless
OlivierBBB Dec 6, 2024
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
35 changes: 35 additions & 0 deletions ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SELFDESTRUCT testing

- STATICX
- i.e. done in an execution context spawned through STATICCALL
- OOGX
- zero / nonzero balance
- warmth / cold recipient
- self recipient
- new account cost for recipient
- REVERT'ed later or not
- inside of a CREATE / deployment transaction
- leads to early deployment of empty code
- said account will be wiped off the world later
- can still have storage in the mean time

- carried out several times in the same account, same transaction
- reverted yes or no at the end
- done indirectly (i.e. through DELEGATECALL / CALLCODE)
- interaction with storage

More involved:
- deploying from an account MARKED_FOR_SELFDESTRUCT
- deploying with CREATE from an account MARKED_FOR_SELFDESTRUCT

This would be to reproduce CREATE address collisions


# PRC calls

- all 9 precompiles
- testing all possible success / failure paths (some extensive work was already done for EC stuff)
- in particular for gas
- testing variations on CALLDATA
- testing the output RETURNDATA
- interaction with DELEGATECALL / CALLCODE ?
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ public void traceContextEnter(MessageFrame frame) {
frameType,
newChildContextNumber(),
this.deploymentStatusOf(frame.getContractAddress()),
frame.getValue(),
frame.getApparentValue(),
Copy link
Collaborator Author

@OlivierBBB OlivierBBB Dec 6, 2024

Choose a reason for hiding this comment

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

Important bug fix, required e.g. for DELEGATECALL to provide the CallFrame with the correct value i.e. callValue

frame.getRemainingGas(),
frame.getRecipientAddress(),
this.deploymentNumberOf(frame.getRecipientAddress()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,6 @@ public long computeGasNext(short exceptions) {

final long gasAfterDeductingCost = computeGasRemaining() - computeGasCost();

OpCode opCode = hub.opCode();
GasProjection gasUtility = Hub.GAS_PROJECTOR.of(hub.messageFrame(), opCode);

return switch (hub.opCodeData().instructionFamily()) {
case KEC, COPY, STACK_RAM, STORAGE, LOG, HALT -> gasAfterDeductingCost;
case CREATE -> gasAfterDeductingCost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,17 @@ public class StpCall implements TraceSubFragment {
@EqualsAndHashCode.Include long gasPaidOutOfPocket;
@EqualsAndHashCode.Include long stipend;

public StpCall(Hub hub, long memoryExpansionGas) {
this.memoryExpansionGas = memoryExpansionGas;
public StpCall(Hub hub, MessageFrame frame, long memoryExpansionGas) {
this.opCode = hub.opCode();
this.gasActual = hub.messageFrame().getRemainingGas();
checkArgument(this.opCode.isCall() || this.opCode.isCreate());

this.memoryExpansionGas = memoryExpansionGas;
this.gasActual = frame.getRemainingGas();

if (this.opCode.isCall()) {
this.stpCallForCalls(hub);
} else {
this.stpCallForCreates(hub);
this.stpCallForCreates(frame);
}
}

Expand Down Expand Up @@ -114,8 +115,7 @@ private long gasPaidOutOfPocketForCalls() {
}
}

private void stpCallForCreates(Hub hub) {
MessageFrame frame = hub.messageFrame();
private void stpCallForCreates(MessageFrame frame) {

this.gas = ZERO; // irrelevant
this.value = EWord.of(frame.getStackItem(0));
Expand All @@ -132,7 +132,7 @@ private long computeGasPaidOutOfPocketForCreates() {
return 0;
} else {
long gasMinusUpfrontCost = gasActual - upfrontGasCost;
return gasMinusUpfrontCost - (gasMinusUpfrontCost >> 6);
return gasMinusUpfrontCost - gasMinusUpfrontCost / 64;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,16 @@ public enum CreateScenario {
CREATE_NON_EMPTY_INIT_CODE_FAILURE_WILL_REVERT,
CREATE_NON_EMPTY_INIT_CODE_FAILURE_WONT_REVERT,
CREATE_NON_EMPTY_INIT_CODE_SUCCESS_WILL_REVERT,
CREATE_NON_EMPTY_INIT_CODE_SUCCESS_WONT_REVERT
CREATE_NON_EMPTY_INIT_CODE_SUCCESS_WONT_REVERT;

public boolean isAnyOf(CreateScenario... createScenarios) {
for (CreateScenario createScenario : createScenarios) {
if (createScenario.equals(this)) {
return true;
}
}
return false;
}
}

@Setter @Getter private CreateScenario scenario;
Expand Down
Loading
Loading