-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix IsServiceTransaction by allowing all 0 gas price transactions to …
…be service transactions when processing and validator transactions to be service transactions when producing block (#3572)
- Loading branch information
1 parent
aaef50f
commit affbf1e
Showing
7 changed files
with
162 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/Nethermind/Nethermind.Consensus.AuRa/Transactions/LocalTxFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2021 Demerzel Solutions Limited | ||
// This file is part of the Nethermind library. | ||
// | ||
// The Nethermind library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// The Nethermind library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with the Nethermind. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System; | ||
using Nethermind.Consensus.Transactions; | ||
using Nethermind.Core; | ||
|
||
namespace Nethermind.Consensus.AuRa.Transactions | ||
{ | ||
public class LocalTxFilter : ITxFilter | ||
{ | ||
private readonly ISigner _signer; | ||
|
||
public LocalTxFilter(ISigner signer) | ||
{ | ||
_signer = signer; | ||
} | ||
|
||
public (bool Allowed, string Reason) IsAllowed(Transaction tx, BlockHeader parentHeader) | ||
{ | ||
if (tx.SenderAddress == _signer.Address) | ||
{ | ||
tx.IsServiceTransaction = true; | ||
} | ||
|
||
return (true, string.Empty); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/Nethermind/Nethermind.Consensus.AuRa/Transactions/ServiceTxFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) 2021 Demerzel Solutions Limited | ||
// This file is part of the Nethermind library. | ||
// | ||
// The Nethermind library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// The Nethermind library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with the Nethermind. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System; | ||
using Nethermind.Consensus.Transactions; | ||
using Nethermind.Core; | ||
using Nethermind.Core.Specs; | ||
|
||
namespace Nethermind.Consensus.AuRa.Transactions | ||
{ | ||
public class ServiceTxFilter : ITxFilter | ||
{ | ||
private readonly ISpecProvider _specProvider; | ||
|
||
public ServiceTxFilter(ISpecProvider specProvider) | ||
{ | ||
_specProvider = specProvider; | ||
} | ||
|
||
public (bool Allowed, string Reason) IsAllowed(Transaction tx, BlockHeader parentHeader) | ||
{ | ||
if (tx.IsZeroGasPrice(parentHeader, _specProvider)) | ||
{ | ||
tx.IsServiceTransaction = true; | ||
} | ||
|
||
return (true, string.Empty); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/Nethermind/Nethermind.Consensus.AuRa/Transactions/TransactionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2021 Demerzel Solutions Limited | ||
// This file is part of the Nethermind library. | ||
// | ||
// The Nethermind library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// The Nethermind library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with the Nethermind. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using Nethermind.Core; | ||
using Nethermind.Core.Specs; | ||
|
||
namespace Nethermind.Consensus.AuRa.Transactions | ||
{ | ||
public static class TransactionExtensions | ||
{ | ||
public static bool IsZeroGasPrice(this Transaction tx, BlockHeader parentHeader, ISpecProvider specProvider) | ||
{ | ||
bool isEip1559Enabled = specProvider.GetSpec(parentHeader.Number + 1).IsEip1559Enabled; | ||
bool checkByFeeCap = isEip1559Enabled && tx.IsEip1559; | ||
if (checkByFeeCap && !tx.MaxFeePerGas.IsZero) // only 0 gas price transactions are system transactions and can be whitelisted | ||
{ | ||
return false; | ||
} | ||
else if (!tx.GasPrice.IsZero && !checkByFeeCap) | ||
{ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters