Skip to content

Conversation

@lu-pinto
Copy link
Member

PR description

This PR is a follow-up cleanup of PR #9556 to remove unnecessary Bytes32 usages where appropriate. I've observed that choice between Bytes32 and Hash in code is not always appropriate so this helps clarify some parts of the code where we really mean Hash and not Bytes32.
Both are 32 bytes in size, in reality Hash is actually a keccak256 hashing function value which always outputs 32 byte.

Other cleanups will follow but I cut this work here to make it reviewable.

Fixed Issue(s)

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • spotless: ./gradlew spotlessApply
  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests
  • hive tests: Engine or other RPCs modified?

@lu-pinto lu-pinto force-pushed the address-hash-using-bytes branch from 8688818 to d4bdfac Compare January 23, 2026 13:26
Copy link
Contributor

Choose a reason for hiding this comment

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

why were these deleted? were they ever used?

Copy link
Member Author

Choose a reason for hiding this comment

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

I tracked it down using git blame, they were added initially for the Deposit functionality of Ethereum but I believe signature verification was later moved to the CL, if it was ever in the EL at some stage.
Right now we only get the RLP, validate that the fields are there and use them to compute the requests hash, nothing else. Look at DepositLogDecoder.
So we don't need these classes anymore.

public static Hash wrap(final Bytes bytes) {
checkArgument(
bytes.size() == Bytes32.SIZE,
"A hash must be %s bytes long, got %s",
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this could bite at runtime.

Copy link
Member Author

Choose a reason for hiding this comment

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

IMO this will be optimized out, specially if we never trip it. If there's a way it doesn't we should make it easier for the compiler to do so.

}

/**
* Wrap bytes to hash.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Wrap bytes to hash. The input must be 32 bytes in length.

@@ -86,7 +87,12 @@
* @param bytes the bytes
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @param bytes the bytes
* @param bytes the bytes. Must be exactly 32 bytes.

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.

2 participants