Skip to content

Conversation

@Gabriel-Trintinalia
Copy link
Contributor

PR description

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?

Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: Gabriel-Trintinalia <[email protected]>
Copilot AI review requested due to automatic review settings November 17, 2025 04:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

* <li>A pre-state trace (complete state snapshot of relevant accounts)
* </ul>
*/
public class StateTraceGenerator {
Copy link
Contributor

Choose a reason for hiding this comment

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

Although it's tested indirectly with the integration tests would still be good to get some unit tests around this

// Case 2: Account existed pre-transaction
final String originalValueHex = rootAccount.getStorageValue(key).toHexString();
// Record differences, or everything if pre-state mode is enabled
if (!originalValueHex.equals(newValueHex) || isPreState) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Think it would be slightly better to do the comparison on the uint256 instead of comparing the hex string

* Writes the "post" state for an account (diff mode). Includes only changed and non-zero
* fields.
*/
private void writePostNode(
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like there is a bit of duplication with writeNode.

try {
gen.writeStringField("balance", b);
} catch (IOException e) {
throw new RuntimeException(e);
Copy link
Contributor

Choose a reason for hiding this comment

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

It probably makes sense to fail early if any exception occurs, but the same isn't being done for fields in writePostNode, should it be?

Signed-off-by: Gabriel-Trintinalia <[email protected]>
@Gabriel-Trintinalia Gabriel-Trintinalia enabled auto-merge (squash) November 24, 2025 07:43
@Gabriel-Trintinalia Gabriel-Trintinalia merged commit 98cca9b into hyperledger:main Nov 24, 2025
46 checks passed
pinges pushed a commit to pinges/besu that referenced this pull request Dec 15, 2025
* Implement pre state diff mode tracer

Signed-off-by: Gabriel-Trintinalia <[email protected]>

* add tests

Signed-off-by: Gabriel-Trintinalia <[email protected]>

* add tests

Signed-off-by: Gabriel-Trintinalia <[email protected]>

* remove unused methods

Signed-off-by: Gabriel-Trintinalia <[email protected]>

* Accept PR suggestions

Signed-off-by: Gabriel-Trintinalia <[email protected]>

---------

Signed-off-by: Gabriel-Trintinalia <[email protected]>
Signed-off-by: [email protected] <[email protected]>
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