Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
744c46ca
Unverified
Commit
744c46ca
authored
Jun 21, 2021
by
Ralph Pichler
Committed by
GitHub
Jun 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: only greylist after error (#2168)
parent
5163768e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
8 deletions
+49
-8
sender_matcher.go
pkg/transaction/sender_matcher.go
+49
-8
No files found.
pkg/transaction/sender_matcher.go
View file @
744c46ca
...
@@ -71,35 +71,62 @@ func (m *Matcher) Matches(ctx context.Context, tx []byte, networkID uint64, send
...
@@ -71,35 +71,62 @@ func (m *Matcher) Matches(ctx context.Context, tx []byte, networkID uint64, send
return
nil
,
ErrGreylisted
return
nil
,
ErrGreylisted
}
}
err
=
m
.
storage
.
Put
(
peerOverlayKey
(
senderOverlay
,
incomingTx
),
&
overlayVerification
{
nTx
,
isPending
,
err
:=
m
.
backend
.
TransactionByHash
(
ctx
,
incomingTx
)
if
err
!=
nil
{
err2
:=
m
.
storage
.
Put
(
peerOverlayKey
(
senderOverlay
,
incomingTx
),
&
overlayVerification
{
TimeStamp
:
m
.
timeNow
(),
TimeStamp
:
m
.
timeNow
(),
Verified
:
false
,
Verified
:
false
,
})
})
if
err
!=
nil
{
if
err2
!=
nil
{
return
nil
,
err
return
nil
,
err2
}
}
nTx
,
isPending
,
err
:=
m
.
backend
.
TransactionByHash
(
ctx
,
incomingTx
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"%v: %w"
,
err
,
ErrTransactionNotFound
)
return
nil
,
fmt
.
Errorf
(
"%v: %w"
,
err
,
ErrTransactionNotFound
)
}
}
if
isPending
{
if
isPending
{
err2
:=
m
.
storage
.
Put
(
peerOverlayKey
(
senderOverlay
,
incomingTx
),
&
overlayVerification
{
TimeStamp
:
m
.
timeNow
(),
Verified
:
false
,
})
if
err2
!=
nil
{
return
nil
,
err2
}
return
nil
,
ErrTransactionPending
return
nil
,
ErrTransactionPending
}
}
sender
,
err
:=
types
.
Sender
(
m
.
signer
,
nTx
)
sender
,
err
:=
types
.
Sender
(
m
.
signer
,
nTx
)
if
err
!=
nil
{
if
err
!=
nil
{
err2
:=
m
.
storage
.
Put
(
peerOverlayKey
(
senderOverlay
,
incomingTx
),
&
overlayVerification
{
TimeStamp
:
m
.
timeNow
(),
Verified
:
false
,
})
if
err2
!=
nil
{
return
nil
,
err2
}
return
nil
,
fmt
.
Errorf
(
"%v: %w"
,
err
,
ErrTransactionSenderInvalid
)
return
nil
,
fmt
.
Errorf
(
"%v: %w"
,
err
,
ErrTransactionSenderInvalid
)
}
}
receipt
,
err
:=
m
.
backend
.
TransactionReceipt
(
ctx
,
incomingTx
)
receipt
,
err
:=
m
.
backend
.
TransactionReceipt
(
ctx
,
incomingTx
)
if
err
!=
nil
{
if
err
!=
nil
{
err2
:=
m
.
storage
.
Put
(
peerOverlayKey
(
senderOverlay
,
incomingTx
),
&
overlayVerification
{
TimeStamp
:
m
.
timeNow
(),
Verified
:
false
,
})
if
err2
!=
nil
{
return
nil
,
err2
}
return
nil
,
err
return
nil
,
err
}
}
nextBlock
,
err
:=
m
.
backend
.
HeaderByNumber
(
ctx
,
big
.
NewInt
(
0
)
.
Add
(
receipt
.
BlockNumber
,
big
.
NewInt
(
1
)))
nextBlock
,
err
:=
m
.
backend
.
HeaderByNumber
(
ctx
,
big
.
NewInt
(
0
)
.
Add
(
receipt
.
BlockNumber
,
big
.
NewInt
(
1
)))
if
err
!=
nil
{
if
err
!=
nil
{
err2
:=
m
.
storage
.
Put
(
peerOverlayKey
(
senderOverlay
,
incomingTx
),
&
overlayVerification
{
TimeStamp
:
m
.
timeNow
(),
Verified
:
false
,
})
if
err2
!=
nil
{
return
nil
,
err2
}
return
nil
,
err
return
nil
,
err
}
}
...
@@ -108,12 +135,26 @@ func (m *Matcher) Matches(ctx context.Context, tx []byte, networkID uint64, send
...
@@ -108,12 +135,26 @@ func (m *Matcher) Matches(ctx context.Context, tx []byte, networkID uint64, send
nextBlockHash
:=
nextBlock
.
Hash
()
.
Bytes
()
nextBlockHash
:=
nextBlock
.
Hash
()
.
Bytes
()
if
!
bytes
.
Equal
(
receiptBlockHash
,
nextBlockParentHash
)
{
if
!
bytes
.
Equal
(
receiptBlockHash
,
nextBlockParentHash
)
{
err2
:=
m
.
storage
.
Put
(
peerOverlayKey
(
senderOverlay
,
incomingTx
),
&
overlayVerification
{
TimeStamp
:
m
.
timeNow
(),
Verified
:
false
,
})
if
err2
!=
nil
{
return
nil
,
err2
}
return
nil
,
fmt
.
Errorf
(
"receipt hash %x does not match block's parent hash %x: %w"
,
receiptBlockHash
,
nextBlockParentHash
,
ErrBlockHashMismatch
)
return
nil
,
fmt
.
Errorf
(
"receipt hash %x does not match block's parent hash %x: %w"
,
receiptBlockHash
,
nextBlockParentHash
,
ErrBlockHashMismatch
)
}
}
expectedRemoteBzzAddress
:=
crypto
.
NewOverlayFromEthereumAddress
(
sender
.
Bytes
(),
networkID
,
nextBlockHash
)
expectedRemoteBzzAddress
:=
crypto
.
NewOverlayFromEthereumAddress
(
sender
.
Bytes
(),
networkID
,
nextBlockHash
)
if
!
expectedRemoteBzzAddress
.
Equal
(
senderOverlay
)
{
if
!
expectedRemoteBzzAddress
.
Equal
(
senderOverlay
)
{
err2
:=
m
.
storage
.
Put
(
peerOverlayKey
(
senderOverlay
,
incomingTx
),
&
overlayVerification
{
TimeStamp
:
m
.
timeNow
(),
Verified
:
false
,
})
if
err2
!=
nil
{
return
nil
,
err2
}
return
nil
,
ErrOverlayMismatch
return
nil
,
ErrOverlayMismatch
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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