Skip to content

Commit a0a0b7a

Browse files
author
imshubham22apr-gif
committed
Move EventStreamReport into the swirlds-cli module #25188
Signed-off-by: imshubham22apr-gif <imshubham22apr@gmail.com>
1 parent a9641f8 commit a0a0b7a

28 files changed

Lines changed: 78 additions & 358 deletions

File tree

hedera-node/hapi-utils/src/main/java/com/hedera/node/app/hapi/utils/CommonPbjConverters.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ private static <T, R extends GeneratedMessage> R explicitPbjToProto(
282282
final var bytes = requireNonNull(proto).toByteArray();
283283
final var codecField = requireNonNull(pbjClass).getDeclaredField("PROTOBUF");
284284
final var codec = (Codec<R>) codecField.get(null);
285-
return codec.parse(BufferedData.wrap(bytes));
285+
return codec.parseStrict(BufferedData.wrap(bytes));
286286
} catch (NoSuchFieldException | IllegalAccessException | ParseException e) {
287287
// Should be impossible, so just propagate an exception
288288
throw new RuntimeException("Invalid conversion to PBJ for " + pbjClass.getSimpleName(), e);
@@ -417,7 +417,7 @@ public static FileID toPbj(com.hederahashgraph.api.proto.java.FileID fileID) {
417417
requireNonNull(keyValue);
418418
try {
419419
final var bytes = keyValue.toByteArray();
420-
return Key.PROTOBUF.parse(BufferedData.wrap(bytes));
420+
return Key.PROTOBUF.parseStrict(BufferedData.wrap(bytes));
421421
} catch (ParseException e) {
422422
throw new RuntimeException(e);
423423
}
@@ -442,8 +442,7 @@ public static Timestamp toPbj(@NonNull com.hederahashgraph.api.proto.java.Timest
442442
requireNonNull(txBody);
443443
try {
444444
final var bytes = txBody.toByteArray();
445-
return TransactionBody.PROTOBUF.parse(
446-
BufferedData.wrap(bytes), false, false, DEFAULT_MAX_DEPTH, MAX_PBJ_RECORD_SIZE);
445+
return TransactionBody.PROTOBUF.parseStrict(BufferedData.wrap(bytes));
447446
} catch (ParseException e) {
448447
throw new RuntimeException(e);
449448
}

hedera-node/hapi-utils/src/main/java/com/hedera/node/app/hapi/utils/blocks/BlockStreamAccess.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,27 +169,21 @@ public static <K, V> Map<K, V> computeMapFromUpdates(
169169
*/
170170
public static Block blockFrom(@NonNull final Path path) {
171171
final var fileName = path.getFileName().toString();
172+
Block block;
172173
try {
173174
if (fileName.endsWith(".gz")) {
174175
try (final GZIPInputStream in = new GZIPInputStream(Files.newInputStream(path))) {
175-
return Block.PROTOBUF.parse(
176-
Bytes.wrap(in.readAllBytes()).toReadableSequentialData(),
177-
false,
178-
false,
179-
DEFAULT_MAX_DEPTH,
180-
MAX_PBJ_RECORD_SIZE);
176+
block = Block.PROTOBUF.parseStrict(
177+
Bytes.wrap(in.readAllBytes()).toReadableSequentialData());
181178
}
182179
} else {
183-
return Block.PROTOBUF.parse(
184-
Bytes.wrap(Files.readAllBytes(path)).toReadableSequentialData(),
185-
false,
186-
false,
187-
DEFAULT_MAX_DEPTH,
188-
MAX_PBJ_RECORD_SIZE);
180+
block = Block.PROTOBUF.parseStrict(
181+
Bytes.wrap(Files.readAllBytes(path)).toReadableSequentialData());
189182
}
190183
} catch (IOException | ParseException e) {
191184
throw new RuntimeException("Failed reading block @ " + path, e);
192185
}
186+
return block;
193187
}
194188

195189
private static Stream<StateChange> stateChangesForState(@NonNull final List<Block> blocks, final int stateId) {

hedera-node/hapi-utils/src/main/java/com/hedera/node/app/hapi/utils/forensics/TransactionParts.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public record TransactionParts(
3333
public static TransactionParts from(@NonNull final BlockItem item) {
3434
try {
3535
final var serializedSignedTx = item.signedTransactionOrThrow();
36-
final var signedTx = SignedTransaction.PROTOBUF.parse(serializedSignedTx);
36+
final var signedTx = SignedTransaction.PROTOBUF.parseStrict(serializedSignedTx);
3737
final var body = TransactionBody.parseFrom(signedTx.bodyBytes().toByteArray());
3838
return new TransactionParts(
3939
Transaction.newBuilder()

hedera-node/hedera-app/src/main/java/com/hedera/node/app/blocks/impl/BlockStreamBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ private BlockItem transactionResultBlockItem() {
14811481

14821482
private TransactionBody inProgressBody() {
14831483
try {
1484-
return TransactionBody.PROTOBUF.parse(signedTx.bodyBytes().toReadableSequentialData());
1484+
return TransactionBody.PROTOBUF.parseStrict(signedTx.bodyBytes().toReadableSequentialData());
14851485
} catch (Exception e) {
14861486
throw new IllegalStateException("Record being built for unparseable transaction", e);
14871487
}

hedera-node/hedera-app/src/main/java/com/hedera/node/app/blocks/impl/streaming/BlockBufferIO.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ private BufferedBlock readBlockFile(final File file) throws IOException, ParseEx
180180
byteBuffer.get(payload);
181181
final Bytes bytes = Bytes.wrap(payload);
182182

183-
return BufferedBlock.PROTOBUF.parse(
184-
bytes.toReadableSequentialData(), false, false, maxReadDepth, length);
183+
return BufferedBlock.PROTOBUF.parseStrict(bytes.toReadableSequentialData());
185184
}
186185
}
187186
}

hedera-node/hedera-app/src/main/java/com/hedera/node/app/blocks/impl/streaming/BlockNodeConfigService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ private void loadConfiguration() {
183183
}
184184

185185
final byte[] bytes = Files.readAllBytes(path);
186-
connectionInfo = BlockNodeConnectionInfo.JSON.parse(Bytes.wrap(bytes));
186+
connectionInfo = BlockNodeConnectionInfo.JSON.parseStrict(Bytes.wrap(bytes));
187187
} catch (final IOException | ParseException e) {
188188
logger.warn("Failed to read/parse block node configuration from {}", path, e);
189189
return;

hedera-node/hedera-app/src/main/java/com/hedera/node/app/blocks/impl/streaming/FileBlockItemWriter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public static List<OnDiskPendingBlock> loadContiguousPendingBlocks(
257257
final var proofJsonPath = proofJson.toPath();
258258
final PendingProof pendingProof;
259259
try {
260-
pendingProof = PendingProof.JSON.parse(new ReadableStreamingData(proofJsonPath));
260+
pendingProof = PendingProof.JSON.parseStrict(new ReadableStreamingData(proofJsonPath));
261261
} catch (IOException | ParseException e) {
262262
logger.warn(
263263
"Error reading pending proof metadata from {} (not considering remaining - {})",
@@ -310,8 +310,8 @@ public static List<OnDiskPendingBlock> loadContiguousPendingBlocks(
310310

311311
private static Block parseBlock(final byte[] bytes, final int maxReadDepth, final int maxReadSize)
312312
throws ParseException {
313-
return Block.PROTOBUF.parse(
314-
Bytes.wrap(bytes).toReadableSequentialData(), false, false, maxReadDepth, maxReadSize);
313+
return Block.PROTOBUF.parseStrict(
314+
Bytes.wrap(bytes).toReadableSequentialData());
315315
}
316316

317317
/**

hedera-node/hedera-app/src/main/java/com/hedera/node/app/blocks/impl/streaming/RequestResponseMarshaller.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public T parse(@NonNull final InputStream inputStream) {
4242
requireNonNull(inputStream);
4343

4444
try {
45-
return codec.parse(Bytes.wrap(inputStream.readAllBytes()));
45+
return codec.parseStrict(Bytes.wrap(inputStream.readAllBytes()));
4646
} catch (final ParseException | IOException e) {
4747
throw new RuntimeException(e);
4848
}

hedera-node/hedera-app/src/main/java/com/hedera/node/app/fees/ExchangeRateManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private void internalUpdate(@NonNull final Bytes bytes, @Nullable AccountID paye
101101
// Parse the exchange rate file. If we cannot parse it, we just continue with whatever our previous rate was.
102102
final ExchangeRateSet proposedRates;
103103
try {
104-
proposedRates = ExchangeRateSet.PROTOBUF.parse(bytes.toReadableSequentialData());
104+
proposedRates = ExchangeRateSet.PROTOBUF.parseStrict(bytes.toReadableSequentialData());
105105
} catch (final ParseException e) {
106106
throw new HandleException(ResponseCodeEnum.INVALID_EXCHANGE_RATE_FILE);
107107
}
@@ -205,7 +205,7 @@ public ExchangeRateInfo exchangeRateInfo(@NonNull final State state) {
205205
final var bytes = FileUtilities.getFileContent(state, fileID);
206206
final ExchangeRateSet exchangeRates;
207207
try {
208-
exchangeRates = ExchangeRateSet.PROTOBUF.parse(bytes.toReadableSequentialData());
208+
exchangeRates = ExchangeRateSet.PROTOBUF.parseStrict(bytes.toReadableSequentialData());
209209
} catch (ParseException e) {
210210
// This should never happen
211211
throw new IllegalStateException(e);

hedera-node/hedera-app/src/main/java/com/hedera/node/app/fees/FeeManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public ResponseCodeEnum update(@NonNull final Bytes bytes) {
129129
// Parse the current and next fee schedules
130130
final CurrentAndNextFeeSchedule schedules;
131131
try {
132-
schedules = CurrentAndNextFeeSchedule.PROTOBUF.parse(bytes.toReadableSequentialData());
132+
schedules = CurrentAndNextFeeSchedule.PROTOBUF.parseStrict(bytes.toReadableSequentialData());
133133
} catch (final BufferUnderflowException | ParseException ex) {
134134
return ResponseCodeEnum.FEE_SCHEDULE_FILE_PART_UPLOADED;
135135
}
@@ -192,7 +192,7 @@ public synchronized ResponseCodeEnum updateSimpleFees(@NonNull final Bytes bytes
192192
// Parse the current and next fee schedules
193193
try {
194194
final org.hiero.hapi.support.fees.FeeSchedule schedule =
195-
org.hiero.hapi.support.fees.FeeSchedule.PROTOBUF.parse(bytes);
195+
org.hiero.hapi.support.fees.FeeSchedule.PROTOBUF.parseStrict(bytes);
196196
if (isValid(schedule)) {
197197
logger.info("Successfully validated simple fee schedule.");
198198
this.simpleFeesSchedule = schedule;

0 commit comments

Comments
 (0)