Skip to content

Commit

Permalink
fix setting parentchain pallet block processed storage for all targets (
Browse files Browse the repository at this point in the history
#1616)

* fix by swallowing error

* slightly more elegant

* even more elegant
  • Loading branch information
brenzi authored Oct 16, 2024
1 parent 039a3e4 commit 4ecbc8b
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions core-primitives/stf-executor/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use itp_stf_interface::{
parentchain_pallet::ParentchainPalletInstancesInterface, StateCallInterface, UpdateState,
};
use itp_stf_primitives::{
error::StfError,
traits::TrustedCallVerification,
types::{ShardIdentifier, TrustedOperation, TrustedOperationOrHash},
};
Expand Down Expand Up @@ -169,11 +170,13 @@ where
Stf: UpdateState<
StateHandler::StateT,
<StateHandler::StateT as SgxExternalitiesTrait>::SgxExternalitiesDiffType,
> + ParentchainPalletInstancesInterface<StateHandler::StateT, ParentchainHeader>,
> + ParentchainPalletInstancesInterface<
StateHandler::StateT,
ParentchainHeader,
Error = StfError,
>,
<StateHandler::StateT as SgxExternalitiesTrait>::SgxExternalitiesDiffType:
IntoIterator<Item = (Vec<u8>, Option<Vec<u8>>)>,
<Stf as ParentchainPalletInstancesInterface<StateHandler::StateT, ParentchainHeader>>::Error:
Debug,
<StateHandler::StateT as SgxExternalitiesTrait>::SgxExternalitiesDiffType:
From<BTreeMap<Vec<u8>, Option<Vec<u8>>>>,
TCS: PartialEq + Encode + Decode + Debug + Clone + Send + Sync + TrustedCallVerification,
Expand All @@ -199,12 +202,15 @@ where
let shards = self.state_handler.list_shards()?;
for shard_id in shards {
let (state_lock, mut state) = self.state_handler.load_for_mutation(&shard_id)?;
match Stf::update_parentchain_integritee_block(&mut state, header.clone()) {
Ok(_) => {
self.state_handler.write_after_mutation(state, state_lock, &shard_id)?;
},
Err(e) => error!("Could not update parentchain block. {:?}: {:?}", shard_id, e),
}
match parentchain_id {
ParentchainId::Integritee =>
Stf::update_parentchain_integritee_block(&mut state, header.clone()),
ParentchainId::TargetA =>
Stf::update_parentchain_target_a_block(&mut state, header.clone()),
ParentchainId::TargetB =>
Stf::update_parentchain_target_a_block(&mut state, header.clone()),
}?;
self.state_handler.write_after_mutation(state, state_lock, &shard_id)?;
}

if parentchain_id != &ParentchainId::Integritee {
Expand Down

0 comments on commit 4ecbc8b

Please sign in to comment.