Skip to content
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

Trigger OperationTracer on contexts enter & exit #5756

Merged
merged 24 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
65a428d
Trigger `OperationTracer` on contexts enter & exit
delehef Aug 7, 2023
b64e7fb
Update CHANGELOG.md
delehef Aug 7, 2023
776d24f
Spotless
delehef Aug 7, 2023
813118b
Daniel's comments
delehef Aug 9, 2023
ca9d725
Ensure `OperationTracer` is not null before calling it
delehef Aug 9, 2023
848165c
Move back hook calls into `process`
delehef Aug 10, 2023
41c75f0
Fix @shemnon comments
delehef Aug 10, 2023
3d8f3df
Merge branch 'main' into feat/issue-5728/trace-context-changes
daniellehrner Aug 21, 2023
7d466bb
added test for context enter and context exit
daniellehrner Aug 21, 2023
21edd27
spotless
daniellehrner Aug 21, 2023
836907c
Trigger `OperationTracer` on contexts enter & exit
delehef Aug 7, 2023
01f5d56
Update CHANGELOG.md
delehef Aug 7, 2023
86e2cc1
Spotless
delehef Aug 7, 2023
b9837f8
Daniel's comments
delehef Aug 9, 2023
a8029fa
Ensure `OperationTracer` is not null before calling it
delehef Aug 9, 2023
bc073d4
Move back hook calls into `process`
delehef Aug 10, 2023
b5c206a
Fix @shemnon comments
delehef Aug 10, 2023
208cd34
added test for context enter and context exit
daniellehrner Aug 21, 2023
106f2fd
spotless
daniellehrner Aug 21, 2023
277ba8b
added a test without mocking
daniellehrner Aug 23, 2023
f7e0255
Merge branch 'feat/issue-5728/trace-context-changes' of github.com:da…
daniellehrner Aug 23, 2023
764bf5d
Merge branch 'main' into feat/issue-5728/trace-context-changes
daniellehrner Aug 23, 2023
3481bd8
fixed unit tests
daniellehrner Aug 23, 2023
5303abb
Merge branch 'main' into feat/issue-5728/trace-context-changes
macfarla Aug 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Add ABI-decoded revert reason to `eth_call` and `eth_estimateGas` responses [#5705](https://github.com/hyperledger/besu/issues/5705)

### Additions and Improvements
- Add new methods to `OperationTracer` to capture contexts enter/exit [#5756](https://github.com/hyperledger/besu/pull/5756)

### Bug Fixes
- Make smart contract permissioning features work with london fork [#5727](https://github.com/hyperledger/besu/pull/5727)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@
* </tr>
* <tr>
* <td>{@link MessageFrame.State#COMPLETED_FAILED}</td>
* <td>{@link AbstractMessageProcessor#completedFailed(MessageFrame)}</td>
* <td>{@link AbstractMessageProcessor#completedFailed(MessageFrame, OperationTracer)}</td>
* <tr>
* <td>{@link MessageFrame.State#COMPLETED_SUCCESS}</td>
* <td>{@link AbstractMessageProcessor#completedSuccess(MessageFrame)}</td>
* <td>{@link AbstractMessageProcessor#completedSuccess(MessageFrame, OperationTracer)}</td>
* </tr>
* </table>
*/
Expand Down Expand Up @@ -124,7 +124,10 @@ private void clearAccumulatedStateBesidesGasAndOutput(final MessageFrame frame)
*
* @param frame The message frame
*/
private void exceptionalHalt(final MessageFrame frame) {
private void exceptionalHalt(final MessageFrame frame, final OperationTracer operationTracer) {
if (operationTracer != null) {
operationTracer.traceContextExit(frame);
}
delehef marked this conversation as resolved.
Show resolved Hide resolved
clearAccumulatedStateBesidesGasAndOutput(frame);
frame.clearGasRemaining();
frame.clearOutputData();
Expand All @@ -136,7 +139,10 @@ private void exceptionalHalt(final MessageFrame frame) {
*
* @param frame The message frame
*/
protected void revert(final MessageFrame frame) {
protected void revert(final MessageFrame frame, final OperationTracer operationTracer) {
if (operationTracer != null) {
operationTracer.traceContextExit(frame);
}
delehef marked this conversation as resolved.
Show resolved Hide resolved
clearAccumulatedStateBesidesGasAndOutput(frame);
frame.setState(MessageFrame.State.COMPLETED_FAILED);
}
Expand All @@ -146,7 +152,10 @@ protected void revert(final MessageFrame frame) {
*
* @param frame The message frame
*/
private void completedSuccess(final MessageFrame frame) {
private void completedSuccess(final MessageFrame frame, final OperationTracer operationTracer) {
if (operationTracer != null) {
delehef marked this conversation as resolved.
Show resolved Hide resolved
operationTracer.traceContextExit(frame);
}
frame.getWorldUpdater().commit();
frame.commitTransientStorage();
frame.getMessageFrameStack().removeFirst();
Expand All @@ -158,7 +167,10 @@ private void completedSuccess(final MessageFrame frame) {
*
* @param frame The message frame
*/
private void completedFailed(final MessageFrame frame) {
private void completedFailed(final MessageFrame frame, final OperationTracer operationTracer) {
if (operationTracer != null) {
daniellehrner marked this conversation as resolved.
Show resolved Hide resolved
operationTracer.traceContextExit(frame);
}
frame.getMessageFrameStack().removeFirst();
frame.notifyCompletion();
}
Expand All @@ -184,6 +196,10 @@ private void codeExecute(final MessageFrame frame, final OperationTracer operati
* @param operationTracer the operation tracer
*/
public void process(final MessageFrame frame, final OperationTracer operationTracer) {
if (operationTracer != null) {
operationTracer.traceContextEnter(frame);
}

if (frame.getState() == MessageFrame.State.NOT_STARTED) {
start(frame, operationTracer);
}
Expand All @@ -192,6 +208,9 @@ public void process(final MessageFrame frame, final OperationTracer operationTra
codeExecute(frame, operationTracer);

if (frame.getState() == MessageFrame.State.CODE_SUSPENDED) {
if (operationTracer != null) {
delehef marked this conversation as resolved.
Show resolved Hide resolved
operationTracer.traceContextExit(frame);
}
return;
}

Expand All @@ -201,19 +220,19 @@ public void process(final MessageFrame frame, final OperationTracer operationTra
}

if (frame.getState() == MessageFrame.State.EXCEPTIONAL_HALT) {
exceptionalHalt(frame);
exceptionalHalt(frame, operationTracer);
}

if (frame.getState() == MessageFrame.State.REVERT) {
revert(frame);
revert(frame, operationTracer);
}

if (frame.getState() == MessageFrame.State.COMPLETED_SUCCESS) {
completedSuccess(frame);
completedSuccess(frame, operationTracer);
}

if (frame.getState() == MessageFrame.State.COMPLETED_FAILED) {
completedFailed(frame);
completedFailed(frame, operationTracer);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ default void traceStartTransaction(final Transaction transaction) {}
*/
default void traceEndTransaction(final Bytes output, final long gasUsed, final long timeNs) {}

/**
* Trace the entering of a new context
*
* @param frame the frame
*/
default void traceContextEnter(@SuppressWarnings("unused") final MessageFrame frame) {}
Fixed Show fixed Hide fixed

/**
* Trace the exiting of a context
*
* @param frame the frame
*/
default void traceContextExit(@SuppressWarnings("unused") final MessageFrame frame) {}
Fixed Show fixed Hide fixed

/**
* Returns a boolean indicating whether extended tracing is enabled.
*
Expand Down