-
Notifications
You must be signed in to change notification settings - Fork 459
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
Fix gas fees accounting in TransactionProcessor.Trace #5743
Fix gas fees accounting in TransactionProcessor.Trace #5743
Conversation
src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs
Show resolved
Hide resolved
@@ -241,7 +241,7 @@ public void Trace(Transaction transaction, BlockHeader block, ITxTracer txTracer | |||
} | |||
} | |||
|
|||
UInt256 senderReservedGasPayment = noValidation ? UInt256.Zero : (ulong)gasLimit * effectiveGasPrice; | |||
UInt256 senderReservedGasPayment = (ulong)gasLimit * effectiveGasPrice; |
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.
Can you write an explanation for TransactionProcessor changes?
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.
How it works right now:
- If
noValidation
subtract zero(senderReservedGasPayment
) as gas fee - Refund gas. So if
noValidation
we refund gas that we didn't take.
After the fix:
- If
noValidation
do not subtract gas fee at all - Refund only if
noValidation
is false. This fixes mentioned above issue
Another issue:
Right now Trace function uses noValidation
, so we don't charge gas from account during trace. And as we discussed this behavior shouldn't be changed.
When we execute trace_replayBlock
or trace_replayTransaction
not charging fees causes inconsistency between chain state and stat that we get in trace. So I changed these functions to use Execute
instead of Trace
.
public void Trace(Block block, IBlockTracer tracer) => Process(block, tracer, _traceProcessor); | ||
|
||
public void Execute(Block block, IBlockTracer tracer) => Process(block, tracer, _executeProcessor); | ||
|
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.
Why do we need separated processors?
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.
Wrote under previous comment
@@ -118,7 +118,7 @@ protected TestAllTracerWithOutput Execute(long blockNumber, long gasLimit, byte[ | |||
protected (Block block, Transaction transaction) PrepareTx( | |||
long blockNumber, | |||
long gasLimit, | |||
byte[] code, | |||
byte[] code = null, |
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.
mark it nullable
void Trace(Block block, IBlockTracer tracer); | ||
|
||
/// <summary> | ||
/// Allows to trace and verify arbitrary constructed block. Subtracts gas from sender account | ||
/// </summary> | ||
/// <param name="block">Block to trace.</param> | ||
/// <param name="tracer">Trace to act on block processing events.</param> | ||
void Execute(Block block, IBlockTracer tracer); |
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.
Can you add a write-up (maybe in which JSON RPC uses which and why)
Fixes Closes Resolves #
#5680
Changes
Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?