Skip to content

Commit

Permalink
Auth list in RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
ak88 committed Sep 9, 2024
1 parent fc45531 commit d11df9c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Nethermind/Nethermind.Core/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class Transaction
public bool SupportsAccessList => Type >= TxType.AccessList && Type != TxType.DepositTx;
public bool Supports1559 => Type >= TxType.EIP1559 && Type != TxType.DepositTx;
public bool SupportsBlobs => Type == TxType.Blob && Type != TxType.DepositTx;
public bool SupportsAuthorizationList => Type == TxType.SetCode && Type != TxType.DepositTx;
public long GasLimit { get; set; }
public Address? To { get; set; }
public UInt256 Value { get; set; }
Expand Down
46 changes: 46 additions & 0 deletions src/Nethermind/Nethermind.Facade/Eth/AuthorizationTupleForRpc.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using Nethermind.Core;
using Nethermind.Core.Eip2930;
using Nethermind.Evm.Tracing.GethStyle.Custom.JavaScript;
using Nethermind.Int256;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;

namespace Nethermind.Facade.Eth
{
public struct AuthorizationTupleForRpc
{
[JsonConstructor]
public AuthorizationTupleForRpc()
{
}
public AuthorizationTupleForRpc(UInt256 chainId, ulong nonce, Address address, UInt256? yParity, UInt256? s, UInt256? r)
{
ChainId = chainId;
Nonce = nonce;
Address = address;
YParity = yParity;
S = s;
R = r;
}

public UInt256 ChainId { get; set; }
public ulong Nonce { get; set; }
public Address Address { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public UInt256? YParity { get; set; }
public UInt256? S { get; set; }
public UInt256? R { get; set; }

public static IEnumerable<AuthorizationTupleForRpc> FromAuthorizationList(AuthorizationTuple[] authorizationList) =>
authorizationList.Select(tuple => new AuthorizationTupleForRpc(tuple.ChainId,
tuple.Nonce,
tuple.CodeAddress,
tuple.AuthoritySignature.RecoveryId,
new UInt256(tuple.AuthoritySignature.S),
new UInt256(tuple.AuthoritySignature.R)));
}
}
9 changes: 9 additions & 0 deletions src/Nethermind/Nethermind.Facade/Eth/TransactionForRpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ public TransactionForRpc(Hash256? blockHash, long? blockNumber, int? txIndex, Tr
{
AccessList = null;
}
if (transaction.SupportsAuthorizationList)
{
AuthorizationList = transaction.AuthorizationList is null ? Array.Empty<AuthorizationTupleForRpc>() : AuthorizationTupleForRpc.FromAuthorizationList(transaction.AuthorizationList);
}
else
{
AuthorizationList = null;
}
MaxFeePerBlobGas = transaction.MaxFeePerBlobGas;
BlobVersionedHashes = transaction.BlobVersionedHashes;

Expand Down Expand Up @@ -126,6 +134,7 @@ public TransactionForRpc() { }
public TxType Type { get; set; }

public IEnumerable<AccessListItemForRpc>? AccessList { get; set; }
public IEnumerable<AuthorizationTupleForRpc>? AuthorizationList{ get; set; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public UInt256? MaxFeePerBlobGas { get; set; } // eip4844
Expand Down

0 comments on commit d11df9c

Please sign in to comment.