Skip to content

Commit 55c4363

Browse files
committed
chore(deps): bump subxt to v0.36.1
1 parent 508ef9b commit 55c4363

File tree

10 files changed

+200
-131
lines changed

10 files changed

+200
-131
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ tokio = { version = "1.36", features = ["macros", "rt-multi-thread", "sync", "si
2424
pin-project-lite = "0.2"
2525

2626
# subxt
27-
scale-value = "0.14.1"
28-
subxt = { version = "0.35.1", features = ["substrate-compat"] }
27+
scale-value = "0.16.0"
28+
subxt = { version = "0.36.1", features = ["substrate-compat"] }
2929

3030
# polkadot-sdk
3131
frame-election-provider-support = "31.0.0"

src/commands/emergency_solution.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use clap::Parser;
2323
use codec::Encode;
2424
use sp_core::hexdisplay::HexDisplay;
2525
use std::io::Write;
26-
use subxt::tx::TxPayload;
26+
use subxt::tx::Payload;
2727

2828
#[derive(Debug, Clone, Parser)]
2929
#[cfg_attr(test, derive(PartialEq))]
@@ -88,7 +88,9 @@ where
8888
}
8989

9090
let call = epm::set_emergency_result(supports.clone())?;
91-
let encoded_call = call.encode_call_data(&client.chain_api().metadata())?;
91+
let encoded_call = call
92+
.encode_call_data(&client.chain_api().metadata())
93+
.map_err(|e| Error::Subxt(e.into()))?;
9294
let encoded_supports = supports.encode();
9395

9496
// write results to files.

src/commands/monitor.rs

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl FromStr for SubmissionStrategy {
157157
let percent: u32 = percent.parse().map_err(|e| format!("{:?}", e))?;
158158
Self::ClaimBetterThan(Perbill::from_percent(percent))
159159
} else {
160-
return Err(s.into())
160+
return Err(s.into());
161161
};
162162
Ok(res)
163163
}
@@ -424,7 +424,7 @@ where
424424
e,
425425
at.number
426426
);
427-
return Err(e)
427+
return Err(e);
428428
},
429429
};
430430

@@ -487,7 +487,7 @@ where
487487

488488
if let Some(submission) = submission {
489489
if &submission.who == us {
490-
return Err(Error::AlreadySubmitted)
490+
return Err(Error::AlreadySubmitted);
491491
}
492492
}
493493
}
@@ -503,7 +503,7 @@ async fn ensure_solution_passes_strategy(
503503
) -> Result<(), Error> {
504504
// don't care about current scores.
505505
if matches!(strategy, SubmissionStrategy::Always) {
506-
return Ok(())
506+
return Ok(());
507507
}
508508

509509
let addr = runtime::storage().election_provider_multi_phase().signed_submission_indices();
@@ -533,19 +533,19 @@ async fn submit_and_watch_solution<T: MinerConfig + Send + Sync + 'static>(
533533
) -> Result<(), Error> {
534534
let tx = epm::signed_solution(RawSolution { solution, score, round })?;
535535

536-
// session == epoch
537-
let session_len = client
538-
.chain_api()
539-
.constants()
540-
.at(&runtime::constants().babe().epoch_duration())?;
541-
536+
// By default we are using the epoch length as the mortality length.
537+
// If that doesn't is available then we just use the default mortality provided by subxt.
538+
//
542539
// TODO: https://github.com/paritytech/polkadot-staking-miner/issues/730
543540
//
544541
// The extrinsic mortality length is static and it doesn't know when the signed phase ends.
545-
let xt_cfg = DefaultExtrinsicParamsBuilder::default()
546-
.nonce(nonce)
547-
.mortal(at, session_len)
548-
.build();
542+
let xt_cfg = if let Ok(len) =
543+
client.chain_api().constants().at(&runtime::constants().babe().epoch_duration())
544+
{
545+
DefaultExtrinsicParamsBuilder::default().nonce(nonce).mortal(at, len).build()
546+
} else {
547+
DefaultExtrinsicParamsBuilder::default().nonce(nonce).build()
548+
};
549549

550550
let xt = client.chain_api().tx().create_signed(&tx, &*signer, xt_cfg).await?;
551551

@@ -580,23 +580,25 @@ async fn submit_and_watch_solution<T: MinerConfig + Send + Sync + 'static>(
580580
return Err(Error::Other(format!(
581581
"No SolutionStored event found at {:?}",
582582
in_block.block_hash()
583-
)))
583+
)));
584584
}
585585
},
586586
Listen::Finalized => {
587-
let finalized = tx_progress.wait_for_finalized_success().await?;
587+
let finalized_block = tx_progress.wait_for_finalized().await?;
588+
let block_hash = finalized_block.block_hash();
589+
let finalized_success = finalized_block.wait_for_success().await?;
588590

589-
let solution_stored = finalized
591+
let solution_stored = finalized_success
590592
.find_first::<runtime::election_provider_multi_phase::events::SolutionStored>(
591593
);
592594

593595
if let Ok(Some(_)) = solution_stored {
594-
log::info!(target: LOG_TARGET, "Finalized at {:?}", finalized.block_hash());
596+
log::info!(target: LOG_TARGET, "Finalized at {:?}", block_hash);
595597
} else {
596598
return Err(Error::Other(format!(
597599
"No SolutionStored event found at {:?}",
598-
finalized.block_hash()
599-
)))
600+
block_hash,
601+
)));
600602
}
601603
},
602604
};
@@ -659,7 +661,7 @@ async fn dry_run_works(rpc: &RpcClient) -> Result<(), Error> {
659661
"dry-run requires a RPC endpoint with `--rpc-methods unsafe`; \
660662
either connect to another RPC endpoint or disable dry-run"
661663
.to_string(),
662-
))
664+
));
663665
}
664666
}
665667
}

src/epm.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ where
131131
let max_weight: Weight = T::MaxWeight::get();
132132

133133
if est_weight.all_lt(max_weight) {
134-
return Ok(Self { state: State { voters, voters_by_stake }, _marker: PhantomData })
134+
return Ok(Self { state: State { voters, voters_by_stake }, _marker: PhantomData });
135135
}
136136

137137
let Some((_, idx)) = voters_by_stake.pop_first() else { break };
@@ -146,7 +146,7 @@ where
146146
targets.remove(&rm);
147147
}
148148

149-
return Err(Error::Feasibility("Failed to pre-trim weight < T::MaxLength".to_string()))
149+
return Err(Error::Feasibility("Failed to pre-trim weight < T::MaxLength".to_string()));
150150
}
151151

152152
/// Clone the state and trim it, so it get can be reverted.
@@ -156,7 +156,7 @@ where
156156

157157
for _ in 0..n {
158158
let Some((_, idx)) = voters_by_stake.pop_first() else {
159-
return Err(Error::Feasibility("Failed to pre-trim len".to_string()))
159+
return Err(Error::Feasibility("Failed to pre-trim len".to_string()));
160160
};
161161
let rm = voters[idx].0.clone();
162162

@@ -222,7 +222,8 @@ fn read_constant<'a, T: serde::Deserialize<'a>>(
222222
.constants()
223223
.at(&subxt::dynamic::constant(epm_name, constant))
224224
.map_err(|e| invalid_metadata_error(constant.to_string(), e))?
225-
.to_value()?;
225+
.to_value()
226+
.map_err(|e| Error::Subxt(e.into()))?;
226227

227228
scale_value::serde::from_value::<_, T>(val).map_err(|e| {
228229
Error::InvalidMetadata(format!("Decoding `{}` failed {}", std::any::type_name::<T>(), e))
@@ -390,7 +391,7 @@ where
390391
solution,
391392
score,
392393
solution_or_snapshot_size,
393-
})
394+
});
394395
}
395396

396397
prometheus::on_trim_attempt();
@@ -513,7 +514,7 @@ fn to_scale_value<T: scale_info::TypeInfo + 'static + Encode>(val: T) -> Result<
513514

514515
let bytes = val.encode();
515516

516-
decode_as_type(&mut bytes.as_ref(), &ty_id, &types)
517+
decode_as_type(&mut bytes.as_ref(), ty_id, &types)
517518
.map(|v| v.remove_context())
518519
.map_err(|e| {
519520
Error::DynamicTransaction(format!(

src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub fn kill_main_task_if_critical_err(tx: &tokio::sync::mpsc::UnboundedSender<Er
101101
"Failed to downcast RPC error; this is a bug please file an issue"
102102
.to_string(),
103103
));
104-
return
104+
return;
105105
},
106106
};
107107

src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ async fn runtime_upgrade_task(client: ChainClient, tx: oneshot::Sender<Error>) {
214214
Ok(u) => u,
215215
Err(e) => {
216216
let _ = tx.send(e.into());
217-
return
217+
return;
218218
},
219219
};
220220

@@ -228,10 +228,10 @@ async fn runtime_upgrade_task(client: ChainClient, tx: oneshot::Sender<Error>) {
228228
Ok(u) => u,
229229
Err(e) => {
230230
let _ = tx.send(e.into());
231-
return
231+
return;
232232
},
233233
};
234-
continue
234+
continue;
235235
},
236236
};
237237

