Skip to content

Commit d89e379

Browse files
authored
chore: Unify precompile naming (#10875)
1 parent 2cb5c38 commit d89e379

File tree

35 files changed

+93
-97
lines changed

35 files changed

+93
-97
lines changed

src/Nethermind/Ethereum.Basic.Test/TransactionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void Test(TransactionTest test)
5252

5353
BigInteger expectedS = decodedSigned.Signature.S.Span.ToUnsignedBigInteger();
5454
BigInteger actualS = decodedUnsigned.Signature.S.Span.ToUnsignedBigInteger();
55-
BigInteger otherS = (BigInteger)Secp256K1Curve.N - actualS;
55+
BigInteger otherS = (BigInteger)SecP256k1Curve.N - actualS;
5656

5757
Assert.That(otherS == expectedS || actualS == expectedS, "S is wrong");
5858

src/Nethermind/Nethermind.Benchmark/Evm/EcRecoverBenchmark.cs renamed to src/Nethermind/Nethermind.Benchmark/Evm/ECRecoverBenchmark.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Nethermind.Benchmarks.Evm
88
{
9-
public class EcRecoverBenchmark
9+
public class ECRecoverBenchmark
1010
{
1111
[GlobalSetup]
1212
public void Setup()

src/Nethermind/Nethermind.Blockchain.Test/Validators/TxValidatorTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public void Curve_is_correct()
3737
BigInteger N = BigInteger.Parse("115792089237316195423570985008687907852837564279074904382605163141518161494337");
3838
BigInteger HalfN = N / 2;
3939

40-
Secp256K1Curve.N.Convert(out BigInteger n);
41-
Secp256K1Curve.HalfN.Convert(out BigInteger halfN);
40+
SecP256k1Curve.N.Convert(out BigInteger n);
41+
SecP256k1Curve.HalfN.Convert(out BigInteger halfN);
4242

4343
(N == n).Should().BeTrue();
4444
(HalfN == halfN).Should().BeTrue();
@@ -71,7 +71,7 @@ public void Zero_signature_component_is_not_valid(byte[] sigData)
7171
[TestCase(1, ExpectedResult = true, TestName = "R equal to N minus one is valid")]
7272
public bool R_boundary_values(int subtractFromN)
7373
{
74-
UInt256 r = Secp256K1Curve.N - (UInt256)subtractFromN;
74+
UInt256 r = SecP256k1Curve.N - (UInt256)subtractFromN;
7575
UInt256 s = UInt256.One;
7676
Signature signature = new(r, s, (ulong)CalculateV());
7777
Transaction tx = Build.A.Transaction.WithSignature(signature).TestObject;

src/Nethermind/Nethermind.Blockchain/EthereumPrecompileProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ private static FrozenDictionary<AddressAsKey, CodeInfo> Precompiles
1616
{
1717
get => new Dictionary<AddressAsKey, CodeInfo>
1818
{
19-
[EcRecoverPrecompile.Address] = new(EcRecoverPrecompile.Instance),
19+
[ECRecoverPrecompile.Address] = new(ECRecoverPrecompile.Instance),
2020
[Sha256Precompile.Address] = new(Sha256Precompile.Instance),
2121
[Ripemd160Precompile.Address] = new(Ripemd160Precompile.Instance),
2222
[IdentityPrecompile.Address] = new(IdentityPrecompile.Instance),
@@ -36,9 +36,9 @@ private static FrozenDictionary<AddressAsKey, CodeInfo> Precompiles
3636
[Bls12381FpToG1Precompile.Address] = new(Bls12381FpToG1Precompile.Instance),
3737
[Bls12381Fp2ToG2Precompile.Address] = new(Bls12381Fp2ToG2Precompile.Instance),
3838

39-
[PointEvaluationPrecompile.Address] = new(PointEvaluationPrecompile.Instance),
39+
[KzgPointEvaluationPrecompile.Address] = new(KzgPointEvaluationPrecompile.Instance),
4040

41-
[Secp256r1Precompile.Address] = new(Secp256r1Precompile.Instance),
41+
[SecP256r1Precompile.Address] = new(SecP256r1Precompile.Instance),
4242

4343
[L1SloadPrecompile.Address] = new(L1SloadPrecompile.Instance),
4444
}.ToFrozenDictionary();

src/Nethermind/Nethermind.Consensus/Validators/TxValidator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,9 @@ public ValidationResult IsWellFormed(Transaction transaction, IReleaseSpec relea
335335
UInt256 sValue = new(signature.SAsSpan, isBigEndian: true);
336336
UInt256 rValue = new(signature.RAsSpan, isBigEndian: true);
337337

338-
UInt256 sMax = releaseSpec.IsEip2Enabled ? Secp256K1Curve.HalfNPlusOne : Secp256K1Curve.N;
338+
UInt256 sMax = releaseSpec.IsEip2Enabled ? SecP256k1Curve.HalfNPlusOne : SecP256k1Curve.N;
339339
return sValue.IsZero || sValue >= sMax ? TxErrorMessages.InvalidTxSignature
340-
: rValue.IsZero || rValue >= Secp256K1Curve.N ? TxErrorMessages.InvalidTxSignature
340+
: rValue.IsZero || rValue >= SecP256k1Curve.N ? TxErrorMessages.InvalidTxSignature
341341
: signature.V is 27 or 28 ? ValidationResult.Success
342342
: ValidateChainId(transaction, releaseSpec);
343343
}

src/Nethermind/Nethermind.Core/Precompiles/PrecompiledAddresses.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ namespace Nethermind.Core.Precompiles;
88
/// </summary>
99
public static class PrecompiledAddresses
1010
{
11-
public static readonly AddressAsKey EcRecover = Address.FromNumber(0x01);
11+
public static readonly AddressAsKey ECRecover = Address.FromNumber(0x01);
1212
public static readonly AddressAsKey Sha256 = Address.FromNumber(0x02);
1313
public static readonly AddressAsKey Ripemd160 = Address.FromNumber(0x03);
1414
public static readonly AddressAsKey Identity = Address.FromNumber(0x04);
1515
public static readonly AddressAsKey ModExp = Address.FromNumber(0x05);
16-
public static readonly AddressAsKey Bn128Add = Address.FromNumber(0x06);
17-
public static readonly AddressAsKey Bn128Mul = Address.FromNumber(0x07);
18-
public static readonly AddressAsKey Bn128Pairing = Address.FromNumber(0x08);
16+
public static readonly AddressAsKey BN254Add = Address.FromNumber(0x06);
17+
public static readonly AddressAsKey BN254Mul = Address.FromNumber(0x07);
18+
public static readonly AddressAsKey BN254PairingCheck = Address.FromNumber(0x08);
1919
public static readonly AddressAsKey Blake2F = Address.FromNumber(0x09);
2020
public static readonly AddressAsKey PointEvaluation = Address.FromNumber(0x0a);
2121
public static readonly AddressAsKey Bls12381G1Add = Address.FromNumber(0x0b);
@@ -25,10 +25,6 @@ public static class PrecompiledAddresses
2525
public static readonly AddressAsKey Bls12381PairingCheck = Address.FromNumber(0x0f);
2626
public static readonly AddressAsKey Bls12381FpToG1 = Address.FromNumber(0x10);
2727
public static readonly AddressAsKey Bls12381Fp2ToG2 = Address.FromNumber(0x11);
28-
29-
// P256Verify (RIP-7212)
3028
public static readonly AddressAsKey P256Verify = Address.FromNumber(0x0100);
31-
32-
// Other precompiles
3329
public static readonly AddressAsKey L1Sload = Address.FromNumber(0x10001);
3430
}

src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public interface IReleaseSpec : IEip1559Spec, IReceiptSpec
341341
bool IsEip4844FeeCollectorEnabled { get; }
342342

343343
/// <summary>
344-
/// Secp256r1 precompile
344+
/// SecP256r1 precompile
345345
/// </summary>
346346
bool IsRip7212Enabled { get; }
347347
bool IsEip7951Enabled { get; }

src/Nethermind/Nethermind.Crypto/Secp256K1Curve.cs renamed to src/Nethermind/Nethermind.Crypto/SecP256k1Curve.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Nethermind.Crypto;
77

8-
public static class Secp256K1Curve
8+
public static class SecP256k1Curve
99
{
1010
//public static readonly BigInteger P =
1111
// BigInteger.Pow(2, 256)

src/Nethermind/Nethermind.Evm.Precompiles/EcRecoverPrecompile.cs renamed to src/Nethermind/Nethermind.Evm.Precompiles/ECRecoverPrecompile.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
namespace Nethermind.Evm.Precompiles;
1414

15-
public class EcRecoverPrecompile : IPrecompile<EcRecoverPrecompile>
15+
public class ECRecoverPrecompile : IPrecompile<ECRecoverPrecompile>
1616
{
17-
public static readonly EcRecoverPrecompile Instance = new();
17+
public static readonly ECRecoverPrecompile Instance = new();
1818
private static readonly Result<byte[]> Empty = Array.Empty<byte>();
1919

20-
private EcRecoverPrecompile()
20+
private ECRecoverPrecompile()
2121
{
2222
}
2323

@@ -33,7 +33,7 @@ private EcRecoverPrecompile()
3333

3434
public Result<byte[]> Run(ReadOnlyMemory<byte> inputData, IReleaseSpec releaseSpec)
3535
{
36-
Metrics.EcRecoverPrecompile++;
36+
Metrics.ECRecoverPrecompile++;
3737
return inputData.Length >= 128 ? RunInternal(inputData.Span) : RunInternal(inputData);
3838
}
3939

src/Nethermind/Nethermind.Evm.Precompiles/Extensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static OrderedDictionary<string, Address> ListPrecompiles(this IReleaseSp
1313
{
1414
OrderedDictionary<string, Address> precompiles = [];
1515

16-
AddPrecompile<EcRecoverPrecompile>();
16+
AddPrecompile<ECRecoverPrecompile>();
1717
AddPrecompile<Sha256Precompile>();
1818
AddPrecompile<Ripemd160Precompile>();
1919
AddPrecompile<IdentityPrecompile>();
@@ -37,7 +37,7 @@ public static OrderedDictionary<string, Address> ListPrecompiles(this IReleaseSp
3737

3838
if (spec.IsEip4844Enabled)
3939
{
40-
AddPrecompile<PointEvaluationPrecompile>();
40+
AddPrecompile<KzgPointEvaluationPrecompile>();
4141
}
4242

4343
if (spec.Bls12381Enabled)
@@ -53,7 +53,7 @@ public static OrderedDictionary<string, Address> ListPrecompiles(this IReleaseSp
5353

5454
if (spec.IsEip7951Enabled)
5555
{
56-
AddPrecompile<Secp256r1Precompile>();
56+
AddPrecompile<SecP256r1Precompile>();
5757
}
5858

5959
if (spec.IsRip7728Enabled)

0 commit comments

Comments
 (0)