Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
张蕾
Geth-Modification
Commits
ed47f29b
Unverified
Commit
ed47f29b
authored
Apr 26, 2019
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth: enforce chain above CHT before accepting txs into the pool
parent
3873a731
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
6 deletions
+32
-6
handler.go
eth/handler.go
+21
-4
sync.go
eth/sync.go
+11
-2
No files found.
eth/handler.go
View file @
ed47f29b
...
...
@@ -181,13 +181,30 @@ func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, ne
return
blockchain
.
CurrentBlock
()
.
NumberU64
()
}
inserter
:=
func
(
blocks
types
.
Blocks
)
(
int
,
error
)
{
// If fast sync is running, deny importing weird blocks
// If sync hasn't reached the checkpoint yet, deny importing weird blocks.
//
// Ideally we would also compare the head block's timestamp and similarly reject
// the propagated block if the head is too old. Unfortunately there is a corner
// case when starting new networks, where the genesis might be ancient (0 unix)
// which would prevent full nodes from accepting it.
if
manager
.
blockchain
.
CurrentBlock
()
.
NumberU64
()
<
manager
.
checkpointNumber
{
log
.
Warn
(
"Unsynced yet, discarded propagated block"
,
"number"
,
blocks
[
0
]
.
Number
(),
"hash"
,
blocks
[
0
]
.
Hash
())
return
0
,
nil
}
// If fast sync is running, deny importing weird blocks. This is a problematic
// clause when starting up a new network, because fast-syncing miners might not
// accept each others' blocks until a restart. Unfortunately we haven't figured
// out a way yet where nodes can decide unilaterally whether the network is new
// or not. This should be fixed if we figure out a solution.
if
atomic
.
LoadUint32
(
&
manager
.
fastSync
)
==
1
{
log
.
Warn
(
"
Discarded ba
d propagated block"
,
"number"
,
blocks
[
0
]
.
Number
(),
"hash"
,
blocks
[
0
]
.
Hash
())
log
.
Warn
(
"
Fast syncing, discarde
d propagated block"
,
"number"
,
blocks
[
0
]
.
Number
(),
"hash"
,
blocks
[
0
]
.
Hash
())
return
0
,
nil
}
atomic
.
StoreUint32
(
&
manager
.
acceptTxs
,
1
)
// Mark initial sync done on any fetcher import
return
manager
.
blockchain
.
InsertChain
(
blocks
)
n
,
err
:=
manager
.
blockchain
.
InsertChain
(
blocks
)
if
err
==
nil
{
atomic
.
StoreUint32
(
&
manager
.
acceptTxs
,
1
)
// Mark initial sync done on any fetcher import
}
return
n
,
err
}
manager
.
fetcher
=
fetcher
.
New
(
blockchain
.
GetBlockByHash
,
validator
,
manager
.
BroadcastBlock
,
heighter
,
inserter
,
manager
.
removePeer
)
...
...
eth/sync.go
View file @
ed47f29b
...
...
@@ -202,8 +202,17 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
log
.
Info
(
"Fast sync complete, auto disabling"
)
atomic
.
StoreUint32
(
&
pm
.
fastSync
,
0
)
}
atomic
.
StoreUint32
(
&
pm
.
acceptTxs
,
1
)
// Mark initial sync done
if
head
:=
pm
.
blockchain
.
CurrentBlock
();
head
.
NumberU64
()
>
0
{
// If we've successfully finished a sync cycle and passed any required checkpoint,
// enable accepting transactions from the network.
head
:=
pm
.
blockchain
.
CurrentBlock
()
if
head
.
NumberU64
()
>=
pm
.
checkpointNumber
{
// Checkpoint passed, sanity check the timestamp to have a fallback mechanism
// for non-checkpointed (number = 0) private networks.
if
head
.
Time
()
>=
uint64
(
time
.
Now
()
.
AddDate
(
0
,
-
1
,
0
)
.
Unix
())
{
atomic
.
StoreUint32
(
&
pm
.
acceptTxs
,
1
)
}
}
if
head
.
NumberU64
()
>
0
{
// We've completed a sync cycle, notify all peers of new state. This path is
// essential in star-topology networks where a gateway node needs to notify
// all its out-of-date peers of the availability of a new block. This failure
...
...
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