aboutsummaryrefslogtreecommitdiffstats
path: root/les/handler.go
Commit message (Collapse)AuthorAgeFilesLines
* Change import go github.com/dexon-foundation/dexonWei-Ning Huang2019-03-121-17/+17
|
* all: new p2p node representation (#17643)Felix Lange2018-09-251-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Package p2p/enode provides a generalized representation of p2p nodes which can contain arbitrary information in key/value pairs. It is also the new home for the node database. The "v4" identity scheme is also moved here from p2p/enr to remove the dependency on Ethereum crypto from that package. Record signature handling is changed significantly. The identity scheme registry is removed and acceptable schemes must be passed to any method that needs identity. This means records must now be validated explicitly after decoding. The enode API is designed to make signature handling easy and safe: most APIs around the codebase work with enode.Node, which is a wrapper around a valid record. Going from enr.Record to enode.Node requires a valid signature. * p2p/discover: port to p2p/enode This ports the discovery code to the new node representation in p2p/enode. The wire protocol is unchanged, this can be considered a refactoring change. The Kademlia table can now deal with nodes using an arbitrary identity scheme. This requires a few incompatible API changes: - Table.Lookup is not available anymore. It used to take a public key as argument because v4 protocol requires one. Its replacement is LookupRandom. - Table.Resolve takes *enode.Node instead of NodeID. This is also for v4 protocol compatibility because nodes cannot be looked up by ID alone. - Types Node and NodeID are gone. Further commits in the series will be fixes all over the the codebase to deal with those removals. * p2p: port to p2p/enode and discovery changes This adapts package p2p to the changes in p2p/discover. All uses of discover.Node and discover.NodeID are replaced by their equivalents from p2p/enode. New API is added to retrieve the enode.Node instance of a peer. The behavior of Server.Self with discovery disabled is improved. It now tries much harder to report a working IP address, falling back to 127.0.0.1 if no suitable address can be determined through other means. These changes were needed for tests of other packages later in the series. * p2p/simulations, p2p/testing: port to p2p/enode No surprises here, mostly replacements of discover.Node, discover.NodeID with their new equivalents. The 'interesting' API changes are: - testing.ProtocolSession tracks complete nodes, not just their IDs. - adapters.NodeConfig has a new method to create a complete node. These changes were needed to make swarm tests work. Note that the NodeID change makes the code incompatible with old simulation snapshots. * whisper/whisperv5, whisper/whisperv6: port to p2p/enode This port was easy because whisper uses []byte for node IDs and URL strings in the API. * eth: port to p2p/enode Again, easy to port because eth uses strings for node IDs and doesn't care about node information in any way. * les: port to p2p/enode Apart from replacing discover.NodeID with enode.ID, most changes are in the server pool code. It now deals with complete nodes instead of (Pubkey, IP, Port) triples. The database format is unchanged for now, but we should probably change it to use the node database later. * node: port to p2p/enode This change simply replaces discover.Node and discover.NodeID with their new equivalents. * swarm/network: port to p2p/enode Swarm has its own node address representation, BzzAddr, containing both an overlay address (the hash of a secp256k1 public key) and an underlay address (enode:// URL). There are no changes to the BzzAddr format in this commit, but certain operations such as creating a BzzAddr from a node ID are now impossible because node IDs aren't public keys anymore. Most swarm-related changes in the series remove uses of NewAddrFromNodeID, replacing it with NewAddr which takes a complete node as argument. ToOverlayAddr is removed because we can just use the node ID directly.
* all: make indexer configurable (#17188)gary rong2018-08-281-5/+8
|
* les: fix crasher in NodeInfo when running as server (#17419)Felix Lange2018-08-171-101/+27
| | | | | | | | | | | | | | | | | * les: fix crasher in NodeInfo when running as server The ProtocolManager computes CHT and Bloom trie roots by asking the indexers for their current head. It tried to get the indexers from LesOdr, but no LesOdr instance is created in server mode. Attempt to fix this by moving the indexers, protocol creation and NodeInfo to a new lesCommons struct which is embedded into both server and client. All this setup code should really be cleaned up, but this is just a hotfix so we have to do that some other time. * les: fix commons protocol maker
* light: CHT and bloom trie indexers working in light mode (#16534)Felföldi Zsolt2018-08-161-7/+27
| | | | | | | This PR enables the indexers to work in light client mode by downloading a part of these tries (the Merkle proofs of the last values of the last known section) in order to be able to add new values and recalculate subsequent hashes. It also adds CHT data to NodeInfo.
* les: implement client connection logic (#16899)Felföldi Zsolt2018-08-151-1/+21
| | | | | | | | | | | | | | | | | | | | | | | This PR implements les.freeClientPool. It also adds a simulated clock in common/mclock, which enables time-sensitive tests to run quickly and still produce accurate results, and package common/prque which is a generalised variant of prque that enables removing elements other than the top one from the queue. les.freeClientPool implements a client database that limits the connection time of each client and manages accepting/rejecting incoming connections and even kicking out some connected clients. The pool calculates recent usage time for each known client (a value that increases linearly when the client is connected and decreases exponentially when not connected). Clients with lower recent usage are preferred, unknown nodes have the highest priority. Already connected nodes receive a small bias in their favor in order to avoid accepting and instantly kicking out clients. Note: the pool can use any string for client identification. Using signature keys for that purpose would not make sense when being known has a negative value for the client. Currently the LES protocol manager uses IP addresses (without port address) to identify clients.
* all: simplify switches (#17267)Oleg Kovalov2018-07-301-2/+1
| | | | | | * all: simplify switches * silly mistake
* core, eth, les: more efficient hash-based header chain retrieval (#16946)Felföldi Zsolt2018-06-121-13/+22
|
* les: pass server pool to protocol manager (#16947)Felföldi Zsolt2018-06-121-1/+2
|
* les: add Skip overflow check to GetBlockHeadersMsg handler (#16891)Felföldi Zsolt2018-06-051-7/+18
|
* core/rawdb: separate raw database access to own package (#16666)Péter Szilágyi2018-05-071-46/+58
|
* eth, les: allow exceeding maxPeers for trusted peers (#16189)Andrey Petrov2018-02-271-1/+2
| | | Fixes #3326, #14472
* les, light: fix CHT trie retrievals (#16039)Péter Szilágyi2018-02-111-28/+16
| | | | | | | | | | | | * les, light: fix CHT trie retrievals * les, light: minor polishes, test remote CHT retrievals * les, light: deterministic nodeset rlp, bloombits test skeleton * les: add an event emission to the les bloombits test * les: drop dead tester code
* core, trie: intermediate mempool between trie and database (#15857)Péter Szilágyi2018-02-061-82/+111
| | | This commit reduces database I/O by not writing every state trie to disk.
* les: limit LES peer count and improve peer configuration logic (#16010)Felföldi Zsolt2018-02-051-1/+8
| | | | | | * les: limit number of LES connections * eth, cmd/utils: light vs max peer configuration logic
* core, eth, les, light: get rid of redundant methodsPéter Szilágyi2018-01-311-8/+14
|
* les: fix TxStatusMsg RLP coding (#15974)Felföldi Zsolt2018-01-271-2/+2
|
* les: fix les/1 CHT compatibility issue (#15692)Felföldi Zsolt2018-01-091-2/+2
|
* various: remove redundant parentheses (#15793)Furkan KAMACI2018-01-031-2/+2
|
* eth, les, light: expose chain config in les node info too (#15732)Péter Szilágyi2017-12-281-3/+14
|
* core, eth, les: fix messy code (#15367)Péter Szilágyi2017-10-251-30/+35
| | | | | | | | * core, eth, les: fix messy code * les: fixed tx status test and rlp encoding * core: add a workaround for light sync
* les, light: LES/2 protocol version (#14970)Felföldi Zsolt2017-10-241-28/+326
| | | | | | | | | | | | | | | | | | This PR implements the new LES protocol version extensions: * new and more efficient Merkle proofs reply format (when replying to a multiple Merkle proofs request, we just send a single set of trie nodes containing all necessary nodes) * BBT (BloomBitsTrie) works similarly to the existing CHT and contains the bloombits search data to speed up log searches * GetTxStatusMsg returns the inclusion position or the pending/queued/unknown state of a transaction referenced by hash * an optional signature of new block data (number/hash/td) can be included in AnnounceMsg to provide an option for "very light clients" (mobile/embedded devices) to skip expensive Ethash check and accept multiple signatures of somewhat trusted servers (still a lot better than trusting a single server completely and retrieving everything through RPC). The new client mode is not implemented in this PR, just the protocol extension.
* core, eth/downloader: commit block data using batches (#15115)Felix Lange2017-09-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ethdb: add Putter interface and Has method * ethdb: improve docs and add IdealBatchSize * ethdb: remove memory batch lock Batches are not safe for concurrent use. * core: use ethdb.Putter for Write* functions This covers the easy cases. * core/state: simplify StateSync * trie: optimize local node check * ethdb: add ValueSize to Batch * core: optimize HasHeader check This avoids one random database read get the block number. For many uses of HasHeader, the expectation is that it's actually there. Using Has avoids a load + decode of the value. * core: write fast sync block data in batches Collect writes into batches up to the ideal size instead of issuing many small, concurrent writes. * eth/downloader: commit larger state batches Collect nodes into a batch up to the ideal size instead of committing whenever a node is received. * core: optimize HasBlock check This avoids a random database read to get the number. * core: use numberCache in HasHeader numberCache has higher capacity, increasing the odds of finding the header without a database lookup. * core: write imported block data using a batch Restore batch writes of state and add blocks, tx entries, receipts to the same batch. The change also simplifies the miner. This commit also removes posting of logs when a forked block is imported. * core: fix DB write error handling * ethdb: use RLock for Has * core: fix HasBlock comment
* core, light: send chain events using event.Feed (#14865)Miya Chen2017-08-181-0/+1
|
* les: fix megacheck warnings (#14941)Felföldi Zsolt2017-08-091-6/+0
| | | | | | * les: fix megacheck warnings * les: fixed testGetProofs
* Merge pull request #14737 from holiman/txpool_localaccountsPéter Szilágyi2017-07-101-3/+3
|\ | | | | Txpool localaccounts
| * core, eth, les: polish txpool API around local/remote txsPéter Szilágyi2017-07-051-3/+3
| |
* | eth/downloader, les, light: Changes in response to reviewNick Johnson2017-07-031-14/+1
| |
* | eth, les: Refactor downloader peer to use structsNick Johnson2017-06-291-47/+73
| |
* | eth, les, light: Refactor downloader to use blockchain interfaceNick Johnson2017-06-281-3/+1
|/
* les: code refactoring (#14416)Felföldi Zsolt2017-06-211-128/+79
| | | | | | | | | | | | This commit does various code refactorings: - generalizes and moves the request retrieval/timeout/resend logic out of LesOdr (will be used by a subsequent PR) - reworks the peer management logic so that all services can register with peerSet to get notified about added/dropped peers (also gets rid of the ugly getAllPeers callback in requestDistributor) - moves peerSet, LesOdr, requestDistributor and retrieveManager initialization out of ProtocolManager because I believe they do not really belong there and the whole init process was ugly and ad-hoc
* cmd, eth, les, mobile: make networkid uint64 everywherePéter Szilágyi2017-04-251-3/+3
|
* core, consensus: pluggable consensus engines (#3817)Péter Szilágyi2017-04-051-2/+2
| | | | | This commit adds pluggable consensus engines to go-ethereum. In short, it introduces a generic consensus interface, and refactors the entire codebase to use this interface.
* les: implement request distributor, fix blocking issues (#3660)Felföldi Zsolt2017-03-231-9/+57
| | | | | * les: implement request distributor, fix blocking issues * core: moved header validation before chain mutex lock
* all: update light logs (and a few others) to the new modelPéter Szilágyi2017-03-031-37/+31
|
* eth, les, swarm: fix go vet issues sufraced by log15Péter Szilágyi2017-02-231-1/+1
|
* all: blidly swap out glog to our log15, logs need reworkPéter Szilágyi2017-02-231-36/+35
|
* les: add unknown peers to server pool instead of rejecting themZsolt Felfoldi2017-01-261-3/+0
|
* les: fixed selectPeer deadlock, improved request distributionZsolt Felfoldi2017-01-061-33/+36
| | | | les/flowcontrol: using proper types for relative and absolute times
* Merge pull request #3413 from zsfelfoldi/light-topic4Felix Lange2016-12-131-56/+53
|\ | | | | les, p2p/discv5: implement server pool, improve peer selection, light fetcher and topic searching
| * eth, les: defer starting LES service until ETH initial sync is finishedZsolt Felfoldi2016-12-101-2/+2
| |
| * les: using random request IDsZsolt Felfoldi2016-12-101-2/+2
| |
| * les: improved header fetcher and server statisticsZsolt Felfoldi2016-12-101-31/+22
| |
| * les: fixed light fetcher request ID matchingZsolt Felfoldi2016-12-081-1/+1
| |
| * les: implement light server poolZsolt Felfoldi2016-12-081-45/+51
| |
* | core: bugfix state change race condition in txpool (#3412)bas-vk2016-12-111-2/+6
|/ | | | | | | | The transaction pool keeps track of the current nonce in its local pendingState. When a new block comes in the pendingState is reset. During the reset it fetches multiple times the current state through the use of the currentState callback. When a second block comes in during the reset its possible that the state changes during the reset. If that block holds transactions that are currently in the pool the local pendingState that is used to determine nonces can get out of sync.
* p2p/discv5: fixed bootnode connect issuesZsolt Felfoldi2016-11-141-2/+3
|
* Merge pull request #3179 from obscuren/eip-158Felix Lange2016-11-141-2/+3
|\ | | | | EIP158 & 160 Hardfork
| * core, core/state, trie: EIP158, reprice & skip empty account writeJeffrey Wilcke2016-11-131-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit implements EIP158 part 1, 2, 3 & 4 1. If an account is empty it's no longer written to the trie. An empty account is defined as (balance=0, nonce=0, storage=0, code=0). 2. Delete an empty account if it's touched 3. An empty account is redefined as either non-existent or empty. 4. Zero value calls and zero value suicides no longer consume the 25k reation costs. params: moved core/config to params Signed-off-by: Jeffrey Wilcke <jeffrey@ethereum.org>
* | les: cleaned up logging (#3256)Jeffrey Wilcke2016-11-131-21/+21
|/
* les: add missing nil check and handle quit in findServersZsolt Felfoldi2016-11-111-2/+5
|
* all: update license informationFelix Lange2016-11-091-1/+1
|
* p2p/discv5: added new topic discovery packageZsolt Felfoldi2016-11-091-1/+48
|
* les: light client protocol and APIZsolt Felfoldi2016-11-091-0/+854