-
Notifications
You must be signed in to change notification settings - Fork 434
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
Add EngineRequestGenerator tool #7266
base: master
Are you sure you want to change the base?
Conversation
…thermindEth/nethermind into feature/requests_generator_v2 # Conflicts: # tools/EngineRequestsGenerator/TestCaseGenerator.cs
…nerator_v2 # Conflicts: # src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs # src/tests
…quests_generator_v2
…thermindEth/nethermind into feature/requests_generator_v2
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.
A lot of memory inefficiency - is it at least fast?
Where lists are temporary we could use ArrayPoolList.
Changes to main classes could be done better.
@@ -131,32 +134,35 @@ protected virtual async Task<TestBlockchain> Build(ISpecProvider? specProvider = | |||
TrieStore = new TrieStore(StateDb, LogManager); | |||
State = new WorldState(TrieStore, DbProvider.CodeDb, LogManager, new PreBlockCaches()); | |||
|
|||
// Eip4788 precompile state account | |||
if (specProvider?.GenesisSpec?.IsBeaconBlockRootAvailable ?? false) | |||
if (!keepStateEmpty) |
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.
Instead of adding a parameter maybe better to:
- Put below state modifying code into virtual method and then override it and do nothing.
- Have a property That indicates if state should be empty - set it or override it in usages.
List<byte> currentWord = i == 0 | ||
? initCode.Slice(0, initCode.Count % 32) | ||
: initCode.Slice((int)i - 32 + initCode.Count % 32, 32); |
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.
Use Spans
|
||
// push memory offset - i | ||
byte[] memoryOffset = i.ToBigEndianByteArrayWithoutLeadingZeros(); | ||
if (memoryOffset is [0]) |
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 not compare i
here?
} | ||
|
||
// push size of init code to read from memory | ||
byte[] sizeOfInitCode = initCode.Count.ToByteArray().WithoutLeadingZeros().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.
ToArray() x2
return byteCode; | ||
} | ||
|
||
private static List<byte> GenerateInitCode(List<byte> codeToDeploy) |
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.
same stuff here
var str = JsonConvert.SerializeObject(metadatas); | ||
|
||
await File.WriteAllTextAsync($"{_outputPath}/metadata.json", str); |
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.
Serialize directly to file
if (attributes == null || attributes.Length != 1) | ||
throw new ArgumentException("Incorrect amount of attributes found"); | ||
|
||
return attributes[0]; |
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.
if (attributes == null || attributes.Length != 1) | |
throw new ArgumentException("Incorrect amount of attributes found"); | |
return attributes[0]; | |
return attributes?.First() ?? throw new ArgumentException("Incorrect amount of attributes found"); |
codeToDeploy.Add((byte)Instruction.MSTORE8); | ||
|
||
|
||
byte[] stateVector = new byte[64]; |
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.
stackalloc?
codeToDeploy.Add((byte)Instruction.MSTORE); | ||
|
||
|
||
byte[] messageBlockVector = new byte[128]; |
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.
stackalloc?
…nerator_v2 # Conflicts: # src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs
Changes
Despite of more than 3500 lines of code it is safe to be merged to the master - most of lines is just newly added code to
EngineRequestGenerator
project. From main solution, only 2 classes are modified:Types of changes
Testing
Requires testing
Documentation
Requires documentation update