Conversation
EVM Opcode Benchmark DiffAggregated runs: base=1, pr=1 No significant regressions or improvements detected. |
There was a problem hiding this comment.
Pull request overview
This PR adds an extension point for customizing the EVM BlockExecutionContext per chain, and uses it to inject an XDC-specific PREVRANDAO value during block processing.
Changes:
- Added
BlockExecutionContext.WithPrevRandao(...)factory to allow customPREVRANDAOinjection. - Added
BlockProcessor.CreateBlockExecutionContext(...)(virtual) and routed transaction execution through it. - Overrode
CreateBlockExecutionContextinXdcBlockProcessorto provide an XDC-specificPREVRANDAOvalue derived from the block number.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Nethermind/Nethermind.Xdc/XdcBlockProcessor.cs |
Overrides block execution context creation to inject an XDC-specific PREVRANDAO. |
src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs |
Refactors BlockExecutionContext construction and adds a WithPrevRandao factory for custom RNG injection. |
src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs |
Introduces a virtual hook for creating BlockExecutionContext and uses it when setting up transaction execution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| protected override BlockExecutionContext CreateBlockExecutionContext(BlockHeader header, IReleaseSpec spec) => | ||
| BlockExecutionContext.WithPrevRandao(header, spec, | ||
| ValueKeccak.Compute(header.Number.ToBigEndianSpanWithoutLeadingZeros(out _))); |
There was a problem hiding this comment.
So for block value of 0 (which we probably won't hit?) I think it will be different from XDC version, as big.Int.Bytes() returns [] in Go, while our version returns [0].
But in general, +1 for a test comparing this function output against static pre-computed XDC values for a few inputs, as I'm not so confident our ToBigEndianSpanWithoutLeadingZeros always matches big.Int.Bytes().
XDC uses the block number as a random number, not the difficulty.
Changes
BlockExecutionContext.WithPrevRandaostatic factory for custom RNG injectionCreateBlockExecutionContextto pass xdc specificPREVRANDAOxdcTypes of changes
What types of changes does your code introduce?