Skip to content

Commit d3baa2a

Browse files
committed
rm debug buffer
1 parent 6878ba1 commit d3baa2a

File tree

22 files changed

+42
-905
lines changed

22 files changed

+42
-905
lines changed

cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -953,11 +953,6 @@ parameter_types! {
953953
pub CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30);
954954
}
955955

956-
type EventRecord = frame_system::EventRecord<
957-
<Runtime as frame_system::Config>::RuntimeEvent,
958-
<Runtime as frame_system::Config>::Hash,
959-
>;
960-
961956
impl pallet_revive::Config for Runtime {
962957
type Time = Timestamp;
963958
type Currency = Balances;
@@ -2073,7 +2068,7 @@ impl_runtime_apis! {
20732068
}
20742069
}
20752070

2076-
impl pallet_revive::ReviveApi<Block, AccountId, Balance, Nonce, BlockNumber, EventRecord> for Runtime
2071+
impl pallet_revive::ReviveApi<Block, AccountId, Balance, Nonce, BlockNumber> for Runtime
20772072
{
20782073
fn balance(address: H160) -> U256 {
20792074
Revive::evm_balance(&address)
@@ -2108,7 +2103,7 @@ impl_runtime_apis! {
21082103
gas_limit: Option<Weight>,
21092104
storage_deposit_limit: Option<Balance>,
21102105
input_data: Vec<u8>,
2111-
) -> pallet_revive::ContractResult<pallet_revive::ExecReturnValue, Balance, EventRecord> {
2106+
) -> pallet_revive::ContractResult<pallet_revive::ExecReturnValue, Balance> {
21122107
let blockweights= <Runtime as frame_system::Config>::BlockWeights::get();
21132108
Revive::bare_call(
21142109
RuntimeOrigin::signed(origin),
@@ -2117,8 +2112,6 @@ impl_runtime_apis! {
21172112
gas_limit.unwrap_or(blockweights.max_block),
21182113
pallet_revive::DepositLimit::Balance(storage_deposit_limit.unwrap_or(u128::MAX)),
21192114
input_data,
2120-
pallet_revive::DebugInfo::UnsafeDebug,
2121-
pallet_revive::CollectEvents::UnsafeCollect,
21222115
)
21232116
}
21242117

@@ -2130,7 +2123,7 @@ impl_runtime_apis! {
21302123
code: pallet_revive::Code,
21312124
data: Vec<u8>,
21322125
salt: Option<[u8; 32]>,
2133-
) -> pallet_revive::ContractResult<pallet_revive::InstantiateReturnValue, Balance, EventRecord>
2126+
) -> pallet_revive::ContractResult<pallet_revive::InstantiateReturnValue, Balance>
21342127
{
21352128
let blockweights= <Runtime as frame_system::Config>::BlockWeights::get();
21362129
Revive::bare_instantiate(
@@ -2141,8 +2134,6 @@ impl_runtime_apis! {
21412134
code,
21422135
data,
21432136
salt,
2144-
pallet_revive::DebugInfo::UnsafeDebug,
2145-
pallet_revive::CollectEvents::UnsafeCollect,
21462137
)
21472138
}
21482139

substrate/bin/node/runtime/src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3212,7 +3212,7 @@ impl_runtime_apis! {
32123212
}
32133213
}
32143214

3215-
impl pallet_revive::ReviveApi<Block, AccountId, Balance, Nonce, BlockNumber, EventRecord> for Runtime
3215+
impl pallet_revive::ReviveApi<Block, AccountId, Balance, Nonce, BlockNumber> for Runtime
32163216
{
32173217
fn balance(address: H160) -> U256 {
32183218
Revive::evm_balance(&address)
@@ -3247,16 +3247,14 @@ impl_runtime_apis! {
32473247
gas_limit: Option<Weight>,
32483248
storage_deposit_limit: Option<Balance>,
32493249
input_data: Vec<u8>,
3250-
) -> pallet_revive::ContractResult<pallet_revive::ExecReturnValue, Balance, EventRecord> {
3250+
) -> pallet_revive::ContractResult<pallet_revive::ExecReturnValue, Balance> {
32513251
Revive::bare_call(
32523252
RuntimeOrigin::signed(origin),
32533253
dest,
32543254
value,
32553255
gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block),
32563256
pallet_revive::DepositLimit::Balance(storage_deposit_limit.unwrap_or(u128::MAX)),
32573257
input_data,
3258-
pallet_revive::DebugInfo::UnsafeDebug,
3259-
pallet_revive::CollectEvents::UnsafeCollect,
32603258
)
32613259
}
32623260

@@ -3268,7 +3266,7 @@ impl_runtime_apis! {
32683266
code: pallet_revive::Code,
32693267
data: Vec<u8>,
32703268
salt: Option<[u8; 32]>,
3271-
) -> pallet_revive::ContractResult<pallet_revive::InstantiateReturnValue, Balance, EventRecord>
3269+
) -> pallet_revive::ContractResult<pallet_revive::InstantiateReturnValue, Balance>
32723270
{
32733271
Revive::bare_instantiate(
32743272
RuntimeOrigin::signed(origin),
@@ -3278,8 +3276,6 @@ impl_runtime_apis! {
32783276
code,
32793277
data,
32803278
salt,
3281-
pallet_revive::DebugInfo::UnsafeDebug,
3282-
pallet_revive::CollectEvents::UnsafeCollect,
32833279
)
32843280
}
32853281

substrate/frame/revive/README.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,6 @@ This module executes PolkaVM smart contracts. These can potentially be written i
4949
RISC-V. For now, the only officially supported languages are Solidity (via [`revive`](https://github.com/xermicus/revive))
5050
and Rust (check the `fixtures` directory for Rust examples).
5151

52-
## Debugging
53-
54-
Contracts can emit messages to the client when called as RPC through the
55-
[`debug_message`](https://paritytech.github.io/substrate/master/pallet_revive/trait.SyscallDocs.html#tymethod.debug_message)
56-
API.
57-
58-
Those messages are gathered into an internal buffer and sent to the RPC client. It is up to the individual client if
59-
and how those messages are presented to the user.
60-
61-
This buffer is also printed as a debug message. In order to see these messages on the node console the log level for the
62-
`runtime::revive` target needs to be raised to at least the `debug` level. However, those messages are easy to
63-
overlook because of the noise generated by block production. A good starting point for observing them on the console is
64-
using this command line in the root directory of the Substrate repository:
65-
66-
```bash
67-
cargo run --release -- --dev -lerror,runtime::revive=debug
68-
```
69-
70-
This raises the log level of `runtime::revive` to `debug` and all other targets to `error` in order to prevent them
71-
from spamming the console.
72-
73-
`--dev`: Use a dev chain spec `--tmp`: Use temporary storage for chain data (the chain state is deleted on exit)
74-
7552
## Host function tracing
7653

7754
For contract authors, it can be a helpful debugging tool to see which host functions are called, with which arguments,

substrate/frame/revive/fixtures/contracts/debug_message_invalid_utf8.rs

Lines changed: 0 additions & 33 deletions
This file was deleted.

substrate/frame/revive/fixtures/contracts/debug_message_logging_disabled.rs

Lines changed: 0 additions & 33 deletions
This file was deleted.

substrate/frame/revive/fixtures/contracts/debug_message_works.rs

Lines changed: 0 additions & 33 deletions
This file was deleted.

substrate/frame/revive/proc-macro/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -510,12 +510,7 @@ fn expand_functions(def: &EnvDef) -> TokenStream2 {
510510
quote! {
511511
// wrap body in closure to make sure the tracing is always executed
512512
let result = (|| #body)();
513-
if ::log::log_enabled!(target: "runtime::revive::strace", ::log::Level::Trace) {
514-
use core::fmt::Write;
515-
let mut msg = alloc::string::String::default();
516-
let _ = core::write!(&mut msg, #trace_fmt_str, #( #trace_fmt_args, )* result);
517-
self.ext().append_debug_buffer(&msg);
518-
}
513+
::log::trace!(target: "runtime::revive::strace", #trace_fmt_str, #( #trace_fmt_args, )* result);
519514
result
520515
}
521516
};

substrate/frame/revive/src/benchmarking/call_builder.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::{
2222
storage::meter::Meter,
2323
transient_storage::MeterEntry,
2424
wasm::{PreparedCall, Runtime},
25-
BalanceOf, Config, DebugBuffer, Error, GasMeter, MomentOf, Origin, WasmBlob, Weight,
25+
BalanceOf, Config, Error, GasMeter, MomentOf, Origin, WasmBlob, Weight,
2626
};
2727
use alloc::{vec, vec::Vec};
2828
use frame_benchmarking::benchmarking;
@@ -38,7 +38,6 @@ pub struct CallSetup<T: Config> {
3838
gas_meter: GasMeter<T>,
3939
storage_meter: Meter<T>,
4040
value: BalanceOf<T>,
41-
debug_message: Option<DebugBuffer>,
4241
data: Vec<u8>,
4342
transient_storage_size: u32,
4443
}
@@ -91,7 +90,6 @@ where
9190
gas_meter: GasMeter::new(Weight::MAX),
9291
storage_meter,
9392
value: 0u32.into(),
94-
debug_message: None,
9593
data: vec![],
9694
transient_storage_size: 0,
9795
}
@@ -122,16 +120,6 @@ where
122120
self.transient_storage_size = size;
123121
}
124122

125-
/// Set the debug message.
126-
pub fn enable_debug_message(&mut self) {
127-
self.debug_message = Some(Default::default());
128-
}
129-
130-
/// Get the debug message.
131-
pub fn debug_message(&self) -> Option<DebugBuffer> {
132-
self.debug_message.clone()
133-
}
134-
135123
/// Get the call's input data.
136124
pub fn data(&self) -> Vec<u8> {
137125
self.data.clone()
@@ -150,7 +138,6 @@ where
150138
&mut self.gas_meter,
151139
&mut self.storage_meter,
152140
self.value,
153-
self.debug_message.as_mut(),
154141
);
155142
if self.transient_storage_size > 0 {
156143
Self::with_transient_storage(&mut ext.0, self.transient_storage_size).unwrap();

substrate/frame/revive/src/benchmarking/mod.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ where
107107
Code::Upload(module.code),
108108
data,
109109
salt,
110-
DebugInfo::Skip,
111-
CollectEvents::Skip,
112110
);
113111

114112
let address = outcome.result?.addr;
@@ -1047,32 +1045,6 @@ mod benchmarks {
10471045
);
10481046
}
10491047

1050-
// Benchmark debug_message call
1051-
// Whereas this function is used in RPC mode only, it still should be secured
1052-
// against an excessive use.
1053-
//
1054-
// i: size of input in bytes up to maximum allowed contract memory or maximum allowed debug
1055-
// buffer size, whichever is less.
1056-
#[benchmark]
1057-
fn seal_debug_message(
1058-
i: Linear<0, { (limits::code::BLOB_BYTES).min(limits::DEBUG_BUFFER_BYTES) }>,
1059-
) {
1060-
let mut setup = CallSetup::<T>::default();
1061-
setup.enable_debug_message();
1062-
let (mut ext, _) = setup.ext();
1063-
let mut runtime = crate::wasm::Runtime::<_, [u8]>::new(&mut ext, vec![]);
1064-
// Fill memory with printable ASCII bytes.
1065-
let mut memory = (0..i).zip((32..127).cycle()).map(|i| i.1).collect::<Vec<_>>();
1066-
1067-
let result;
1068-
#[block]
1069-
{
1070-
result = runtime.bench_debug_message(memory.as_mut_slice(), 0, i);
1071-
}
1072-
assert_ok!(result);
1073-
assert_eq!(setup.debug_message().unwrap().len() as u32, i);
1074-
}
1075-
10761048
#[benchmark(skip_meta, pov_mode = Measured)]
10771049
fn get_storage_empty() -> Result<(), BenchmarkError> {
10781050
let max_key_len = limits::STORAGE_KEY_BYTES;

0 commit comments

Comments
 (0)