Cross-contract calling: simple debugger (#14678)

* Provide basic breakpoints

* Rename to Observer

* Rename feature. Single trait. Borrow-checker

* : frame_system::Config

* Confused type name

* Minor bugs

* pub trait

* No unnecessary cloning

* Make node compile with all features

* Move everything debug-related to a single module

* Add docs and implementation for ()

* fmt

* Make it feature-gated or for tests

* Prepare testing kit

* Testcase

* Fmt

* Use feature in dev-deps

* ?

* feature propagation

* AAAA

* lol, that doesn't make much sense to me

* Turn on

* clippy

* Remove self dep

* fmt, feature-gating test

* Noop to trigger CI

* idk

* add feature to pipeline

* Corrupt test to see if it is actually being run

* Revert change

* Doc for conf type

* Review

* Imports

* ...

* Remove debug for kitchen-sink

* Move test

* Fix imports

* I must have already tried this one...
This commit is contained in:
Piotr Mikołajczyk
2023-08-05 16:15:03 +02:00
committed by GitHub
parent 32bd1c397b
commit b24b66c991
9 changed files with 216 additions and 3 deletions
+13 -1
View File
@@ -15,6 +15,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#[cfg(feature = "unsafe-debug")]
use crate::unsafe_debug::ExecutionObserver;
use crate::{
gas::GasMeter,
storage::{self, DepositAccount, WriteOutcome},
@@ -344,7 +346,7 @@ pub trait Ext: sealing::Sealed {
}
/// Describes the different functions that can be exported by an [`Executable`].
#[derive(Clone, Copy, PartialEq)]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum ExportedFunction {
/// The constructor function which is executed on deployment of a contract.
Constructor,
@@ -904,11 +906,21 @@ where
// Every non delegate call or instantiate also optionally transfers the balance.
self.initial_transfer()?;
#[cfg(feature = "unsafe-debug")]
let (code_hash, input_clone) = {
let code_hash = *executable.code_hash();
T::Debug::before_call(&code_hash, entry_point, &input_data);
(code_hash, input_data.clone())
};
// Call into the Wasm blob.
let output = executable
.execute(self, &entry_point, input_data)
.map_err(|e| ExecError { error: e.error, origin: ErrorOrigin::Callee })?;
#[cfg(feature = "unsafe-debug")]
T::Debug::after_call(&code_hash, entry_point, input_clone, &output);
// Avoid useless work that would be reverted anyways.
if output.did_revert() {
return Ok(output)