Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Rebase statediffing service with 1.9.9 #2

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
181 commits
Select commit Hold shift + click to select a range
d13d4e7
README: accounts in alloc field should exist (#20005)
FlashSheridan Sep 10, 2019
b38b67b
common, graphql: fix hash/address decoding + UI content type
karalabe Sep 10, 2019
3f508dd
core, metrics, p2p: switch some invalid counters to gauges
karalabe Sep 10, 2019
c8edd62
core/state: optimize some internals during encoding
holiman Sep 5, 2019
8f545e4
eth: remove unused field (#20049)
trung Sep 10, 2019
9bf45a8
tests: expose internal RunNoVerify method (#20051)
holiman Sep 11, 2019
9b7a698
all: make unit tests work with Go 1.13 (#20053)
fjl Sep 11, 2019
0b88628
travis, Dockerfile, appveyor: bump to Go 1.13
karalabe Sep 12, 2019
19ee463
build: switch PPA from Gophers dep to manual download
karalabe Sep 12, 2019
b634ddf
Revert "build: switch PPA from Gophers dep to manual download" (#20061)
karalabe Sep 12, 2019
f231018
core: remove unused gas return in ApplyTransaction (#20065)
rmulhol Sep 12, 2019
5948e15
rlp: improve nil pointer handling (#20064)
fjl Sep 13, 2019
3b815cd
cmd/evm: make evm default to all ethash protocol changes
holiman Sep 13, 2019
044c44e
core/state: accumulate writes and only update tries when must
karalabe Aug 12, 2019
17a0938
core: add blockchain test too for revert cornercase
holiman Sep 16, 2019
129649f
common/mclock: clean up AfterFunc support (#20054)
fjl Sep 16, 2019
3aa8cfc
core: smaller txpool status locking (#20080)
holiman Sep 17, 2019
f8fea87
core: dedup known transactions without global lock, track metrics
karalabe Sep 17, 2019
9e25464
les: multiple server bugfixes (#20079)
zsfelfoldi Sep 17, 2019
6bdf944
core: fix tx dedup return error count
karalabe Sep 18, 2019
4e147fa
params: activate Istanbul on Ropsten and Görli
soc1c Sep 19, 2019
db7491f
params: bump CHTs for the 1.9.4 release
karalabe Sep 19, 2019
510358f
core/forkid, params: fix tests, enable Istanbul on Rinkeby + testers
karalabe Sep 19, 2019
bc29f18
vendor: pull in USB Windows fixes
karalabe Sep 19, 2019
3f5fd57
params: release Geth v1.9.4 stable
karalabe Sep 19, 2019
f893b9d
params: start v1.9.5 release cycle
karalabe Sep 19, 2019
86e8a36
params: remove legacy bootnodes
skylenet Sep 19, 2019
41258ce
core/state: fix state object deep copy (#20100)
rjl493456442 Sep 20, 2019
ddb3749
params: release Geth v1.9.5 stable
fjl Sep 20, 2019
524e521
params: start v1.9.6 release cycle
fjl Sep 20, 2019
05e4e73
core/state: fix copy-commit-copy (#20113)
karalabe Sep 24, 2019
439a1ed
dashboard: log host+port
holiman Sep 24, 2019
0f030d5
les: fix checkpoint sync (#20120)
rjl493456442 Sep 25, 2019
ae4c946
p2p/dnsdisc: add implementation of EIP-1459 (#20094)
fjl Sep 25, 2019
b7c22d0
tests/solidity: add contract to test every opcode (#19283)
lhendre Sep 26, 2019
db3aac4
internal/ethapi: support block number or hash on state-related method…
ryanschneider Sep 26, 2019
cca42b3
core/blockchain: remove block from futureBlocks on error (#19763)
ywzqwwt Sep 26, 2019
6fd8d65
core/state: fix database leak and copy tests (#19306)
zcheng9 Sep 26, 2019
660a9f6
core: initialize current block/fastblock atomics to nil, fix #19286 (…
holiman Sep 26, 2019
b6280e8
ethdb/leveldb: disable seek compaction (#20130)
rjl493456442 Sep 26, 2019
1f97547
p2p: measure subprotocol bandwidth usage
karalabe Sep 27, 2019
7c73292
github: Added capital P (#20139)
kishore-hariram Sep 30, 2019
8ba6c63
tests: update test suite for istanbul (#20082)
holiman Oct 2, 2019
4a2c02d
cmd/bootnode: fix exit behavior with -genkey (#20110)
dherbst Oct 2, 2019
440c22b
les: add empty "les" ENR entry for servers (#20145)
fjl Oct 2, 2019
e57dcb0
params: release Geth v1.9.6 stable
fjl Oct 3, 2019
5aef43b
params: begin v1.9.7 release cycle
fjl Oct 3, 2019
fad5775
cmd/utils: fix command line flag resolve (#20167)
rjl493456442 Oct 15, 2019
c56dd7a
params: check fork ordering when initializing new genesis, fixes #201…
holiman Oct 16, 2019
2d6ba6d
p2p/dnsdisc: update to latest EIP-1459 spec (#20168)
fjl Oct 16, 2019
3907f79
p2p/simulations: add node properties support and utility functions (#…
chadsr Oct 17, 2019
cf22e8b
README: use new miner threads flag instead of legacy minerthreads fla…
jeffwalsh Oct 17, 2019
a5be7ce
Changed http:// to https:// on links in log/README.md (#20178)
sandakersmann Oct 18, 2019
f801dc9
dashboard: change links in README to https (#20181)
sandakersmann Oct 18, 2019
1b2cdc2
metrics: change links in README.md to https (#20182)
sandakersmann Oct 20, 2019
d23dd69
miner: add generate and import unit test (#20111)
rjl493456442 Oct 20, 2019
ccca2e7
accounts/abi/bind: take into account gas price during gas estimation …
pdyraga Oct 21, 2019
d64c85c
clef: resolve windows pipes, fixes #20121 (#20166)
holiman Oct 24, 2019
f52b6a2
consensus: fix possessives in comments. (#20209)
gballet Oct 28, 2019
c8a13c8
cmd/evm: remove surrounding whitespace in hex input code (#20211)
michaelforney Oct 28, 2019
d235225
trie: remove node ordering slice in sync batch (#19929)
rjl493456442 Oct 28, 2019
256b262
core/asm: assembly parser label fixes (#20210)
michaelforney Oct 29, 2019
d58bf2a
eth/downloader: fix data race in downloader
holiman Oct 25, 2019
8bfae73
cmd/devp2p, p2p: dial using node iterator, discovery crawler (#20132)
fjl Oct 29, 2019
a84b873
eth: eth/64 - extend handshake packet with fork id
karalabe Sep 30, 2019
667eb35
core/forkid: add two clauses for more precise validation (#20220)
karalabe Oct 30, 2019
0408371
miner: increase import time allowance (#20217)
rjl493456442 Oct 30, 2019
f3f64f9
cmd/devp2p, core/forkid: make forkid.Filter API uniform
karalabe Oct 31, 2019
15ab4d8
params, core/forkid: configure mainnet istanbul block 9069K (#20222)
holiman Oct 31, 2019
456d057
accounts/abi: add internalType information and fix issues (#20179)
rjl493456442 Oct 31, 2019
30b82e4
appveyor: bump to Go 1.13.4
SamuelMarks Nov 2, 2019
6866bfe
les: rework clientpool (#20077)
rjl493456442 Nov 2, 2019
5523fa0
cmd/puppeth: integrate istanbul into puppeth (#19926)
rjl493456442 Nov 4, 2019
cd70baa
core/evm: avoid copying memory for input in calls (#20177)
holiman Nov 4, 2019
2846308
travis, build, internal: use own Go bundle for PPA builds (#20240)
karalabe Nov 5, 2019
20cb48a
travis: bump linter to Go 1.13.x
karalabe Nov 5, 2019
49a0139
params: hard-code new CHTs for the 1.9.7 release
karalabe Nov 6, 2019
691ab54
les: fix and slim the unit tests of les (#20247)
rjl493456442 Nov 6, 2019
e5e855c
params: release Geth v1.9.7
karalabe Nov 7, 2019
bde09a3
params: begin v1.9.8 release cycle
karalabe Nov 7, 2019
79cfb3b
p2p/enode: mock DNS resolver in URL parsing test (#20252)
fjl Nov 7, 2019
e8a1cb0
travis: enable test suite on ARM64 (#20219)
gballet Nov 8, 2019
354c1e2
p2p: fix bug in TestPeerDisconnect (#20277)
Nov 13, 2019
61690f5
dashboard: send current block to the dashboard client (#19762)
kurkomisi Nov 13, 2019
2d04713
miner: increase worker test timeout (#20268)
gballet Nov 13, 2019
b173398
les: implement server priority API (#20070)
zsfelfoldi Nov 13, 2019
a38d627
accounts/abi/bind, cmd/abigen: implement alias for abigen (#20244)
rjl493456442 Nov 14, 2019
19a4fdf
rpc: fix typo example code (#20284)
Jorropo Nov 14, 2019
82771dd
cmd/faucet: use github.com/gorilla/websocket (#20283)
fjl Nov 14, 2019
b5f5619
dashboard: remove the dashboard (#20279)
fjl Nov 14, 2019
4baa8bb
whisper/whisperv6: fix staticcheck issues (#20288)
gballet Nov 14, 2019
01dafdc
build: gather info to investigate why builds fail on ARM (#20281)
gballet Nov 14, 2019
dd3a02f
params: finish sentence in comment (#20291)
meowsbits Nov 14, 2019
1b8755d
core/vm: fix tracer interface parameter name (#20294)
nebojsa94 Nov 15, 2019
ff5d3b6
internal/ethapi: don't query wallets at every execution of gas estima…
holiman Nov 11, 2019
fe05134
cmd/evm: Allow loading input from file (#20273)
michaelforney Nov 17, 2019
0d01c9d
rpc, p2p/simulations: use github.com/gorilla/websocket (#20289)
fjl Nov 18, 2019
2ec77ef
build: use golangci-lint (#20295)
fjl Nov 18, 2019
f94f9a1
travis: remove traces and use travis_wait in ARM build (#20296)
gballet Nov 18, 2019
203263e
core: s/isEIP155/isHomestead/g (fix IntrinsicGas signature var name) …
meowsbits Nov 18, 2019
6fd2b31
les: rename UpdateBalance to AddBalance and simplify return format (#…
zsfelfoldi Nov 18, 2019
36f409d
travis: use travis_wait for both install and build (#20309)
gballet Nov 18, 2019
5a9ee5e
build: add test cmd flag -v for verbose logs (#20298)
meowsbits Nov 18, 2019
b8b1edd
cmd/clef: fix staticcheck warnings (#20314)
fjl Nov 18, 2019
2bd68c3
consensus/clique: add clique_status API method (#20103)
holiman Nov 18, 2019
308a5b3
consensus/clique: fix struct tags for status API (#20316)
fjl Nov 18, 2019
03ea59d
cmd/ethkey: fix file permissions in changepassword command (#20313)
fjl Nov 19, 2019
3ef5328
p2p/netutil: fix staticcheck warning (#20315)
fjl Nov 19, 2019
24fd557
core/rawdb: check hash before return data from ancient db (#20195)
rjl493456442 Nov 19, 2019
daad644
travis: deactivate arm build during push (#20321)
gballet Nov 19, 2019
d5380c0
ethclient: remove use of common.ToHex (#20326)
fjl Nov 19, 2019
3b56400
cmd/wnode: remove uses of common.ToHex (#20327)
fjl Nov 19, 2019
2aace48
event: remove unused field 'closed' (#20324)
fjl Nov 19, 2019
a6a20fd
.github: remove 'nonsense' from CODEOWNERS (#20329)
gballet Nov 19, 2019
1a52d18
whisper/whisperv6: fix staticcheck warnings (#20328)
fjl Nov 19, 2019
2ecd59c
p2p: remove unused code (#20325)
fjl Nov 19, 2019
eb08eec
p2p/simulations: fix staticcheck warnings (#20322)
fjl Nov 19, 2019
61b32fd
internal/web3ext, les: update clique JS and make it work with the lig…
fjl Nov 19, 2019
0093c73
rpc: remove 'exported or builtin' restriction for parameters (#20332)
fjl Nov 20, 2019
086f2b5
core: fix staticcheck warnings (#20323)
fjl Nov 20, 2019
cf06a76
miner: fix data race in tests (#20310)
rjl493456442 Nov 20, 2019
bbb3124
cmd/puppeth: update chain spec of parity (#20241)
rjl493456442 Nov 20, 2019
09254ef
go.mod, vendor: switch to Go modules
karalabe Nov 18, 2019
d1da933
travis: explicitly enable go modules in Go 1.11 and 1.12
karalabe Nov 18, 2019
c5eca30
accounts/abi/bind: switch binding test to go modules
karalabe Nov 18, 2019
ee797b4
travis, build: aggregate and upload go mod dependencies for PPA
karalabe Nov 18, 2019
bf66b43
go.mod: tidy up the modules to avoid xgo writes to go.sum
karalabe Nov 18, 2019
d0e1a29
build, internal/build: drop own file/folder copier
karalabe Nov 18, 2019
c0108bd
travis: fake build ppa only for go module dependencies
karalabe Nov 18, 2019
891816a
mobile: fix CopyFile switch to package cp
karalabe Nov 18, 2019
a0dbe54
tests: refactor TestState to dedupe walk callback
meowsbits Nov 20, 2019
4380659
build, travis: use ephemeral debsrc GOPATH to get mod deps
karalabe Nov 20, 2019
5d287ee
tests: enable TransactionTests Istanbul case (#20337)
meowsbits Nov 20, 2019
223c330
cmd/puppeth: x-spec nonce data type, use types.BlockNonce
meowsbits Nov 20, 2019
a6544ea
cmd/puppeth: make ssh prompt more user-friendly
holiman Nov 21, 2019
103037a
common/hexutil: improve GraphQL error messages (#20353)
fjl Nov 21, 2019
00ae676
build: pull in ci.go dependencies for the PPA builder
karalabe Nov 21, 2019
2f20253
common: improve GraphQL error messages (#20354)
fjl Nov 21, 2019
d4520b0
core/types: remove BlockBy sorting code (#20355)
fjl Nov 21, 2019
04d05f4
build: skip go clean on PPA, messes with the module trick
karalabe Nov 21, 2019
f42ce3d
accounts/abi/bind/backends: remove unused assignment (#20359)
fjl Nov 21, 2019
4b528b5
accounts/abi: fix staticcheck warnings (#20358)
fjl Nov 21, 2019
928f05a
core/state: fix staticcheck warnings (#20357)
fjl Nov 22, 2019
693fa15
metrics: fix issues reported by staticcheck (#20365)
gballet Nov 22, 2019
abee9f2
trie: remove unused code (#20366)
fjl Nov 22, 2019
5fc4f93
p2p/discv5: add deprecation warning and remove unused code (#20367)
fjl Nov 22, 2019
5c70ccb
tests, signer: remove staticcheck warnings (#20364)
gballet Nov 23, 2019
af378c2
core/asm: allow numbers in labels (#20362)
michaelforney Nov 23, 2019
9081848
miner: fix staticcheck warnings (#20375)
gballet Nov 24, 2019
c69a5ac
eth/tracers: fix staticcheck warnings (#20379)
gballet Nov 24, 2019
dace204
trie: replace bigcache with fastcache (#19971)
rjl493456442 Nov 25, 2019
a9acff7
cmd/geth: remove network id from version cmd
meowsbits Nov 25, 2019
d25502d
rlp: fix staticcheck warnings (#20368)
fjl Nov 25, 2019
9464c4f
accounts/abi/bind: avoid reclaring structs (#20381)
rjl493456442 Nov 25, 2019
32c5dde
accounts/keystore: fix staticcheck warnings (#20373)
gballet Nov 25, 2019
0053af9
p2p/discover: slow down lookups on empty table (#20389)
fjl Nov 26, 2019
a66f2be
les: fix clientInfo deadlock (#20395)
zsfelfoldi Nov 26, 2019
0c5d762
params: release go-ethereum v1.9.8
karalabe Nov 26, 2019
c8a26e0
params: begin v1.9.9 release cycle
karalabe Nov 26, 2019
c00aff6
cmd: fix command help messages in modules (#20203)
zacscoding Nov 26, 2019
6ab9ca8
les: fix staticcheck warnings (#20371)
gballet Nov 27, 2019
7e31c1c
core: fix staticcheck warnings (#20384)
gballet Nov 27, 2019
9a5c634
core/rawdb: fix reinit regression caused by the hash check PR
karalabe Nov 27, 2019
035fbf4
deps: update fastcache to 1.5.3
holiman Nov 27, 2019
01580dd
consensus/ethash: refactor remote sealer (#20335)
fjl Nov 28, 2019
3ce1ffb
log: fix staticcheck warnings (#20388)
gballet Nov 28, 2019
e6a40ea
trie: remove dead code (#20405)
rjl493456442 Nov 28, 2019
fe2eb82
cmd/faucet, cmd/geth: fix staticcheck warnings (#20374)
gballet Nov 29, 2019
9431c43
internal: fix staticcheck warnings (#20380)
gballet Nov 29, 2019
6f764e5
accounts/scwallet: fix staticcheck warnings (#20370)
gballet Nov 29, 2019
ac68fd2
internal/web3ext: add debug_accountRange (#20410)
xinluyin Nov 29, 2019
ac34619
accounts/usbwallet: fix staticcheck warnings (#20372)
gballet Nov 29, 2019
d8f79aa
core, miner: remove PostChainEvents (#19396)
rjl493456442 Nov 29, 2019
d05cf37
accounts/abi/bind: fix destructive packing of *big.Int (#20412)
MariusVanDerWijden Dec 2, 2019
f08a025
trie: track dirty cache metrics, track clean writes on commit
karalabe Dec 2, 2019
24ebeb4
params: update CHTs for v1.9.9 release
karalabe Dec 5, 2019
1ffa09a
p2p/enode: remove data race in sliceIter (#20421)
MariusVanDerWijden Dec 5, 2019
4993a36
consensus/ethash, params: eip-2384: bump difficulty bomb (#20347)
holiman Dec 6, 2019
10e11ef
params: release Geth v1.9.9
karalabe Dec 6, 2019
a7ac3a2
Update test block hashes
elizabethengelman Dec 20, 2019
e3bcdd6
Cleanup after rebasing v1.9.9
elizabethengelman Dec 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
eth: eth/64 - extend handshake packet with fork id
  • Loading branch information
karalabe authored and elizabethengelman committed Dec 20, 2019
commit a84b8732a4ef72730fde5a1b64fee989617ebc1d
5 changes: 4 additions & 1 deletion core/forkid/forkid.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ type ID struct {
Next uint64 // Block number of the next upcoming fork, or 0 if no forks are known
}

// Filter is a fork id filter to validate a remotely advertised ID.
type Filter func(id ID) error

// NewID calculates the Ethereum fork ID from the chain config and head.
func NewID(chain *core.BlockChain) ID {
return newID(
Expand Down Expand Up @@ -82,7 +85,7 @@ func newID(config *params.ChainConfig, genesis common.Hash, head uint64) ID {

// NewFilter creates a filter that returns if a fork ID should be rejected or not
// based on the local chain's status.
func NewFilter(chain *core.BlockChain) func(id ID) error {
func NewFilter(chain *core.BlockChain) Filter {
return newFilter(
chain.Config(),
chain.Genesis().Hash(),
Expand Down
7 changes: 5 additions & 2 deletions eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/forkid"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/eth/fetcher"
Expand Down Expand Up @@ -63,7 +64,8 @@ func errResp(code errCode, format string, v ...interface{}) error {
}

type ProtocolManager struct {
networkID uint64
networkID uint64
forkFilter forkid.Filter // Fork ID filter, constant across the lifetime of the node

fastSync uint32 // Flag whether fast sync is enabled (gets disabled if we already have blocks)
acceptTxs uint32 // Flag whether we're considered synchronised (enables transaction processing)
Expand Down Expand Up @@ -103,6 +105,7 @@ func NewProtocolManager(config *params.ChainConfig, checkpoint *params.TrustedCh
// Create the protocol manager with the base fields
manager := &ProtocolManager{
networkID: networkID,
forkFilter: forkid.NewFilter(blockchain),
eventMux: mux,
txpool: txpool,
blockchain: blockchain,
Expand Down Expand Up @@ -304,7 +307,7 @@ func (pm *ProtocolManager) handle(p *peer) error {
number = head.Number.Uint64()
td = pm.blockchain.GetTd(hash, number)
)
if err := p.Handshake(pm.networkID, td, hash, genesis.Hash()); err != nil {
if err := p.Handshake(pm.networkID, td, hash, genesis.Hash(), forkid.NewID(pm.blockchain), pm.forkFilter); err != nil {
p.Log().Debug("Ethereum handshake failed", "err", err)
return err
}
Expand Down
6 changes: 4 additions & 2 deletions eth/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ import (
)

// Tests that block headers can be retrieved from a remote chain based on user queries.
func TestGetBlockHeaders62(t *testing.T) { testGetBlockHeaders(t, 62) }
func TestGetBlockHeaders63(t *testing.T) { testGetBlockHeaders(t, 63) }
func TestGetBlockHeaders64(t *testing.T) { testGetBlockHeaders(t, 64) }

func testGetBlockHeaders(t *testing.T, protocol int) {
pm, _ := newTestProtocolManagerMust(t, downloader.FullSync, downloader.MaxHashFetch+15, nil, nil)
Expand Down Expand Up @@ -198,8 +198,8 @@ func testGetBlockHeaders(t *testing.T, protocol int) {
}

// Tests that block contents can be retrieved from a remote chain based on their hashes.
func TestGetBlockBodies62(t *testing.T) { testGetBlockBodies(t, 62) }
func TestGetBlockBodies63(t *testing.T) { testGetBlockBodies(t, 63) }
func TestGetBlockBodies64(t *testing.T) { testGetBlockBodies(t, 64) }

func testGetBlockBodies(t *testing.T, protocol int) {
pm, _ := newTestProtocolManagerMust(t, downloader.FullSync, downloader.MaxBlockFetch+15, nil, nil)
Expand Down Expand Up @@ -271,6 +271,7 @@ func testGetBlockBodies(t *testing.T, protocol int) {

// Tests that the node state database can be retrieved based on hashes.
func TestGetNodeData63(t *testing.T) { testGetNodeData(t, 63) }
func TestGetNodeData64(t *testing.T) { testGetNodeData(t, 64) }

func testGetNodeData(t *testing.T, protocol int) {
// Define three accounts to simulate transactions with
Expand Down Expand Up @@ -367,6 +368,7 @@ func testGetNodeData(t *testing.T, protocol int) {

// Tests that the transaction receipts can be retrieved based on hashes.
func TestGetReceipt63(t *testing.T) { testGetReceipt(t, 63) }
func TestGetReceipt64(t *testing.T) { testGetReceipt(t, 64) }

func testGetReceipt(t *testing.T, protocol int) {
// Define three accounts to simulate transactions with
Expand Down
33 changes: 25 additions & 8 deletions eth/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package eth
import (
"crypto/ecdsa"
"crypto/rand"
"fmt"
"math/big"
"sort"
"sync"
Expand All @@ -30,6 +31,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/forkid"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
Expand Down Expand Up @@ -171,20 +173,35 @@ func newTestPeer(name string, version int, pm *ProtocolManager, shake bool) (*te
head = pm.blockchain.CurrentHeader()
td = pm.blockchain.GetTd(head.Hash(), head.Number.Uint64())
)
tp.handshake(nil, td, head.Hash(), genesis.Hash())
tp.handshake(nil, td, head.Hash(), genesis.Hash(), forkid.NewID(pm.blockchain), forkid.NewFilter(pm.blockchain))
}
return tp, errc
}

// handshake simulates a trivial handshake that expects the same state from the
// remote side as we are simulating locally.
func (p *testPeer) handshake(t *testing.T, td *big.Int, head common.Hash, genesis common.Hash) {
msg := &statusData{
ProtocolVersion: uint32(p.version),
NetworkId: DefaultConfig.NetworkId,
TD: td,
CurrentBlock: head,
GenesisBlock: genesis,
func (p *testPeer) handshake(t *testing.T, td *big.Int, head common.Hash, genesis common.Hash, forkID forkid.ID, forkFilter forkid.Filter) {
var msg interface{}
switch {
case p.version == eth63:
msg = &statusData63{
ProtocolVersion: uint32(p.version),
NetworkId: DefaultConfig.NetworkId,
TD: td,
CurrentBlock: head,
GenesisBlock: genesis,
}
case p.version == eth64:
msg = &statusData{
ProtocolVersion: uint32(p.version),
NetworkID: DefaultConfig.NetworkId,
TD: td,
Head: head,
Genesis: genesis,
ForkID: forkID,
}
default:
panic(fmt.Sprintf("unsupported eth protocol version: %d", p.version))
}
if err := p2p.ExpectMsg(p.app, StatusMsg, msg); err != nil {
t.Fatalf("status recv: %v", err)
Expand Down
90 changes: 76 additions & 14 deletions eth/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

mapset "github.com/deckarep/golang-set"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/forkid"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rlp"
Expand Down Expand Up @@ -353,22 +354,46 @@ func (p *peer) RequestReceipts(hashes []common.Hash) error {

// Handshake executes the eth protocol handshake, negotiating version number,
// network IDs, difficulties, head and genesis blocks.
func (p *peer) Handshake(network uint64, td *big.Int, head common.Hash, genesis common.Hash) error {
func (p *peer) Handshake(network uint64, td *big.Int, head common.Hash, genesis common.Hash, forkID forkid.ID, forkFilter forkid.Filter) error {
// Send out own handshake in a new thread
errc := make(chan error, 2)
var status statusData // safe to read after two values have been received from errc

var (
status63 statusData63 // safe to read after two values have been received from errc
status statusData // safe to read after two values have been received from errc
)
go func() {
errc <- p2p.Send(p.rw, StatusMsg, &statusData{
ProtocolVersion: uint32(p.version),
NetworkId: network,
TD: td,
CurrentBlock: head,
GenesisBlock: genesis,
})
switch {
case p.version == eth63:
errc <- p2p.Send(p.rw, StatusMsg, &statusData63{
ProtocolVersion: uint32(p.version),
NetworkId: network,
TD: td,
CurrentBlock: head,
GenesisBlock: genesis,
})
case p.version == eth64:
errc <- p2p.Send(p.rw, StatusMsg, &statusData{
ProtocolVersion: uint32(p.version),
NetworkID: network,
TD: td,
Head: head,
Genesis: genesis,
ForkID: forkID,
})
default:
panic(fmt.Sprintf("unsupported eth protocol version: %d", p.version))
}
}()
go func() {
errc <- p.readStatus(network, &status, genesis)
switch {
case p.version == eth63:
errc <- p.readStatusLegacy(network, &status63, genesis)
case p.version == eth64:
errc <- p.readStatus(network, &status, genesis, forkFilter)
default:
panic(fmt.Sprintf("unsupported eth protocol version: %d", p.version))
}
}()
timeout := time.NewTimer(handshakeTimeout)
defer timeout.Stop()
Expand All @@ -382,11 +407,18 @@ func (p *peer) Handshake(network uint64, td *big.Int, head common.Hash, genesis
return p2p.DiscReadTimeout
}
}
p.td, p.head = status.TD, status.CurrentBlock
switch {
case p.version == eth63:
p.td, p.head = status63.TD, status63.CurrentBlock
case p.version == eth64:
p.td, p.head = status.TD, status.Head
default:
panic(fmt.Sprintf("unsupported eth protocol version: %d", p.version))
}
return nil
}

func (p *peer) readStatus(network uint64, status *statusData, genesis common.Hash) (err error) {
func (p *peer) readStatusLegacy(network uint64, status *statusData63, genesis common.Hash) error {
msg, err := p.rw.ReadMsg()
if err != nil {
return err
Expand All @@ -402,17 +434,47 @@ func (p *peer) readStatus(network uint64, status *statusData, genesis common.Has
return errResp(ErrDecode, "msg %v: %v", msg, err)
}
if status.GenesisBlock != genesis {
return errResp(ErrGenesisBlockMismatch, "%x (!= %x)", status.GenesisBlock[:8], genesis[:8])
return errResp(ErrGenesisMismatch, "%x (!= %x)", status.GenesisBlock[:8], genesis[:8])
}
if status.NetworkId != network {
return errResp(ErrNetworkIdMismatch, "%d (!= %d)", status.NetworkId, network)
return errResp(ErrNetworkIDMismatch, "%d (!= %d)", status.NetworkId, network)
}
if int(status.ProtocolVersion) != p.version {
return errResp(ErrProtocolVersionMismatch, "%d (!= %d)", status.ProtocolVersion, p.version)
}
return nil
}

func (p *peer) readStatus(network uint64, status *statusData, genesis common.Hash, forkFilter forkid.Filter) error {
msg, err := p.rw.ReadMsg()
if err != nil {
return err
}
if msg.Code != StatusMsg {
return errResp(ErrNoStatusMsg, "first msg has code %x (!= %x)", msg.Code, StatusMsg)
}
if msg.Size > protocolMaxMsgSize {
return errResp(ErrMsgTooLarge, "%v > %v", msg.Size, protocolMaxMsgSize)
}
// Decode the handshake and make sure everything matches
if err := msg.Decode(&status); err != nil {
return errResp(ErrDecode, "msg %v: %v", msg, err)
}
if status.NetworkID != network {
return errResp(ErrNetworkIDMismatch, "%d (!= %d)", status.NetworkID, network)
}
if int(status.ProtocolVersion) != p.version {
return errResp(ErrProtocolVersionMismatch, "%d (!= %d)", status.ProtocolVersion, p.version)
}
if status.Genesis != genesis {
return errResp(ErrGenesisMismatch, "%x (!= %x)", status.Genesis, genesis)
}
if err := forkFilter(status.ForkID); err != nil {
return errResp(ErrForkIDRejected, "%v", err)
}
return nil
}

// String implements fmt.Stringer.
func (p *peer) String() string {
return fmt.Sprintf("Peer %s [%s]", p.id,
Expand Down
44 changes: 26 additions & 18 deletions eth/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,31 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/forkid"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/rlp"
)

// Constants to match up protocol versions and messages
const (
eth62 = 62
eth63 = 63
eth64 = 64
)

// protocolName is the official short name of the protocol used during capability negotiation.
const protocolName = "eth"

// ProtocolVersions are the supported versions of the eth protocol (first is primary).
var ProtocolVersions = []uint{eth63}
var ProtocolVersions = []uint{eth64, eth63}

// protocolLengths are the number of implemented message corresponding to different protocol versions.
var protocolLengths = map[uint]uint64{eth63: 17, eth62: 8}
var protocolLengths = map[uint]uint64{eth64: 17, eth63: 17}

const protocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message

// eth protocol message codes
const (
// Protocol messages belonging to eth/62
StatusMsg = 0x00
NewBlockHashesMsg = 0x01
TxMsg = 0x02
Expand All @@ -56,12 +56,10 @@ const (
GetBlockBodiesMsg = 0x05
BlockBodiesMsg = 0x06
NewBlockMsg = 0x07

// Protocol messages belonging to eth/63
GetNodeDataMsg = 0x0d
NodeDataMsg = 0x0e
GetReceiptsMsg = 0x0f
ReceiptsMsg = 0x10
GetNodeDataMsg = 0x0d
NodeDataMsg = 0x0e
GetReceiptsMsg = 0x0f
ReceiptsMsg = 0x10
)

type errCode int
Expand All @@ -71,11 +69,11 @@ const (
ErrDecode
ErrInvalidMsgCode
ErrProtocolVersionMismatch
ErrNetworkIdMismatch
ErrGenesisBlockMismatch
ErrNetworkIDMismatch
ErrGenesisMismatch
ErrForkIDRejected
ErrNoStatusMsg
ErrExtraStatusMsg
ErrSuspendedPeer
)

func (e errCode) String() string {
Expand All @@ -88,11 +86,11 @@ var errorToString = map[int]string{
ErrDecode: "Invalid message",
ErrInvalidMsgCode: "Invalid message code",
ErrProtocolVersionMismatch: "Protocol version mismatch",
ErrNetworkIdMismatch: "NetworkId mismatch",
ErrGenesisBlockMismatch: "Genesis block mismatch",
ErrNetworkIDMismatch: "Network ID mismatch",
ErrGenesisMismatch: "Genesis mismatch",
ErrForkIDRejected: "Fork ID rejected",
ErrNoStatusMsg: "No status message",
ErrExtraStatusMsg: "Extra status message",
ErrSuspendedPeer: "Suspended peer",
}

type txPool interface {
Expand All @@ -108,15 +106,25 @@ type txPool interface {
SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription
}

// statusData is the network packet for the status message.
type statusData struct {
// statusData63 is the network packet for the status message for eth/63.
type statusData63 struct {
ProtocolVersion uint32
NetworkId uint64
TD *big.Int
CurrentBlock common.Hash
GenesisBlock common.Hash
}

// statusData is the network packet for the status message for eth/64 and later.
type statusData struct {
ProtocolVersion uint32
NetworkID uint64
TD *big.Int
Head common.Hash
Genesis common.Hash
ForkID forkid.ID
}

// newBlockHashesData is the network packet for the block announcements.
type newBlockHashesData []struct {
Hash common.Hash // Hash of one particular block being announced
Expand Down
Loading