@@ -240,7 +240,7 @@ async fn runtime_upgrade_task(client: ChainClient, tx: oneshot::Sender<Error>) {
240240
Ok(()) => {
241241
if let Err(e) = epm::update_metadata_constants(&client) {
242242
let _ = tx.send(e);
243-
return
243+
return;
244244
}
245245
prometheus::on_runtime_upgrade();
246246
log::info!(target: LOG_TARGET, "upgrade to version: {} successful", version);

src/static_types.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub mod westend {
119119
active_voters,
120120
desired_targets.try_into().expect("Desired targets < u16::MAX"),
121121
) else {
122-
return Weight::MAX
122+
return Weight::MAX;
123123
};
124124

125125
// Mock a RawSolution to get the correct weight without having to do the heavy work.
@@ -131,7 +131,7 @@ pub mod westend {
131131
if raw.solution.voter_count() != active_voters as usize ||
132132
raw.solution.unique_targets().len() != desired_targets as usize
133133
{
134-
return Weight::MAX
134+
return Weight::MAX;
135135
}
136136

137137
futures::executor::block_on(epm::runtime_api_solution_weight(
@@ -177,7 +177,7 @@ pub mod polkadot {
177177
active_voters,
178178
desired_targets.try_into().expect("Desired targets < u16::MAX"),
179179
) else {
180-
return Weight::MAX
180+
return Weight::MAX;
181181
};
182182

183183
// Mock a RawSolution to get the correct weight without having to do the heavy work.
@@ -189,7 +189,7 @@ pub mod polkadot {
189189
if raw.solution.voter_count() != active_voters as usize ||
190190
raw.solution.unique_targets().len() != desired_targets as usize
191191
{
192-
return Weight::MAX
192+
return Weight::MAX;
193193
}
194194

195195
futures::executor::block_on(epm::runtime_api_solution_weight(
@@ -235,7 +235,7 @@ pub mod kusama {
235235
active_voters,
236236
desired_targets.try_into().expect("Desired targets < u16::MAX"),
237237
) else {
238-
return Weight::MAX
238+
return Weight::MAX;
239239
};
240240

241241
// Mock a RawSolution to get the correct weight without having to do the heavy work.
@@ -247,7 +247,7 @@ pub mod kusama {
247247
if raw.solution.voter_count() != active_voters as usize ||
248248
raw.solution.unique_targets().len() != desired_targets as usize
249249
{
250-
return Weight::MAX
250+
return Weight::MAX;
251251
}
252252

253253
futures::executor::block_on(epm::runtime_api_solution_weight(

tests/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ pub async fn wait_for_mined_solution(ws_url: &str) -> anyhow::Result<SolutionSto
194194

195195
while let Some(block) = blocks_sub.next().await {
196196
if now.elapsed() > MAX_DURATION_FOR_SUBMIT_SOLUTION {
197-
break
197+
break;
198198
}
199199

200200
let block = block?;
@@ -204,7 +204,7 @@ pub async fn wait_for_mined_solution(ws_url: &str) -> anyhow::Result<SolutionSto
204204
let ev = ev?;
205205

206206
if let Some(solution_ev) = ev.as_event::<SolutionStored>()? {
207-
return Ok(solution_ev)
207+
return Ok(solution_ev);
208208
}
209209
}
210210
}

tests/monitor.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,11 @@ async fn submit_monitor_works_basic() {
1818
// TODO: https://github.com/paritytech/staking-miner-v2/issues/673
1919
// test_submit_solution(Target::Node(Chain::Polkadot)).await;
2020
// test_submit_solution(Target::Node(Chain::Kusama)).await;
21-
// TODO: https://github.com/paritytech/polkadot-staking-miner/issues/806
22-
// test_submit_solution(Target::StakingMinerPlayground).await;
21+
test_submit_solution(Target::StakingMinerPlayground).await;
2322
test_submit_solution(Target::Node(Chain::Westend)).await;
2423
}
2524

26-
// TODO: https://github.com/paritytech/polkadot-staking-miner/issues/806
2725
#[tokio::test]
28-
#[ignore]
2926
async fn default_trimming_works() {
3027
init_logger();
3128
let (_drop, ws_url) = run_staking_miner_playground();
@@ -89,7 +86,7 @@ async fn has_trimming_output(miner: &mut KillChildOnDrop) -> bool {
8986
}
9087

9188
if now.elapsed() > MAX_DURATION_FOR_SUBMIT_SOLUTION {
92-
break
89+
break;
9390
}
9491
}
9592

0 commit comments

Comments
 (0)