Skip to content

Commit ba68de5

Browse files
authored
Merge pull request #448 from subspace/fix-execute-block
Fix `execute_block` of cirrus-pallet-executive
2 parents 62bd312 + 87a0bee commit ba68de5

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

cumulus/client/cirrus-executor/src/bundle_processor.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,7 @@ where
213213
// TODO: handle the import result properly.
214214
match import_result {
215215
ImportResult::Imported(..) => {},
216-
ImportResult::AlreadyInChain => {
217-
panic!("Block already in chain {}: {:?}", header_number, header_hash);
218-
},
216+
ImportResult::AlreadyInChain => {},
219217
ImportResult::KnownBad => {
220218
panic!("Bad block {}: {:?}", header_number, header_hash);
221219
},

cumulus/client/cirrus-executor/src/tests.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ async fn test_executor_full_node_catching_up() {
4040

4141
// run cirrus dave (a secondary chain full node)
4242
let dave = cirrus_test_service::TestNodeBuilder::new(tokio_handle, Dave)
43-
.connect_to_parachain_node(&charlie)
4443
.connect_to_relay_chain_node(&alice)
4544
.build(Role::Full)
4645
.await;
@@ -86,7 +85,6 @@ async fn execution_proof_creation_and_verification_should_work() {
8685

8786
// run cirrus dave (a secondary chain full node)
8887
let dave = cirrus_test_service::TestNodeBuilder::new(tokio_handle, Dave)
89-
.connect_to_parachain_node(&charlie)
9088
.connect_to_relay_chain_node(&alice)
9189
.build(Role::Full)
9290
.await;
@@ -347,7 +345,6 @@ async fn invalid_execution_proof_should_not_work() {
347345

348346
// run cirrus dave (a secondary chain full node)
349347
let dave = cirrus_test_service::TestNodeBuilder::new(tokio_handle, Dave)
350-
.connect_to_parachain_node(&charlie)
351348
.connect_to_relay_chain_node(&alice)
352349
.build(Role::Full)
353350
.await;
@@ -613,8 +610,9 @@ async fn pallet_executor_unsigned_extrinsics_should_work() {
613610
};
614611

615612
assert_eq!(vec![tx1, tx2, tx3], ready_txs());
616-
alice_executor.wait_for_blocks(1).await;
617-
// The ready txs will be consumed and included in the next block.
613+
614+
// Wait for a few more blocks to ensure the ready txs can be consumed.
615+
alice_executor.wait_for_blocks(5).await;
618616
assert!(ready_txs().is_empty());
619617

620618
alice_executor.wait_for_blocks(4).await;
@@ -657,16 +655,19 @@ async fn pallet_executor_unsigned_extrinsics_should_work() {
657655
// )
658656
// );
659657

660-
alice_executor.wait_for_blocks(1).await;
658+
// Wait for a few more blocks to ensure the ready txs can be consumed.
659+
alice_executor.wait_for_blocks(5).await;
661660
assert!(ready_txs().is_empty());
662661
assert_eq!(HashSet::from([tx5, tx6, tx7]), future_txs());
662+
663663
let tx4 = create_and_send_submit_execution_receipt(4)
664664
.await
665665
.expect("Submit receipt successfully");
666666
// All future txs become ready once the required tx is ready.
667667
assert_eq!(vec![tx4, tx5, tx6, tx7], ready_txs());
668668
assert!(future_txs().is_empty());
669-
alice_executor.wait_for_blocks(1).await;
670-
// The ready txs will be consumed and included in the next block.
669+
670+
// Wait for a few more blocks to ensure the ready txs can be consumed.
671+
alice_executor.wait_for_blocks(5).await;
671672
assert!(ready_txs().is_empty());
672673
}

cumulus/pallets/executive/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,11 @@ impl<
328328
}
329329
});
330330

331+
// Note the storage root before finalizing the block so that the block imported during the
332+
// syncing processs produces the same storage root with the one processed based on
333+
// the primary block.
334+
Pallet::<ExecutiveConfig>::push_root(Self::storage_root());
335+
331336
// post-extrinsics book-keeping
332337
<frame_system::Pallet<System>>::note_finished_extrinsics();
333338

cumulus/test/service/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ async fn start_node_impl(
188188
subspace_test_runtime::RuntimeApi,
189189
subspace_test_client::TestExecutorDispatch,
190190
>(primary_chain_config.into(), false)
191-
.map_err(|_| sc_service::Error::Other("Failed to build a full subspace node".into()))?
191+
.map_err(|e| {
192+
sc_service::Error::Other(format!("Failed to build a full subspace node: {e}"))
193+
})?
192194
};
193195

194196
let client = params.client.clone();

0 commit comments

Comments
 (0)