Allow Root to assume SourceAccount. (#1011)

* Allow Root to assume SourceAccount.

* fmt code
This commit is contained in:
kaichao
2021-06-22 15:20:00 +08:00
committed by Bastian Köcher
parent 6ff79e9959
commit 010588e95a
4 changed files with 7 additions and 10 deletions
+3 -6
View File
@@ -355,7 +355,7 @@ where
} }
CallOrigin::SourceAccount(ref source_account_id) => { CallOrigin::SourceAccount(ref source_account_id) => {
ensure!( ensure!(
sender_origin == &RawOrigin::Signed(source_account_id.clone()), sender_origin == &RawOrigin::Signed(source_account_id.clone()) || sender_origin == &RawOrigin::Root,
BadOrigin BadOrigin
); );
Ok(Some(source_account_id.clone())) Ok(Some(source_account_id.clone()))
@@ -964,10 +964,7 @@ mod tests {
Err(BadOrigin) Err(BadOrigin)
)); ));
// If we try and send the message from Root, it is also rejected // The Root account is allowed to assume any expected origin account
assert!(matches!( assert!(matches!(verify_message_origin(&RawOrigin::Root, &message), Ok(Some(1))));
verify_message_origin(&RawOrigin::Root, &message),
Err(BadOrigin)
));
} }
} }
+1 -1
View File
@@ -201,7 +201,7 @@ message needs to be read. So there's another
When choosing values for these parameters, you must also keep in mind that if proof in your scheme When choosing values for these parameters, you must also keep in mind that if proof in your scheme
is based on finality of headers (and it is the most obvious option for Substrate-based chains with is based on finality of headers (and it is the most obvious option for Substrate-based chains with
finality notion), then choosing too small values for these parameters may cause significant delays finality notion), then choosing too small values for these parameters may cause significant delays
in message delivery. That's because there too many actors involved in this scheme: 1) authorities in message delivery. That's because there are too many actors involved in this scheme: 1) authorities
that are finalizing headers of the target chain need to finalize header with non-empty map; 2) the that are finalizing headers of the target chain need to finalize header with non-empty map; 2) the
headers relayer then needs to submit this header and its finality proof to the source chain; 3) the headers relayer then needs to submit this header and its finality proof to the source chain; 3) the
messages relayer must then send confirmation transaction (storage proof of this map) to the source messages relayer must then send confirmation transaction (storage proof of this map) to the source
@@ -102,7 +102,7 @@ pub enum CallOrigin<SourceChainAccountId, TargetChainAccountPublic, TargetChainS
/// Call is sent by the `SourceChainAccountId` on the source chain. On the target chain it is /// Call is sent by the `SourceChainAccountId` on the source chain. On the target chain it is
/// dispatched from a derived account ID. /// dispatched from a derived account ID.
/// ///
/// The account ID on the target chain is derived from the source account ID This is useful if /// The account ID on the target chain is derived from the source account ID. This is useful if
/// you need a way to represent foreign accounts on this chain for call dispatch purposes. /// you need a way to represent foreign accounts on this chain for call dispatch purposes.
/// ///
/// Note that the derived account does not need to have a private key on the target chain. This /// Note that the derived account does not need to have a private key on the target chain. This
+1 -1
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>. // along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Tools to interact with (Open) Ethereum node using RPC methods. //! Tools to interact with Substrate node using RPC methods.
#![warn(missing_docs)] #![warn(missing_docs)]