public static void dumpWorldState(final MutableWorldState worldState, final PrintWriter out) {
    out.println("{");
    worldState
        .streamAccounts(Bytes32.ZERO, Integer.MAX_VALUE)
        .sorted(Comparator.comparing(o -> o.getAddress().orElse(Address.ZERO).toHexString()))
        .forEach(
            a -> {
              var account = worldState.get(a.getAddress().get());
              out.println(" \"" + account.getAddress().toHexString() + "\": {");
              if (account.getCode() != null && !account.getCode().isEmpty()) {
                out.println("  \"code\": \"" + account.getCode().toHexString() + "\",");
              }
              var storageEntries =
                  account.storageEntriesFrom(Bytes32.ZERO, Integer.MAX_VALUE).values().stream()
                      .map(
                          e ->
                              Map.entry(
                                  e.getKey().orElse(UInt256.ZERO),
                                  account.getStorageValue(UInt256.fromBytes(e.getKey().get()))))
                      .filter(e -> !e.getValue().isZero())
                      .sorted(Map.Entry.comparingByKey())
                      .toList();
              if (!storageEntries.isEmpty()) {
                out.println("  \"storage\": {");
                out.println(
                    STORAGE_JOINER.join(
                        storageEntries.stream()
                            .map(
                                e ->
                                    "   \""
                                        + e.getKey().toQuantityHexString()
                                        + "\": \""
                                        + e.getValue().toQuantityHexString()
                                        + "\"")
                            .toList()));
                out.println("  },");
              }
              out.print("  \"balance\": \"" + account.getBalance().toDecimalString() + "\"");
              if (account.getNonce() != 0) {
                out.println(",");
                out.println("  \"nonce\": " + account.getNonce());
              } else {
                out.println();
              }
              out.println(" },");
            });
    out.println("}");
    out.flush();
  }
Dumps the current state of the Ethereum world state to the provided PrintWriter. The state
includes account balances, nonces, codes, and storage. The output is in JSON format.

@param worldState The Ethereum world state to be dumped.
@param out The PrintWriter to which the state is dumped.
ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java