good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor 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
open
bor
Commits
85b6823d
Commit
85b6823d
authored
5 years ago
by
Zsolt Felföldi
Committed by
Péter Szilágyi
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
les: check required message types in cost table (#19454)
parent
78d90c47
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
les/peer.go
+18
-3
18 additions, 3 deletions
les/peer.go
les/peer_test.go
+2
-2
2 additions, 2 deletions
les/peer_test.go
with
20 additions
and
5 deletions
les/peer.go
+
18
−
3
View file @
85b6823d
...
@@ -232,7 +232,11 @@ func (p *peer) GetRequestCost(msgcode uint64, amount int) uint64 {
...
@@ -232,7 +232,11 @@ func (p *peer) GetRequestCost(msgcode uint64, amount int) uint64 {
p
.
lock
.
RLock
()
p
.
lock
.
RLock
()
defer
p
.
lock
.
RUnlock
()
defer
p
.
lock
.
RUnlock
()
cost
:=
p
.
fcCosts
[
msgcode
]
.
baseCost
+
p
.
fcCosts
[
msgcode
]
.
reqCost
*
uint64
(
amount
)
costs
:=
p
.
fcCosts
[
msgcode
]
if
costs
==
nil
{
return
0
}
cost
:=
costs
.
baseCost
+
costs
.
reqCost
*
uint64
(
amount
)
if
cost
>
p
.
fcParams
.
BufLimit
{
if
cost
>
p
.
fcParams
.
BufLimit
{
cost
=
p
.
fcParams
.
BufLimit
cost
=
p
.
fcParams
.
BufLimit
}
}
...
@@ -243,8 +247,12 @@ func (p *peer) GetTxRelayCost(amount, size int) uint64 {
...
@@ -243,8 +247,12 @@ func (p *peer) GetTxRelayCost(amount, size int) uint64 {
p
.
lock
.
RLock
()
p
.
lock
.
RLock
()
defer
p
.
lock
.
RUnlock
()
defer
p
.
lock
.
RUnlock
()
cost
:=
p
.
fcCosts
[
SendTxV2Msg
]
.
baseCost
+
p
.
fcCosts
[
SendTxV2Msg
]
.
reqCost
*
uint64
(
amount
)
costs
:=
p
.
fcCosts
[
SendTxV2Msg
]
sizeCost
:=
p
.
fcCosts
[
SendTxV2Msg
]
.
baseCost
+
p
.
fcCosts
[
SendTxV2Msg
]
.
reqCost
*
uint64
(
size
)
/
txSizeCostLimit
if
costs
==
nil
{
return
0
}
cost
:=
costs
.
baseCost
+
costs
.
reqCost
*
uint64
(
amount
)
sizeCost
:=
costs
.
baseCost
+
costs
.
reqCost
*
uint64
(
size
)
/
txSizeCostLimit
if
sizeCost
>
cost
{
if
sizeCost
>
cost
{
cost
=
sizeCost
cost
=
sizeCost
}
}
...
@@ -564,6 +572,13 @@ func (p *peer) Handshake(td *big.Int, head common.Hash, headNum uint64, genesis
...
@@ -564,6 +572,13 @@ func (p *peer) Handshake(td *big.Int, head common.Hash, headNum uint64, genesis
p
.
fcParams
=
params
p
.
fcParams
=
params
p
.
fcServer
=
flowcontrol
.
NewServerNode
(
params
,
&
mclock
.
System
{})
p
.
fcServer
=
flowcontrol
.
NewServerNode
(
params
,
&
mclock
.
System
{})
p
.
fcCosts
=
MRC
.
decode
()
p
.
fcCosts
=
MRC
.
decode
()
if
!
p
.
isOnlyAnnounce
{
for
msgCode
:=
range
reqAvgTimeCost
{
if
p
.
fcCosts
[
msgCode
]
==
nil
{
return
errResp
(
ErrUselessPeer
,
"peer does not support message %d"
,
msgCode
)
}
}
}
}
}
p
.
headInfo
=
&
announceData
{
Td
:
rTd
,
Hash
:
rHash
,
Number
:
rNum
}
p
.
headInfo
=
&
announceData
{
Td
:
rTd
,
Hash
:
rHash
,
Number
:
rNum
}
return
nil
return
nil
...
...
This diff is collapsed.
Click to expand it.
les/peer_test.go
+
2
−
2
View file @
85b6823d
...
@@ -54,7 +54,7 @@ func TestPeerHandshakeSetAnnounceTypeToAnnounceTypeSignedForTrustedPeer(t *testi
...
@@ -54,7 +54,7 @@ func TestPeerHandshakeSetAnnounceTypeToAnnounceTypeSignedForTrustedPeer(t *testi
l
=
l
.
add
(
"txRelay"
,
nil
)
l
=
l
.
add
(
"txRelay"
,
nil
)
l
=
l
.
add
(
"flowControl/BL"
,
uint64
(
0
))
l
=
l
.
add
(
"flowControl/BL"
,
uint64
(
0
))
l
=
l
.
add
(
"flowControl/MRR"
,
uint64
(
0
))
l
=
l
.
add
(
"flowControl/MRR"
,
uint64
(
0
))
l
=
l
.
add
(
"flowControl/MRC"
,
Requ
estCostList
{}
)
l
=
l
.
add
(
"flowControl/MRC"
,
t
estCostList
()
)
return
l
return
l
},
},
...
@@ -99,7 +99,7 @@ func TestPeerHandshakeAnnounceTypeSignedForTrustedPeersPeerNotInTrusted(t *testi
...
@@ -99,7 +99,7 @@ func TestPeerHandshakeAnnounceTypeSignedForTrustedPeersPeerNotInTrusted(t *testi
l
=
l
.
add
(
"txRelay"
,
nil
)
l
=
l
.
add
(
"txRelay"
,
nil
)
l
=
l
.
add
(
"flowControl/BL"
,
uint64
(
0
))
l
=
l
.
add
(
"flowControl/BL"
,
uint64
(
0
))
l
=
l
.
add
(
"flowControl/MRR"
,
uint64
(
0
))
l
=
l
.
add
(
"flowControl/MRR"
,
uint64
(
0
))
l
=
l
.
add
(
"flowControl/MRC"
,
Requ
estCostList
{}
)
l
=
l
.
add
(
"flowControl/MRC"
,
t
estCostList
()
)
return
l
return
l
},
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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