Skip to content

Commit

Permalink
fix nonce
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Feb 25, 2025
1 parent 5a91801 commit 7b1c546
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions app-libs/stf/src/stf_sgx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ where
// no signature check will happen. Still, we need to supply that field with a fake value.
let fake_signature =
Signature::Sr25519([0u8; 64].as_slice().try_into().expect("must work"));
let enclave_nonce =
System::account_nonce(enclave_signer_account::<AccountId>()).saturating_add(1);
let mut enclave_nonce =
System::account_nonce(enclave_signer_account::<AccountId>());
let genesis_hash = shielding_target_genesis_hash().unwrap_or_default();
for account in accounts {
info!("force unshield all for {:?}", account_id_to_string(&account));
Expand All @@ -327,7 +327,7 @@ where
account.clone(),
Some(asset_id),
),
nonce: enclave_nonce, //nonce will no longer increase as we bypass signature check
nonce: enclave_nonce,
delegate: None,
signature: fake_signature.clone(),
};
Expand All @@ -342,6 +342,7 @@ where
);
})
.ok();
enclave_nonce += 1;
}
}
if System::account(&account).data.free > 0 {
Expand All @@ -365,6 +366,7 @@ where
);
})
.ok();
enclave_nonce += 1;
}
}
Ok(())
Expand Down
4 changes: 3 additions & 1 deletion app-libs/stf/src/trusted_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ where
) -> Result<(), Self::Error> {
let _role = ensure_authorization(&self)?;
// todo! spending limits according to role https://github.com/integritee-network/worker/issues/1656
ensure!(may_execute(&self), Self::Error::Filtered);

let sender = self.call.sender_account().clone();
let call_hash = blake2_256(&self.call.encode());
let system_nonce = System::account_nonce(&sender);
Expand All @@ -314,6 +314,8 @@ where
// so it should be considered as valid
System::inc_account_nonce(&sender);

ensure!(may_execute(&self), Self::Error::Filtered);

match self.call.clone() {
TrustedCall::noop(who) => {
debug!("noop called by {}", account_id_to_string(&who),);
Expand Down

0 comments on commit 7b1c546

Please sign in to comment.