Skip to content

Conversation

marcindsobczak
Copy link
Contributor

@marcindsobczak marcindsobczak commented Jul 17, 2024

Changes

  • adding tool used for gas limit project to main repo

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:

  • TestBlockchain
  • EngineModuleTests.Setup

Types of changes

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: tool for gas limit project

Testing

Requires testing

  • Yes
  • No

Documentation

Requires documentation update

  • Yes
  • No

…nto feature/requests_generator_v2_modexp_vulnerabilities

# Conflicts:
#	tools/EngineRequestsGenerator/TestCase.cs
#	tools/EngineRequestsGenerator/TestCaseGenerator.cs
Copy link
Member

@LukaszRozmej LukaszRozmej left a 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.


// Eip4788 precompile state account
if (specProvider?.GenesisSpec?.IsBeaconBlockRootAvailable ?? false)
if (!keepStateEmpty)
Copy link
Member

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:

  1. Put below state modifying code into virtual method and then override it and do nothing.
  2. Have a property That indicates if state should be empty - set it or override it in usages.

Comment on lines +18 to +20
List<byte> currentWord = i == 0
? initCode.Slice(0, initCode.Count % 32)
: initCode.Slice((int)i - 32 + initCode.Count % 32, 32);
Copy link
Member

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])
Copy link
Member

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();
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same stuff here

Comment on lines +27 to +29
var str = JsonConvert.SerializeObject(metadatas);

await File.WriteAllTextAsync($"{_outputPath}/metadata.json", str);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serialize directly to file

Comment on lines +56 to +59
if (attributes == null || attributes.Length != 1)
throw new ArgumentException("Incorrect amount of attributes found");

return attributes[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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];
Copy link
Member

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];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stackalloc?

…plorations' into feature/requests_generator_v2_vulnerabilitiesv2

# Conflicts:
#	tools/EngineRequestsGenerator/TestCase.cs
#	tools/EngineRequestsGenerator/TestCaseGenerator.cs
#	tools/EngineRequestsGenerator/TestCases/Modexp.cs
This reverts commit 46b9e33
…nerator_v2

# Conflicts:
#	src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs
#	src/Nethermind/Nethermind.Merge.Plugin.Test/BaseEngineModuleTests.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants