Skip to content

Commit 754c5ff

Browse files
committed
Merge remote-tracking branch 'origin/master' into na-remove-subxt-substrate-compat-feature
2 parents b9fe96f + 42e9de7 commit 754c5ff

File tree

15 files changed

+1004
-494
lines changed

15 files changed

+1004
-494
lines changed

Cargo.lock

Lines changed: 848 additions & 412 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ hyper-rustls = { version = "0.27.3", default-features = false, features = ["http
827827
hyper-util = { version = "0.1.5", default-features = false }
828828
impl-serde = { version = "0.5.0", default-features = false }
829829
impl-trait-for-tuples = { version = "0.2.2" }
830-
indexmap = { version = "2.0.0" }
830+
indexmap = { version = "2.7.1" }
831831
indicatif = { version = "0.17.7" }
832832
integer-sqrt = { version = "0.1.2" }
833833
ip_network = { version = "0.4.1" }
@@ -856,7 +856,7 @@ linked-hash-map = { version = "0.5.4" }
856856
linked_hash_set = { version = "0.1.4" }
857857
linregress = { version = "0.5.1" }
858858
lite-json = { version = "0.2.0", default-features = false }
859-
litep2p = { version = "0.9.0", features = ["websocket"] }
859+
litep2p = { version = "0.9.1", features = ["websocket"] }
860860
log = { version = "0.4.22", default-features = false }
861861
macro_magic = { version = "0.5.1" }
862862
maplit = { version = "1.0.2" }
@@ -1374,7 +1374,7 @@ tt-call = { version = "1.0.8" }
13741374
tuplex = { version = "0.1", default-features = false }
13751375
twox-hash = { version = "1.6.3", default-features = false }
13761376
unsigned-varint = { version = "0.7.2" }
1377-
url = { version = "2.4.0" }
1377+
url = { version = "2.5.4" }
13781378
void = { version = "1.0.2" }
13791379
w3f-bls = { version = "0.1.3", default-features = false }
13801380
wait-timeout = { version = "0.2" }

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,11 +2372,15 @@ impl_runtime_apis! {
23722372
{
23732373
use pallet_revive::tracing::trace;
23742374
let mut tracer = config.build(Revive::evm_gas_from_weight);
2375-
trace(&mut tracer, || {
2376-
Self::eth_transact(tx)
2377-
})?;
2378-
2379-
Ok(tracer.collect_traces().pop().expect("eth_transact succeeded, trace must exist, qed"))
2375+
let result = trace(&mut tracer, || Self::eth_transact(tx));
2376+
2377+
if let Some(trace) = tracer.collect_traces().pop() {
2378+
Ok(trace)
2379+
} else if let Err(err) = result {
2380+
Err(err)
2381+
} else {
2382+
Ok(Default::default())
2383+
}
23802384
}
23812385
}
23822386
}

prdoc/pr_7614.prdoc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
title: '[pallet-revive] tracing improvements'
2+
doc:
3+
- audience: Runtime Dev
4+
description: |-
5+
Various pallet-revive improvements
6+
7+
- add check for precompiles addresses,
8+
So we can easily identified which one are being called and not supported yet
9+
10+
- fixes debug_call for revert call
11+
If a call revert we still want to get the traces for that call, that matches geth behaviors, diff tests will be added to the test suite for this
12+
13+
- fixes traces for staticcall
14+
The call type was not always being reported properly.
15+
crates:
16+
- name: asset-hub-westend-runtime
17+
bump: minor
18+
- name: pallet-revive-eth-rpc
19+
bump: minor
20+
- name: pallet-revive
21+
bump: minor

prdoc/pr_7640.prdoc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
title: Bring the latest compatibility fixes via litep2p v0.9.1
2+
3+
doc:
4+
- audience: [Node Dev, Node Operator]
5+
description: |
6+
This release enhances compatibility between litep2p and libp2p by using the latest Yamux upstream version.
7+
Additionally, it includes various improvements and fixes to boost the stability and performance of the WebSocket stream and the multistream-select protocol.
8+
9+
crates:
10+
- name: sc-network
11+
bump: minor
12+
- name: cumulus-client-cli
13+
bump: minor
14+
- name: sc-network-types
15+
bump: minor
16+
- name: sc-transaction-pool-api
17+
bump: minor
18+
- name: sc-transaction-pool
19+
bump: minor
20+
- name: polkadot-statement-distribution
21+
bump: minor
22+
- name: polkadot-dispute-distribution
23+
bump: minor
24+
- name: cumulus-relay-chain-rpc-interface
25+
bump: minor

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3745,11 +3745,15 @@ impl_runtime_apis! {
37453745
{
37463746
use pallet_revive::tracing::trace;
37473747
let mut tracer = config.build(Revive::evm_gas_from_weight);
3748-
trace(&mut tracer, || {
3749-
Self::eth_transact(tx)
3750-
})?;
3751-
3752-
Ok(tracer.collect_traces().pop().expect("eth_transact succeeded, trace must exist, qed"))
3748+
let result = trace(&mut tracer, || Self::eth_transact(tx));
3749+
3750+
if let Some(trace) = tracer.collect_traces().pop() {
3751+
Ok(trace)
3752+
} else if let Err(err) = result {
3753+
Err(err)
3754+
} else {
3755+
Ok(Default::default())
3756+
}
37533757
}
37543758
}
37553759

substrate/client/network/src/litep2p/mod.rs

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ use crate::{
3939
},
4040
},
4141
peer_store::PeerStoreProvider,
42-
protocol,
4342
service::{
4443
metrics::{register_without_sources, MetricSources, Metrics, NotificationMetrics},
4544
out_events,
@@ -277,53 +276,6 @@ impl Litep2pNetworkBackend {
277276
};
278277
let config_builder = ConfigBuilder::new();
279278

280-
// The yamux buffer size limit is configured to be equal to the maximum frame size
281-
// of all protocols. 10 bytes are added to each limit for the length prefix that
282-
// is not included in the upper layer protocols limit but is still present in the
283-
// yamux buffer. These 10 bytes correspond to the maximum size required to encode
284-
// a variable-length-encoding 64bits number. In other words, we make the
285-
// assumption that no notification larger than 2^64 will ever be sent.
286-
let yamux_maximum_buffer_size = {
287-
let requests_max = config
288-
.request_response_protocols
289-
.iter()
290-
.map(|cfg| usize::try_from(cfg.max_request_size).unwrap_or(usize::MAX));
291-
let responses_max = config
292-
.request_response_protocols
293-
.iter()
294-
.map(|cfg| usize::try_from(cfg.max_response_size).unwrap_or(usize::MAX));
295-
let notifs_max = config
296-
.notification_protocols
297-
.iter()
298-
.map(|cfg| usize::try_from(cfg.max_notification_size()).unwrap_or(usize::MAX));
299-
300-
// A "default" max is added to cover all the other protocols: ping, identify,
301-
// kademlia, block announces, and transactions.
302-
let default_max = cmp::max(
303-
1024 * 1024,
304-
usize::try_from(protocol::BLOCK_ANNOUNCES_TRANSACTIONS_SUBSTREAM_SIZE)
305-
.unwrap_or(usize::MAX),
306-
);
307-
308-
iter::once(default_max)
309-
.chain(requests_max)
310-
.chain(responses_max)
311-
.chain(notifs_max)
312-
.max()
313-
.expect("iterator known to always yield at least one element; qed")
314-
.saturating_add(10)
315-
};
316-
317-
let yamux_config = {
318-
let mut yamux_config = litep2p::yamux::Config::default();
319-
// Enable proper flow-control: window updates are only sent when
320-
// buffered data has been consumed.
321-
yamux_config.set_window_update_mode(litep2p::yamux::WindowUpdateMode::OnRead);
322-
yamux_config.set_max_buffer_size(yamux_maximum_buffer_size);
323-
324-
yamux_config
325-
};
326-
327279
let (tcp, websocket): (Vec<Option<_>>, Vec<Option<_>>) = config
328280
.network_config
329281
.listen_addresses
@@ -372,13 +324,13 @@ impl Litep2pNetworkBackend {
372324
config_builder
373325
.with_websocket(WebSocketTransportConfig {
374326
listen_addresses: websocket.into_iter().flatten().map(Into::into).collect(),
375-
yamux_config: yamux_config.clone(),
327+
yamux_config: litep2p::yamux::Config::default(),
376328
nodelay: true,
377329
..Default::default()
378330
})
379331
.with_tcp(TcpTransportConfig {
380332
listen_addresses: tcp.into_iter().flatten().map(Into::into).collect(),
381-
yamux_config,
333+
yamux_config: litep2p::yamux::Config::default(),
382334
nodelay: true,
383335
..Default::default()
384336
})

substrate/client/network/src/protocol.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use crate::{
2222
protocol_controller::{self, SetId},
2323
service::{metrics::NotificationMetrics, traits::Direction},
2424
types::ProtocolName,
25-
MAX_RESPONSE_SIZE,
2625
};
2726

2827
use codec::Encode;
@@ -56,10 +55,6 @@ pub mod message;
5655
// Log target for this file.
5756
const LOG_TARGET: &str = "sub-libp2p";
5857

59-
/// Maximum size used for notifications in the block announce and transaction protocols.
60-
// Must be equal to `max(MAX_BLOCK_ANNOUNCE_SIZE, MAX_TRANSACTIONS_SIZE)`.
61-
pub(crate) const BLOCK_ANNOUNCES_TRANSACTIONS_SUBSTREAM_SIZE: u64 = MAX_RESPONSE_SIZE;
62-
6358
/// Identifier of the peerset for the block announces protocol.
6459
const HARDCODED_PEERSETS_SYNC: SetId = SetId::from(0);
6560

-304 KB
Binary file not shown.

substrate/frame/revive/src/evm/api/debug_rpc_types.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ pub struct CallTrace<Gas = U256> {
181181
#[serde(skip_serializing_if = "Vec::is_empty")]
182182
pub logs: Vec<CallLog>,
183183
/// Amount of value transferred.
184-
pub value: U256,
184+
#[serde(skip_serializing_if = "Option::is_none")]
185+
pub value: Option<U256>,
185186
/// Type of call.
186187
#[serde(rename = "type")]
187188
pub call_type: CallType,

substrate/frame/revive/src/evm/tracing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl<Gas: Default, GasMapper: Fn(Weight) -> Gas> Tracer for CallTracer<Gas, GasM
7070
self.traces.push(CallTrace {
7171
from,
7272
to,
73-
value,
73+
value: if is_read_only { None } else { Some(value) },
7474
call_type,
7575
input: input.to_vec().into(),
7676
gas: (self.gas_mapper)(gas_left),

substrate/frame/revive/src/exec.rs

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,13 @@ where
13731373
}
13741374
}
13751375

1376+
/// Determine if the given address is a precompile.
1377+
/// For now, we consider that all addresses between 0x1 and 0xff are reserved for precompiles.
1378+
fn is_precompile(address: &H160) -> bool {
1379+
let bytes = address.as_bytes();
1380+
bytes.starts_with(&[0u8; 19]) && bytes[19] != 0
1381+
}
1382+
13761383
impl<'a, T, E> Ext for Stack<'a, T, E>
13771384
where
13781385
T: Config,
@@ -1403,6 +1410,11 @@ where
14031410
*self.last_frame_output_mut() = Default::default();
14041411

14051412
let try_call = || {
1413+
if is_precompile(dest_addr) {
1414+
log::debug!(target: crate::LOG_TARGET, "Unsupported precompile address {dest_addr:?}");
1415+
return Err(Error::<T>::UnsupportedPrecompileAddress.into());
1416+
}
1417+
14061418
let dest = T::AddressMapper::to_account_id(dest_addr);
14071419
if !self.allows_reentry(&dest) {
14081420
return Err(<Error<T>>::ReentranceDenied.into());
@@ -1420,28 +1432,38 @@ where
14201432
CachedContract::Cached(contract) => Some(contract.clone()),
14211433
_ => None,
14221434
});
1435+
1436+
// Enable read-only access if requested; cannot disable it if already set.
1437+
let is_read_only = read_only || self.is_read_only();
1438+
14231439
if let Some(executable) = self.push_frame(
14241440
FrameArgs::Call { dest: dest.clone(), cached_info, delegated_call: None },
14251441
value,
14261442
gas_limit,
14271443
deposit_limit.saturated_into::<BalanceOf<T>>(),
1428-
// Enable read-only access if requested; cannot disable it if already set.
1429-
read_only || self.is_read_only(),
1444+
is_read_only,
14301445
)? {
14311446
self.run(executable, input_data)
14321447
} else {
1433-
let result = Self::transfer_from_origin(
1434-
&self.origin,
1435-
&Origin::from_account_id(self.account_id().clone()),
1436-
&dest,
1437-
value,
1438-
);
1448+
let result = if is_read_only && value.is_zero() {
1449+
Ok(Default::default())
1450+
} else if is_read_only {
1451+
Err(Error::<T>::StateChangeDenied.into())
1452+
} else {
1453+
Self::transfer_from_origin(
1454+
&self.origin,
1455+
&Origin::from_account_id(self.account_id().clone()),
1456+
&dest,
1457+
value,
1458+
)
1459+
};
1460+
14391461
if_tracing(|t| {
14401462
t.enter_child_span(
14411463
T::AddressMapper::to_address(self.account_id()),
14421464
T::AddressMapper::to_address(&dest),
14431465
false,
1444-
false,
1466+
is_read_only,
14451467
value,
14461468
&input_data,
14471469
Weight::zero(),

substrate/frame/revive/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,8 @@ pub mod pallet {
492492
InvalidGenericTransaction,
493493
/// The refcount of a code either over or underflowed.
494494
RefcountOverOrUnderflow,
495+
/// Unsupported precompile address
496+
UnsupportedPrecompileAddress,
495497
}
496498

497499
/// A reason for the pallet contracts placing a hold on funds.

substrate/frame/revive/src/test_utils/builder.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ builder!(
146146

147147
/// Build the instantiate call and unwrap the account id.
148148
pub fn build_and_unwrap_contract(self) -> Contract<T> {
149-
let addr = self.build().result.unwrap().addr;
149+
let result = self.build().result.unwrap();
150+
assert!(!result.result.did_revert(), "instantiation did revert");
151+
152+
let addr = result.addr;
150153
let account_id = T::AddressMapper::to_account_id(&addr);
151154
Contract{ account_id, addr }
152155
}

0 commit comments

Comments
 (0)