-
Notifications
You must be signed in to change notification settings - Fork 897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve flat trace generation performance #6472
Changes from 11 commits
c89e4db
45448b2
395a89a
663a065
da0ce79
5b9de6e
8f78a07
ce36c61
0de955a
9d058a3
4a8fa04
dd553c3
c0cc9fd
ec123a6
b8e548f
51b06f8
35e246d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -530,11 +530,19 @@ private static FlatTrace.Context handleCallDataLoad( | |||
|
||||
private static boolean hasRevertInSubCall( | ||||
final TransactionTrace transactionTrace, final TraceFrame callFrame) { | ||||
return transactionTrace.getTraceFrames().stream() | ||||
.filter(traceFrame -> !traceFrame.equals(callFrame)) | ||||
.takeWhile(traceFrame -> !traceFrame.getOpcode().equals("RETURN")) | ||||
.filter(traceFrame -> traceFrame.getOpcode().equals("REVERT")) | ||||
.anyMatch(traceFrame -> traceFrame.getDepth() == callFrame.getDepth()); | ||||
for (int i = 0; i < transactionTrace.getTraceFrames().size(); i++) { | ||||
if (i + 1 < transactionTrace.getTraceFrames().size()) { | ||||
final TraceFrame next = transactionTrace.getTraceFrames().get(i + 1); | ||||
if (next.getDepth() == callFrame.getDepth()) { | ||||
if (next.getOpcodeNumber() == 0xFD) { // REVERT opCode | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be worth making AbstractOperation.getOpcode() static and doing the comparison to that to avoid creating another range of enums. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This commit is outdated. Making AbstractOperation.getOpcode() static means that we need to make opcode static in AbstractOperation which is not the case, opcode depends on the implementation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding an OPCODE constant to RevertOperation and ReturnOperation so we can reduce magic constants in the code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestion, I was thinking actually of an Enum OpCode to store all the opcodes and use only the Enum in the EVM and outside, like Opcode.REVERT.getOpcodeNumber() for 0xFD There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shemnon I've added the OpCode enum within the EVM and would like to use it across all EVM opcode operations. An implementation example has been provided for ADDMOD. Does this approach work for you ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not what I meant. Such an OpCode enum breaks extensibility to downstream users use. Please revert. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I intended was something like this, where a constant is added to the Operation classes, not an entirely different enum.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually understood your suggestion but wanted to suggest an implementation that would work for similar use cases in the future, but it looks like it wasn't a good idea. I'm going to revert the last changes. |
||||
return true; | ||||
} else if (next.getOpcodeNumber() == 0xF3) { // RETURN opCode | ||||
return false; | ||||
} | ||||
} | ||||
} | ||||
} | ||||
return false; | ||||
} | ||||
|
||||
private static String calculateCallingAddress(final FlatTrace.Context lastContext) { | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of a random question (Side note: I dont really have Java exp) but what is the point of this If condition? Wouldn't starting the loop at 1 and running it until
size() - 1
have the same result? (Or if iterating in reverse has no side-effects, even starting at size() - 1 and running while its > 0)