-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consortium: enable snap sync on Ronin (#389)
* consortium: avoid reading statedb in block header verification path In snap sync, we only verify header without processing block transactions so the statedb is not available. As a result, we need to avoid reading statedb in the header verification path and must use the information from header instead. This commit disables signer list verification in extra data of checkpoint block header in consortium version 1 when snap/fast sync. In consortium version 2, at the forked block, when getting the list of validators, we read this information from header instead of contract, it is expected to behave the same as before. This commit does not change the header verification process when full sync. * eth/protocols/snap: fix problems due to idle-but-busy peers * eth/protocols/snap: throttle trie heal requests when peers DoS us (#25666) * eth/protocols/snap: throttle trie heal requests when peers DoS us * eth/protocols/snap: lower heal throttle log to debug Co-authored-by: Martin Holst Swende <martin@swende.se> * eth/protocols/snap: fix comment Co-authored-by: Martin Holst Swende <martin@swende.se> * eth/protocols/snap: sort trienode heal requests by path (#24779) * sort snap trienode heal requests * eth/protocols/snap: remove debug code * eth/protocols/snap: simplify sort, generate pathsets later * eth/protocols/snap: review concern * eth/protocols/snap: renamings * eth/protocols/snap: add comments in Merge * eth/protocols/snap: remove variable 'last' in Merge * eth/protocols/snap: fix lint flaws in test Co-authored-by: Felix Lange <fjl@twurst.com> * eth/ethconfig: make full sync the default sync mode Make full sync the default sync mode until we thoroughly test the snap sync. --------- Co-authored-by: Martin Holst Swende <martin@swende.se> Co-authored-by: Péter Szilágyi <peterke@gmail.com> Co-authored-by: Felix Lange <fjl@twurst.com>
- Loading branch information
1 parent
d27eb42
commit 8778779
Showing
10 changed files
with
418 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// Copyright 2022 The go-ethereum Authors | ||
// This file is part of the go-ethereum library. | ||
// | ||
// The go-ethereum library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// The go-ethereum library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package snap | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/trie" | ||
) | ||
|
||
func hexToNibbles(s string) []byte { | ||
if len(s) >= 2 && s[0] == '0' && s[1] == 'x' { | ||
s = s[2:] | ||
} | ||
var s2 []byte | ||
for _, ch := range []byte(s) { | ||
s2 = append(s2, '0') | ||
s2 = append(s2, ch) | ||
} | ||
return common.Hex2Bytes(string(s2)) | ||
} | ||
|
||
func TestRequestSorting(t *testing.T) { | ||
|
||
// - Path 0x9 -> {0x19} | ||
// - Path 0x99 -> {0x0099} | ||
// - Path 0x01234567890123456789012345678901012345678901234567890123456789019 -> {0x0123456789012345678901234567890101234567890123456789012345678901, 0x19} | ||
// - Path 0x012345678901234567890123456789010123456789012345678901234567890199 -> {0x0123456789012345678901234567890101234567890123456789012345678901, 0x0099} | ||
var f = func(path string) (trie.SyncPath, TrieNodePathSet, common.Hash) { | ||
data := hexToNibbles(path) | ||
sp := trie.NewSyncPath(data) | ||
tnps := TrieNodePathSet([][]byte(sp)) | ||
hash := common.Hash{} | ||
return sp, tnps, hash | ||
} | ||
var ( | ||
hashes []common.Hash | ||
paths []trie.SyncPath | ||
pathsets []TrieNodePathSet | ||
) | ||
for _, x := range []string{ | ||
"0x9", | ||
"0x012345678901234567890123456789010123456789012345678901234567890195", | ||
"0x012345678901234567890123456789010123456789012345678901234567890197", | ||
"0x012345678901234567890123456789010123456789012345678901234567890196", | ||
"0x99", | ||
"0x012345678901234567890123456789010123456789012345678901234567890199", | ||
"0x01234567890123456789012345678901012345678901234567890123456789019", | ||
"0x0123456789012345678901234567890101234567890123456789012345678901", | ||
"0x01234567890123456789012345678901012345678901234567890123456789010", | ||
"0x01234567890123456789012345678901012345678901234567890123456789011", | ||
} { | ||
sp, tnps, hash := f(x) | ||
hashes = append(hashes, hash) | ||
paths = append(paths, sp) | ||
pathsets = append(pathsets, tnps) | ||
} | ||
_, paths, pathsets = sortByAccountPath(hashes, paths) | ||
{ | ||
var b = new(bytes.Buffer) | ||
for i := 0; i < len(paths); i++ { | ||
fmt.Fprintf(b, "\n%d. paths %x", i, paths[i]) | ||
} | ||
want := ` | ||
0. paths [0099] | ||
1. paths [0123456789012345678901234567890101234567890123456789012345678901 00] | ||
2. paths [0123456789012345678901234567890101234567890123456789012345678901 0095] | ||
3. paths [0123456789012345678901234567890101234567890123456789012345678901 0096] | ||
4. paths [0123456789012345678901234567890101234567890123456789012345678901 0097] | ||
5. paths [0123456789012345678901234567890101234567890123456789012345678901 0099] | ||
6. paths [0123456789012345678901234567890101234567890123456789012345678901 10] | ||
7. paths [0123456789012345678901234567890101234567890123456789012345678901 11] | ||
8. paths [0123456789012345678901234567890101234567890123456789012345678901 19] | ||
9. paths [19]` | ||
if have := b.String(); have != want { | ||
t.Errorf("have:%v\nwant:%v\n", have, want) | ||
} | ||
} | ||
{ | ||
var b = new(bytes.Buffer) | ||
for i := 0; i < len(pathsets); i++ { | ||
fmt.Fprintf(b, "\n%d. pathset %x", i, pathsets[i]) | ||
} | ||
want := ` | ||
0. pathset [0099] | ||
1. pathset [0123456789012345678901234567890101234567890123456789012345678901 00 0095 0096 0097 0099 10 11 19] | ||
2. pathset [19]` | ||
if have := b.String(); have != want { | ||
t.Errorf("have:%v\nwant:%v\n", have, want) | ||
} | ||
} | ||
} |
Oops, something went wrong.