Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor TransactionForRpc (Alternative) #7483

Merged
merged 189 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
189 commits
Select commit Hold shift + click to select a range
84178b8
Initial `RpcLegacyTransaction`
emlautarom1 Sep 4, 2024
a2739f4
Change field order
emlautarom1 Sep 5, 2024
af3b042
Support null as `ChainId` through `TransactionBuilder`
emlautarom1 Sep 5, 2024
ec1a21e
Initial `RpcAccessListTransaction`
emlautarom1 Sep 5, 2024
88dd0e3
Add `RandomSignature`s
emlautarom1 Sep 5, 2024
e9994ea
Use `TestItem` random `Signature`s
emlautarom1 Sep 5, 2024
1839a0d
Initial `RpcEIP1559Transaction`
emlautarom1 Sep 5, 2024
2833a9e
Rename `TestCaseSource`
emlautarom1 Sep 5, 2024
3caed48
Fix `DefaultChainId`
emlautarom1 Sep 5, 2024
67ec222
Guarantee Blob transaction invariants
emlautarom1 Sep 5, 2024
0f997c9
Initial `RpcBlobTransaction`
emlautarom1 Sep 5, 2024
5ae394a
Initial `IRpcTransaction`
emlautarom1 Sep 10, 2024
14d3cae
Initial `IRpcTransactionConverter`
emlautarom1 Sep 10, 2024
11c237e
Move `RpcXTransaction` to class hierarchy
emlautarom1 Sep 10, 2024
7580bc4
Merge `RPCXTransactionTests` into a single test
emlautarom1 Sep 10, 2024
b073e50
Rename test class
emlautarom1 Sep 11, 2024
a13fcc0
Initial `RpcOptimismTransaction`
emlautarom1 Sep 11, 2024
48326d5
Add `WithSourceHash` to builder
emlautarom1 Sep 11, 2024
16765be
Initial `RpcAccessList`
emlautarom1 Sep 11, 2024
f673490
Annotate converter instead of registering
emlautarom1 Sep 11, 2024
cdd4f23
Use annotation for `IRpcTransaction`
emlautarom1 Sep 11, 2024
a9f6277
Initial `RpcGenericTransaction`
emlautarom1 Sep 12, 2024
7db803b
Initial JSON deserialization code
emlautarom1 Sep 13, 2024
0fee0cf
Remove `TxReceipt` for now
emlautarom1 Sep 13, 2024
19686a1
Test for member equality in JSON (de)serialization
emlautarom1 Sep 13, 2024
38f2a1f
Introduce `ITransactionConverter<T>`
emlautarom1 Sep 13, 2024
4e040bf
Add `TODO`
emlautarom1 Sep 13, 2024
07690be
Update inline docs
emlautarom1 Sep 13, 2024
92394c1
Whitespace
emlautarom1 Sep 13, 2024
b7c42cf
Delete unused classes
emlautarom1 Sep 13, 2024
fe8e7e7
Define `RpcNethermindTransaction` as base class
emlautarom1 Sep 13, 2024
c76f72f
Inherit from `RpcNethermindTransaction`
emlautarom1 Sep 13, 2024
629dda7
Add `TransactionConverterExtraData`
emlautarom1 Sep 13, 2024
e3c884a
Add `ToTransaction`
emlautarom1 Sep 13, 2024
33213e5
Implement `ToTransaction`
emlautarom1 Sep 13, 2024
115dbfc
Update inline docs
emlautarom1 Sep 13, 2024
fb91767
Remove deprecated fields in Blob transactions
emlautarom1 Sep 13, 2024
90fe6fa
Retrofit `Data ~ Input` fix
emlautarom1 Sep 13, 2024
121e057
Move docs
emlautarom1 Sep 13, 2024
cbc3b7f
Initial `ToTransactionWithDefaults`
emlautarom1 Sep 16, 2024
3660df5
Change `ChainId` from UInt256 to ulong in JSON DTO
emlautarom1 Sep 16, 2024
5311804
Update inline TODOs
emlautarom1 Sep 16, 2024
f8c0495
Implement remaining `ToTransactionWithDefaults`
emlautarom1 Sep 16, 2024
dd43cf9
Add `From` field
emlautarom1 Sep 16, 2024
34de464
Add defaults test
emlautarom1 Sep 16, 2024
f8283e4
Add `EnsureDefaults`
emlautarom1 Sep 16, 2024
0b63ce6
Add test ignore
emlautarom1 Sep 16, 2024
eb98675
Forward `baseFee`
emlautarom1 Sep 16, 2024
11b1522
Use `RpcGenericTransaction` approach
emlautarom1 Sep 16, 2024
f4dd96b
Update flow docs
emlautarom1 Sep 16, 2024
8ee417e
Remove JSON constructor
emlautarom1 Sep 16, 2024
422460b
Add `IToTransaction<T>`
emlautarom1 Sep 16, 2024
416a21e
Add `RpcGenericTransaction`
emlautarom1 Sep 16, 2024
e2683f9
Implement `IToTransaction, IFromTransaction`
emlautarom1 Sep 16, 2024
1bb457d
Implement `ToTransactionWithDefaults`
emlautarom1 Sep 16, 2024
aaf6d53
Remove deleted files
emlautarom1 Sep 16, 2024
443115c
Implement `IToTransaction, IFromTransaction` for OP
emlautarom1 Sep 16, 2024
c431ad9
Add `EnsureDefaults`
emlautarom1 Sep 16, 2024
6cda988
Remove roundtrip tests
emlautarom1 Sep 16, 2024
e2e7691
Test for Nethermind fields
emlautarom1 Sep 16, 2024
5ad5049
Move files
emlautarom1 Sep 16, 2024
825d455
Proper inline docs
emlautarom1 Sep 16, 2024
5f3e553
Rename class
emlautarom1 Sep 16, 2024
79761d0
Fix import
emlautarom1 Sep 16, 2024
1ff3356
Simplify XML reference
emlautarom1 Sep 16, 2024
80264f4
Fix imports
emlautarom1 Sep 16, 2024
e07620d
Make fields `init` only
emlautarom1 Sep 16, 2024
70abd1b
Add transition `RpcGenericTransactionExtensions`
emlautarom1 Sep 16, 2024
aba2970
Preserve nullability
emlautarom1 Sep 16, 2024
70b175c
Simplify accessor
emlautarom1 Sep 16, 2024
93f94a9
Remove `chainId` from `ToTransactionWithDefaults`
emlautarom1 Sep 16, 2024
a9a06f4
Add more fallback methods durin dev
emlautarom1 Sep 16, 2024
4d88ba9
Remove `IRpcTransaction`
emlautarom1 Sep 16, 2024
e5d576d
Mimic `RpcNethermindTransaction.TransactionConverter`
emlautarom1 Sep 16, 2024
1d13861
Remove duplicated comment
emlautarom1 Sep 16, 2024
8a70ee5
Merge branch 'master' into refactor/individual-transaction-for-rpc
emlautarom1 Sep 16, 2024
04133ef
Fix whitespace
emlautarom1 Sep 16, 2024
4a07b2e
Merge branch 'master' into refactor/individual-transaction-for-rpc
emlautarom1 Sep 18, 2024
28e7173
Revert (again) to class hierarchy deserialization
emlautarom1 Sep 18, 2024
4f115eb
Reorder field initiatlization
emlautarom1 Sep 18, 2024
154512f
Add `From`
emlautarom1 Sep 18, 2024
d52c29a
Use `default`
emlautarom1 Sep 18, 2024
9d587ae
Add `ToTransaction`
emlautarom1 Sep 18, 2024
e51e23a
Assert subclass
emlautarom1 Sep 18, 2024
0df8888
Hide converter classes
emlautarom1 Sep 18, 2024
02e5765
Do not serialize `From` field
emlautarom1 Sep 18, 2024
ff726c8
Change `DefaultChainId` type
emlautarom1 Sep 18, 2024
865102a
Test for type constraint
emlautarom1 Sep 18, 2024
67895c2
Add `blobs`
emlautarom1 Sep 18, 2024
fce6373
Fix Tx Builder
emlautarom1 Sep 18, 2024
c804800
Add JSON constructors
emlautarom1 Sep 18, 2024
182ad70
Update licence year
emlautarom1 Sep 18, 2024
e52c79d
Update `RpcAccessList` tests
emlautarom1 Sep 19, 2024
aec8152
Add `EnsureDefaults`
emlautarom1 Sep 19, 2024
fcb1557
Implement abstract method in `RpcOptimismTransaction`
emlautarom1 Sep 19, 2024
fe90fcf
Add `Nonce` to Optimism
emlautarom1 Sep 19, 2024
a3b80d8
Make `Nonce` nullable
emlautarom1 Sep 19, 2024
8096c9e
Support nullable `StorageKeys`
emlautarom1 Sep 19, 2024
e30d035
Add nullability annotation
emlautarom1 Sep 19, 2024
19abbe0
Remove converter static field
emlautarom1 Sep 19, 2024
aea65b7
Add `Data` as an alias
emlautarom1 Sep 19, 2024
d153056
Add default JSON converters for RPC Transactions
emlautarom1 Sep 19, 2024
8a90075
Support deserializing string wrapped objects
emlautarom1 Sep 20, 2024
f44b4e4
Update main code
emlautarom1 Sep 20, 2024
9f10463
Delete Optimism RPC class
emlautarom1 Sep 20, 2024
cd5b22d
Make `TxType` to `virtual` to ensure invariants
emlautarom1 Sep 20, 2024
8420769
Include `TransactionConverterExtraData`
emlautarom1 Sep 20, 2024
7f72f37
Serialize `From`
emlautarom1 Sep 20, 2024
302a125
Update comparison to use JSON equality
emlautarom1 Sep 20, 2024
9eda9fd
Update comparison to use JSON equality
emlautarom1 Sep 20, 2024
6ee32a1
Use new types
emlautarom1 Sep 20, 2024
fe46fe2
Reintroduce TxType asserts
emlautarom1 Sep 20, 2024
78db619
Use Newtonsoft.JSON for tests
emlautarom1 Sep 20, 2024
4d4628e
Use class instead of record
emlautarom1 Sep 20, 2024
3e44de9
Use Newtonsoft.JSON for tests
emlautarom1 Sep 20, 2024
49521cb
Use Newtonsoft.JSON for tests
emlautarom1 Sep 23, 2024
78fd52f
Use new types
emlautarom1 Sep 23, 2024
8cd3505
Use new types
emlautarom1 Sep 23, 2024
0a6c06a
Update tests
emlautarom1 Sep 23, 2024
5db8814
Test for proper JSON equality
emlautarom1 Sep 23, 2024
cb1c471
Use new types
emlautarom1 Sep 23, 2024
9f4e404
Use new types
emlautarom1 Sep 23, 2024
ec83822
Use new types
emlautarom1 Sep 23, 2024
84022e1
Use new types
emlautarom1 Sep 23, 2024
ce86129
Use new types
emlautarom1 Sep 23, 2024
2ea0629
Reintroduce `UpdateTxType`
emlautarom1 Sep 23, 2024
0cda531
Use new types
emlautarom1 Sep 23, 2024
5ab8eb6
Update base class
emlautarom1 Sep 23, 2024
61bd483
Fix test
emlautarom1 Sep 23, 2024
ed8dc32
Rollback builder changes
emlautarom1 Sep 23, 2024
8d2eb6f
Use new types
emlautarom1 Sep 23, 2024
de52ef9
Rename RpcTransaction
emlautarom1 Sep 23, 2024
80ea178
Rename Optimism transaction
emlautarom1 Sep 23, 2024
5ad37bf
Rename struct
emlautarom1 Sep 23, 2024
0f0d03e
Remove traces from previous naming
emlautarom1 Sep 23, 2024
564ab95
Merge branch 'master' into refactor/transaction-for-rpc-hierarchy
emlautarom1 Sep 23, 2024
4035a07
Use correct code
emlautarom1 Sep 23, 2024
5145de9
Run dotnet format
emlautarom1 Sep 23, 2024
d710e79
Make types explicit
emlautarom1 Sep 23, 2024
b0e9075
Add `Nonce` to Optimism JSON serialization
emlautarom1 Sep 24, 2024
6144dab
1. Move more to generics
LukaszRozmej Sep 24, 2024
e2a9968
remove unneded method
LukaszRozmej Sep 24, 2024
6e801bc
fixes
LukaszRozmej Sep 24, 2024
51bc6bf
whitespace
LukaszRozmej Sep 24, 2024
93ca13b
Reduce code
emlautarom1 Sep 24, 2024
8ac7342
Cleanup docs, naming and nullability annotations
emlautarom1 Sep 24, 2024
bae6ecc
Merge remote-tracking branch 'origin/master' into refactor/transactio…
emlautarom1 Sep 25, 2024
d8a4465
Remove redundant default parameter
emlautarom1 Sep 25, 2024
b617ede
Separate `ITxTyped` from `IFromTransaction`
emlautarom1 Sep 25, 2024
4e90ed8
Inline private method
emlautarom1 Sep 25, 2024
7152b65
Rename tests
emlautarom1 Sep 25, 2024
86c5c77
Merge test suites
emlautarom1 Sep 25, 2024
fa24456
Reintroduce local method for consistency
emlautarom1 Sep 25, 2024
de871bf
Casing
emlautarom1 Sep 25, 2024
112a72c
Inline all JSON equality tests
emlautarom1 Sep 25, 2024
f841207
Move `ShouldSetBaseFee` to class method
emlautarom1 Sep 25, 2024
fa0b53e
Merge branch 'master' into refactor/transaction-for-rpc-hierarchy
emlautarom1 Sep 25, 2024
7c67ad6
Merge branch 'master' into refactor/transaction-for-rpc-hierarchy
emlautarom1 Sep 26, 2024
86d7ce3
Revert interface hierarchy
emlautarom1 Sep 27, 2024
58f2acc
Merge branch 'master' into refactor/transaction-for-rpc-hierarchy
emlautarom1 Sep 27, 2024
40c7ba2
Fix merge
emlautarom1 Sep 27, 2024
d0025fd
Pass `ChainId` to `FromTransaction`
emlautarom1 Sep 27, 2024
992e8e7
Pass `ChainId` to `TxPoolContent`
emlautarom1 Sep 27, 2024
1cb3e4f
Remove `DefaultChainId` hack
emlautarom1 Sep 27, 2024
ac903ad
Merge branch 'master' into refactor/transaction-for-rpc-hierarchy
emlautarom1 Sep 27, 2024
750ad0d
Remove defaulting mechanism for OP transactions
emlautarom1 Sep 30, 2024
f004f26
Reject malformed OP transactions
emlautarom1 Sep 30, 2024
ebb50d2
Initialize serializer once
emlautarom1 Sep 30, 2024
7738c0f
Merge branch 'master' into refactor/transaction-for-rpc-hierarchy
emlautarom1 Sep 30, 2024
7562257
Formatting
emlautarom1 Sep 30, 2024
0690958
Reintroduce laziness to `AccessListForRpc`
emlautarom1 Oct 1, 2024
b785352
Wrap up `Nonce` behavior in OP
emlautarom1 Oct 1, 2024
7c4a9ed
Fix Blob transaction code
emlautarom1 Oct 1, 2024
1c68869
Json Type parsing (#7538)
benaadams Oct 2, 2024
58396a8
Change private `TransactionType` to struct
emlautarom1 Oct 2, 2024
0ff03ac
Merge branch 'master' into refactor/transaction-for-rpc-hierarchy
emlautarom1 Oct 2, 2024
281f6af
Merge branch 'refactor/transaction-for-rpc-hierarchy' of https://gith…
emlautarom1 Oct 2, 2024
42c1b29
Avoid double serialization in tests
emlautarom1 Oct 3, 2024
5002733
Avoid double serialization in RPC tests (#7547)
emlautarom1 Oct 4, 2024
686269f
Merge branch 'master' into refactor/transaction-for-rpc-hierarchy
emlautarom1 Oct 4, 2024
e51b88d
Merge branch 'master' into refactor/transaction-for-rpc-hierarchy
emlautarom1 Oct 8, 2024
0e97573
Add `SetCodeTransactionForRpc`
emlautarom1 Oct 8, 2024
02a3537
Add `AuthorizationListForRpc`
emlautarom1 Oct 8, 2024
52cec69
Do not serialize deprecated fields in SetCode transactions
emlautarom1 Oct 8, 2024
0225a5c
Remove TODO
emlautarom1 Oct 8, 2024
806bb2c
Merge branch 'master' into refactor/transaction-for-rpc-hierarchy
emlautarom1 Oct 9, 2024
c9d0730
Merge branch 'master' into refactor/transaction-for-rpc-hierarchy
emlautarom1 Oct 14, 2024
b6b57bf
Remove nullability annotations
emlautarom1 Oct 14, 2024
2023723
Include Y, R, and yParity fields
emlautarom1 Oct 14, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ internal static void RegisterTransactionType<T>() where T : TransactionForRpc, I

public override TransactionForRpc? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.ValueIsEscaped)
{
string escapedJson = JsonSerializer.Deserialize<string>(ref reader);
return JsonSerializer.Deserialize<TransactionForRpc>(escapedJson, options);
}

// Copy the reader so we can do a double parse:
// The first parse extract the `Type` while the second parses the entire Transaction
Utf8JsonReader txTypeReader = reader;
Expand Down
27 changes: 20 additions & 7 deletions src/Nethermind/Nethermind.JsonRpc.Test/RpcTest.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

Expand All @@ -14,8 +13,6 @@
using Nethermind.Logging;
using Nethermind.Serialization.Json;

using NUnit.Framework;

namespace Nethermind.JsonRpc.Test;

public static class RpcTest
Expand Down Expand Up @@ -63,10 +60,26 @@ private static IJsonRpcService BuildRpcService<T>(T module) where T : class, IRp
return service;
}

public static JsonRpcRequest GetJsonRequest(string method, params string[]? parameters)
public static JsonRpcRequest GetJsonRequest(string method, params string?[]? parameters)
{
var doc = JsonDocument.Parse(JsonSerializer.Serialize(parameters?.ToArray()));
var request = new JsonRpcRequest()
// NOTE: Since parameters are already passed as strings we want to avoid double serialization of JSON objects
var sb = new StringBuilder("[");
foreach (var param in parameters ?? [])
{
if (!string.IsNullOrEmpty(param) && param[0] == '{')
{
sb.Append(param);
}
else
{
sb.Append(JsonSerializer.Serialize(param));
}
sb.Append(',');
}
sb.Append(']');
emlautarom1 marked this conversation as resolved.
Show resolved Hide resolved
var doc = JsonDocument.Parse(sb.ToString(), new JsonDocumentOptions { AllowTrailingCommas = true });
emlautarom1 marked this conversation as resolved.
Show resolved Hide resolved

var request = new JsonRpcRequest
{
JsonRpc = "2.0",
Method = method,
Expand Down
Loading