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
64f9c1ea
Commit
64f9c1ea
authored
Apr 05, 2019
by
Zsolt Felfoldi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
les, light: remove support for les/1 4096 block CHT sections
parent
5515f364
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
26 additions
and
68 deletions
+26
-68
backend.go
les/backend.go
+1
-1
benchmark.go
les/benchmark.go
+1
-2
commons.go
les/commons.go
+1
-13
handler.go
les/handler.go
+2
-3
handler_test.go
les/handler_test.go
+7
-15
server.go
les/server.go
+6
-10
postprocess.go
light/postprocess.go
+6
-17
network_params.go
params/network_params.go
+2
-7
No files found.
les/backend.go
View file @
64f9c1ea
...
@@ -119,7 +119,7 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) {
...
@@ -119,7 +119,7 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) {
leth
.
retriever
=
newRetrieveManager
(
peers
,
leth
.
reqDist
,
leth
.
serverPool
)
leth
.
retriever
=
newRetrieveManager
(
peers
,
leth
.
reqDist
,
leth
.
serverPool
)
leth
.
odr
=
NewLesOdr
(
chainDb
,
light
.
DefaultClientIndexerConfig
,
leth
.
retriever
)
leth
.
odr
=
NewLesOdr
(
chainDb
,
light
.
DefaultClientIndexerConfig
,
leth
.
retriever
)
leth
.
chtIndexer
=
light
.
NewChtIndexer
(
chainDb
,
leth
.
odr
,
params
.
CHTFrequency
Client
,
params
.
HelperTrieConfirmations
)
leth
.
chtIndexer
=
light
.
NewChtIndexer
(
chainDb
,
leth
.
odr
,
params
.
CHTFrequency
,
params
.
HelperTrieConfirmations
)
leth
.
bloomTrieIndexer
=
light
.
NewBloomTrieIndexer
(
chainDb
,
leth
.
odr
,
params
.
BloomBitsBlocksClient
,
params
.
BloomTrieFrequency
)
leth
.
bloomTrieIndexer
=
light
.
NewBloomTrieIndexer
(
chainDb
,
leth
.
odr
,
params
.
BloomBitsBlocksClient
,
params
.
BloomTrieFrequency
)
leth
.
odr
.
SetIndexers
(
leth
.
chtIndexer
,
leth
.
bloomTrieIndexer
,
leth
.
bloomIndexer
)
leth
.
odr
.
SetIndexers
(
leth
.
chtIndexer
,
leth
.
bloomTrieIndexer
,
leth
.
bloomIndexer
)
...
...
les/benchmark.go
View file @
64f9c1ea
...
@@ -135,8 +135,7 @@ func (b *benchmarkHelperTrie) init(pm *ProtocolManager, count int) error {
...
@@ -135,8 +135,7 @@ func (b *benchmarkHelperTrie) init(pm *ProtocolManager, count int) error {
b
.
sectionCount
,
b
.
headNum
,
_
=
pm
.
server
.
bloomTrieIndexer
.
Sections
()
b
.
sectionCount
,
b
.
headNum
,
_
=
pm
.
server
.
bloomTrieIndexer
.
Sections
()
}
else
{
}
else
{
b
.
sectionCount
,
_
,
_
=
pm
.
server
.
chtIndexer
.
Sections
()
b
.
sectionCount
,
_
,
_
=
pm
.
server
.
chtIndexer
.
Sections
()
b
.
sectionCount
/=
(
params
.
CHTFrequencyClient
/
params
.
CHTFrequencyServer
)
b
.
headNum
=
b
.
sectionCount
*
params
.
CHTFrequency
-
1
b
.
headNum
=
b
.
sectionCount
*
params
.
CHTFrequencyClient
-
1
}
}
if
b
.
sectionCount
==
0
{
if
b
.
sectionCount
==
0
{
return
fmt
.
Errorf
(
"no processed sections available"
)
return
fmt
.
Errorf
(
"no processed sections available"
)
...
...
les/commons.go
View file @
64f9c1ea
...
@@ -80,28 +80,16 @@ func (c *lesCommons) nodeInfo() interface{} {
...
@@ -80,28 +80,16 @@ func (c *lesCommons) nodeInfo() interface{} {
sections
,
_
,
_
:=
c
.
chtIndexer
.
Sections
()
sections
,
_
,
_
:=
c
.
chtIndexer
.
Sections
()
sections2
,
_
,
_
:=
c
.
bloomTrieIndexer
.
Sections
()
sections2
,
_
,
_
:=
c
.
bloomTrieIndexer
.
Sections
()
if
!
c
.
protocolManager
.
lightSync
{
// convert to client section size if running in server mode
sections
/=
c
.
iConfig
.
PairChtSize
/
c
.
iConfig
.
ChtSize
}
if
sections2
<
sections
{
if
sections2
<
sections
{
sections
=
sections2
sections
=
sections2
}
}
if
sections
>
0
{
if
sections
>
0
{
sectionIndex
:=
sections
-
1
sectionIndex
:=
sections
-
1
sectionHead
:=
c
.
bloomTrieIndexer
.
SectionHead
(
sectionIndex
)
sectionHead
:=
c
.
bloomTrieIndexer
.
SectionHead
(
sectionIndex
)
var
chtRoot
common
.
Hash
if
c
.
protocolManager
.
lightSync
{
chtRoot
=
light
.
GetChtRoot
(
c
.
chainDb
,
sectionIndex
,
sectionHead
)
}
else
{
idxV2
:=
(
sectionIndex
+
1
)
*
c
.
iConfig
.
PairChtSize
/
c
.
iConfig
.
ChtSize
-
1
chtRoot
=
light
.
GetChtRoot
(
c
.
chainDb
,
idxV2
,
sectionHead
)
}
cht
=
params
.
TrustedCheckpoint
{
cht
=
params
.
TrustedCheckpoint
{
SectionIndex
:
sectionIndex
,
SectionIndex
:
sectionIndex
,
SectionHead
:
sectionHead
,
SectionHead
:
sectionHead
,
CHTRoot
:
chtRoot
,
CHTRoot
:
light
.
GetChtRoot
(
c
.
chainDb
,
sectionIndex
,
sectionHead
)
,
BloomRoot
:
light
.
GetBloomTrieRoot
(
c
.
chainDb
,
sectionIndex
,
sectionHead
),
BloomRoot
:
light
.
GetBloomTrieRoot
(
c
.
chainDb
,
sectionIndex
,
sectionHead
),
}
}
}
}
...
...
les/handler.go
View file @
64f9c1ea
...
@@ -1075,9 +1075,8 @@ func (pm *ProtocolManager) getAccount(triedb *trie.Database, root, hash common.H
...
@@ -1075,9 +1075,8 @@ func (pm *ProtocolManager) getAccount(triedb *trie.Database, root, hash common.H
func
(
pm
*
ProtocolManager
)
getHelperTrie
(
id
uint
,
idx
uint64
)
(
common
.
Hash
,
string
)
{
func
(
pm
*
ProtocolManager
)
getHelperTrie
(
id
uint
,
idx
uint64
)
(
common
.
Hash
,
string
)
{
switch
id
{
switch
id
{
case
htCanonical
:
case
htCanonical
:
idxV1
:=
(
idx
+
1
)
*
(
pm
.
iConfig
.
PairChtSize
/
pm
.
iConfig
.
ChtSize
)
-
1
sectionHead
:=
rawdb
.
ReadCanonicalHash
(
pm
.
chainDb
,
(
idx
+
1
)
*
pm
.
iConfig
.
ChtSize
-
1
)
sectionHead
:=
rawdb
.
ReadCanonicalHash
(
pm
.
chainDb
,
(
idxV1
+
1
)
*
pm
.
iConfig
.
ChtSize
-
1
)
return
light
.
GetChtRoot
(
pm
.
chainDb
,
idx
,
sectionHead
),
light
.
ChtTablePrefix
return
light
.
GetChtRoot
(
pm
.
chainDb
,
idxV1
,
sectionHead
),
light
.
ChtTablePrefix
case
htBloomBits
:
case
htBloomBits
:
sectionHead
:=
rawdb
.
ReadCanonicalHash
(
pm
.
chainDb
,
(
idx
+
1
)
*
pm
.
iConfig
.
BloomTrieSize
-
1
)
sectionHead
:=
rawdb
.
ReadCanonicalHash
(
pm
.
chainDb
,
(
idx
+
1
)
*
pm
.
iConfig
.
BloomTrieSize
-
1
)
return
light
.
GetBloomTrieRoot
(
pm
.
chainDb
,
idx
,
sectionHead
),
light
.
BloomTrieTablePrefix
return
light
.
GetBloomTrieRoot
(
pm
.
chainDb
,
idx
,
sectionHead
),
light
.
BloomTrieTablePrefix
...
...
les/handler_test.go
View file @
64f9c1ea
...
@@ -342,43 +342,37 @@ func TestGetCHTProofsLes2(t *testing.T) { testGetCHTProofs(t, 2) }
...
@@ -342,43 +342,37 @@ func TestGetCHTProofsLes2(t *testing.T) { testGetCHTProofs(t, 2) }
func
testGetCHTProofs
(
t
*
testing
.
T
,
protocol
int
)
{
func
testGetCHTProofs
(
t
*
testing
.
T
,
protocol
int
)
{
config
:=
light
.
TestServerIndexerConfig
config
:=
light
.
TestServerIndexerConfig
frequency
:=
config
.
ChtSize
if
protocol
==
2
{
//qqq
frequency
=
config
.
PairChtSize
}
waitIndexers
:=
func
(
cIndexer
,
bIndexer
,
btIndexer
*
core
.
ChainIndexer
)
{
waitIndexers
:=
func
(
cIndexer
,
bIndexer
,
btIndexer
*
core
.
ChainIndexer
)
{
expectSections
:=
frequency
/
config
.
ChtSize
for
{
for
{
cs
,
_
,
_
:=
cIndexer
.
Sections
()
cs
,
_
,
_
:=
cIndexer
.
Sections
()
bs
,
_
,
_
:=
bIndexer
.
Sections
()
if
cs
>=
1
{
if
cs
>=
expectSections
&&
bs
>=
expectSections
{
break
break
}
}
time
.
Sleep
(
10
*
time
.
Millisecond
)
time
.
Sleep
(
10
*
time
.
Millisecond
)
}
}
}
}
server
,
tearDown
:=
newServerEnv
(
t
,
int
(
frequency
+
config
.
ChtConfirms
),
protocol
,
waitIndexers
)
server
,
tearDown
:=
newServerEnv
(
t
,
int
(
config
.
ChtSize
+
config
.
ChtConfirms
),
protocol
,
waitIndexers
)
defer
tearDown
()
defer
tearDown
()
bc
:=
server
.
pm
.
blockchain
.
(
*
core
.
BlockChain
)
bc
:=
server
.
pm
.
blockchain
.
(
*
core
.
BlockChain
)
// Assemble the proofs from the different protocols
// Assemble the proofs from the different protocols
header
:=
bc
.
GetHeaderByNumber
(
frequency
-
1
)
header
:=
bc
.
GetHeaderByNumber
(
config
.
ChtSize
-
1
)
rlp
,
_
:=
rlp
.
EncodeToBytes
(
header
)
rlp
,
_
:=
rlp
.
EncodeToBytes
(
header
)
key
:=
make
([]
byte
,
8
)
key
:=
make
([]
byte
,
8
)
binary
.
BigEndian
.
PutUint64
(
key
,
frequency
-
1
)
binary
.
BigEndian
.
PutUint64
(
key
,
config
.
ChtSize
-
1
)
proofsV2
:=
HelperTrieResps
{
proofsV2
:=
HelperTrieResps
{
AuxData
:
[][]
byte
{
rlp
},
AuxData
:
[][]
byte
{
rlp
},
}
}
root
:=
light
.
GetChtRoot
(
server
.
db
,
(
frequency
/
config
.
ChtSize
)
-
1
,
bc
.
GetHeaderByNumber
(
frequency
-
1
)
.
Hash
())
root
:=
light
.
GetChtRoot
(
server
.
db
,
0
,
bc
.
GetHeaderByNumber
(
config
.
ChtSize
-
1
)
.
Hash
())
trie
,
_
:=
trie
.
New
(
root
,
trie
.
NewDatabase
(
rawdb
.
NewTable
(
server
.
db
,
light
.
ChtTablePrefix
)))
trie
,
_
:=
trie
.
New
(
root
,
trie
.
NewDatabase
(
rawdb
.
NewTable
(
server
.
db
,
light
.
ChtTablePrefix
)))
trie
.
Prove
(
key
,
0
,
&
proofsV2
.
Proofs
)
trie
.
Prove
(
key
,
0
,
&
proofsV2
.
Proofs
)
// Assemble the requests for the different protocols
// Assemble the requests for the different protocols
requestsV2
:=
[]
HelperTrieReq
{{
requestsV2
:=
[]
HelperTrieReq
{{
Type
:
htCanonical
,
Type
:
htCanonical
,
TrieIdx
:
frequency
/
config
.
PairChtSize
-
1
,
TrieIdx
:
0
,
Key
:
key
,
Key
:
key
,
AuxReq
:
auxHeader
,
AuxReq
:
auxHeader
,
}}
}}
...
@@ -396,10 +390,8 @@ func TestGetBloombitsProofs(t *testing.T) {
...
@@ -396,10 +390,8 @@ func TestGetBloombitsProofs(t *testing.T) {
waitIndexers
:=
func
(
cIndexer
,
bIndexer
,
btIndexer
*
core
.
ChainIndexer
)
{
waitIndexers
:=
func
(
cIndexer
,
bIndexer
,
btIndexer
*
core
.
ChainIndexer
)
{
for
{
for
{
cs
,
_
,
_
:=
cIndexer
.
Sections
()
bs
,
_
,
_
:=
bIndexer
.
Sections
()
bts
,
_
,
_
:=
btIndexer
.
Sections
()
bts
,
_
,
_
:=
btIndexer
.
Sections
()
if
cs
>=
8
&&
bs
>=
8
&&
bts
>=
1
{
if
bts
>=
1
{
break
break
}
}
time
.
Sleep
(
10
*
time
.
Millisecond
)
time
.
Sleep
(
10
*
time
.
Millisecond
)
...
...
les/server.go
View file @
64f9c1ea
...
@@ -89,7 +89,7 @@ func NewLesServer(eth *eth.Ethereum, config *eth.Config) (*LesServer, error) {
...
@@ -89,7 +89,7 @@ func NewLesServer(eth *eth.Ethereum, config *eth.Config) (*LesServer, error) {
config
:
config
,
config
:
config
,
chainDb
:
eth
.
ChainDb
(),
chainDb
:
eth
.
ChainDb
(),
iConfig
:
light
.
DefaultServerIndexerConfig
,
iConfig
:
light
.
DefaultServerIndexerConfig
,
chtIndexer
:
light
.
NewChtIndexer
(
eth
.
ChainDb
(),
nil
,
params
.
CHTFrequency
Server
,
params
.
HelperTrieProcessConfirmations
),
chtIndexer
:
light
.
NewChtIndexer
(
eth
.
ChainDb
(),
nil
,
params
.
CHTFrequency
,
params
.
HelperTrieProcessConfirmations
),
bloomTrieIndexer
:
light
.
NewBloomTrieIndexer
(
eth
.
ChainDb
(),
nil
,
params
.
BloomBitsBlocks
,
params
.
BloomTrieFrequency
),
bloomTrieIndexer
:
light
.
NewBloomTrieIndexer
(
eth
.
ChainDb
(),
nil
,
params
.
BloomBitsBlocks
,
params
.
BloomTrieFrequency
),
protocolManager
:
pm
,
protocolManager
:
pm
,
},
},
...
@@ -108,15 +108,11 @@ func NewLesServer(eth *eth.Ethereum, config *eth.Config) (*LesServer, error) {
...
@@ -108,15 +108,11 @@ func NewLesServer(eth *eth.Ethereum, config *eth.Config) (*LesServer, error) {
srv
.
thcBlockProcessing
=
config
.
LightServ
/
100
+
1
srv
.
thcBlockProcessing
=
config
.
LightServ
/
100
+
1
srv
.
fcManager
=
flowcontrol
.
NewClientManager
(
nil
,
&
mclock
.
System
{})
srv
.
fcManager
=
flowcontrol
.
NewClientManager
(
nil
,
&
mclock
.
System
{})
chtV1SectionCount
,
_
,
_
:=
srv
.
chtIndexer
.
Sections
()
// indexer still uses LES/1 4k section size for backwards server compatibility
chtSectionCount
,
_
,
_
:=
srv
.
chtIndexer
.
Sections
()
chtV2SectionCount
:=
chtV1SectionCount
/
(
params
.
CHTFrequencyClient
/
params
.
CHTFrequencyServer
)
if
chtSectionCount
!=
0
{
if
chtV2SectionCount
!=
0
{
chtLastSection
:=
chtSectionCount
-
1
// convert to LES/2 section
chtSectionHead
:=
srv
.
chtIndexer
.
SectionHead
(
chtLastSection
)
chtLastSection
:=
chtV2SectionCount
-
1
chtRoot
:=
light
.
GetChtRoot
(
pm
.
chainDb
,
chtLastSection
,
chtSectionHead
)
// convert last LES/2 section index back to LES/1 index for chtIndexer.SectionHead
chtLastSectionV1
:=
(
chtLastSection
+
1
)
*
(
params
.
CHTFrequencyClient
/
params
.
CHTFrequencyServer
)
-
1
chtSectionHead
:=
srv
.
chtIndexer
.
SectionHead
(
chtLastSectionV1
)
chtRoot
:=
light
.
GetChtRoot
(
pm
.
chainDb
,
chtLastSectionV1
,
chtSectionHead
)
logger
.
Info
(
"Loaded CHT"
,
"section"
,
chtLastSection
,
"head"
,
chtSectionHead
,
"root"
,
chtRoot
)
logger
.
Info
(
"Loaded CHT"
,
"section"
,
chtLastSection
,
"head"
,
chtSectionHead
,
"root"
,
chtRoot
)
}
}
bloomTrieSectionCount
,
_
,
_
:=
srv
.
bloomTrieIndexer
.
Sections
()
bloomTrieSectionCount
,
_
,
_
:=
srv
.
bloomTrieIndexer
.
Sections
()
...
...
light/postprocess.go
View file @
64f9c1ea
...
@@ -41,9 +41,6 @@ type IndexerConfig struct {
...
@@ -41,9 +41,6 @@ type IndexerConfig struct {
// The block frequency for creating CHTs.
// The block frequency for creating CHTs.
ChtSize
uint64
ChtSize
uint64
// A special auxiliary field represents client's chtsize for server config, otherwise represents server's chtsize.
PairChtSize
uint64
// The number of confirmations needed to generate/accept a canonical hash help trie.
// The number of confirmations needed to generate/accept a canonical hash help trie.
ChtConfirms
uint64
ChtConfirms
uint64
...
@@ -64,8 +61,7 @@ type IndexerConfig struct {
...
@@ -64,8 +61,7 @@ type IndexerConfig struct {
var
(
var
(
// DefaultServerIndexerConfig wraps a set of configs as a default indexer config for server side.
// DefaultServerIndexerConfig wraps a set of configs as a default indexer config for server side.
DefaultServerIndexerConfig
=
&
IndexerConfig
{
DefaultServerIndexerConfig
=
&
IndexerConfig
{
ChtSize
:
params
.
CHTFrequencyServer
,
ChtSize
:
params
.
CHTFrequency
,
PairChtSize
:
params
.
CHTFrequencyClient
,
ChtConfirms
:
params
.
HelperTrieProcessConfirmations
,
ChtConfirms
:
params
.
HelperTrieProcessConfirmations
,
BloomSize
:
params
.
BloomBitsBlocks
,
BloomSize
:
params
.
BloomBitsBlocks
,
BloomConfirms
:
params
.
BloomConfirms
,
BloomConfirms
:
params
.
BloomConfirms
,
...
@@ -74,8 +70,7 @@ var (
...
@@ -74,8 +70,7 @@ var (
}
}
// DefaultClientIndexerConfig wraps a set of configs as a default indexer config for client side.
// DefaultClientIndexerConfig wraps a set of configs as a default indexer config for client side.
DefaultClientIndexerConfig
=
&
IndexerConfig
{
DefaultClientIndexerConfig
=
&
IndexerConfig
{
ChtSize
:
params
.
CHTFrequencyClient
,
ChtSize
:
params
.
CHTFrequency
,
PairChtSize
:
params
.
CHTFrequencyServer
,
ChtConfirms
:
params
.
HelperTrieConfirmations
,
ChtConfirms
:
params
.
HelperTrieConfirmations
,
BloomSize
:
params
.
BloomBitsBlocksClient
,
BloomSize
:
params
.
BloomBitsBlocksClient
,
BloomConfirms
:
params
.
HelperTrieConfirmations
,
BloomConfirms
:
params
.
HelperTrieConfirmations
,
...
@@ -84,8 +79,7 @@ var (
...
@@ -84,8 +79,7 @@ var (
}
}
// TestServerIndexerConfig wraps a set of configs as a test indexer config for server side.
// TestServerIndexerConfig wraps a set of configs as a test indexer config for server side.
TestServerIndexerConfig
=
&
IndexerConfig
{
TestServerIndexerConfig
=
&
IndexerConfig
{
ChtSize
:
64
,
ChtSize
:
512
,
PairChtSize
:
512
,
ChtConfirms
:
4
,
ChtConfirms
:
4
,
BloomSize
:
64
,
BloomSize
:
64
,
BloomConfirms
:
4
,
BloomConfirms
:
4
,
...
@@ -95,7 +89,6 @@ var (
...
@@ -95,7 +89,6 @@ var (
// TestClientIndexerConfig wraps a set of configs as a test indexer config for client side.
// TestClientIndexerConfig wraps a set of configs as a test indexer config for client side.
TestClientIndexerConfig
=
&
IndexerConfig
{
TestClientIndexerConfig
=
&
IndexerConfig
{
ChtSize
:
512
,
ChtSize
:
512
,
PairChtSize
:
64
,
ChtConfirms
:
32
,
ChtConfirms
:
32
,
BloomSize
:
512
,
BloomSize
:
512
,
BloomConfirms
:
32
,
BloomConfirms
:
32
,
...
@@ -116,7 +109,7 @@ var (
...
@@ -116,7 +109,7 @@ var (
ErrNoTrustedCht
=
errors
.
New
(
"no trusted canonical hash trie"
)
ErrNoTrustedCht
=
errors
.
New
(
"no trusted canonical hash trie"
)
ErrNoTrustedBloomTrie
=
errors
.
New
(
"no trusted bloom trie"
)
ErrNoTrustedBloomTrie
=
errors
.
New
(
"no trusted bloom trie"
)
ErrNoHeader
=
errors
.
New
(
"header not found"
)
ErrNoHeader
=
errors
.
New
(
"header not found"
)
chtPrefix
=
[]
byte
(
"chtRoot-"
)
// chtPrefix + chtNum (uint64 big endian) -> trie root hash
chtPrefix
=
[]
byte
(
"chtRoot
V2
-"
)
// chtPrefix + chtNum (uint64 big endian) -> trie root hash
ChtTablePrefix
=
"cht-"
ChtTablePrefix
=
"cht-"
)
)
...
@@ -127,7 +120,6 @@ type ChtNode struct {
...
@@ -127,7 +120,6 @@ type ChtNode struct {
}
}
// GetChtRoot reads the CHT root associated to the given section from the database
// GetChtRoot reads the CHT root associated to the given section from the database
// Note that sectionIdx is specified according to LES/1 CHT section size.
func
GetChtRoot
(
db
ethdb
.
Database
,
sectionIdx
uint64
,
sectionHead
common
.
Hash
)
common
.
Hash
{
func
GetChtRoot
(
db
ethdb
.
Database
,
sectionIdx
uint64
,
sectionHead
common
.
Hash
)
common
.
Hash
{
var
encNumber
[
8
]
byte
var
encNumber
[
8
]
byte
binary
.
BigEndian
.
PutUint64
(
encNumber
[
:
],
sectionIdx
)
binary
.
BigEndian
.
PutUint64
(
encNumber
[
:
],
sectionIdx
)
...
@@ -136,7 +128,6 @@ func GetChtRoot(db ethdb.Database, sectionIdx uint64, sectionHead common.Hash) c
...
@@ -136,7 +128,6 @@ func GetChtRoot(db ethdb.Database, sectionIdx uint64, sectionHead common.Hash) c
}
}
// StoreChtRoot writes the CHT root associated to the given section into the database
// StoreChtRoot writes the CHT root associated to the given section into the database
// Note that sectionIdx is specified according to LES/1 CHT section size.
func
StoreChtRoot
(
db
ethdb
.
Database
,
sectionIdx
uint64
,
sectionHead
,
root
common
.
Hash
)
{
func
StoreChtRoot
(
db
ethdb
.
Database
,
sectionIdx
uint64
,
sectionHead
,
root
common
.
Hash
)
{
var
encNumber
[
8
]
byte
var
encNumber
[
8
]
byte
binary
.
BigEndian
.
PutUint64
(
encNumber
[
:
],
sectionIdx
)
binary
.
BigEndian
.
PutUint64
(
encNumber
[
:
],
sectionIdx
)
...
@@ -163,7 +154,7 @@ func NewChtIndexer(db ethdb.Database, odr OdrBackend, size, confirms uint64) *co
...
@@ -163,7 +154,7 @@ func NewChtIndexer(db ethdb.Database, odr OdrBackend, size, confirms uint64) *co
triedb
:
trie
.
NewDatabaseWithCache
(
trieTable
,
1
),
// Use a tiny cache only to keep memory down
triedb
:
trie
.
NewDatabaseWithCache
(
trieTable
,
1
),
// Use a tiny cache only to keep memory down
sectionSize
:
size
,
sectionSize
:
size
,
}
}
return
core
.
NewChainIndexer
(
db
,
rawdb
.
NewTable
(
db
,
"chtIndex-"
),
backend
,
size
,
confirms
,
time
.
Millisecond
*
100
,
"cht"
)
return
core
.
NewChainIndexer
(
db
,
rawdb
.
NewTable
(
db
,
"chtIndex
V2
-"
),
backend
,
size
,
confirms
,
time
.
Millisecond
*
100
,
"cht"
)
}
}
// fetchMissingNodes tries to retrieve the last entry of the latest trusted CHT from the
// fetchMissingNodes tries to retrieve the last entry of the latest trusted CHT from the
...
@@ -235,9 +226,7 @@ func (c *ChtIndexerBackend) Commit() error {
...
@@ -235,9 +226,7 @@ func (c *ChtIndexerBackend) Commit() error {
}
}
c
.
triedb
.
Commit
(
root
,
false
)
c
.
triedb
.
Commit
(
root
,
false
)
if
((
c
.
section
+
1
)
*
c
.
sectionSize
)
%
params
.
CHTFrequencyClient
==
0
{
log
.
Info
(
"Storing CHT"
,
"section"
,
c
.
section
,
"head"
,
fmt
.
Sprintf
(
"%064x"
,
c
.
lastHash
),
"root"
,
fmt
.
Sprintf
(
"%064x"
,
root
))
log
.
Info
(
"Storing CHT"
,
"section"
,
c
.
section
*
c
.
sectionSize
/
params
.
CHTFrequencyClient
,
"head"
,
fmt
.
Sprintf
(
"%064x"
,
c
.
lastHash
),
"root"
,
fmt
.
Sprintf
(
"%064x"
,
root
))
}
StoreChtRoot
(
c
.
diskdb
,
c
.
section
,
c
.
lastHash
,
root
)
StoreChtRoot
(
c
.
diskdb
,
c
.
section
,
c
.
lastHash
,
root
)
return
nil
return
nil
}
}
...
...
params/network_params.go
View file @
64f9c1ea
...
@@ -32,13 +32,8 @@ const (
...
@@ -32,13 +32,8 @@ const (
// considered probably final and its rotated bits are calculated.
// considered probably final and its rotated bits are calculated.
BloomConfirms
=
256
BloomConfirms
=
256
// CHTFrequencyClient is the block frequency for creating CHTs on the client side.
// CHTFrequency is the block frequency for creating CHTs
CHTFrequencyClient
=
32768
CHTFrequency
=
32768
// CHTFrequencyServer is the block frequency for creating CHTs on the server side.
// Eventually this can be merged back with the client version, but that requires a
// full database upgrade, so that should be left for a suitable moment.
CHTFrequencyServer
=
4096
// BloomTrieFrequency is the block frequency for creating BloomTrie on both
// BloomTrieFrequency is the block frequency for creating BloomTrie on both
// server/client sides.
// server/client sides.
...
...
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