Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

rpc/chainHead: Fix pruned blocks events from forks #13379

Merged
merged 39 commits into from
Mar 7, 2023
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ec1b613
rpc/chainhead: Test unpin for noncanonical prunned blocks
lexnv Feb 8, 2023
1236d59
rpc/tests: Ensure fork is not reported by the Finalized event
lexnv Feb 13, 2023
477029f
rpc/chainhead: Detect pruned forks to ignore from events
lexnv Feb 13, 2023
e3531a1
rpc/tests: Check unpin can be called on pruned hashes
lexnv Feb 13, 2023
5288cd9
Fix clippy
lexnv Feb 13, 2023
904840d
rpc/chain_head: Handle race with memory blocks and notifications
lexnv Feb 16, 2023
8dddb1e
rpc/chain_head: Add data config for the `follow` future
lexnv Feb 16, 2023
b9e8f6f
rpc/chain_head: Address feedback
lexnv Feb 16, 2023
a796034
rpc/chain_head: Move best block cache on the data config
lexnv Feb 16, 2023
1d0b4d2
rpc/chain_head: Send new events from the finalized stream
lexnv Feb 16, 2023
3bb66e4
rpc/chian_head: Report all pruned blocks
lexnv Feb 16, 2023
3847c74
rpc/chain_head: Move `chainHead_follow` logic on dedicated file
lexnv Feb 17, 2023
64876fa
rpc/chain_head: Delegate follow logic to `chain_head_follow`
lexnv Feb 17, 2023
f84c4ce
rpc/chain_head: Remove subscriptions on drop
lexnv Feb 17, 2023
908d1f2
rpc/tests: Ignore pruned blocks for a longer fork
lexnv Feb 17, 2023
01e98b0
rpc/tests: Check all pruned blocks are reported, not just stale heads
lexnv Feb 17, 2023
33f5f10
Merge remote-tracking branch 'origin/master' into lexnv/chainhead_pru…
lexnv Feb 17, 2023
eceeb92
rpc/tests: Remove println debug and fix indentation
lexnv Feb 17, 2023
b05f5fc
rpc/chain_head: Remove unnecessary trait bounds
lexnv Feb 17, 2023
425d6e7
rpc/chain_head: Add debug log for pruned forks
lexnv Feb 17, 2023
002acba
Revert "rpc/chain_head: Add debug log for pruned forks"
lexnv Feb 20, 2023
b585d8b
Merge remote-tracking branch 'origin/master' into lexnv/chainhead_pru…
lexnv Feb 21, 2023
04fbcff
Merge remote-tracking branch 'origin/master' into lexnv/chainhead_pru…
lexnv Feb 27, 2023
6a9c36e
Merge remote-tracking branch 'origin/master' into lexnv/chainhead_pru…
lexnv Feb 27, 2023
4140b5b
Adjust blockID for testing
lexnv Feb 27, 2023
aca8f3b
Update client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
lexnv Mar 1, 2023
6429e05
rpc/chain_head: Rename `ChainHeadFollow` to `ChainHeadFollower`
lexnv Mar 1, 2023
d3dd4a4
rpc/chain_head: Remove subscriptions manually
lexnv Mar 1, 2023
3786aa8
rpc/chain_head: Improve log messages by adding subID and errors
lexnv Mar 1, 2023
c24cdc6
rpc/chain_head: Ensure `follow` stops sending events on first error
lexnv Mar 1, 2023
bf85692
rpc/chain_head: Use default constructor
lexnv Mar 1, 2023
5ba5cd2
rpc/chain_head: Add `StartupPoint` structure
lexnv Mar 1, 2023
f0a40f0
rpc/chain_head: Rename `in_memory_blocks`
lexnv Mar 1, 2023
47853cb
rpc/chain_head: Fix comment typo
lexnv Mar 1, 2023
708aa0e
rpc/chain_head: Keep unique blocks and remove itertools
lexnv Mar 2, 2023
49245dc
rpc/chain_head: Make sure `bestBlocks` events are generated in order
lexnv Mar 2, 2023
095a39d
rpc/chain_head: Maintain order of reported blocks
lexnv Mar 2, 2023
ce35d02
rpc/chain_head: Parent of finalized block could be unpinned
lexnv Mar 2, 2023
08d2344
rpc/chain_head: Fix warning
lexnv Mar 2, 2023
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
Prev Previous commit
Next Next commit
rpc/tests: Ensure fork is not reported by the Finalized event
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
  • Loading branch information
lexnv committed Feb 13, 2023
commit 1236d5955b16c49688835f917e4a79f796a478e2
19 changes: 5 additions & 14 deletions client/rpc-spec-v2/src/chain_head/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,15 +1065,12 @@ async fn follow_unpin_pruned_block() {
})
.unwrap();
let block_3 = block_builder.build().unwrap().block;
let block_3_hash = block_3.header.hash();
client.import(BlockOrigin::Own, block_3.clone()).await.unwrap();

// Block 3 is not pruned, pruning happens at height (N - 1).
client.finalize_block(block_2_hash, None).unwrap();

let mut sub = api.subscribe("chainHead_unstable_follow", [false]).await.unwrap();
let sub_id = sub.subscription_id();
let sub_id = serde_json::to_string(&sub_id).unwrap();

// Initialized must always be reported first.
let event: FollowEvent<String> = get_next_event(&mut sub).await;
Expand All @@ -1085,10 +1082,10 @@ async fn follow_unpin_pruned_block() {
});
assert_eq!(event, expected);

// Block tree:
// Block tree:
//
// finalized -> block 1 -> block 2 -> block 4
// ^^^ finalized
// ^^^ finalized
// -> block 1 -> block 3
//
// Mark block 4 as finalized to force block 3 to get pruned.
Expand All @@ -1114,17 +1111,11 @@ async fn follow_unpin_pruned_block() {
});
assert_eq!(event, expected);

// Block 3 must be pruned.
// Block 3 must not be reported as pruned.
let event: FollowEvent<String> = get_next_event(&mut sub).await;
let expected = FollowEvent::Finalized(Finalized {
finalized_block_hashes: vec![
format!("{:?}", block_4_hash),
],
pruned_block_hashes: vec![format!("{:?}", block_3_hash),],
finalized_block_hashes: vec![format!("{:?}", block_4_hash)],
pruned_block_hashes: vec![],
});
assert_eq!(event, expected);

// Pruned hash can be unpinned.
let hash = format!("{:?}", block_3_hash);
let _res: () = api.call("chainHead_unstable_unpin", [&sub_id, &hash]).await.unwrap();
}