Skip to content

Commit

Permalink
#93 fix for collision storage clearing - REVERT fix pending
Browse files Browse the repository at this point in the history
  • Loading branch information
tkstanczak committed Nov 8, 2018
1 parent 510e3d3 commit 15f5569
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Nethermind.Blockchain.Validators;
Expand Down
12 changes: 7 additions & 5 deletions src/Nethermind/Nethermind.Evm/VirtualMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2151,17 +2151,19 @@ void UpdateMemoryCost(UInt256 position, UInt256 length)

_state.IncrementNonce(env.ExecutingAccount);

int stateSnapshot = _state.TakeSnapshot();
int storageSnapshot = _storage.TakeSnapshot();

bool accountExists = _state.AccountExists(contractAddress);
if (accountExists && ((GetCachedCodeInfo(contractAddress)?.MachineCode?.Length ?? 0) != 0 || _state.GetNonce(contractAddress) != 0))
{
/* we get the snapshot before this as there is a possibility with that we will touch an empty account and remove it even if the REVERT operation follows */
if (_logger.IsTrace) _logger.Trace($"Contract collision at {contractAddress}");
PushZero(bytesOnStack); // TODO: this push 0 approach should be replaced with some proper approach to call result
PushZero(bytesOnStack);
break;
}

int stateSnapshot = _state.TakeSnapshot();
int storageSnapshot = _storage.TakeSnapshot();


_state.UpdateStorageRoot(contractAddress, Keccak.EmptyTreeHash);
_state.SubtractFromBalance(env.ExecutingAccount, value, spec);
ExecutionEnvironment callEnv = new ExecutionEnvironment();
callEnv.TransferValue = value;
Expand Down

0 comments on commit 15f5569

Please sign in to comment.