Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public interface IReleaseSpec : IEip1559Spec, IReceiptSpec
bool BlockLevelAccessListsEnabled => IsEip7928Enabled;

/// <summary>
/// EIP-7708: ETH transfers emit a log
/// EIP-7708: ETH transfers and burns emit a log
/// </summary>
public bool IsEip7708Enabled { get; }

Expand Down
8 changes: 4 additions & 4 deletions src/Nethermind/Nethermind.Evm.Test/Eip7708Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ private Task<BasicTestBlockchain> CreateChain()
private static LogEntry ExpectedTransferLog(Address from, Address to, UInt256 value) =>
new(TransferLog.Sender, value.ToBigEndian(), [TransferLog.TransferSignature, from.ToHash().ToHash256(), to.ToHash().ToHash256()]);

private static LogEntry ExpectedSelfDestructLog(Address account, UInt256 value) =>
new(TransferLog.Sender, value.ToBigEndian(), [TransferLog.SelfDestructSignature, account.ToHash().ToHash256()]);
private static LogEntry ExpectedBurnLog(Address account, UInt256 value) =>
new(TransferLog.Sender, value.ToBigEndian(), [TransferLog.BurnSignature, account.ToHash().ToHash256()]);

private void AssertLogs(TxReceipt[] receipts, LogEntry[] expectedLogs, bool logCondition = true)
{
Expand Down Expand Up @@ -196,7 +196,7 @@ public async Task SelfDestruct_ToSelf_EmitsSelfDestructLog(ulong contractBalance

Block block = await chain.AddBlock(callTx);

AssertLogs(chain.ReceiptStorage.Get(block), [ExpectedSelfDestructLog(contractAddress, contractBalance)], contractBalance != 0);
AssertLogs(chain.ReceiptStorage.Get(block), [ExpectedBurnLog(contractAddress, contractBalance)], contractBalance != 0);
}

[Test]
Expand Down Expand Up @@ -275,7 +275,7 @@ public async Task SelfDestruct_ThenReceivesEth_EmitsLogs()
ExpectedTransferLog(contractBAddress, contractAAddress, contractABalance),
ExpectedTransferLog(contractAAddress, inheritorA, contractABalance),
ExpectedTransferLog(contractBAddress, contractAAddress, ethToSend),
ExpectedSelfDestructLog(contractAAddress, ethToSend)
ExpectedBurnLog(contractAAddress, ethToSend)
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private static EvmExceptionType InstructionSelfDestruct<TGasPolicy>(VirtualMachi

if (executingAccount == inheritor)
{
vm.AddSelfDestructLog(executingAccount, result);
vm.AddBurnLog(executingAccount, result);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ private int ExecuteEvmCall<TTracingInst>(
UInt256 balance = WorldState.GetBalance(toBeDestroyed);
if (!balance.IsZero)
{
substate.Logs.Add(TransferLog.CreateSelfDestruct(toBeDestroyed, balance));
substate.Logs.Add(TransferLog.CreateBurn(toBeDestroyed, balance));
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/Nethermind/Nethermind.Evm/TransferLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ public static class TransferLog
{
// keccak256('Transfer(address,address,uint256)')
public static readonly Hash256 TransferSignature = new("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef");
// keccak256('Selfdestruct(address,uint256)')
public static readonly Hash256 SelfDestructSignature = new("0x4bfaba3443c1a1836cd362418edc679fc96cae8449cbefccb6457cdf2c943083");
// keccak256('Burn(address,uint256)')
public static readonly Hash256 BurnSignature = new("0xcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5");
public static readonly Address Sender = Address.SystemUser;
public static readonly Address Erc20Sender = new("0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");

public static LogEntry CreateTransfer(Address from, Address to, in UInt256 amount) =>
CreateTransferInternal(Sender, from, to, amount);

public static LogEntry CreateSelfDestruct(Address contract, in UInt256 amount) =>
new(Sender, amount.ToBigEndian(), [SelfDestructSignature, contract.ToHash().ToHash256()]);
public static LogEntry CreateBurn(Address account, in UInt256 amount) =>
new(Sender, amount.ToBigEndian(), [BurnSignature, account.ToHash().ToHash256()]);

public static LogEntry CreateSimulateTransfer(Address from, Address to, in UInt256 amount) =>
CreateTransferInternal(Erc20Sender, from, to, amount);
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Evm/VirtualMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1500,11 +1500,11 @@ internal void AddTransferLog(Address from, Address to, in UInt256 value)
}
}

internal void AddSelfDestructLog(Address contract, in UInt256 value)
internal void AddBurnLog(Address account, in UInt256 value)
{
if (Spec.IsEip7708Enabled && !value.IsZero)
{
AddLog(TransferLog.CreateSelfDestruct(contract, value));
AddLog(TransferLog.CreateBurn(account, value));
}
}
}
Expand Down