Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
polkadot
Commits
ad985e61
Unverified
Commit
ad985e61
authored
Mar 24, 2021
by
Arkadiy Paronyan
Committed by
GitHub
Mar 24, 2021
Browse files
Additional logging (#2693)
parent
d2d50352
Pipeline
#130332
failed with stages
in 15 minutes and 12 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
node/network/approval-distribution/src/lib.rs
View file @
ad985e61
...
@@ -410,6 +410,14 @@ impl State {
...
@@ -410,6 +410,14 @@ impl State {
Some
(
entry
)
=>
entry
,
Some
(
entry
)
=>
entry
,
None
=>
{
None
=>
{
if
let
Some
(
peer_id
)
=
source
.peer_id
()
{
if
let
Some
(
peer_id
)
=
source
.peer_id
()
{
tracing
::
debug!
(
target
:
LOG_TARGET
,
?
source
,
?
peer_id
,
?
block_hash
,
?
validator_index
,
"Unexpected assignment"
,
);
modify_reputation
(
ctx
,
peer_id
,
COST_UNEXPECTED_MESSAGE
)
.await
;
modify_reputation
(
ctx
,
peer_id
,
COST_UNEXPECTED_MESSAGE
)
.await
;
}
}
return
;
return
;
...
@@ -428,11 +436,25 @@ impl State {
...
@@ -428,11 +436,25 @@ impl State {
match
entry
.known_by
.entry
(
peer_id
.clone
())
{
match
entry
.known_by
.entry
(
peer_id
.clone
())
{
hash_map
::
Entry
::
Occupied
(
knowledge
)
=>
{
hash_map
::
Entry
::
Occupied
(
knowledge
)
=>
{
if
knowledge
.get
()
.known_messages
.contains
(
&
fingerprint
)
{
if
knowledge
.get
()
.known_messages
.contains
(
&
fingerprint
)
{
tracing
::
debug!
(
target
:
LOG_TARGET
,
?
source
,
?
peer_id
,
?
fingerprint
,
"Duplicate assignment"
,
);
modify_reputation
(
ctx
,
peer_id
,
COST_DUPLICATE_MESSAGE
)
.await
;
modify_reputation
(
ctx
,
peer_id
,
COST_DUPLICATE_MESSAGE
)
.await
;
return
;
return
;
}
}
}
}
hash_map
::
Entry
::
Vacant
(
_
)
=>
{
hash_map
::
Entry
::
Vacant
(
_
)
=>
{
tracing
::
debug!
(
target
:
LOG_TARGET
,
?
source
,
?
peer_id
,
?
fingerprint
,
"Assignment from unknown peer"
,
);
modify_reputation
(
ctx
,
peer_id
.clone
(),
COST_UNEXPECTED_MESSAGE
)
.await
;
modify_reputation
(
ctx
,
peer_id
.clone
(),
COST_UNEXPECTED_MESSAGE
)
.await
;
}
}
}
}
...
@@ -441,6 +463,13 @@ impl State {
...
@@ -441,6 +463,13 @@ impl State {
if
entry
.knowledge.known_messages
.contains
(
&
fingerprint
)
{
if
entry
.knowledge.known_messages
.contains
(
&
fingerprint
)
{
modify_reputation
(
ctx
,
peer_id
.clone
(),
BENEFIT_VALID_MESSAGE
)
.await
;
modify_reputation
(
ctx
,
peer_id
.clone
(),
BENEFIT_VALID_MESSAGE
)
.await
;
if
let
Some
(
peer_knowledge
)
=
entry
.known_by
.get_mut
(
&
peer_id
)
{
if
let
Some
(
peer_knowledge
)
=
entry
.known_by
.get_mut
(
&
peer_id
)
{
tracing
::
trace!
(
target
:
LOG_TARGET
,
?
source
,
?
peer_id
,
?
fingerprint
,
"Known assignment"
,
);
peer_knowledge
.known_messages
.insert
(
fingerprint
.clone
());
peer_knowledge
.known_messages
.insert
(
fingerprint
.clone
());
}
}
return
;
return
;
...
@@ -465,6 +494,14 @@ impl State {
...
@@ -465,6 +494,14 @@ impl State {
}
}
};
};
tracing
::
trace!
(
target
:
LOG_TARGET
,
?
source
,
?
peer_id
,
?
fingerprint
,
?
result
,
"Checked assignment"
,
);
match
result
{
match
result
{
AssignmentCheckResult
::
Accepted
=>
{
AssignmentCheckResult
::
Accepted
=>
{
modify_reputation
(
ctx
,
peer_id
.clone
(),
BENEFIT_VALID_MESSAGE_FIRST
)
.await
;
modify_reputation
(
ctx
,
peer_id
.clone
(),
BENEFIT_VALID_MESSAGE_FIRST
)
.await
;
...
@@ -488,11 +525,6 @@ impl State {
...
@@ -488,11 +525,6 @@ impl State {
}
}
AssignmentCheckResult
::
Bad
=>
{
AssignmentCheckResult
::
Bad
=>
{
modify_reputation
(
ctx
,
peer_id
,
COST_INVALID_MESSAGE
)
.await
;
modify_reputation
(
ctx
,
peer_id
,
COST_INVALID_MESSAGE
)
.await
;
tracing
::
info!
(
target
:
LOG_TARGET
,
?
peer_id
,
"Got a bad assignment from peer"
,
);
return
;
return
;
}
}
}
}
...
@@ -599,6 +631,13 @@ impl State {
...
@@ -599,6 +631,13 @@ impl State {
);
);
if
!
entry
.knowledge.known_messages
.contains
(
&
assignment_fingerprint
)
{
if
!
entry
.knowledge.known_messages
.contains
(
&
assignment_fingerprint
)
{
tracing
::
debug!
(
target
:
LOG_TARGET
,
?
source
,
?
peer_id
,
?
fingerprint
,
"Unknown approval assignment"
,
);
modify_reputation
(
ctx
,
peer_id
,
COST_UNEXPECTED_MESSAGE
)
.await
;
modify_reputation
(
ctx
,
peer_id
,
COST_UNEXPECTED_MESSAGE
)
.await
;
return
;
return
;
}
}
...
@@ -606,18 +645,39 @@ impl State {
...
@@ -606,18 +645,39 @@ impl State {
// check if our knowledge of the peer already contains this approval
// check if our knowledge of the peer already contains this approval
match
entry
.known_by
.entry
(
peer_id
.clone
())
{
match
entry
.known_by
.entry
(
peer_id
.clone
())
{
hash_map
::
Entry
::
Occupied
(
knowledge
)
=>
{
hash_map
::
Entry
::
Occupied
(
knowledge
)
=>
{
tracing
::
debug!
(
target
:
LOG_TARGET
,
?
source
,
?
peer_id
,
?
fingerprint
,
"Duplicate approval"
,
);
if
knowledge
.get
()
.known_messages
.contains
(
&
fingerprint
)
{
if
knowledge
.get
()
.known_messages
.contains
(
&
fingerprint
)
{
modify_reputation
(
ctx
,
peer_id
,
COST_DUPLICATE_MESSAGE
)
.await
;
modify_reputation
(
ctx
,
peer_id
,
COST_DUPLICATE_MESSAGE
)
.await
;
return
;
return
;
}
}
}
}
hash_map
::
Entry
::
Vacant
(
_
)
=>
{
hash_map
::
Entry
::
Vacant
(
_
)
=>
{
tracing
::
debug!
(
target
:
LOG_TARGET
,
?
source
,
?
peer_id
,
?
fingerprint
,
"Approval from unknown peer"
,
);
modify_reputation
(
ctx
,
peer_id
.clone
(),
COST_UNEXPECTED_MESSAGE
)
.await
;
modify_reputation
(
ctx
,
peer_id
.clone
(),
COST_UNEXPECTED_MESSAGE
)
.await
;
}
}
}
}
// if the approval is known to be valid, reward the peer
// if the approval is known to be valid, reward the peer
if
entry
.knowledge.known_messages
.contains
(
&
fingerprint
)
{
if
entry
.knowledge.known_messages
.contains
(
&
fingerprint
)
{
tracing
::
trace!
(
target
:
LOG_TARGET
,
?
source
,
?
peer_id
,
?
fingerprint
,
"Known approval"
,
);
modify_reputation
(
ctx
,
peer_id
.clone
(),
BENEFIT_VALID_MESSAGE
)
.await
;
modify_reputation
(
ctx
,
peer_id
.clone
(),
BENEFIT_VALID_MESSAGE
)
.await
;
if
let
Some
(
peer_knowledge
)
=
entry
.known_by
.get_mut
(
&
peer_id
)
{
if
let
Some
(
peer_knowledge
)
=
entry
.known_by
.get_mut
(
&
peer_id
)
{
peer_knowledge
.known_messages
.insert
(
fingerprint
.clone
());
peer_knowledge
.known_messages
.insert
(
fingerprint
.clone
());
...
@@ -643,6 +703,14 @@ impl State {
...
@@ -643,6 +703,14 @@ impl State {
}
}
};
};
tracing
::
trace!
(
target
:
LOG_TARGET
,
?
source
,
?
peer_id
,
?
fingerprint
,
?
result
,
"Checked approval"
,
);
match
result
{
match
result
{
ApprovalCheckResult
::
Accepted
=>
{
ApprovalCheckResult
::
Accepted
=>
{
modify_reputation
(
ctx
,
peer_id
.clone
(),
BENEFIT_VALID_MESSAGE_FIRST
)
.await
;
modify_reputation
(
ctx
,
peer_id
.clone
(),
BENEFIT_VALID_MESSAGE_FIRST
)
.await
;
...
...
Write
Preview
Supports
Markdown
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!
Cancel
Please
register
or
sign in
to comment