Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
d3baa2a
rm debug buffer
pgherveou Jan 14, 2025
fd2c61d
!fixup d3baa2a09c601e3cd907bbb6d54ca71bf0a1af67
pgherveou Jan 14, 2025
2477f02
Add basic tracing support
pgherveou Jan 14, 2025
e07f355
fix kitchensink build
pgherveou Jan 14, 2025
b964051
fix rustdoc error
pgherveou Jan 15, 2025
a604fc2
JS stuffs
pgherveou Jan 14, 2025
6c4671a
Eth RPC updates
pgherveou Jan 14, 2025
4c98f33
Add unimplemented for now
pgherveou Jan 14, 2025
72c710c
update js stuff
pgherveou Jan 16, 2025
9e15ada
fix client impl
pgherveou Jan 16, 2025
ff92507
fix debug_rpc_types
pgherveou Jan 16, 2025
1c640b7
fix revive/src/lib
pgherveou Jan 16, 2025
58c0c7a
Merge branch 'master' into pg/add-tracing-support
pgherveou Jan 16, 2025
79868a3
Merge branch 'pg/add-tracing-support' into pg/add-tracing-support-2
pgherveou Jan 16, 2025
eb2219e
fixes
pgherveou Jan 16, 2025
ca3f378
fix merge conflict update misses
pgherveou Jan 16, 2025
3ca2726
fixes
pgherveou Jan 16, 2025
aa8a9af
Simplify
pgherveou Jan 16, 2025
3102f8a
no pub
pgherveou Jan 16, 2025
394bee9
Merge branch 'pg/add-tracing-support' into pg/add-tracing-support-2
pgherveou Jan 16, 2025
f8699c5
missing licences
pgherveou Jan 16, 2025
cfd1e0d
Merge branch 'pg/add-tracing-support' into pg/add-tracing-support-2
pgherveou Jan 16, 2025
839b986
Update serialization
pgherveou Jan 16, 2025
81b4458
Merge branch 'pg/add-tracing-support' into pg/add-tracing-support-2
pgherveou Jan 16, 2025
8a57e4b
fix nostd build
pgherveou Jan 16, 2025
0f5599d
Merge branch 'pg/add-tracing-support' into pg/add-tracing-support-2
pgherveou Jan 16, 2025
ba9ac59
fix zepter
pgherveou Jan 16, 2025
e15cc08
taplo fix
pgherveou Jan 16, 2025
266616f
fix naming
pgherveou Jan 16, 2025
ff7d0ec
Merge branch 'pg/add-tracing-support' into pg/add-tracing-support-2
pgherveou Jan 16, 2025
39fc72b
fixes
pgherveou Jan 16, 2025
49e78a3
left over
pgherveou Jan 16, 2025
143d939
missing traces for balance transfer
pgherveou Jan 16, 2025
8049343
Rename with_tracer -> if_tracer
pgherveou Jan 16, 2025
6cc112f
Address PR comments
pgherveou Jan 16, 2025
4d68032
fix test
pgherveou Jan 16, 2025
7d4000e
wip geth-diff
pgherveou Jan 17, 2025
9915c08
rm Debug config
pgherveou Jan 17, 2025
461db51
fix comments
pgherveou Jan 17, 2025
1a09c6b
Fix benchmark
pgherveou Jan 17, 2025
d7412f6
clippy
pgherveou Jan 17, 2025
322c41e
tweak generic bound
pgherveou Jan 17, 2025
d5b8391
Add tests to report gas usage
pgherveou Jan 17, 2025
6ca575c
fix type
pgherveou Jan 17, 2025
dae7966
left over
pgherveou Jan 16, 2025
45718b8
missing traces for balance transfer
pgherveou Jan 16, 2025
d53e89d
Rename with_tracer -> if_tracer
pgherveou Jan 16, 2025
6d213df
Address PR comments
pgherveou Jan 16, 2025
9f3037d
fix test
pgherveou Jan 16, 2025
4d549e3
rm Debug config
pgherveou Jan 17, 2025
168f2bf
fix comments
pgherveou Jan 17, 2025
8964ede
Fix benchmark
pgherveou Jan 17, 2025
a667194
clippy
pgherveou Jan 17, 2025
d2b182f
tweak generic bound
pgherveou Jan 17, 2025
43b7d92
Add tests to report gas usage
pgherveou Jan 17, 2025
9137870
rpc fixes
pgherveou Jan 17, 2025
419c968
fix type
pgherveou Jan 17, 2025
92132e7
fix def
pgherveou Jan 17, 2025
46c7ba9
update
pgherveou Jan 17, 2025
76e56b9
Add build from config
pgherveou Jan 17, 2025
a173be9
Merge branch 'pg/add-tracing-support' into pg/add-tracing-support-2
pgherveou Jan 17, 2025
175585c
fix
pgherveou Jan 17, 2025
aaa2335
fix imports
pgherveou Jan 17, 2025
aee720f
PR review
pgherveou Jan 17, 2025
787fb54
Update substrate/frame/revive/src/tracing.rs
pgherveou Jan 17, 2025
fade0a2
Merge branch 'pg/add-tracing-support' into pg/add-tracing-support-2
pgherveou Jan 17, 2025
996c01f
move that to next PR
pgherveou Jan 17, 2025
bc961cc
Merge branch 'master' into pg/add-tracing-support
pgherveou Jan 17, 2025
1749536
Merge branch 'pg/add-tracing-support' into pg/add-tracing-support-2
pgherveou Jan 17, 2025
48ff8e7
Update from pgherveou running command 'prdoc --audience runtime_dev -…
Jan 17, 2025
a8be8e0
review-bot upgrade (#7214)
mutantcornholio Jan 17, 2025
afa1e92
enable-deprecation-warning for old command bot (#7221)
mordamax Jan 17, 2025
241b1e1
added new proxy ParaRegistration to Westend (#6995)
SBalaguer Jan 17, 2025
87d7324
[pallet-revive] Add tracing support (1/3) (#7166)
pgherveou Jan 17, 2025
dd0b7d5
fix lint
pgherveou Jan 17, 2025
5e778f1
Merge branch 'master' into pg/add-tracing-support-2
pgherveou Jan 23, 2025
7a46af1
Fixes
pgherveou Feb 5, 2025
b527fc7
nit
pgherveou Feb 5, 2025
8ed5113
rm log
pgherveou Feb 5, 2025
e23b270
fix
pgherveou Feb 5, 2025
571aaaa
Update from pgherveou running command 'prdoc --audience runtime_dev -…
github-actions[bot] Feb 5, 2025
e692fdd
get rid of extra traits
pgherveou Feb 5, 2025
8f1e5e1
fix
pgherveou Feb 5, 2025
3eb3fec
update example api
pgherveou Feb 5, 2025
22421a2
Fix rpc
pgherveou Feb 5, 2025
cff3c5d
Update from pgherveou running command 'prdoc --audience runtime_dev -…
github-actions[bot] Feb 5, 2025
af848d5
Add assert
pgherveou Feb 5, 2025
462f643
wip
pgherveou Feb 6, 2025
60e21bf
fix
pgherveou Feb 6, 2025
08c21b5
rm eth-indexer
pgherveou Feb 6, 2025
9fa7698
fix
pgherveou Feb 6, 2025
af72b25
rm helper method
pgherveou Feb 6, 2025
cb54a9d
Update from pgherveou running command 'prdoc --audience runtime_dev -…
github-actions[bot] Feb 6, 2025
5e647f4
enable old block indexing
pgherveou Feb 6, 2025
d074f35
run migration in receipt_provider
pgherveou Feb 6, 2025
e4a4482
fix clippy, cleanup db
pgherveou Feb 6, 2025
289e3fd
fix tests
pgherveou Feb 6, 2025
a5a20d0
add skeleton
pgherveou Feb 6, 2025
7b2b40e
Merge branch 'master' into pg/fix-eth-fee-rpc
pgherveou Feb 6, 2025
8171f3e
fix
pgherveou Feb 6, 2025
3f11f2e
fixes
pgherveou Feb 7, 2025
bfb37f2
fix metadata
pgherveou Feb 7, 2025
729ce37
Merge branch 'pg/fix-eth-fee-rpc' into pg/fix-rpc-dead-lock
pgherveou Feb 7, 2025
646966d
Fixes
pgherveou Feb 7, 2025
1110ff7
Merge branch 'pg/fix-rpc-dead-lock' into pg/add-eth-get-logs
pgherveou Feb 7, 2025
bcdd5d5
fixes
pgherveou Feb 7, 2025
7598103
fix index
pgherveou Feb 7, 2025
00dca85
fix interface
pgherveou Feb 7, 2025
276cdd8
fix tests
pgherveou Feb 7, 2025
1f324a5
Merge branch 'master' into pg/fix-rpc-dead-lock
pgherveou Feb 7, 2025
3248fb9
fix some js files
pgherveou Feb 7, 2025
7e9ba43
Merge branch 'pg/fix-rpc-dead-lock' into pg/add-eth-get-logs
pgherveou Feb 7, 2025
39a6f6e
add js test
pgherveou Feb 7, 2025
d6477ca
Update from pgherveou running command 'prdoc --audience runtime_dev -…
github-actions[bot] Feb 7, 2025
12f3e7a
index by hash
pgherveou Feb 7, 2025
60f0641
make clippy happy
pgherveou Feb 7, 2025
7326670
Merge branch 'pg/add-eth-get-logs' into pg/add-tracing-support-2
pgherveou Feb 7, 2025
3e3e1b7
merge base
pgherveou Feb 7, 2025
5bbbd48
fix conflict
pgherveou Feb 7, 2025
f0a6f4b
fix
pgherveou Feb 7, 2025
7cf792f
fixes
pgherveou Feb 7, 2025
8728b28
Update substrate/frame/revive/rpc/src/block_info_provider.rs
pgherveou Feb 7, 2025
0c29859
Merge branch 'master' into pg/add-eth-get-logs
pgherveou Feb 7, 2025
e497c73
wip
pgherveou Feb 10, 2025
c6349ec
Update prdoc/pr_7506.prdoc
pgherveou Feb 10, 2025
b955a37
fix it
pgherveou Feb 10, 2025
f780ea7
fix westend
pgherveou Feb 10, 2025
63728a8
fix bad merge
pgherveou Feb 10, 2025
2bde7a2
wip prep tracing tests
pgherveou Feb 10, 2025
47d66e1
fix misc debugging log
pgherveou Feb 10, 2025
bec6d62
add test
pgherveou Feb 10, 2025
5824496
fix js stuff
pgherveou Feb 10, 2025
518ed26
Merge branch 'pg/add-eth-get-logs' into pg/add-tracing-support-2
pgherveou Feb 10, 2025
ba7e91d
fix up prdoc
pgherveou Feb 10, 2025
c662f1d
fix
pgherveou Feb 10, 2025
42aec25
fix comment
pgherveou Feb 10, 2025
18d5176
add missing licence
pgherveou Feb 10, 2025
2dcbeac
Merge branch 'master' into pg/add-tracing-support-2
pgherveou Feb 10, 2025
0434075
cargo clippy
pgherveou Feb 10, 2025
e347d57
fix links
pgherveou Feb 10, 2025
adad735
fix tests
pgherveou Feb 10, 2025
0bd3f0e
fix toml
pgherveou Feb 10, 2025
a76bbcd
missing licence
pgherveou Feb 10, 2025
d5a9303
add debug_traceCall
pgherveou Feb 11, 2025
012ac2d
add fixture
pgherveou Feb 11, 2025
b8fed26
add debug_trace_call
pgherveou Feb 11, 2025
51595b2
add westend impl
pgherveou Feb 11, 2025
8c083d8
add block pruning
pgherveou Feb 11, 2025
751e154
fix prdoc
pgherveou Feb 11, 2025
903e16b
fix sql prepare
pgherveou Feb 11, 2025
1c7fc7e
fix up geth-diff
pgherveou Feb 11, 2025
bf0b91d
prettier
pgherveou Feb 11, 2025
abe63f5
fix up solhint
pgherveou Feb 11, 2025
4fe2557
fmt
pgherveou Feb 11, 2025
ba656b3
rename fn
pgherveou Feb 11, 2025
5babf1f
fix test
pgherveou Feb 11, 2025
a705404
add removal tests
pgherveou Feb 11, 2025
405c853
fix test
pgherveou Feb 11, 2025
adcf28b
fix
pgherveou Feb 11, 2025
079514d
fix test
pgherveou Feb 11, 2025
4b58c92
fix spammer script
pgherveou Feb 11, 2025
c92b112
fmt cargo.toml
pgherveou Feb 11, 2025
513ef40
rm debug logs
pgherveou Feb 11, 2025
53e9e2e
do not hard code chain id
pgherveou Feb 11, 2025
18b9605
fix test
pgherveou Feb 11, 2025
4857a51
Merge branch 'master' into pg/add-tracing-support-2
pgherveou Feb 12, 2025
6e31b95
fix zepter
pgherveou Feb 12, 2025
c80f19c
fix taplo
pgherveou Feb 12, 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
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2307,6 +2307,67 @@ impl_runtime_apis! {
key
)
}

fn trace_block(
block: Block,
config: pallet_revive::evm::TracerConfig
) -> Vec<(u32, pallet_revive::evm::CallTrace)> {
use pallet_revive::tracing::trace;
let mut tracer = config.build(Revive::evm_gas_from_weight);
let mut traces = vec![];
let (header, extrinsics) = block.deconstruct();

Executive::initialize_block(&header);
for (index, ext) in extrinsics.into_iter().enumerate() {
trace(&mut tracer, || {
let _ = Executive::apply_extrinsic(ext);
});

if let Some(tx_trace) = tracer.collect_traces().pop() {
traces.push((index as u32, tx_trace));
}
}

traces
}

fn trace_tx(
block: Block,
tx_index: u32,
config: pallet_revive::evm::TracerConfig
) -> Option<pallet_revive::evm::CallTrace> {
use pallet_revive::tracing::trace;
let mut tracer = config.build(Revive::evm_gas_from_weight);
let (header, extrinsics) = block.deconstruct();

Executive::initialize_block(&header);
for (index, ext) in extrinsics.into_iter().enumerate() {
if index as u32 == tx_index {
trace(&mut tracer, || {
let _ = Executive::apply_extrinsic(ext);
});
break;
} else {
let _ = Executive::apply_extrinsic(ext);
}
}

tracer.collect_traces().pop()
}

fn trace_call(
tx: pallet_revive::evm::GenericTransaction,
config: pallet_revive::evm::TracerConfig)
-> Result<pallet_revive::evm::CallTrace, pallet_revive::EthTransactError>
{
use pallet_revive::tracing::trace;
let mut tracer = config.build(Revive::evm_gas_from_weight);
trace(&mut tracer, || {
Self::eth_transact(tx)
})?;

Ok(tracer.collect_traces().pop().expect("eth_transact succeeded, trace must exist, qed"))
}
}
}

Expand Down
16 changes: 16 additions & 0 deletions prdoc/pr_7167.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
title: '[pallet-revive] Add tracing support (2/2)'
doc:
- audience: Runtime Dev
description: |-
- Add debug endpoint to eth-rpc for capturing a block or a single transaction traces
- Use in-memory DB for non-archive node

See:
- PR #7166
crates:
- name: pallet-revive-eth-rpc
bump: minor
- name: pallet-revive
bump: minor
- name: asset-hub-westend-runtime
bump: minor
61 changes: 61 additions & 0 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3406,6 +3406,67 @@ impl_runtime_apis! {
key
)
}

fn trace_block(
block: Block,
config: pallet_revive::evm::TracerConfig
) -> Vec<(u32, pallet_revive::evm::CallTrace)> {
use pallet_revive::tracing::trace;
let mut tracer = config.build(Revive::evm_gas_from_weight);
let mut traces = vec![];
let (header, extrinsics) = block.deconstruct();

Executive::initialize_block(&header);
for (index, ext) in extrinsics.into_iter().enumerate() {
trace(&mut tracer, || {
let _ = Executive::apply_extrinsic(ext);
});

if let Some(tx_trace) = tracer.collect_traces().pop() {
traces.push((index as u32, tx_trace));
}
}

traces
}

fn trace_tx(
block: Block,
tx_index: u32,
config: pallet_revive::evm::TracerConfig
) -> Option<pallet_revive::evm::CallTrace> {
use pallet_revive::tracing::trace;
let mut tracer = config.build(Revive::evm_gas_from_weight);
let (header, extrinsics) = block.deconstruct();

Executive::initialize_block(&header);
for (index, ext) in extrinsics.into_iter().enumerate() {
if index as u32 == tx_index {
trace(&mut tracer, || {
let _ = Executive::apply_extrinsic(ext);
});
break;
} else {
let _ = Executive::apply_extrinsic(ext);
}
}

tracer.collect_traces().pop()
}

fn trace_call(
tx: pallet_revive::evm::GenericTransaction,
config: pallet_revive::evm::TracerConfig)
-> Result<pallet_revive::evm::CallTrace, pallet_revive::EthTransactError>
{
use pallet_revive::tracing::trace;
let mut tracer = config.build(Revive::evm_gas_from_weight);
trace(&mut tracer, || {
Self::eth_transact(tx)
})?;

Ok(tracer.collect_traces().pop().expect("eth_transact succeeded, trace must exist, qed"))
}
}

impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/revive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ workspace = true
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
alloy-core = { workspace = true, features = ["sol-types"] }
codec = { features = ["derive", "max-encoded-len"], workspace = true }
derive_more = { workspace = true }
environmental = { workspace = true }
Expand Down Expand Up @@ -77,6 +78,7 @@ xcm-builder = { workspace = true, default-features = true }
[features]
default = ["std"]
std = [
"alloy-core/std",
"codec/std",
"environmental/std",
"ethabi/std",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion substrate/frame/revive/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ path = "examples/rust/remark-extrinsic.rs"
anyhow = { workspace = true }
clap = { workspace = true, features = ["derive", "env"] }
codec = { workspace = true, features = ["derive"] }
ethabi = { version = "18.0.0" }
futures = { workspace = true, features = ["thread-pool"] }
hex = { workspace = true }
jsonrpsee = { workspace = true, features = ["full"] }
Expand All @@ -57,6 +56,7 @@ sc-service = { workspace = true, default-features = true }
sp-arithmetic = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
sp-crypto-hashing = { workspace = true }
sp-runtime = { workspace = true, default-features = true }
sp-weights = { workspace = true, default-features = true }
sqlx = { version = "0.8.2", features = ["macros", "runtime-tokio", "sqlite"] }
subxt = { workspace = true, default-features = true, features = [
Expand All @@ -70,6 +70,7 @@ tokio = { workspace = true, features = ["full"] }

[dev-dependencies]
env_logger = { workspace = true }
ethabi = { version = "18.0.0" }
pretty_assertions = { workspace = true }
static_init = { workspace = true }
substrate-cli-test-utils = { workspace = true }
Expand Down
9 changes: 9 additions & 0 deletions substrate/frame/revive/rpc/examples/js/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "solhint:recommended",
"rules": {
"compiler-version": ["error", "^0.8.0"],
"gas-custom-errors": "off",
"one-contract-per-file": "off",
"no-empty-blocks": "off"
}
}
Binary file modified substrate/frame/revive/rpc/examples/js/bun.lockb
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract FlipperCaller {
address public flipperAddress;

// Constructor to initialize Flipper's address
constructor(address _flipperAddress) {
constructor(address _flipperAddress) public {
flipperAddress = _flipperAddress;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ contract PiggyBank {
uint256 private balance;
address public owner;

constructor() {
constructor() public {
owner = msg.sender;
balance = 0;
}
Expand All @@ -21,7 +21,7 @@ contract PiggyBank {
}

function withdraw(uint256 withdrawAmount) public returns (uint256 remainingBal) {
require(msg.sender == owner);
require(msg.sender == owner, "You are not the owner");
balance -= withdrawAmount;
(bool success, ) = payable(msg.sender).call{value: withdrawAmount}("");
require(success, "Transfer failed");
Expand Down
52 changes: 52 additions & 0 deletions substrate/frame/revive/rpc/examples/js/contracts/Tracing.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract TracingCaller {
event TraceEvent(uint256 value, string message);
address payable public callee;

constructor(address payable _callee) public payable {
require(_callee != address(0), "Callee address cannot be zero");
callee = _callee;
}

function start(uint256 counter) external {
if (counter == 0) {
return;
}

uint256 paymentAmount = 0.01 ether;
callee.transfer(paymentAmount);

emit TraceEvent(counter, "before");
TracingCallee(callee).consumeGas(counter);
emit TraceEvent(counter, "after");

try TracingCallee(callee).failingFunction{value: paymentAmount}() {
} catch {
}

this.start(counter - 1);
}
}

contract TracingCallee {
event CalleeCalled(uint256 counter);

function consumeGas(uint256 counter) external {
// burn some gas
for (uint256 i = 0; i < 10; i++) {
uint256(keccak256(abi.encodePacked(i)));
}

emit CalleeCalled(counter);
}

function failingFunction() external payable {
require(false, "This function always fails");
}

// Enable contract to receive Ether
receive() external payable {}
}

4 changes: 3 additions & 1 deletion substrate/frame/revive/rpc/examples/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"prettier": "prettier --write ."
"prettier": "prettier --write .",
"solhint": "solhint \"contracts/**/*.sol\""
},
"dependencies": {
"@parity/revive": "^0.0.9",
"ethers": "^6.13.5",
"solc": "^0.8.28",
"solhint": "^5.0.5",
"viem": "^2.22.4"
},
"devDependencies": {
Expand Down
Loading
Loading