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

Change for 7702 for devnet-4 #7590

Merged
merged 17 commits into from
Oct 28, 2024
5 changes: 3 additions & 2 deletions src/Nethermind/Ethereum.Test.Base/AuthorizationListJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-only

using Nethermind.Core;
using Nethermind.Int256;

namespace Ethereum.Test.Base;
public class AuthorizationListJson
Expand All @@ -10,7 +11,7 @@ public class AuthorizationListJson
public Address Address { get; set; }
public ulong Nonce { get; set; }
public ulong V { get; set; }
ak88 marked this conversation as resolved.
Show resolved Hide resolved
public byte[] R { get; set; }
public byte[] S { get; set; }
public UInt256 R { get; set; }
public UInt256 S { get; set; }
public Address Signer { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using System.Numerics;
using FluentAssertions;
using Microsoft.AspNetCore.Mvc.Routing;
using Nethermind.Consensus.Messages;
using Nethermind.Consensus.Validators;
using Nethermind.Core;
Expand Down Expand Up @@ -528,7 +529,7 @@ public void IsWellFormed_CreateTxInSetCode_ReturnsFalse()
{
TransactionBuilder<Transaction> txBuilder = Build.A.Transaction
.WithType(TxType.SetCode)
.WithAuthorizationCode(new AuthorizationTuple(0, TestItem.AddressA, 0, 0, [], []))
.WithAuthorizationCode(new AuthorizationTuple(0, TestItem.AddressA, 0, 0, 0, 0))
.WithMaxFeePerGas(100000)
.WithGasLimit(1000000)
.WithChainId(TestBlockchainIds.ChainId)
Expand All @@ -552,7 +553,7 @@ public void IsWellFormed_AuthorizationListTxInPragueSpec_ReturnsTrue()
TransactionBuilder<Transaction> txBuilder = Build.A.Transaction
.WithType(TxType.SetCode)
.WithTo(TestItem.AddressA)
.WithAuthorizationCode(new AuthorizationTuple(0, TestItem.AddressA, 0, 0, [], []))
.WithAuthorizationCode(new AuthorizationTuple(0, TestItem.AddressA, 0, 0, 0, 0))
.WithMaxFeePerGas(100000)
.WithGasLimit(1000000)
.WithChainId(TestBlockchainIds.ChainId)
Expand Down Expand Up @@ -622,7 +623,6 @@ public void IsWellFormed_AuthorizationTupleHasBadSignature_ReturnsFalse(ulong yP

Assert.That(txValidator.IsWellFormed(tx, Prague.Instance).AsBool, Is.EqualTo(expected));
}

private static IEnumerable<TxType> NonSetCodeTypes() =>
Enum.GetValues<TxType>().Where(t => t != TxType.SetCode && t != TxType.DepositTx);

Expand Down
9 changes: 0 additions & 9 deletions src/Nethermind/Nethermind.Consensus/Validators/TxValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,6 @@ public ValidationResult IsWellFormed(Transaction transaction, IReleaseSpec relea
transaction.AuthorizationList switch
{
null or { Length: 0 } => TxErrorMessages.MissingAuthorizationList,
var authorizationList when authorizationList.Any(a => !ValidateAuthoritySignature(a.AuthoritySignature)) =>
TxErrorMessages.InvalidAuthoritySignature,
_ => ValidationResult.Success
};

private bool ValidateAuthoritySignature(Signature signature)
{
UInt256 sValue = new(signature.SAsSpan, isBigEndian: true);

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this not needed anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It went from invalidating the tx to just invalidating the tuple instead, so the check is now in TransactionProcessor.

return sValue < Secp256K1Curve.HalfNPlusOne && signature.RecoveryId is 0 or 1;
}
}
5 changes: 3 additions & 2 deletions src/Nethermind/Nethermind.Core/AuthorizationTuple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-only

using Nethermind.Core.Crypto;
using Nethermind.Int256;
using System;

namespace Nethermind.Core;
Expand All @@ -17,8 +18,8 @@ public AuthorizationTuple(
Address codeAddress,
ulong nonce,
ulong yParity,
byte[] r,
byte[] s,
UInt256 r,
UInt256 s,
Address? authority = null) : this(chainId, codeAddress, nonce, new Signature(r, s, yParity + Signature.VOffset), authority)
{ }

Expand Down
28 changes: 14 additions & 14 deletions src/Nethermind/Nethermind.Evm.Test/IntrinsicGasCalculatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ [new AuthorizationTuple(
new Address(TestContext.CurrentContext.Random.NextBytes(20)),
TestContext.CurrentContext.Random.NextULong(),
TestContext.CurrentContext.Random.NextULong(),
TestContext.CurrentContext.Random.NextBytes(10),
TestContext.CurrentContext.Random.NextBytes(10))
new UInt256(TestContext.CurrentContext.Random.NextBytes(10)),
new UInt256(TestContext.CurrentContext.Random.NextBytes(10)))
],
GasCostOf.NewAccount);
yield return (
Expand All @@ -136,15 +136,15 @@ [new AuthorizationTuple(
new Address(TestContext.CurrentContext.Random.NextBytes(20)),
TestContext.CurrentContext.Random.NextULong(),
TestContext.CurrentContext.Random.NextULong(),
TestContext.CurrentContext.Random.NextBytes(10),
TestContext.CurrentContext.Random.NextBytes(10)),
new UInt256(TestContext.CurrentContext.Random.NextBytes(10)),
new UInt256(TestContext.CurrentContext.Random.NextBytes(10))),
new AuthorizationTuple(
TestContext.CurrentContext.Random.NextULong(),
new Address(TestContext.CurrentContext.Random.NextBytes(20)),
TestContext.CurrentContext.Random.NextULong(),
TestContext.CurrentContext.Random.NextULong(),
TestContext.CurrentContext.Random.NextBytes(10),
TestContext.CurrentContext.Random.NextBytes(10))
new UInt256(TestContext.CurrentContext.Random.NextBytes(10)),
new UInt256(TestContext.CurrentContext.Random.NextBytes(10)))
],
GasCostOf.NewAccount * 2);
yield return (
Expand All @@ -153,22 +153,22 @@ [new AuthorizationTuple(
new Address(TestContext.CurrentContext.Random.NextBytes(20)),
TestContext.CurrentContext.Random.NextULong(),
TestContext.CurrentContext.Random.NextULong(),
TestContext.CurrentContext.Random.NextBytes(10),
TestContext.CurrentContext.Random.NextBytes(10)),
new UInt256(TestContext.CurrentContext.Random.NextBytes(10)),
new UInt256(TestContext.CurrentContext.Random.NextBytes(10))),
new AuthorizationTuple(
TestContext.CurrentContext.Random.NextULong(),
new Address(TestContext.CurrentContext.Random.NextBytes(20)),
TestContext.CurrentContext.Random.NextULong(),
TestContext.CurrentContext.Random.NextULong(),
TestContext.CurrentContext.Random.NextBytes(10),
TestContext.CurrentContext.Random.NextBytes(10)),
new UInt256(TestContext.CurrentContext.Random.NextBytes(10)),
new UInt256(TestContext.CurrentContext.Random.NextBytes(10))),
new AuthorizationTuple(
TestContext.CurrentContext.Random.NextULong(),
new Address(TestContext.CurrentContext.Random.NextBytes(20)),
TestContext.CurrentContext.Random.NextULong(),
TestContext.CurrentContext.Random.NextULong(),
TestContext.CurrentContext.Random.NextBytes(10),
TestContext.CurrentContext.Random.NextBytes(10))
new UInt256(TestContext.CurrentContext.Random.NextBytes(10)),
new UInt256(TestContext.CurrentContext.Random.NextBytes(10)))
],
GasCostOf.NewAccount * 3);
}
Expand All @@ -193,8 +193,8 @@ public void Calculate_TxHasAuthorizationListBeforePrague_ThrowsInvalidDataExcept
TestItem.AddressF,
0,
TestContext.CurrentContext.Random.NextULong(),
TestContext.CurrentContext.Random.NextBytes(10),
TestContext.CurrentContext.Random.NextBytes(10))
new UInt256(TestContext.CurrentContext.Random.NextBytes(10)),
new UInt256(TestContext.CurrentContext.Random.NextBytes(10)))
)
.TestObject;

Expand Down
Loading
Loading