Skip to content

Commit

Permalink
small refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
LukaszRozmej committed Jan 2, 2025
1 parent f1c1b89 commit 88e3b32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
26 changes: 7 additions & 19 deletions src/Nethermind/Nethermind.Evm/EvmState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,7 @@ public static EvmState RentFrame(
return state;
}

private static EvmState Rent()
{
if (_statePool.TryDequeue(out EvmState state))
{
return state;
}
return new EvmState();
}
private static EvmState Rent() => _statePool.TryDequeue(out EvmState state) ? state : new EvmState();

private void Initialize(
long gasAvailable,
Expand Down Expand Up @@ -145,18 +138,13 @@ private void Initialize(
_isDisposed = false;
}

public Address From
public Address From => ExecutionType switch
{
get
{
return ExecutionType switch
{
ExecutionType.STATICCALL or ExecutionType.CALL or ExecutionType.CALLCODE or ExecutionType.CREATE or ExecutionType.CREATE2 or ExecutionType.TRANSACTION => Env.Caller,
ExecutionType.DELEGATECALL => Env.ExecutingAccount,
_ => throw new ArgumentOutOfRangeException(),
};
}
}
ExecutionType.STATICCALL or ExecutionType.CALL or ExecutionType.CALLCODE or ExecutionType.CREATE
or ExecutionType.CREATE2 or ExecutionType.TRANSACTION => Env.Caller,
ExecutionType.DELEGATECALL => Env.ExecutingAccount,
_ => throw new ArgumentOutOfRangeException(),
};

public Address To => Env.CodeSource ?? Env.ExecutingAccount;
internal bool IsPrecompile => Env.CodeInfo.IsPrecompile;
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Evm/StackAccessTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void Dispose()

private class TrackingState
{
private readonly static ConcurrentQueue<TrackingState> _trackerPool = new();
private static readonly ConcurrentQueue<TrackingState> _trackerPool = new();
public static TrackingState RentState() => _trackerPool.TryDequeue(out TrackingState tracker) ? tracker : new TrackingState();

public static void ResetAndReturn(TrackingState state)
Expand Down

0 comments on commit 88e3b32

Please sign in to comment.