Skip to content

Commit

Permalink
address few comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rjnrohit committed Oct 15, 2024
1 parent a87a144 commit 5bd0edf
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ public IEnumerable<ExecutionRequest> ProcessDeposits(TxReceipt[] receipts, IRele
private ExecutionRequest DecodeDepositRequest(LogEntry log)
{
object[] result = _abiEncoder.Decode(AbiEncodingStyle.None, _depositEventABI, log.Data);
List<byte> flattenedResult = new List<byte>();
byte[] flattenedResult = new byte[depositRequestsBytesSize];
int offset = 0;

foreach (var item in result)
{
if (item is byte[] byteArray)
{
flattenedResult.AddRange(byteArray);
Array.Copy(byteArray, 0, flattenedResult, offset, byteArray.Length);
offset += byteArray.Length;
}
else
{
Expand All @@ -72,15 +74,15 @@ private ExecutionRequest DecodeDepositRequest(LogEntry log)
}

// make sure the flattened result is of the correct size
if (flattenedResult.Count != depositRequestsBytesSize)
if (offset != depositRequestsBytesSize)
{
throw new InvalidOperationException($"Decoded ABI result has incorrect size. Expected {depositRequestsBytesSize} bytes, got {flattenedResult.Count} bytes.");
throw new InvalidOperationException($"Decoded ABI result has incorrect size. Expected {depositRequestsBytesSize} bytes, got {offset} bytes.");
}

return new ExecutionRequest
{
RequestType = (byte)ExecutionRequestType.Deposit,
RequestData = flattenedResult.ToArray()
RequestData = flattenedResult
};
}

Expand Down Expand Up @@ -131,7 +133,7 @@ private IEnumerable<ExecutionRequest> ReadRequests(Block block, IWorldState stat

public Hash256 CalculateRequestsHash(Block block, IWorldState state, TxReceipt[] receipts, IReleaseSpec spec, out ArrayPoolList<ExecutionRequest> requests)
{
ArrayPoolList<ExecutionRequest> requestsList = new ArrayPoolList<ExecutionRequest>(0);
ArrayPoolList<ExecutionRequest> requestsList = new ArrayPoolList<ExecutionRequest>(receipts.Length * 2);
using (SHA256 sha256 = SHA256.Create())
{
using (SHA256 sha256Inner = SHA256.Create())
Expand Down

0 comments on commit 5bd0edf

Please sign in to comment.