Skip to content

Commit

Permalink
fix: remove duplicated MoveBucketRequest event handling in both block…
Browse files Browse the repository at this point in the history
… import and finality notification
  • Loading branch information
snowmead committed Feb 25, 2025
1 parent 0af92c3 commit 0ed100f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 42 deletions.
29 changes: 0 additions & 29 deletions client/blockchain-service/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1401,35 +1401,6 @@ where
}
}
}
RuntimeEvent::FileSystem(
pallet_file_system::Event::MoveBucketRequested {
who: _,
bucket_id,
new_msp_id,
new_value_prop_id,
},
) => {
match self.provider_id {
// As a BSP, this node is interested in the event to allow the new MSP to request files from it.
Some(StorageProviderId::BackupStorageProvider(_)) => {
self.emit(MoveBucketRequested {
bucket_id,
new_msp_id,
});
}
// As an MSP, this node is interested in the event only if this node is the new MSP.
Some(StorageProviderId::MainStorageProvider(msp_id))
if msp_id == new_msp_id =>
{
self.emit(MoveBucketRequestedForMsp {
bucket_id,
value_prop_id: new_value_prop_id,
});
}
// Otherwise, ignore the event.
_ => {}
}
}
RuntimeEvent::FileSystem(
pallet_file_system::Event::MoveBucketRejected {
bucket_id,
Expand Down
25 changes: 12 additions & 13 deletions test/suites/integration/msp/move-bucket-reject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ describeMspNet(
throw new Error(`Expected ${source.length} NewStorageRequest events`);
}

await userApi.wait.bspVolunteerInTxPool();

// Wait for the MSP to receive and store all files by polling until they are all in storage
await waitFor({
lambda: async () => {
Expand Down Expand Up @@ -206,8 +208,11 @@ describeMspNet(
// also prioritise a fast response, so if the Forest Write Lock is available, it will send
// the first response it can immediately.
await userApi.wait.mspResponseInTxPool();
// This includes BSP volunteers
await userApi.block.seal();

await userApi.wait.bspStoredInTxPool();

// Wait for the MSP to update its local forest root by polling until it matches the on-chain root
await waitFor({
lambda: async () => {
Expand Down Expand Up @@ -358,14 +363,11 @@ describeMspNet(
await userApi.wait.waitForTxInPool({
module: "fileSystem",
method: "mspRespondMoveBucketRequest",
timeout: 45000 // Increased timeout to account for DB connection timeout
expectedEvent: "MoveBucketRejected",
timeout: 45000,
shouldSeal: true
});

const { events } = await userApi.block.seal();

// Verify that the move request was rejected
assertEventPresent(userApi, "fileSystem", "MoveBucketRejected", events);

// Resume postgres
await postgresContainer.unpause();

Expand Down Expand Up @@ -410,20 +412,17 @@ describeMspNet(
// Finalising the block in the BSP node as well, to trigger the reorg in the BSP node too.
const finalisedBlockHash = await userApi.rpc.chain.getFinalizedHead();

// Wait for BSP node to have imported the finalised block built by the user node.
// Wait for MSP2 node to have imported the finalised block built by the user node.
await msp2Api.wait.blockImported(finalisedBlockHash.toString());
await msp2Api.block.finaliseBlock(finalisedBlockHash.toString());

// Wait for the rejection response from MSP2
await userApi.wait.waitForTxInPool({
module: "fileSystem",
method: "mspRespondMoveBucketRequest"
method: "mspRespondMoveBucketRequest",
expectedEvent: "MoveBucketRejected",
shouldSeal: true
});

const { events } = await userApi.block.seal();

// Verify that the move request was rejected
assertEventPresent(userApi, "fileSystem", "MoveBucketRejected", events);
});
}
);

0 comments on commit 0ed100f

Please sign in to comment.