Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
d6f1bb89
Commit
d6f1bb89
authored
2 years ago
by
Pierre Krieger
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Don't send back empty proofs if light request fails (#12372)
parent
6f9ae78d
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/client/network/light/src/light_client_requests/handler.rs
+22
-28
22 additions, 28 deletions
...client/network/light/src/light_client_requests/handler.rs
with
22 additions
and
28 deletions
substrate/client/network/light/src/light_client_requests/handler.rs
+
22
−
28
View file @
d6f1bb89
...
...
@@ -28,7 +28,7 @@ use futures::{channel::mpsc, prelude::*};
use
libp2p
::
PeerId
;
use
log
::{
debug
,
trace
};
use
prost
::
Message
;
use
sc_client_api
::{
BlockBackend
,
ProofProvider
,
StorageProof
};
use
sc_client_api
::{
BlockBackend
,
ProofProvider
};
use
sc_network_common
::{
config
::
ProtocolId
,
request_responses
::{
IncomingRequest
,
OutgoingResponse
,
ProtocolConfig
},
...
...
@@ -176,12 +176,15 @@ where
let
block
=
Decode
::
decode
(
&
mut
request
.block
.as_ref
())
?
;
let
proof
=
let
response
=
match
self
.client
.execution_proof
(
&
BlockId
::
Hash
(
block
),
&
request
.method
,
&
request
.data
)
{
Ok
((
_
,
proof
))
=>
proof
,
Ok
((
_
,
proof
))
=>
{
let
r
=
schema
::
v1
::
light
::
RemoteCallResponse
{
proof
:
proof
.encode
()
};
Some
(
schema
::
v1
::
light
::
response
::
Response
::
RemoteCallResponse
(
r
))
},
Err
(
e
)
=>
{
trace!
(
"remote call request from {} ({} at {:?}) failed with: {}"
,
...
...
@@ -190,16 +193,11 @@ where
request
.block
,
e
,
);
StorageProof
::
empty
()
None
},
};
let
response
=
{
let
r
=
schema
::
v1
::
light
::
RemoteCallResponse
{
proof
:
proof
.encode
()
};
schema
::
v1
::
light
::
response
::
Response
::
RemoteCallResponse
(
r
)
};
Ok
(
schema
::
v1
::
light
::
Response
{
response
:
Some
(
response
)
})
Ok
(
schema
::
v1
::
light
::
Response
{
response
})
}
fn
on_remote_read_request
(
...
...
@@ -221,11 +219,14 @@ where
let
block
=
Decode
::
decode
(
&
mut
request
.block
.as_ref
())
?
;
let
proof
=
match
self
let
response
=
match
self
.client
.read_proof
(
&
BlockId
::
Hash
(
block
),
&
mut
request
.keys
.iter
()
.map
(
AsRef
::
as_ref
))
{
Ok
(
proof
)
=>
proof
,
Ok
(
proof
)
=>
{
let
r
=
schema
::
v1
::
light
::
RemoteReadResponse
{
proof
:
proof
.encode
()
};
Some
(
schema
::
v1
::
light
::
response
::
Response
::
RemoteReadResponse
(
r
))
},
Err
(
error
)
=>
{
trace!
(
"remote read request from {} ({} at {:?}) failed with: {}"
,
...
...
@@ -234,16 +235,11 @@ where
request
.block
,
error
,
);
StorageProof
::
empty
()
None
},
};
let
response
=
{
let
r
=
schema
::
v1
::
light
::
RemoteReadResponse
{
proof
:
proof
.encode
()
};
schema
::
v1
::
light
::
response
::
Response
::
RemoteReadResponse
(
r
)
};
Ok
(
schema
::
v1
::
light
::
Response
{
response
:
Some
(
response
)
})
Ok
(
schema
::
v1
::
light
::
Response
{
response
})
}
fn
on_remote_read_child_request
(
...
...
@@ -271,14 +267,17 @@ where
Some
((
ChildType
::
ParentKeyId
,
storage_key
))
=>
Ok
(
ChildInfo
::
new_default
(
storage_key
)),
None
=>
Err
(
sp_blockchain
::
Error
::
InvalidChildStorageKey
),
};
let
proof
=
match
child_info
.and_then
(|
child_info
|
{
let
response
=
match
child_info
.and_then
(|
child_info
|
{
self
.client
.read_child_proof
(
&
BlockId
::
Hash
(
block
),
&
child_info
,
&
mut
request
.keys
.iter
()
.map
(
AsRef
::
as_ref
),
)
})
{
Ok
(
proof
)
=>
proof
,
Ok
(
proof
)
=>
{
let
r
=
schema
::
v1
::
light
::
RemoteReadResponse
{
proof
:
proof
.encode
()
};
Some
(
schema
::
v1
::
light
::
response
::
Response
::
RemoteReadResponse
(
r
))
},
Err
(
error
)
=>
{
trace!
(
"remote read child request from {} ({} {} at {:?}) failed with: {}"
,
...
...
@@ -288,16 +287,11 @@ where
request
.block
,
error
,
);
StorageProof
::
empty
()
None
},
};
let
response
=
{
let
r
=
schema
::
v1
::
light
::
RemoteReadResponse
{
proof
:
proof
.encode
()
};
schema
::
v1
::
light
::
response
::
Response
::
RemoteReadResponse
(
r
)
};
Ok
(
schema
::
v1
::
light
::
Response
{
response
:
Some
(
response
)
})
Ok
(
schema
::
v1
::
light
::
Response
{
response
})
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment