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

Direct fail create tx rather than throwing exceptions #7436

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Changes from all commits
Commits
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 @@ -526,8 +526,7 @@ protected virtual void ExecuteEvmCall(

if (substate.ShouldRevert || substate.IsError)
{
if (Logger.IsTrace)
Logger.Trace("Restoring state from before transaction");
if (Logger.IsTrace) Logger.Trace("Restoring state from before transaction");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goto Fail; here too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You get redund on revert would cause it to skip

spentGas = Refund...

WorldState.Restore(snapshot);
}
else
Expand All @@ -539,12 +538,12 @@ protected virtual void ExecuteEvmCall(
long codeDepositGasCost = CodeDepositHandler.CalculateCost(substate.Output.Length, spec);
if (unspentGas < codeDepositGasCost && spec.ChargeForTopLevelCreate)
{
ThrowOutOfGasException();
goto Fail;
}

if (CodeDepositHandler.CodeIsInvalid(spec, substate.Output))
{
ThrowInvalidCodeException();
goto Fail;
}

if (unspentGas >= codeDepositGasCost)
Expand Down Expand Up @@ -572,13 +571,17 @@ protected virtual void ExecuteEvmCall(
}

spentGas = Refund(tx, header, spec, opts, substate, unspentGas, env.TxExecutionContext.GasPrice);
goto Complete;
}
catch (Exception ex) when (ex is EvmException or OverflowException) // TODO: OverflowException? still needed? hope not
{
if (Logger.IsTrace) Logger.Trace($"EVM EXCEPTION: {ex.GetType().Name}:{ex.Message}");
WorldState.Restore(snapshot);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goto Fail; here too? (probably not needed as it is next instruction?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just falls through

}
Fail:
if (Logger.IsTrace) Logger.Trace("Restoring state from before transaction");
WorldState.Restore(snapshot);

Complete:
if (!opts.HasFlag(ExecutionOptions.NoValidation))
header.GasUsed += spentGas;
}
Expand Down Expand Up @@ -649,14 +652,6 @@ protected virtual long Refund(Transaction tx, BlockHeader header, IReleaseSpec s
[StackTraceHidden]
private static void ThrowInvalidDataException(string message) => throw new InvalidDataException(message);

[DoesNotReturn]
[StackTraceHidden]
private static void ThrowInvalidCodeException() => throw new InvalidCodeException();

[DoesNotReturn]
[StackTraceHidden]
private static void ThrowOutOfGasException() => throw new OutOfGasException();

[DoesNotReturn]
[StackTraceHidden]
private static void ThrowTransactionCollisionException() => throw new TransactionCollisionException();
Expand Down