Eip 4788/beacon parent block root in evm#5476
Conversation
aa05d72 to
68c4fce
Compare
9d4aadf to
7c35693
Compare
smartprogrammer93
left a comment
There was a problem hiding this comment.
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
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); |
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
MarekM25
left a comment
There was a problem hiding this comment.
wrong naming (BeaconStateRoot -> ParentBeaconBlockRoot)?
MarekM25
left a comment
There was a problem hiding this comment.
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
| Is.EqualTo(input.IsExcessDataGasSet)); | ||
| } | ||
|
|
||
| [TestCaseSource(nameof(BeacondStateRootGetPayloadV3ForDifferentSpecTestSource))] |
There was a problem hiding this comment.
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.
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.
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.
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.
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.AddressfieldTypes of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?