|
56 | 56 | //! |
57 | 57 | //! [Computation section]: https://subspace.network/news/subspace-network-whitepaper |
58 | 58 | //! [`BlockBuilder`]: ../cirrus_block_builder/struct.BlockBuilder.html |
| 59 | +//! [`FraudProof`]: ../sp_executor/struct.FraudProof.html |
59 | 60 |
|
60 | 61 | #![feature(drain_filter)] |
61 | 62 |
|
@@ -85,7 +86,7 @@ use sp_consensus::{BlockStatus, SelectChain}; |
85 | 86 | use sp_consensus_slots::Slot; |
86 | 87 | use sp_core::traits::{CodeExecutor, SpawnEssentialNamed, SpawnNamed}; |
87 | 88 | use sp_executor::{ |
88 | | - Bundle, BundleEquivocationProof, ExecutionReceipt, ExecutorApi, ExecutorId, FraudProof, |
| 89 | + Bundle, BundleEquivocationProof, ExecutionReceipt, ExecutorApi, ExecutorId, |
89 | 90 | InvalidTransactionProof, OpaqueBundle, SignedBundle, SignedExecutionReceipt, |
90 | 91 | }; |
91 | 92 | use sp_keystore::SyncCryptoStorePtr; |
@@ -323,93 +324,6 @@ where |
323 | 324 | } |
324 | 325 | } |
325 | 326 |
|
326 | | - fn submit_bundle_equivocation_proof(&self, bundle_equivocation_proof: BundleEquivocationProof) { |
327 | | - let primary_chain_client = self.primary_chain_client.clone(); |
328 | | - // TODO: No backpressure |
329 | | - self.spawner.spawn_blocking( |
330 | | - "cirrus-submit-bundle-equivocation-proof", |
331 | | - None, |
332 | | - async move { |
333 | | - tracing::debug!( |
334 | | - target: LOG_TARGET, |
335 | | - "Submitting bundle equivocation proof in a background task..." |
336 | | - ); |
337 | | - if let Err(error) = primary_chain_client |
338 | | - .runtime_api() |
339 | | - .submit_bundle_equivocation_proof_unsigned( |
340 | | - &BlockId::Hash(primary_chain_client.info().best_hash), |
341 | | - bundle_equivocation_proof, |
342 | | - ) |
343 | | - { |
344 | | - tracing::error!( |
345 | | - target: LOG_TARGET, |
346 | | - error = ?error, |
347 | | - "Failed to submit bundle equivocation proof" |
348 | | - ); |
349 | | - } |
350 | | - } |
351 | | - .boxed(), |
352 | | - ); |
353 | | - } |
354 | | - |
355 | | - fn submit_fraud_proof(&self, fraud_proof: FraudProof) { |
356 | | - let primary_chain_client = self.primary_chain_client.clone(); |
357 | | - // TODO: No backpressure |
358 | | - self.spawner.spawn_blocking( |
359 | | - "cirrus-submit-fraud-proof", |
360 | | - None, |
361 | | - async move { |
362 | | - tracing::debug!( |
363 | | - target: LOG_TARGET, |
364 | | - "Submitting fraud proof in a background task..." |
365 | | - ); |
366 | | - if let Err(error) = primary_chain_client |
367 | | - .runtime_api() |
368 | | - .submit_fraud_proof_unsigned( |
369 | | - &BlockId::Hash(primary_chain_client.info().best_hash), |
370 | | - fraud_proof, |
371 | | - ) |
372 | | - { |
373 | | - tracing::error!( |
374 | | - target: LOG_TARGET, |
375 | | - error = ?error, |
376 | | - "Failed to submit fraud proof" |
377 | | - ); |
378 | | - } |
379 | | - } |
380 | | - .boxed(), |
381 | | - ); |
382 | | - } |
383 | | - |
384 | | - fn submit_invalid_transaction_proof(&self, invalid_transaction_proof: InvalidTransactionProof) { |
385 | | - let primary_chain_client = self.primary_chain_client.clone(); |
386 | | - // TODO: No backpressure |
387 | | - self.spawner.spawn_blocking( |
388 | | - "cirrus-submit-invalid-transaction-proof", |
389 | | - None, |
390 | | - async move { |
391 | | - tracing::debug!( |
392 | | - target: LOG_TARGET, |
393 | | - "Submitting invalid transaction proof in a background task..." |
394 | | - ); |
395 | | - if let Err(error) = primary_chain_client |
396 | | - .runtime_api() |
397 | | - .submit_invalid_transaction_proof_unsigned( |
398 | | - &BlockId::Hash(primary_chain_client.info().best_hash), |
399 | | - invalid_transaction_proof, |
400 | | - ) |
401 | | - { |
402 | | - tracing::error!( |
403 | | - target: LOG_TARGET, |
404 | | - error = ?error, |
405 | | - "Failed to submit invalid transaction proof" |
406 | | - ); |
407 | | - } |
408 | | - } |
409 | | - .boxed(), |
410 | | - ); |
411 | | - } |
412 | | - |
413 | 327 | /// The background is that a receipt received from the network points to a future block |
414 | 328 | /// from the local view, so we need to wait for the receipt for the block at the same |
415 | 329 | /// height to be produced locally in order to check the validity of the external receipt. |
@@ -581,7 +495,12 @@ where |
581 | 495 |
|
582 | 496 | // A bundle equivocation occurs. |
583 | 497 | if let Some(equivocation_proof) = check_equivocation(bundle) { |
584 | | - self.submit_bundle_equivocation_proof(equivocation_proof); |
| 498 | + self.primary_chain_client |
| 499 | + .runtime_api() |
| 500 | + .submit_bundle_equivocation_proof_unsigned( |
| 501 | + &BlockId::Hash(self.primary_chain_client.info().best_hash), |
| 502 | + equivocation_proof, |
| 503 | + )?; |
585 | 504 | return Err(GossipMessageError::BundleEquivocation); |
586 | 505 | } |
587 | 506 |
|
@@ -622,7 +541,12 @@ where |
622 | 541 | // if illegal => illegal tx proof |
623 | 542 | let invalid_transaction_proof = InvalidTransactionProof; |
624 | 543 |
|
625 | | - self.submit_invalid_transaction_proof(invalid_transaction_proof); |
| 544 | + self.primary_chain_client |
| 545 | + .runtime_api() |
| 546 | + .submit_invalid_transaction_proof_unsigned( |
| 547 | + &BlockId::Hash(self.primary_chain_client.info().best_hash), |
| 548 | + invalid_transaction_proof, |
| 549 | + )?; |
626 | 550 | } |
627 | 551 | } |
628 | 552 |
|
@@ -726,7 +650,12 @@ where |
726 | 650 | signed_receipt_hash, |
727 | 651 | )?; |
728 | 652 |
|
729 | | - self.submit_fraud_proof(fraud_proof); |
| 653 | + self.primary_chain_client |
| 654 | + .runtime_api() |
| 655 | + .submit_fraud_proof_unsigned( |
| 656 | + &BlockId::Hash(self.primary_chain_client.info().best_hash), |
| 657 | + fraud_proof, |
| 658 | + )?; |
730 | 659 |
|
731 | 660 | Ok(Action::Empty) |
732 | 661 | } else { |
|
0 commit comments