-
Notifications
You must be signed in to change notification settings - Fork 438
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
Eip 4788/beacon parent block root in evm #5476
Conversation
aa05d72
to
68c4fce
Compare
9d4aadf
to
7c35693
Compare
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.
Would advice to keep refactoring changes in separate PR.
src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Evm/Precompiles/Statefull/BeaconStateRootPrecompile.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Evm/Precompiles/Statefull/BeaconStateRootPrecompile.cs
Outdated
Show resolved
Hide resolved
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.
Great, Still would put the refactoring changes in a separate PR <3
af267e2
to
d95d388
Compare
src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Evm/Precompiles/Stateful/BeaconStateRootPrecompile.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Evm/Precompiles/Stateful/BeaconStateRootPrecompile.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Evm/Precompiles/Stateful/BeaconStateRootPrecompile.cs
Outdated
Show resolved
Hide resolved
Span<byte> inputDataSpan = stackalloc byte[32]; | ||
inputData.PrepareEthInput(inputDataSpan); | ||
|
||
UInt256 timestamp = new UInt256(inputDataSpan, true); |
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.
Maybe we can avoid it with Unsafe
? @benaadams
src/Nethermind/Nethermind.Evm/Precompiles/Stateful/BeaconStateRootPrecompile.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Evm/Precompiles/Stateful/BeaconStateRootPrecompile.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs
Outdated
Show resolved
Hide resolved
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.
wrong naming (BeaconStateRoot -> ParentBeaconBlockRoot)?
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.
Added a few comments.
Do you know about any hive tets/execution spec tests for this EIP?
src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs
Outdated
Show resolved
Hide resolved
@@ -38,6 +38,16 @@ public async Task ExccessDataGas_should_present_in_cancun_only((IReleaseSpec Spe | |||
Is.EqualTo(input.IsExcessDataGasSet)); | |||
} | |||
|
|||
[TestCaseSource(nameof(BeacondStateRootGetPayloadV3ForDifferentSpecTestSource))] |
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.
no tests that verify if we can produce blocks with ParentBeaconBlockRoot and send them later through engine API?
no tests that we can't pass null ParentBeaconBlockRoot to payload attributes
src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Evm/Precompiles/Stateful/BeaconBlockRootPrecompile.cs
Outdated
Show resolved
Hide resolved
9aabf7c
to
224a831
Compare
- Added Eip4788 wiring to ChainSpecs
- Added Eip4788 stateful precompile
stateProvider.CreateAccountIfNotExists(BeaconBlockRootPrecompile.Address, 1); | ||
|
||
UInt256.Mod(timestamp, HISTORICAL_ROOTS_LENGTH, out UInt256 timestampReduced); | ||
UInt256 rootIndex = timestampReduced + HISTORICAL_ROOTS_LENGTH; | ||
|
||
StorageCell tsStorageCell = new(BeaconBlockRootPrecompile.Address, timestampReduced); | ||
StorageCell brStorageCell = new(BeaconBlockRootPrecompile.Address, rootIndex); | ||
|
||
stateProvider.Set(tsStorageCell, timestamp.ToBigEndian()); | ||
stateProvider.Set(brStorageCell, parentBeaconBlockRoot.Bytes.ToArray()); |
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.
Wouldn't it be better if this code would live in some static method in BeaconBlockRootPrecompile
?
You are touching its address, you are duplicating the logic of calculating indexes, doesn't make sense to be anywhere else.
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.
funnily tho it was in a static method on IBeaconBlockRootPrecompile, but I dont think it's worth modifying now cause chances are it will be yeeeted out completely one the v2 comes arround
{ | ||
public void HandleBeaconBlockRoot(Block block, IReleaseSpec spec, IWorldState stateProvider) | ||
{ | ||
if (!spec.IsBeaconBlockRootAvailable) return; |
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.
Lets:
- Rename it to InitStatefulPrecompiles (Handler?)
- Create it in the BlockProcessor instead of injecting it, contrary to withdrawals which are consensus specific, this is directly controlled by spec, so doesn't make sense to inject different implementations - sorry if I confused you earlier.
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.
perfect ig (it was painful to make it injectable xD)
aea2755
to
3d975ef
Compare
…V3' into EIP-4788/BeaconStateRoot-in-EVM
…nStateRoot-in-EVM
81eeece
to
895669d
Compare
3142e87
to
26ddb49
Compare
Changes
Precompile.Instance.Address
fieldTypes of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?