-
Notifications
You must be signed in to change notification settings - Fork 390
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
EIP-6780: SELFDESTRUCT only in same transaction #4704
EIP-6780: SELFDESTRUCT only in same transaction #4704
Conversation
if you added a new value
I think this way you wouldn't need to change all the old test files |
@Demuirgos that did not work since both constants will be the same value. the constant name is same. |
@smartprogrammer93, this is close to what I had in mind : using System;
var opcode = (Instruction)0xff; //op code is name agnostic so it only depends on the value
test(opcode, activateShanghai : true); // we pretend test it with "shanghai" activated
// console result : "SELLALL behavior"
test(opcode, activateShanghai : false);// we pretend test it with "shanghai" deactivated
// console result : "SELFDESTRUCT behavior"
void test(Instruction instruction, bool activateShanghai) {
switch(instruction) {
case Instruction.SELLALL | Instruction.SELFDESTRUCT: // since they are both the same value underneath "or"ing them will result in the same value as themselves
if(activateShanghai) { // shanghai specific behaviour
Console.WriteLine("SELLALL behavior");
} else { // old behaviour
Console.WriteLine("SELFDESTRUCT behavior");
}
break;
default :
break;
}
}
enum Instruction {
SELFDESTRUCT = 0xff, // old instruction
SELLALL = 0xff // new instruction with same value as old instruction
} |
@Demuirgos Good idea. thank you |
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.
Not entirely sure if there isn't anything more to it?
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.
@smartprogrammer93 we're renaming opcode for the second time in Nethermind history ;) We did it for the merge and DIFFICULTY/PREVRANDAO opcode. And we had to add one more thing to handle traces: https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.Evm/Instruction.cs#L192
Check this out, I believe you need to do similar thing. It is not consensus critical, but it could be easy to forget later.
src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecBasedSpecProvider.cs
Show resolved
Hide resolved
{ | ||
[TestCase(MainnetSpecProvider.GrayGlacierBlockNumber, 0ul, false)] | ||
[TestCase(MainnetSpecProvider.GrayGlacierBlockNumber, MainnetSpecProvider.CancunBlockTimestamp, true)] | ||
public void self_destruct_not_in_same_transaction(long blockNumber, ulong timestamp, bool onlyOnSameTransaction) |
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.
Can you document these tests a bit, to make it easy to understand the trick being used ?
|
||
[TestCase(MainnetSpecProvider.GrayGlacierBlockNumber, MainnetSpecProvider.CancunBlockTimestamp)] | ||
public void self_destruct_in_same_transaction(long blockNumber, ulong timestamp) | ||
{ |
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.
same here
.PushData(40) | ||
.Op(Instruction.JUMP) | ||
.Op(Instruction.JUMPDEST) | ||
.PushData(TestItem.PrivateKeyB.Address) |
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.
what if you used the ADDRESS
opcode, and why use PrivateKeyB
?
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.
QQ: no need to change tracing: ITxTracer.ReportSelfDestruct?
@@ -178,6 +181,7 @@ private int[] RentReturnStack() | |||
_accessedAddresses = stateForAccessLists._accessedAddresses; | |||
_accessedStorageCells = stateForAccessLists._accessedStorageCells; | |||
_destroyList = stateForAccessLists._destroyList; | |||
_createList = stateForAccessLists._createList; |
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.
I see you are not creating/restoring snapshot on _createList
, while using parent collection. This can cause issues as created items will bubble up to parent context?
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.
I want it to bubble up. I want a list of created contracts in the whole transaction not only the current context
Closes #4650
Types of changes
What types of changes does your code introduce?
Put an
x
in the boxes that applyTesting
Requires testing
In case you checked yes, did you write tests??