Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f140228
add trace for selfdestruct
0xRVE Nov 7, 2025
b93cbce
added test for selfdestruct tracing
0xRVE Nov 7, 2025
d85a536
added trace to second terminate call
0xRVE Nov 7, 2025
2706afb
removed tracing from precompile selfdestruct
0xRVE Nov 7, 2025
0f68ed8
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] Nov 7, 2025
1b9f924
bump evm-test-suite hash
0xRVE Nov 8, 2025
30aaea9
bump evm-test-suite
0xRVE Nov 10, 2025
4c45b5a
try to fix cargo-check-all-crate-macos
0xRVE Nov 10, 2025
baacd33
Merge remote-tracking branch 'origin/master' into rve/selfdestruct-trace
0xRVE Nov 10, 2025
aae7a4c
fix ci
0xRVE Nov 10, 2025
73bc6cf
undo change in yml
0xRVE Nov 10, 2025
5ab8684
fixed call trace tests for evm, still need to fix prestate tests for …
0xRVE Nov 11, 2025
30e7bbf
cleanup
0xRVE Nov 11, 2025
7c8eecf
fixed tracing difference between geth and evm
0xRVE Nov 11, 2025
0f3a081
cleanup
0xRVE Nov 12, 2025
cb0c5ba
Merge branch 'master' into rve/selfdestruct-trace
pgherveou Nov 12, 2025
0f0665a
Fix prestate diff tracing
pgherveou Nov 12, 2025
21777c2
fix test
pgherveou Nov 12, 2025
97ddfc5
update test-evm
pgherveou Nov 12, 2025
e0abf6a
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] Nov 12, 2025
3e42645
Merge branch 'master' into pg/fix-prestate-tracing-2
pgherveou Nov 13, 2025
ad8211c
Merge remote-tracking branch 'origin/pg/fix-prestate-tracing-2' into …
0xRVE Nov 13, 2025
d666a2b
fied selfdestruct diff
0xRVE Nov 13, 2025
f5d5aa6
fixed the evm-test-suite tests
0xRVE Nov 13, 2025
93260cd
bump evm-test-suite
0xRVE Nov 13, 2025
96c4951
Merge remote-tracking branch 'origin/master' into rve/selfdestruct-trace
0xRVE Nov 13, 2025
68f5fcc
ci fix
0xRVE Nov 13, 2025
4148aa7
fixed evm-test-suite for pvm
0xRVE Nov 14, 2025
c8fb593
fix from review comments
0xRVE Nov 14, 2025
420daed
Merge remote-tracking branch 'origin/master' into rve/selfdestruct-trace
0xRVE Nov 14, 2025
849e43e
fixed unit test
0xRVE Nov 14, 2025
2a2800b
fix ci
0xRVE Nov 14, 2025
b493d24
fix ci
0xRVE Nov 15, 2025
9c04baa
empty commiy
0xRVE Nov 16, 2025
91564dc
review comment
0xRVE Nov 17, 2025
828332d
bump evm-test-suite
0xRVE Nov 17, 2025
44036bb
cleanup
0xRVE Nov 19, 2025
0f9909f
cleanup
0xRVE Nov 19, 2025
ef33aac
cleanup
0xRVE Nov 19, 2025
167477e
cleanup
0xRVE Nov 19, 2025
da1768d
Add test for both pretrace and calltrace tracers
pgherveou Nov 19, 2025
0fc69af
Apply suggestion from @pgherveou
pgherveou Nov 19, 2025
bac3ecf
update ref
pgherveou Nov 20, 2025
fe71977
update test-evm
pgherveou Nov 20, 2025
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
7 changes: 7 additions & 0 deletions prdoc/pr_10244.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: '[pallet-revive] add tracing for selfdestruct'
doc:
- audience: Runtime Dev
description: Add tracing for selfdestruct
crates:
- name: pallet-revive
bump: patch
2 changes: 2 additions & 0 deletions substrate/frame/revive/src/evm/api/debug_rpc_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ pub enum CallType {
Create,
/// A create2 call.
Create2,
/// A selfdestruct call.
Selfdestruct,
}

/// A Trace
Expand Down
10 changes: 10 additions & 0 deletions substrate/frame/revive/src/evm/tracing/call_tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ impl<Gas: Default, GasMapper: Fn(Weight) -> Gas> Tracing for CallTracer<Gas, Gas
self.code_with_salt = Some((code.clone(), salt.is_some()));
}

fn terminate(&mut self, from: H160, gas_left: Weight) {
self.traces.push(CallTrace {
from,
to: H160::zero(),
call_type: CallType::Selfdestruct,
gas: (self.gas_mapper)(gas_left),
..Default::default()
});
}

fn enter_child_span(
&mut self,
from: H160,
Expand Down
6 changes: 6 additions & 0 deletions substrate/frame/revive/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,12 @@ where
}

fn terminate_if_same_tx(&mut self, beneficiary: &H160) -> Result<CodeRemoved, DispatchError> {
if_tracing(|tracer| {
tracer.terminate(
self.caller().account_id().map(T::AddressMapper::to_address).unwrap_or_default(),
self.top_frame().nested_gas.gas_left(),
);
});
let (account_id, contract_address, contract_info) = {
let frame = self.top_frame_mut();
if frame.entry_point == ExportedFunction::Constructor {
Expand Down
32 changes: 32 additions & 0 deletions substrate/frame/revive/src/tests/pvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5165,3 +5165,35 @@ fn existential_deposit_shall_not_charged_twice() {
assert_eq!(get_balance(&callee_account), Contracts::min_balance());
});
}

#[test]
fn self_destruct_by_syscall_tracing_works() {
let (binary, _code_hash) = compile_module("self_destruct_by_syscall").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let _ = <Test as Config>::Currency::set_balance(&ALICE, 1_000_000);
let mut tracer = CallTracer::new(Default::default(), |_| U256::zero());

// Instantiate the BOB contract.
let Contract { addr, .. } = builder::bare_instantiate(Code::Upload(binary))
.native_value(100_000)
.build_and_unwrap_contract();

// Check that the BOB contract has been instantiated.
get_contract(&addr);

trace(&mut tracer, || {
builder::call(addr).build().unwrap();
});

let trace = tracer.collect_trace();
assert_eq!(
trace,
Some(CallTrace {
from: ALICE_ADDR,
to: H160::zero(),
call_type: CallType::Selfdestruct,
..Default::default()
})
);
});
}
3 changes: 3 additions & 0 deletions substrate/frame/revive/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ pub trait Tracing {
) {
}

/// Called when a contract calls terminates (selfdestructs)
fn terminate(&mut self, _from: H160, _gas_left: Weight) {}

/// Record the next code and salt to be instantiated.
fn instantiate_code(&mut self, _code: &Code, _salt: Option<&[u8; 32]>) {}

Expand Down
Loading