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
[WIP]Add Eip6110 implementation #6849
base: master
Are you sure you want to change the base?
Conversation
+ add missing checks
{ | ||
foreach (var log in receipts[i].Logs) | ||
{ | ||
if (log.LoggersAddress == spec.Eip6110ContractAddress) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please find the address for various networks (holesky, sepolia, mainnet, chiado, gnosis) and hardcode them in ChainSpecBasedSpecProviderTests
{ | ||
var depositDecoder = new DepositDecoder(); | ||
Deposit? deposit = depositDecoder.Decode(new RlpStream(log.Data)); | ||
depositList[depositCount++] = deposit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will throw exception if processedBlock has more deposits than suggested block
I am afriad that such exception won't be handled (perhaps, it should) and will destroy BlockProcessingQueue.
It means that you would be able to break Nethermind nodes by posting invalid block
src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Validators/IBlockValidator.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Core.Test/Builders/BlockValidatorBuilder.cs
Outdated
Show resolved
Hide resolved
@@ -24,15 +24,16 @@ public Block(BlockHeader header, BlockBody body) | |||
BlockHeader header, | |||
IEnumerable<Transaction> transactions, | |||
IEnumerable<BlockHeader> uncles, | |||
IEnumerable<Withdrawal>? withdrawals = null) | |||
IEnumerable<Withdrawal>? withdrawals = null, | |||
IEnumerable<Deposit>? deposits = null) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check where this constructor is being used and you will find a few obvious bugs
/// </summary> | ||
public class Deposit | ||
{ | ||
public byte[]? PublicKey { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there Engine API spec for this EIP? Names of fields matter for json serialization, here: https://eips.ethereum.org/EIPS/eip-6110 PubKey was used, but the correct names should come from Engine API
src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV3.cs
Outdated
Show resolved
Hide resolved
@@ -252,6 +252,9 @@ private static ReleaseSpec CreateReleaseSpec(ChainSpec chainSpec, long releaseSt | |||
releaseSpec.IsEip4788Enabled = (chainSpec.Parameters.Eip4788TransitionTimestamp ?? ulong.MaxValue) <= releaseStartTimestamp; | |||
releaseSpec.Eip4788ContractAddress = chainSpec.Parameters.Eip4788ContractAddress; | |||
|
|||
releaseSpec.IsEip6110Enabled = (chainSpec.Parameters.Eip6110TransitionTimestamp ?? ulong.MaxValue) <= releaseStartTimestamp; | |||
releaseSpec.Eip6110ContractAddress = chainSpec.Parameters.Eip6110ContractAddress; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should we do if this EIP is specified in config, but no addres? should we stop application with info?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose so, as both inputs are required for correct config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra things that requires thoughts/changes:
- GenesisLoader - how deposits should be loaded by defaulf from chainspec if we start from Prague in genesis, I guess it should be empty deposit
-EngineModuleTests - we need a few tests - BlockForRpc? with question mark not sure
- exchangeCapabilitesHandler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I see one more potential red flag:
I don't see changes in BlockProcessor. For example, for withdrawals which are very similar we have them here: https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs#L250
For EIP 7002 we have it here:
https://github.com/NethermindEth/nethermind/blob/feature/eip-7002/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs#L256
Additionally, check how withdrawals handled root creation for block production, check those two classes:
WithdrawalProcessor
BlockProductionWithdrawalProcessor
It seems that 7002 started with different approach, we have to think about and make it consistent for withdrawals/6110/7002
- moving code from BlockValidator to BlockProcessor - fixing error discards
_logger = logManager.GetClassLogger(); | ||
} | ||
|
||
public void ProcessDeposits(Block block, TxReceipt[] receipts, IReleaseSpec spec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving IReleaseSpec
to ctor instead, or alternatively remove it and make the if check before consumers call ProcessDeposits
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is not possible, you could pass specProvider only. To me this is okay
src/Nethermind/Nethermind.Consensus/Messages/BlockErrorMessages.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Messages/BlockErrorMessages.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Messages/BlockErrorMessages.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: ak88 <anders.holmbjerg@hotmail.com>
Co-authored-by: ak88 <anders.holmbjerg@hotmail.com>
Co-authored-by: ak88 <anders.holmbjerg@hotmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is still red
@@ -116,4 +117,7 @@ public static class BlockErrorMessages | |||
|
|||
public const string NegativeGasUsed = | |||
"NegativeGasUsed: Cannot be negative."; | |||
public static string MissingDeposits => "MissingDeposits: Deposits cannot be null in block when EIP-6110 activated."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have such messages for deposits in BlockErrorMessages but we don't for withdrawals and 7002?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have MissingWithdrawals Error, I am not sure abt Eip7002 tho
src/Nethermind/Nethermind.Consensus/Withdrawals/WithdrawalProcessor.cs
Outdated
Show resolved
Hide resolved
@@ -19,7 +19,7 @@ internal static class BlockExtensions | |||
public static Block CreateCopy(this Block block, BlockHeader header) => | |||
block is BlockToProduce blockToProduce | |||
? new BlockToProduce(header, blockToProduce.Transactions, blockToProduce.Uncles, blockToProduce.Withdrawals) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Demuirgos @rjnrohit check this line carefully:
? new BlockToProduce(header, blockToProduce.Transactions, blockToProduce.Uncles, blockToProduce.Withdrawals)
analyze all usages of BlockToProduce constructor
@@ -355,6 +355,7 @@ async Task<(MergeTestBlockchain blockchain, IEngineRpcModule engineRpcModule)> M | |||
Substitute.For<IAsyncHandler<byte[], ExecutionPayload?>>(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find EngineModuleTests.V4
src/Nethermind/Nethermind.Consensus/Deposits/DepositsProcessor.cs
Outdated
Show resolved
Hide resolved
if (log.LoggersAddress == spec.Eip6110ContractAddress) | ||
{ | ||
var depositDecoder = new DepositDecoder(); | ||
Deposit? deposit = depositDecoder.Decode(new RlpStream(log.Data)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open question, probably to other teams as well: is it possible to get incorrect data here?
CalculateDepositsRoot(block, depositList, spec); | ||
} | ||
|
||
private void CalculateDepositsRoot(Block block, IEnumerable<Deposit> deposits, IReleaseSpec spec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cosmetic a bit, but worth considering: Withdrawals only calculates root during the block production while exits and deposits always calculate the root.
cc: @rjnrohit @Demuirgos
@@ -252,6 +252,9 @@ private static ReleaseSpec CreateReleaseSpec(ChainSpec chainSpec, long releaseSt | |||
releaseSpec.IsEip4788Enabled = (chainSpec.Parameters.Eip4788TransitionTimestamp ?? ulong.MaxValue) <= releaseStartTimestamp; | |||
releaseSpec.Eip4788ContractAddress = chainSpec.Parameters.Eip4788ContractAddress; | |||
|
|||
releaseSpec.IsEip6110Enabled = (chainSpec.Parameters.Eip6110TransitionTimestamp ?? ulong.MaxValue) <= releaseStartTimestamp; | |||
releaseSpec.Eip6110ContractAddress = chainSpec.Parameters.Eip6110ContractAddress; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Cosmetic) I think it would be nice to rename it to DepositContractAddress. This address could be used in the future in other places
private readonly IAsyncHandler<byte[], GetPayloadV4Result?> _getPayloadHandlerV4; | ||
|
||
public Task<ResultWrapper<ForkchoiceUpdatedV1Result>> engine_forkchoiceUpdatedV4(ForkchoiceStateV1 forkchoiceState, PayloadAttributes? payloadAttributes = null) | ||
=> ForkchoiceUpdated(forkchoiceState, payloadAttributes, EngineApiVersions.Cancun); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change from EngineApiVersions.Cancun
to EngineApiVersions.Prague
Fixes Closes Resolves #6274
Please choose one of the keywords above to refer to the issue this PR solves followed by the issue number (e.g. Fixes #000). If no issue number, remove the line. Also, remove everything marked optional that is not applicable. Remove this note after reading.
Changes
Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing
Optional. Remove if not applicable.
Documentation
Requires documentation update
If yes, link the PR to the docs update or the issue with the details labeled
docs
. Remove if not applicable.Requires explanation in Release Notes
If yes, fill in the details here. Remove if not applicable.
Remarks
Optional. Remove if not applicable.