Skip to content
Merged
Show file tree
Hide file tree
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 @@ -286,7 +286,7 @@ public ulong Should_not_estimate_tx_with_high_value(UInt256 txValue)
else if (txValue + (UInt256)gasLimit > AccountBalance)
{
Assert.That(err, Is.Not.Null); // Should have error
Assert.That(err, Is.EqualTo("insufficient sender balance for transfer"));
Assert.That(err, Is.EqualTo(GasEstimator.InsufficientBalance));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Nethermind.Config;
using Nethermind.Core;
using Nethermind.Core.Extensions;
using Nethermind.Core.Messages;
using Nethermind.Core.Specs;
using Nethermind.Evm;
using Nethermind.Evm.TransactionProcessing;
Expand All @@ -28,7 +29,7 @@ public class GasEstimator(
public const string GasExceedsAllowanceMsgPrefix = "gas required exceeds allowance";

/// <summary>Message emitted when the sender has insufficient balance.</summary>
public const string InsufficientBalance = "insufficient sender balance for transfer";
public const string InsufficientBalance = TxErrorMessages.InsufficientFundsForTransfer;

/// <summary>Message emitted when the sender cannot cover gas * price + value.</summary>
public const string InsufficientFundsForGas = "insufficient funds for gas * price + value";
Expand Down
2 changes: 2 additions & 0 deletions src/Nethermind/Nethermind.Core/Messages/TxErrorMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public static string InvalidTxType(string name) =>
"intrinsic gas too low";
public const string GasBelowFloorDataCost =
"gas below floor data cost";
public const string InsufficientFundsForTransfer =
"insufficient funds for transfer";
public const string TxMissingTo =
"blob transaction of type create";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void Does_not_take_into_account_precompiles()
testEnvironment.tracer.ReportActionEnd(600, Array.Empty<byte>());

Assert.That(testEnvironment.estimator.Estimate(tx, block.Header, testEnvironment.tracer, out string? err), Is.EqualTo(0));
Assert.That(err, Is.EqualTo("insufficient sender balance for transfer"));
Assert.That(err, Is.EqualTo(GasEstimator.InsufficientBalance));
}

[Test]
Expand Down Expand Up @@ -75,7 +75,7 @@ public void Handles_well_top_level()
testEnvironment.tracer.ReportActionEnd(600, Array.Empty<byte>());

Assert.That(testEnvironment.estimator.Estimate(tx, block.Header, testEnvironment.tracer, out string? err), Is.EqualTo(0));
Assert.That(err, Is.EqualTo("insufficient sender balance for transfer"));
Assert.That(err, Is.EqualTo(GasEstimator.InsufficientBalance));
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,7 @@ public static TransactionResult EvmException(EvmExceptionType evmExceptionType,
public static readonly TransactionResult GasLimitBelowIntrinsicGas = new(ErrorType.GasLimitBelowIntrinsicGas, errorDescription: "intrinsic gas too low");
public static readonly TransactionResult GasLimitBelowFloorGas = new(ErrorType.GasLimitBelowFloorGas, errorDescription: "gas below floor data cost");
public static readonly TransactionResult InsufficientMaxFeePerGasForSenderBalance = new(ErrorType.InsufficientMaxFeePerGasForSenderBalance, errorDescription: "insufficient funds for gas * price + value");
public static readonly TransactionResult InsufficientSenderBalance = new(ErrorType.InsufficientSenderBalance, errorDescription: "insufficient sender balance for transfer");
public static readonly TransactionResult InsufficientSenderBalance = new(ErrorType.InsufficientSenderBalance, errorDescription: TxErrorMessages.InsufficientFundsForTransfer);
public static readonly TransactionResult MalformedTransaction = new(ErrorType.MalformedTransaction, errorDescription: "malformed");
public static readonly TransactionResult MinerPremiumNegative = new(ErrorType.MinerPremiumNegative, errorDescription: "miner premium is negative");
public static readonly TransactionResult NonceOverflow = new(ErrorType.NonceOverflow, errorDescription: "nonce overflow");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Autofac;
using Nethermind.Blockchain;
using Nethermind.Blockchain.Receipts;
using Nethermind.Blockchain.Tracing;
using Nethermind.Core;
using Nethermind.Core.Crypto;
using Nethermind.Core.Extensions;
Expand Down Expand Up @@ -429,7 +430,7 @@ public void Call_tx_returns_InsufficientSenderBalanceError()

CallOutput callOutput = _blockchainBridge.Call(header, tx);

Assert.That(callOutput.Error, Is.EqualTo("insufficient sender balance for transfer"));
Assert.That(callOutput.Error, Is.EqualTo(GasEstimator.InsufficientBalance));
}

[Test]
Expand All @@ -443,7 +444,7 @@ public void EstimateGas_tx_returns_InsufficientSenderBalanceError()

CallOutput callOutput = _blockchainBridge.EstimateGas(header, tx, 1);

Assert.That(callOutput.Error, Is.EqualTo("insufficient sender balance for transfer"));
Assert.That(callOutput.Error, Is.EqualTo(GasEstimator.InsufficientBalance));
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task Eth_estimateGas_web3_should_return_insufficient_balance_error(
string serialized =
await ctx.Test.TestEthRpc("eth_estimateGas", transaction);
Assert.That(
serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32000,\"message\":\"insufficient sender balance for transfer\"},\"id\":67}"));
serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32000,\"message\":\"insufficient funds for transfer\"},\"id\":67}"));
AssertAccountDoesNotExist(ctx, TestAccount);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ private static string FormatErrorDescription(TransactionResult result)
string detail = result.ErrorDescription;
return result.Error switch
{
ErrorType.InsufficientSenderBalance => ReplacePrefix(detail, "insufficient sender balance for transfer", "insufficient funds for transfer"),
ErrorType.InsufficientMaxFeePerGasForSenderBalance => detail,
ErrorType.SenderHasDeployedCode => ReplacePrefix(detail, "sender has deployed code", "sender not an eoa"),
ErrorType.NonceOverflow => ReplacePrefix(detail, "nonce overflow", "nonce has max value"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// SPDX-License-Identifier: LGPL-3.0-only

using Nethermind.Core;
using Nethermind.Core.Messages;

namespace Nethermind.State
{
public class InsufficientBalanceException(Address address) : StateException($"insufficient sender balance for transfer: address {address}")
public class InsufficientBalanceException(Address address) : StateException($"{TxErrorMessages.InsufficientFundsForTransfer}: address {address}")
{
}
}
Loading