Skip to content

Commit

Permalink
fix .dispatch filtering introduced in paritytech/substrate#6318
Browse files Browse the repository at this point in the history
  • Loading branch information
Alain Brenzikofer committed Sep 12, 2020
1 parent 7ad6138 commit 6dfca0e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions enclave/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2187,6 +2187,7 @@ dependencies = [
"derive_more 0.99.5 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.7.1 (git+https://github.com/mesalock-linux/env_logger-sgx)",
"frame-metadata 11.0.0-rc5 (registry+https://github.com/rust-lang/crates.io-index)",
"frame-support 2.0.0-rc5 (registry+https://github.com/rust-lang/crates.io-index)",
"frame-system 2.0.0-rc5 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)",
"pallet-balances 2.0.0-rc5 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down
5 changes: 5 additions & 0 deletions stf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ default-features = false
package = 'frame-system'
version = '2.0.0-rc5'

[dependencies.support]
default-features = false
package = 'frame-support'
version = '2.0.0-rc5'

[dependencies.metadata]
version = '11.0.0-alpha.6'
package = "frame-metadata"
Expand Down
12 changes: 6 additions & 6 deletions stf/src/sgx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use metadata::StorageHasher;
use sgx_runtime::{Balance, BlockNumber, Runtime};
use sp_core::crypto::AccountId32;
use sp_io::SgxExternalitiesTrait;
use sp_runtime::traits::Dispatchable;
use support::traits::UnfilteredDispatchable;

use crate::{
AccountId, Getter, PublicGetter, ShardIdentifier, State, Stf, TrustedCall, TrustedCallSigned,
Expand Down Expand Up @@ -106,7 +106,7 @@ impl Stf {
free_balance,
reserved_balance,
)
.dispatch(sgx_runtime::Origin::ROOT)
.dispatch_bypass_filter(sgx_runtime::Origin::root())
.map_err(|_| StfError::Dispatch("balance_set_balance".to_string()))?;
Ok(())
}
Expand All @@ -124,7 +124,7 @@ impl Stf {
debug!("sender balance is zero");
}
sgx_runtime::BalancesCall::<Runtime>::transfer(AccountId32::from(to), value)
.dispatch(origin)
.dispatch_bypass_filter(origin)
.map_err(|_| StfError::Dispatch("balance_transfer".to_string()))?;
Ok(())
}
Expand Down Expand Up @@ -200,10 +200,10 @@ impl Stf {
account_info.data.free + amount,
account_info.data.reserved,
)
.dispatch(sgx_runtime::Origin::ROOT)
.dispatch_bypass_filter(sgx_runtime::Origin::root())
.map_err(|_| StfError::Dispatch("shield_funds".to_string()))?,
None => sgx_runtime::BalancesCall::<Runtime>::set_balance(account.into(), amount, 0)
.dispatch(sgx_runtime::Origin::ROOT)
.dispatch_bypass_filter(sgx_runtime::Origin::root())
.map_err(|_| StfError::Dispatch("shield_funds::set_balance".to_string()))?,
};
Ok(())
Expand All @@ -221,7 +221,7 @@ impl Stf {
account_info.data.free - amount,
account_info.data.reserved,
)
.dispatch(sgx_runtime::Origin::ROOT)
.dispatch_bypass_filter(sgx_runtime::Origin::root())
.map_err(|_| StfError::Dispatch("unshield_funds::set_balance".to_string()))?;
Ok(())
}
Expand Down

0 comments on commit 6dfca0e

Please sign in to comment.