Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

[trace] introduce trace failed to Ext #11019

Merged
merged 6 commits into from
Sep 5, 2019
Merged

Conversation

ordian
Copy link
Collaborator

@ordian ordian commented Sep 3, 2019

When a subcall fails, we need to clean up the tracing data (last_mem_written, last_store_written) in the ExecutiveVMTracer. Also to properly track subcalls, we maintain a stack of tracing data.

One approach of doing that is to pass mem_written directly to trace_executed. It does introduce a perf regression.

This PR adds a method trace_failed to Ext, which is called when the execution of an instruction has failed. An alternative suggested by @tomusdrw would be to merge trace_failed into trace_executed by passing a Result<(stack_push: &[U256], mem: &[u8]), ()>, but I'm not sure if is any better.

@ordian ordian added A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. B1-patch-beta 🕷🕷 M4-core ⛓ Core client code / Rust. B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. labels Sep 3, 2019
@ordian ordian added this to the 2.7 milestone Sep 3, 2019
Copy link
Collaborator

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

I was suggesting to merge the two methods to simplify assumptions for implementation (i.e. trace_executed is ALWAYS called after trace_prepare_execute). It would also deduplicate poping from the stack in the implementation of VMTracer.

But looks good anyway!

@@ -166,6 +166,9 @@ pub trait Ext {
/// Prepare to trace an operation. Passthrough for the VM trace.
fn trace_prepare_execute(&mut self, _pc: usize, _instruction: u8, _gas_cost: U256, _mem_written: Option<(usize, usize)>, _store_written: Option<(U256, U256)>) {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we improve the docs here and underline the fact that this call is ALWAYS followed by either trace_executed or trace_failed. and that the implementation is responsible to clean up in either/both of those methods.

@ordian ordian marked this pull request as ready for review September 4, 2019 13:33
@ordian ordian added A0-pleasereview 🤓 Pull request needs code review. and removed A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. labels Sep 4, 2019
Copy link
Collaborator

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

Why did you opt to remove the bounds checks here? For performance reasons? Unless it's a severe regression I think it'd be good to have.

@ordian
Copy link
Collaborator Author

ordian commented Sep 5, 2019

Why did you opt to remove the bounds checks here? For performance reasons? Unless it's a severe regression I think it'd be good to have.

If the bounds could still be incorrect, it would indicate another bug and a warning could easily be missed/ignored. But if we reach a consensus on that the checks should be added back, I don't mind.

@dvdplm
Copy link
Collaborator

dvdplm commented Sep 5, 2019

But if we reach a consensus on that the checks should be added back, I don't mind.

@tomusdrw thoughts? Better to crash?

@tomusdrw
Copy link
Collaborator

tomusdrw commented Sep 5, 2019

@dvdplm I'd rather bound the o and o+s with mem.len() to be safe. The bound checking and a warning was introducing a lot of noise.
To be fair I'd rather not crash and have potentially incorrect data in tracing.

@dvdplm
Copy link
Collaborator

dvdplm commented Sep 5, 2019

f818b23 lgtm

@dvdplm dvdplm merged commit 44c00b1 into master Sep 5, 2019
@ordian ordian deleted the ao-introduce-trace-failed branch September 5, 2019 14:18
dvdplm added a commit that referenced this pull request Sep 9, 2019
* master:
  fix: remove unused error-chain (#11028)
  fix: remove needless use of itertools (#11029)
  Convert `std::test` benchmarks to use Criterion (#10999)
  Fix block detail updating (#11015)
  [trace] introduce trace failed to Ext (#11019)
  cli: update usage and version headers (#10924)
  [private-tx] remove unused rand (#11024)
dvdplm added a commit that referenced this pull request Sep 10, 2019
…he-right-place

* master:
  cleanup json crate (#11027)
  [spec] add istanbul test spec (#11033)
  [json-spec] make blake2 pricing spec more readable (#11034)
  Add blake2_f precompile (#11017)
  Add new line after writing block to hex file. (#10984)
  fix: remove unused error-chain (#11028)
  fix: remove needless use of itertools (#11029)
  Convert `std::test` benchmarks to use Criterion (#10999)
  Fix block detail updating (#11015)
  [trace] introduce trace failed to Ext (#11019)
  cli: update usage and version headers (#10924)
  [private-tx] remove unused rand (#11024)
dvdplm pushed a commit that referenced this pull request Sep 11, 2019
* [trace] add trace_failed to Ext, manage stack of trace data

* [evm] call trace_failed only if self.do_trace

* [evm] add a comment about do_trace set to true

* [vm] improve the doc in trace_prepare_execute

* [trace] add the bounds check back
s3krit pushed a commit that referenced this pull request Sep 11, 2019
* [trace] add trace_failed to Ext, manage stack of trace data

* [evm] call trace_failed only if self.do_trace

* [evm] add a comment about do_trace set to true

* [vm] improve the doc in trace_prepare_execute

* [trace] add the bounds check back
s3krit added a commit that referenced this pull request Sep 11, 2019
s3krit pushed a commit that referenced this pull request Sep 11, 2019
* [trace] add trace_failed to Ext, manage stack of trace data

* [evm] call trace_failed only if self.do_trace

* [evm] add a comment about do_trace set to true

* [vm] improve the doc in trace_prepare_execute

* [trace] add the bounds check back
s3krit pushed a commit that referenced this pull request Sep 12, 2019
* [trace] add trace_failed to Ext, manage stack of trace data

* [evm] call trace_failed only if self.do_trace

* [evm] add a comment about do_trace set to true

* [vm] improve the doc in trace_prepare_execute

* [trace] add the bounds check back
This was referenced Sep 12, 2019
s3krit added a commit that referenced this pull request Sep 12, 2019
* add more tx tests (#11038)
* Fix parallel transactions race-condition (#10995)
* Add blake2_f precompile (#11017)
* [trace] introduce trace failed to Ext (#11019)
* Edit publish-onchain.sh to use https (#11016)
* Fix deadlock in network-devp2p (#11013)
* EIP 1108: Reduce alt_bn128 precompile gas costs (#11008)
* xDai chain support and nodes list update (#10989)
* EIP 2028: transaction gas lowered from 68 to 16 (#10987)
* EIP-1344 Add CHAINID op-code (#10983)
* manual publish jobs for releases, no changes for nightlies (#10977)
* [blooms-db] Fix benchmarks (#10974)
* Verify transaction against its block during import (#10954)
* Better error message for rpc gas price errors (#10931)
* Fix fork choice (#10837)
* Fix compilation on recent nightlies (#10991)
s3krit added a commit that referenced this pull request Sep 12, 2019
* add more tx tests (#11038)
* Fix parallel transactions race-condition (#10995)
* Add blake2_f precompile (#11017)
* [trace] introduce trace failed to Ext (#11019)
* Edit publish-onchain.sh to use https (#11016)
* Fix deadlock in network-devp2p (#11013)
* EIP 1108: Reduce alt_bn128 precompile gas costs (#11008)
* xDai chain support and nodes list update (#10989)
* EIP 2028: transaction gas lowered from 68 to 16 (#10987)
* EIP-1344 Add CHAINID op-code (#10983)
* manual publish jobs for releases, no changes for nightlies (#10977)
* [blooms-db] Fix benchmarks (#10974)
* Verify transaction against its block during import (#10954)
* Better error message for rpc gas price errors (#10931)
* tx-pool: accept local tx with higher gas price when pool full (#10901)
* Fix fork choice (#10837)
* Cleanup unused vm dependencies (#10787)
* Fix compilation on recent nightlies (#10991)
dvdplm added a commit that referenced this pull request Sep 13, 2019
* master: (70 commits)
  ethcore: remove `test-helper feat` from build (#11047)
  Include test-helpers from ethjson (#11045)
  [ethcore]: cleanup dependencies (#11043)
  add more tx tests (#11038)
  Fix parallel transactions race-condition (#10995)
  [ethcore]: make it compile without `test-helpers` feature (#11036)
  Benchmarks for block verification (#11035)
  Move snapshot related traits to their proper place (#11012)
  cleanup json crate (#11027)
  [spec] add istanbul test spec (#11033)
  [json-spec] make blake2 pricing spec more readable (#11034)
  Add blake2_f precompile (#11017)
  Add new line after writing block to hex file. (#10984)
  fix: remove unused error-chain (#11028)
  fix: remove needless use of itertools (#11029)
  Convert `std::test` benchmarks to use Criterion (#10999)
  Fix block detail updating (#11015)
  [trace] introduce trace failed to Ext (#11019)
  cli: update usage and version headers (#10924)
  [private-tx] remove unused rand (#11024)
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-pleasereview 🤓 Pull request needs code review. B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants