-
Notifications
You must be signed in to change notification settings - Fork 438
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
Conversation
- Expose test values and `ValidateSchema`
- Forgot to change the name
- Follows https://github.com/ethereum-optimism/op-geth fields and tests
- Replaces old `AccessListItemForRpc` with proper container
- A lot of questions/unknowns/design decisions
- Mimics `JsonConverter<T>` from `System.Text.Json`
src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/TransactionForRpc.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/TransactionForRpc.cs
Outdated
Show resolved
Hide resolved
- Improve inline docs
…ub.com/NethermindEth/nethermind into refactor/transaction-for-rpc-hierarchy
@@ -280,8 +281,12 @@ public ResultWrapper<byte[]> eth_sign(Address addressData, byte[] message) | |||
|
|||
public virtual Task<ResultWrapper<Hash256>> eth_sendTransaction(TransactionForRpc rpcTx) | |||
{ | |||
Transaction tx = rpcTx.ToTransactionWithDefaults(_blockchainBridge.GetChainId()); | |||
TxHandlingOptions options = rpcTx.Nonce is null ? TxHandlingOptions.ManagedNonce : TxHandlingOptions.None; | |||
Transaction tx = rpcTx.ToTransaction(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the parameter here should be LegacyTransactionForRpc
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do that then we cannot override in OptimismEthRpcModule
. We could not override and make the Optimism module use OptimismTransactionForRpc
but I'm not sure what method is going to be picked up. Need to double check
- Add initial spec tests
- Replaces `AuthorizationTupleForRpc` - Several TODOs
src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/AuthorizationListForRpc.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/AuthorizationListForRpc.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/SetCodeTransactionForRpc.cs
Show resolved
Hide resolved
@@ -80,7 +80,7 @@ static async Task<int> CountNumberOfMessages(Socket socket, CancellationToken to | |||
byte[] buffer = new byte[10]; | |||
while (true) | |||
{ | |||
ReceiveResult? result = await stream.ReceiveAsync(buffer); | |||
ReceiveResult? result = await stream.ReceiveAsync(buffer).ConfigureAwait(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emlautarom1 Why ConfigureAwait(false)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change introduced by @benaadams
Partially solves #7313
Changes
TransactionForRpc
an abstract base classTransactionForRpc
for specific Transaction types (Legacy
,AccessList
,EIP1559
,Blob
andOptimism
)TransactionForRpc -> Transaction
"default" conversions: conversions now use domain specific defaults (ex.GasLimit
defaults to90_000
) instead of C# specific.Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing
Documentation
Requires documentation update
Requires explanation in Release Notes
Remarks
This PR is an alternative version of #7446 that does not introduce a
RpcGenericTransaction
for deserializing purposes; instead we reuse the same type hierarchy for both serialization and deserialization. As a quick summary, this PR introduces the following changes:When deserializing
TransactionForRpc
based on theType
field of the incoming JSON object (if this field is missing we default toLegacy
transactions).ToTransaction
method that constructs a properTransaction
object while setting up the appropriate domain defaults when fields are missing (ex. if the transaction isAccessList
, then the resultingAccessList
field inTransaction
is an empty access list, notnull
).When serializing
Converter
s that know how to take aTransaction
and build aTransactionForRpc
(the above mentioned abstract base class). Each converter knows how to take a Transaction with a specificTxType
and build a subclass (ex. there is a converter fromTransaction
toBlobTransactionForRpc
). Each converter is based on the Ethereum JSON-RPC spec to ensure no fields are missing.TransactionForRpc
but, for example,EIP1559TransactionForRpc
.