13
13
// See the License for the specific language governing permissions and
14
14
// limitations under the License.
15
15
16
+ use core:: fmt:: Debug ;
16
17
use cumulus_primitives_core:: ParaId ;
17
18
use frame_support:: {
18
19
pallet_prelude:: Get ,
@@ -33,8 +34,9 @@ impl<IsForeign: ContainsPair<Location, Location>> ContainsPair<Asset, Location>
33
34
for IsForeignConcreteAsset < IsForeign >
34
35
{
35
36
fn contains ( asset : & Asset , origin : & Location ) -> bool {
36
- log:: trace!( target: "xcm::contains" , "IsForeignConcreteAsset asset: {:?}, origin: {:?}" , asset, origin) ;
37
- matches ! ( asset. id, AssetId ( ref id) if IsForeign :: contains( id, origin) )
37
+ let result = matches ! ( asset. id, AssetId ( ref id) if IsForeign :: contains( id, origin) ) ;
38
+ tracing:: trace!( target: "xcm::contains" , ?asset, ?origin, ?result, "IsForeignConcreteAsset" ) ;
39
+ result
38
40
}
39
41
}
40
42
@@ -43,10 +45,11 @@ impl<IsForeign: ContainsPair<Location, Location>> ContainsPair<Asset, Location>
43
45
pub struct FromSiblingParachain < SelfParaId , L = Location > (
44
46
core:: marker:: PhantomData < ( SelfParaId , L ) > ,
45
47
) ;
46
- impl < SelfParaId : Get < ParaId > , L : TryFrom < Location > + TryInto < Location > + Clone > ContainsPair < L , L >
47
- for FromSiblingParachain < SelfParaId , L >
48
+ impl < SelfParaId : Get < ParaId > , L : TryFrom < Location > + TryInto < Location > + Clone + Debug >
49
+ ContainsPair < L , L > for FromSiblingParachain < SelfParaId , L >
48
50
{
49
51
fn contains ( a : & L , b : & L ) -> bool {
52
+ tracing:: trace!( target: "xcm:contains" , ?a, ?b, "FromSiblingParachain" ) ;
50
53
// We convert locations to latest
51
54
let a = match ( ( * a) . clone ( ) . try_into ( ) , ( * b) . clone ( ) . try_into ( ) ) {
52
55
( Ok ( a) , Ok ( b) ) if a. starts_with ( & b) => a, // `a` needs to be from `b` at least
@@ -70,10 +73,11 @@ pub struct FromNetwork<UniversalLocation, ExpectedNetworkId, L = Location>(
70
73
impl <
71
74
UniversalLocation : Get < InteriorLocation > ,
72
75
ExpectedNetworkId : Get < NetworkId > ,
73
- L : TryFrom < Location > + TryInto < Location > + Clone ,
76
+ L : TryFrom < Location > + TryInto < Location > + Clone + Debug ,
74
77
> ContainsPair < L , L > for FromNetwork < UniversalLocation , ExpectedNetworkId , L >
75
78
{
76
79
fn contains ( a : & L , b : & L ) -> bool {
80
+ tracing:: trace!( target: "xcm:contains" , ?a, ?b, "FromNetwork" ) ;
77
81
// We convert locations to latest
78
82
let a = match ( ( * a) . clone ( ) . try_into ( ) , ( * b) . clone ( ) . try_into ( ) ) {
79
83
( Ok ( a) , Ok ( b) ) if a. starts_with ( & b) => a, // `a` needs to be from `b` at least
86
90
match ensure_is_remote ( universal_source. clone ( ) , a. clone ( ) ) {
87
91
Ok ( ( network_id, _) ) => network_id == ExpectedNetworkId :: get ( ) ,
88
92
Err ( e) => {
89
- log:: trace!(
90
- target: "xcm::contains" ,
91
- "FromNetwork origin: {:?} is not remote to the universal_source: {:?} {:?}" ,
92
- a, universal_source, e
93
- ) ;
93
+ tracing:: debug!( target: "xcm::contains" , origin = ?a, ?universal_source, error = ?e, "FromNetwork origin is not remote to the universal_source" ) ;
94
94
false
95
95
} ,
96
96
}
@@ -118,15 +118,20 @@ impl<
118
118
let expected_origin = OriginLocation :: get ( ) ;
119
119
// ensure `origin` is expected `OriginLocation`
120
120
if !expected_origin. eq ( & origin) {
121
- log :: trace!(
121
+ tracing :: trace!(
122
122
target: "xcm::contains" ,
123
- "RemoteAssetFromLocation asset: {asset:?}, origin: {origin:?} is not from expected {expected_origin:?}"
123
+ ?asset,
124
+ ?origin,
125
+ ?expected_origin,
126
+ "RemoteAssetFromLocation: Asset is not from expected origin"
124
127
) ;
125
128
return false ;
126
129
} else {
127
- log :: trace!(
130
+ tracing :: trace!(
128
131
target: "xcm::contains" ,
129
- "RemoteAssetFromLocation asset: {asset:?}, origin: {origin:?}" ,
132
+ ?asset,
133
+ ?origin,
134
+ "RemoteAssetFromLocation" ,
130
135
) ;
131
136
}
132
137
@@ -138,6 +143,7 @@ impl<AssetsAllowedNetworks: Contains<Location>, OriginLocation: Get<Location>>
138
143
ContainsPair < Asset , Location > for RemoteAssetFromLocation < AssetsAllowedNetworks , OriginLocation >
139
144
{
140
145
fn contains ( asset : & Asset , origin : & Location ) -> bool {
146
+ tracing:: trace!( target: "xcm:contains" , ?asset, ?origin, "RemoteAssetFromLocation" ) ;
141
147
<Self as ContainsPair < Location , Location > >:: contains ( & asset. id . 0 , origin)
142
148
}
143
149
}
0 commit comments